May 30, 2012

MySQL Error : Incorrect information in file

Posted May 30, 2012
I copied an entire WAMP folder from an old computer in an attempt to revive a PHP application. When I started its mysql service and tried to query the tables, I got this:

MySQL Error No. 1033 Incorrect information in file: [filename].frm

I can see the list of tables but I cannot query, it was like the data has been corrupted. When I checked the logs in [wamp folder]\bin\mysql\[mysql folder]\data\*.err, I also found the following:

InnoDB: Error: log file .\ib_logfile0 is of different size 0 10485760 bytes
InnoDB: than specified in the .cnf file 0 5242880 bytes!

  1. Stop the MySQL service,
  2. delete both ib_logfile0 and ib_logfile1 found in  [wamp folder]\bin\mysql\[mysql folder]\data
  3. and start MySQL service again.

May 29, 2012

MS Word to PDF displays boxes when viewed in iOS (iPhone / iPad)

Posted May 29, 2012
If the text in your PDF displays boxes when viewed iPad or iPhone, one of the cause might be the conversion of MS Word to PDF.

Try these simple steps to see if it resolves the issue:
  1. Open MS Word
  2. File -> Save As
  3. Select PDF type
  4. Click Options
  5. ISO 19005-1 compliant (PDF/A) should be ticked.
  6. Try to save the document to PDF and view it in your iPhone / iPad.

I'm using MS Word 2010 and Windows 7.  PDF is properly displayed in desktop and Android devices, but in iOS (UIWebView, Safari, etc), the text is just a series of black boxes; like it's been highlighted with a black marker. The fix above solves the issue.

May 24, 2012

Singleton Pattern in Objective-C (iOS) and release method (oneway) issue

Posted May 24, 2012
Apple gives a good sample on how to create a singleton class; I've modified it a bit for iOS programming:

static MyGizmoClass *sharedInstance = nil;

+ (MyGizmoClass*) sharedInstance
    if (sharedInstance == nil) {
        sharedInstance = [[super allocWithZone:NULL] init];
    return sharedInstance;

+ (id)allocWithZone:(NSZone *)zone
    return [[self sharedInstance] retain];

- (id)copyWithZone:(NSZone *)zone
    return self;

- (id)retain
    return self;

- (NSUInteger)retainCount
    return NSUIntegerMax;  //denotes an object that cannot be released

- (oneway void)release
    //do nothing

- (id)autorelease
    return self;

  1. Used "sharedInstance" method and variable name to make it easier to copy paste.
  2. - (void) release to - (oneway void) release
    The singleton sample produces a warning in the release method because NSObject uses the "oneway" return type modifier. It's basically an indication that the method is used for asynchronous messages. For more details on what oneway does, offers a good explanation.

May 15, 2012

Grails Session Timeout

Posted May 15, 2012
To increase or decrease the default session time-out in grails:

In your project folder, first execute (if you haven't execute this yet):
grails install-templates

After this, you'll be able to see your web.xml in [project folder]/src/templates/war/

Add / modify the code in web.xml


I place the snippet above after my servlet-mapping. The value "60" is in minutes.

Tested on Grails version 2.03. Enjoy!

May 8, 2012

Sublime Text 2 and Command Line Integration

Posted May 8, 2012
A little background: Sublime Text 2 is the ultimate programmer's notepad (Thanks to Lan for introducing me this tool). I've been using it since last year especially when editing Grails applications and so far I'm loving it.

One thing that's lacking out of the box is the shell integration; a way to launch the command line and pass your project's folder path for convenience. Fortunately, there's a package for it. It's called Shell Turtlestein.

  • You can install Shell Turtlestein using Package Control. If you don't have Package Control yet, I highly suggest you install it.
  • When you have the Package Control, access it through Preferences menu > Package Control.
  • Select "Install Package" and search for Shell Turtlestein and select it.
  • After the package is installed, you can use ctrl + alt + shift + C (in Windows) to launch the command line.
  • You can also use ctrl + shift + C to prompt for a shell command.

Search Terms:
  • sublime text 2 command line