Sunday, 30 September 2012

Blackberry Playbook clock problem fix


My Blackberry Playbook's status bar clock no longer responds when clicked. However, it still shows the correct time. Additionally, when I go to the clock app, it takes awhile to load and the times do not match.


A quick solution for this bug is to open the clock app and set the time zone to match your playbook's current time zone.


This bug and its fix were both found in BB10 and earlier.

Normally the clock app and the playbook's time should not get out of sync. It seems as though when this happens, the built-in clock in the status bar no longer works as it should, also producing the problem of not being able to set an alarm. For me, this problem occurred due to an apparent bug (memory leak? buffer overrun?) when playing large mp3 files for a very long time (in my case, it was a 2-hour recording of the ocean overnight for a few days straight -- my neighbourhood is quite noisy).

If anyone at RIM is reading this post, many thanks in advance for finding and fixing this weird bug :) Note that the bug also sometimes seems to affect the ability to network to the playbook itself via wireless or USB, however I haven't found a fix for that.

Tuesday, 25 September 2012

Workaround for ios6 Phonegap 2.0.0 linker error


After upgrading to ios6 and XCode 4.5, when trying to compile my old PhoneGap/Cordova project on an iOS device I get the following error:

"_OBJC_CLASS_$_CDVURLProtocol", referenced from:
Objc-class-ref in AppDelegate.o
"_OBJC_CLASS_$_CDVViewController", referenced from:
_OBJC_CLASS_$_MainViewController in MainViewController.o
"_OBJC_METACLASS_$_CDVViewController", referenced from:
_OBJC_METACLASS_$_MainViewController in MainViewController.o
Symbol(s) not found for architecture armv7s

This error may not necessarily show up when running the program in the simulator.

Temporary workaround:

To have your old PhoneGap project working again, you can try the following:

  • in XCode 4.5, click on your project and click "build settings"
  • change Architecture to "Standard (armv7, armv7s)"
  • change Valid Architectures to be only "armv7, armv7s"
  • change Build Active Architecture Only to "Yes"

You may also have to do this for the linked CordovaLib.xcodeproj. This temporary workaround assumes that you have been using a build configuration similar to the default configuration (e.g. things haven't been heavily customized).


This workaround won't work for projects using older versions that import PhoneGap as a precompiled framework. It should work for versions that import CordovaLib.xcodeproj, but no guarantees.

Keep a lookout for updates with the Apache Cordova/PhoneGap project as this workaround is only a temporary fix for those looking to test their old projects after upgrading their devices to iOS6. Chances are that this bug will be fixed by the PhoneGap team, if it already hasn't been. This workaround will result in dropped support for older ios devices (as the armv7s instruction set isn't supported by devices older than the iPhone 3GS). This workaround was tested with XCode 4.5 and Apache Cordova 2.0.0 on devices with the old 3.5 inch retina screen, recently upgraded to ios6. This workaround has not been tested in a deployed/production setting.

Saturday, 15 September 2012

Increase memory for PHP scripts in MAMP


I'd like to increase the amount of memory allocated to PHP scripts because my optimized script still keeps running out of memory when using MAMP.


If you find that a local PHP script is not executing because it is running out of memory, you can give more memory to PHP scripts by editing the php.ini file(s) in MAMP by the following steps:

  • Stop MAMP servers
  • Open the file /Applications/MAMP/bin/php/php[version]/conf/php.ini (where [version] is the PHP version you're using, e.g. php5.3.6)
  • Search for "memory_limit" (without the quotes). You should end up with something like "memory_limit = 8M"
  • increase the number to however much you will be allocating to your scripts. For example, a 128MB maximum script would need a setting "memory_limit = 128M"
  • restart MAMP servers


This trick is useful for locally-run scripts. For scripts that will be hosted on an external server, you should be careful to match the memory limit of your remote host machine as scripts that will execute in the higher local memory limit may break when deployed online. Not to mention that it is also a useful exercise to think up ways to execute scripts more efficiently.

This was tested on MAMP 2.0.5. Other versions may keep php.ini in a different location.

Friday, 14 September 2012

Count the number of lines in a file using terminal


I would like to count the number of lines in a file.


An easy way to count the number of lines in a file in Linux or OS X is to use the 'wc' command in terminal. For instance:

cat myfile.txt | wc -l 


The 'wc' command can also do a bunch of other useful things. You can find out more by googling, looking at the command's man page, or clicking the following reference:

Replace spaces with newlines using terminal


Using Linux or OS X, I would like to replace spaces with newline characters in a file and output the result to a new file.

For instance, if my file's contents look like the following:
Monday Tuesday Wednesday Thursday Friday

The output should look like:


In the terminal, a simple solution would be to use the 'tr' command, for instance:
cat infile.txt | xargs | tr -s ' ' '\n' > outfile.txt