May 15th, 2012 by blastar
Today I faced with such problem – logs were delayed by about 30 minuted which maked development impossible, solution was pretty simple – I had to change timezone back to Pacific Time GMT-7
Posted in Python | No Comments »
April 5th, 2012 by blastar
Today I had such error, and after firing, my app was closed and I was unable to debug:

Solution was pretty simple, all I had to do, was to remove Entitlements.plist in my Debug target:

Strange, but after that, I can debug again. For this project I’m using pretty old XCode 3.2.5 with iOS SDK 4.1
Posted in iOS | No Comments »
February 25th, 2012 by blastar
It’s quite easy if you know where to start. There are two ways, you can use UILabel or NSString. With UILabel you can control width and height of rendered texture, also you have words wrap and text aligning.
NSError *error;
UILabel *myLabel = [[UILabel alloc] initWithFrame:CGRectMake(0, 0, 200, 30)];
myLabel.text = @"Hello world!";
myLabel.font = [UIFont fontWithName:@"Helvetica" size:18];
myLabel.textColor = [UIColor colorWithRed:0/255.0 green:0/255.0 blue:0/255.0 alpha:1];
myLabel.backgroundColor = [UIColor clearColor];
UIGraphicsBeginImageContext(myLabel.bounds.size);
CGContextTranslateCTM(UIGraphicsGetCurrentContext(), 0, 30);
CGContextScaleCTM(UIGraphicsGetCurrentContext(), 1.0, -1.0);
[myLabel.layer renderInContext:UIGraphicsGetCurrentContext()];
UIImage *layerImage = UIGraphicsGetImageFromCurrentImageContext();
UIGraphicsEndImageContext();
if (error) {
NSLog(@"Label::initWithText - Error loading texture from image: %@",error);
}
So step by step:
1. first we need our UILabel, in CGRectMake we are setting our text size (rectangle)
2. then we need our text to display, also font using UIFont class
3. setting text color is also easy, but then comes little trick – you can use “clearColor” with background to make it transparent
4. next thing is to start new image context with UIGraphicsBeginImageContext
5. next 2 line are important if you don’t want your text to be vertically flipped (third parameter in CGContextTranslateCTM is our UILabel height)
6. then we need to render our label using renderInContext
7. and finally we have ready to use texture using UIImage
Posted in iOS | No Comments »
October 20th, 2011 by blastar
Just call:
$payment = $order->getPayment()->getMethodInstance()->getTitle();
Posted in Magento | No Comments »
October 20th, 2011 by blastar
This one is quite simple:
$countryName = Mage::getModel(’directory/country’)->load($country_id)->getName();
Posted in Magento | No Comments »
October 18th, 2011 by blastar
From time to time previously serialized array will get broken. The most common problem occurs when string length is invalid so instead of
a:2:{i:758;s:4:"test";i:759;s:4:"test";}
you have
a:2:{i:758;s:4:"test";i:759;s:9:"test";}
becouse someone edited something directly in db, in this case to make php unserialize() function to work again, just do this magic:
$data = html_entity_decode($data, ENT_QUOTES, 'UTF-8');
$data = preg_replace('!s:(\d+):"(.*?)";!e', "'s:'.strlen('$2').':\"$2\";'", $data );
$data = unserialize($data);
and you will get all strings lenths to be fixed again.
Posted in PHP | No Comments »
October 11th, 2011 by blastar
Well, this one can be really painful. But solution is simple, just make sure you are stopping every OpenGL AND sound activity in applicationWillResignActive function, not in applicationDidEnterBackground (becouse it’s too late, app is already in background and no OpenGL/Sound is allowed, you can add playing sounds in background into plist but OpenGL won’t be allowed anyway).
Posted in iOS | No Comments »
October 9th, 2011 by blastar
It seems to be trivial, but it’s not. If you want to use custom table and custom model, and sort collection by one of your table’s column, you can’t just use addAttributeToSort as you do with native Magento collection (like “catalog/product”). Instead of this, you should use setOrder, so your code should look like this:
$items = Mage::getModel('module/model')
->getCollection()
->setOrder('date_added', 'DESC')
->addFieldToFilter('category_id', array('eq' => $category_id))
->setPageSize($pageSize)
->setCurPage($currentPage);
Posted in Magento | 3 Comments »
October 1st, 2011 by blastar
Well, that is pretty simple but in case someone will need this, just:
$product = Mage::getModel('catalog/product')->load(123);
$inStock = Mage::getModel('cataloginventory/stock_item')->loadByProduct($product)->getIsInStock();
Posted in Uncategorized | No Comments »
September 8th, 2011 by blastar
In case someone will need this, it’s quite simple:
$order = Mage::getModel('sales/order')->load( 1234 );
$shipment = Mage::getModel('sales/service_order', $order)->prepareShipment(array());
$shipment->register();
$shipment->getOrder()->setCustomerNoteNotify(false);
$shipment->getOrder()->setIsInProcess(true);
$transactionSave = Mage::getModel('core/resource_transaction')->addObject($shipment)->addObject($shipment->getOrder())->save();
Posted in Magento | No Comments »