April 5, 2011

PlayBook details from BlackBerry Dev Day Toronto (video)

PlayBook details from BlackBerry Dev Day Toronto (video)

I was in attendance at the BlackBerry Dev Day in Toronto a few days back (31st March 2011). I was mostly interested in finding out more about the BlackBerry PlayBook from a developer’s perspective as I’ve been developing an app for it recently. Here are some notes I made regarding the PlayBook during the talk as well as a video of a live demonstration of the PlayBook’s prowess.

  • ‘Gold’ version of the PlayBook SDK will be released very close to the launch (19th April) and it will have substantially more new features. This makes sense, as the current SDK available to developers lacks some of the functionality that I occassionally see in offical PlayBook demo videos (e.g. the markers at the start and end of text selection) suggesting that they are holding some features back from developers until they are ready to release it (or run out of time and have to release it as is).
  • Ad Services and Payment Services for PlayBook developers will not be available for at launch in the SDKs, but will be added soon after. Payment Service will be there by summer.
  • Similarly, the Analytics service will be made available on the PlayBook some time after its launch. The service will work through WebTrends. This sounded like a very intrusive service for the users, but potentially great for the application developers. If the developer includes this service in the app, it can be switched on by default (without asking user’s permission) if the developer chooses to do so. The service will send data to WebTrends servers. The only way the user can switch this off is by setting the firewall settings on their device to block www.webtrends.com (not very user friendly). Later they said that the user will be notified through the app that the app is trying to connect to WebTrends and they can choose to block it from there, which is slightly more user friendly. However I’m not sure if they meant if the user will be specifically told that the app is trying to connect to WebTrends, or if the app is asking for general internet connectivity permission. Overall, there was a bit of conflicting information regarding this, and it sounded like a bit of a work in progress – I suspect they will modify things to make it easier for the user to manage this before officially making this service available.
  • There is no support for virtual currencies right now, but they are trying to implement it – as soon as they figure out how to deal with some unique accounting issues related to that.
  • All PlayBook apps submitted by 31st March, are likely to be reviewed by the 19th April launch date with 90-100% probability. The app review team is well-oiled and getting better at reviewing apps. I have to personally agree with this. Keeping track of app submissions and approval dates in the Developer Forum suggests that the team is operating much faster now than in the beginning.
  • Push doesn’t exist on PlayBook today, but will come later.
  • Native PlayBook clients for email, calendar, etc will come later. At launch these will only be accessible via the BlackBerry Bridge (which works through Bluetooth).
  • BBM is not in the PlayBook except for through BlackBerry Bridge (for now).
  • They suggested that it might be worthwhile to launch apps in non-North American markets first (e.g. Indonesia, Mexico/Spain) to get some feedback and revenue and then launch in the larger North American market. They also said its worthwhile offering translations into other languages (particularly Bahasa and Spanish).

Here is a video of RIM’s Director of Developer Relations, Mike KIrkup, demoing the PlayBook to an impressed and applauding crowd.

Interesting parts are at:

  • 0:57, when he demonstrates playing an HD video over HDMI with Need for Speed still running in the background (albeit in a paused state).
  • 3:32: running camera and playing Need for Speed at the same time. Need for Speed is controlled by the accelerometer and you can see the camera angles changing in the live thumbnail view as well as the car turning in that direction in the Need for Speed live thumbnail view simultaneously.
  • 5:24: Over The Air (OTA) update mechanism. The device, when first shipped, will ask the users to perform an OTA update before they can start using it.
March 27, 2011

Lessons Learned Working on a Programming Side-Project

The last few months I had been building an app for the upcoming launch of the BlackBerry PlayBook tablet. Its a fairly simple app – a text editor that syncs notes with Dropbox – and consists of about 3000 lines of source code. Now that I have submitted version 1.0 of my app to the BlackBerry AppWorld, I wanted to take a step back and look at my progress, and more importantly, my productivity.

I used the Mercurial Activity Extension to plot out my commits and collect other relevant data. Here is a chart of my commit activity for the duration of the project along with some annotations:

Lessons Learned Working on a Programming Side-Project

I worked on this during any spare time that I got from my full-time job. I first started during the Christmas/New Year’s holidays. This was the most productive, and also the most frustrating time, since I was learning how to do things on a new platform (Adobe AIR + BlackBerry QNX) for the first time. Also RIM had an offer going on for all developers: if the app was submitted before February 1, and accepted, the developer would win a free PlayBook. So initially I was aiming to finish up in about a month.

However, on January 13 I found out that RIM had extended that deadline to March 15. And my productivity suddenly dropped right after. I realized that I didn’t have an excuse for ignoring all the other things in my life that required my attention, so I started dealing with them. Also, work got a bit busier during early February and I generally found myself having less spare time. Anyhow, my activity started picking up again closer to the next deadline. There was another small drop when I discovered that the second deadline had been extended, but I pulled through this one with a determination to finish by the now defunct second deadline. Eventually, I was able to finish slightly past that deadline, and had my first release ready by 22nd March.

Lessons Learned:

  • Deadlines work. But only when they are enforced by some third-party. Self-imposed deadlines have never been effective for me.
  • Life always gets in the way. There’s just no getting around this one.
  • Momentum is important. It’s hard to get back momentum once you lose it. But once you have it, you’re on a roll and much more productive.
  • Social life gets put on the back burner. Devoting your time between a full-time job, a side-project that feels like another full-time job, and taking care of life’s necessities, really doesn’t leave time for anything else.

I didn’t stop there with my analytics. I wanted to dig deeper into the data. So I plotted a chart of my activity per day of the week:

Lessons Learned Working on a Programming Side-Project

The chart is divided into working days and holidays (weekends, Christmas break, New Year’s, Family Day, and an extra day off I took on the Wednesday between Christmas and New Year’s). Surprisingly, my two most productive days of the week are not on the weekend, but they are Tuesday and Friday.

I knew that I had been doing a lot of my coding during the wee hours of the morning, but I wanted to know exactly how much. So I plotted this chart mapping my number of commits done per hour over all days:

Lessons Learned Working on a Programming Side-Project

It looks like 7am is the most productive time of the day for me. There is a reason why I have gravitated towards working in the mornings: there are the least amount of distractions then. Most of the world is asleep and there is little activity on Facebook, Twitter, tech blogs and news websites to distract me. Also, my mind is fresh in the morning and not tired after a full day of work. Luckily, I have a job that is flexible with their work hours, so I was able to shift my working hours to later in the day. Night time was mostly reservered for eating dinner and unwinding by watching a little TV and clicking away at links on sites I frequently visit.

It also looks like I do roughly about the same number of commits on holidays as a do on workdays. Its just that my commits during holidays are spread out more evenly during the day. This makes me wonder if I am more focused and get the same amount of work done, as I would on a full day of a holiday, that I get done in a few hours on a workday. Perhaps I am subconsciously treating the fact that I can’t be too late to get to the office for my job as a  ‘deadline’. And that deadline mentality forces me to get more things done faster. Perhaps I’m one of those people who work better under pressure.

March 26, 2011

How to Chart your Mercurial Commits with the Activity Extension in Windows

How to Chart your Mercurial Commits with the Activity Extension in Windows

The Mercurial Activity extension lets you measure the number of commits done to a Mercurial repository per day and chart it out using Matplotlib.

The installation process was a bit of a doozy on my Windows system, so I wrote this step-by-step guide. The extension uses the Matplotlib library for plotting the chart, so you will need to have that set up inside your Python distribution. The default Python installation I had on my system was v2.7 64-bit, and the default Mercurial client I was using was TortoiseHg (with Mercurial 1.7). However after some tinkering around, I found out that I couldn’t get the extension to work with this sort of setup – mostly because TortoiseHg comes with its own Python distribution in some DLL file inside a library.zip archive and I have no idea how to install a Matplotlib site-package in there.

So this is what worked for me:

  • Get Python v2.6 32-bit (I found this to be the lowest common denominator which would work with all of Numpy (a pre-requisite for Matplotlib), Matplotlib, Mercurial and the Activity extension). For all remaining steps, make sure you are using this distribution of Python and not your default one (if it is different than this one).
  • Download NumPy and install it inside Python 2.6. I ended up getting the latest stable release: NumPy v1.5.1, win32 for python2.6. The installer is an exe file and you can simply run it to correctly install inside your Python 2.6 distribution. Check that NumPy is installed by running the Python 2.6 interpretter and typing this:

import numpy
print numpy.__version__

  • Download Matplotlib and install it inside Python 2.6. I ended up getting v1.0.0, win32 for python2.6. After installation, check from the Python 2.6 interpretter that its correctly installed

import matplotlib
print matplotlib.__version__

  • Download Mercurial for your Python distribution (even if you already have TortoiseHg installed). This is because we need to install Mercurial inside our Python 2.6 distribution whereas TortoiseHg comes with its own custom Python distribution. I ended up getting Mercurial 1.8.1 for Python 2.6 and x86 Windows. After installation, make sure that you can import it from Python 2.6. Also, you should be able to run ‘hg’ from the ‘Scripts’ folder inside your Python2.6 install (default location: C:Python26Scriptshg)

from mercurial import __version__

  • Finally, download the Activity extension itself. I got v1.4. This will unzip to a bunch of python scripts and a README.txt file. As the README instructs, edit your global mercurial settings file and put the following line under the [extensions] heading:

activity = C:\Programs\hgactivity-1.4\activity.py

Of course, set the actual path to where ever you extracted activity.py. If you have TortoiseHg installed, you can gain access to the global mercurial settings file by right-clicking in Windows Explorer, selecting TortoiseHg->Global Settings, and press the ‘Edit File’ button.

  • Now you are ready to actually use the extension. You will have to use it from a command prompt. cd to the root of a mercurial repository and issue the following command:

C:\Python26\Scripts\hg activity

This will create an activity.png file in the current directory. To see all other options available, run ‘hg activity help’.

Finally, I’d like to thanks the authors of this extension for making it available open source. You can modify activity.py to extract different types of data or present it in different ways. In the version of the script I downloaded, the Y-axis labels were switched off by default. You can fix this by editing the line that says


For other type of edits you’ll probably want to brush up with Python’s datetime class. Have fun! 🙂

December 10, 2010

Blackberry Tablet OS Simulator complains about 64-bit Windows

Blackberry Tablet OS Simulator complains about 64-bit Windows

Hearing about the free Blackberry Playbook offer, I’ve decided to jump on the bandwagon and see what the platform has to offer and how it is to work with. Its running on the Adobe AIR platform, which I am not familiar with at all. I did some Flash and Actionscript development for a project course in university several years back. It wasn’t anything extensive and I haven’t done anything since. I figure its a good chance to look at what’s new out there. However things are not off to a good start. Let me highlight a point with the Tablet Simulator. When you try to install it on a 64-bit Windows machine you get this message:

Win64 not supported

The author of the package you are installing did not include support for this platform


I immediately recognized this as an installer issue since I’ve seen this problem with other softwares. But I was expecting better from a big player like Blackberry. Especially after someone complained about the SDK installer having the same issue a month ago. They did manage to create 64-bit compatible installers for the SDK since I didn’t have any problems installing that. But no one bothered to check the Simulator installer for the same issue. This is not very developer friendly, especially for a company just breaking into the Tablet market and trying to play catch-up with the competition.

I don’t understand how companies can casually overlook 64-bit platforms as they represent the future and many developers have already jumped on board. Its understandable if this was for a consumer product and they didn’t want to support 64-bit systems. But this is a product specifically designed for developers. If you’re not making things easy for your target audience, then you’re doing something wrong.

After some searching I found a post by another developer who came across the same problem. (BTW, there don’t seem to be too many articles about this). I followed his suggestion and opened the installer with 7-zip. Inside there browse to


and extract the contents of Resource1.zip. Inside Resorce1 go to


and the ISO file that we need will be found sitting there. The ISO file is meant to run on VMWare Player. So clearly it has no 32-bit/64-bit architecture issues. Its just the installer that Blackberry couldn’t bother fixing. How stupid is this.

Update: As you can see from the image at the top of the post, I was able to finally get the Simulator running. This just confirms that the Simulator indeed works on 64-bit machines. Its just the installer which doesn’t.


December 9, 2010

Doing some Vector Art

For the longest time I’ve been wanting to have a personal avatar that I could use for my profile picture with online services. I didn’t feel comfortable putting up a real picture, but on the other hand I wanted to have something more personal than some arbitrary photo/design.

So recently, I decided to spend some time and create a vector version of my cartoon-self. Since I am not artistically inclined, I decided to use an existing photo of myself as inspiration. I traced the outline of my face from the photo, and continuously used it for reference for contours, colours and gradients. I tried not to make it too realistic in an effort to avoid the uncanny valley.

I find doing such drawings relaxing and it gets the creative juices flowing. I also got to learn a lot about how things work in Inkscape. I particularly love how you can fine tune vector paths to the smallest detail and easily create smooth lines – something I would never be able to do with just my hands using pencil and paper.

Since I use version control for almost everything (including this project), I was able to document the progress of my work. In the end I wrote up a script to fetch all the versions of my image from the first draft to the final image, and created an animation from them showing the progression of the work:


My python code for extracting all versions of a file from a SVN repository can be found here. Note that you will need to install the pysvn library for your python distribution for this to work.


December 6, 2010

Who is the elusive Ninja Programmer that all the tech companies want to hire?

Who is the elusive Ninja Programmer that all the tech companies want to hire?

If you’ve been browsing around programming-related websites like StackOverflow, you’ll occasionally see ads for companies looking to hire programmers, and quite often you’ll see them trying to entice you with graphics or mentions of Ninjas, Rockstars or Superheros.

Who is the elusive Ninja Programmer that all the tech companies want to hire?

But this isn’t just limited to flashy web ads. If you search job-posting websites like Indeed.com for ‘ninja’, you’ll find several such listings:

Who is the elusive Ninja Programmer that all the tech companies want to hire?

None of these jobs actually want real Ninjas (do they even exist anymore?), nor have anything to do with martial arts for that matter. Instead they are for programming jobs. But who is the target audience? At first glance it seems to be a lure for those wavering souls that have some unfulfilled childhood fantasies. But is there anything more to it than that? I posed the question to the Programmers – Stack Exchange community to get their opinions. The question has since been closed (update: and now un-closed…) – for good reason too: it was attracting a lot of negative comments which is not conducive to the type of community they are trying to build there. However, some good points were raised comparing the traits of a Ninja to the characteristics desired in software developers:

  • Mastery by experience: to be highly skilled due to intense training and practice. This also implies enlightenment (i.e. knowing both your enemies/competition and your friends/end-users)
  • Confidence in tackling the impossible: to have the initiative and determination to deal with problems that others don’t want to touch
  • Economy of effort: to find optimal solutions in the minimal amount of time and with the least amount of effort
  • Resourceful: to know what tools are available, how they can be used and when it is appropriate to use them
  • Stealth and unorthodox style: to be able to go in, under the radar (when required), and finish the job, sometimes by employing techniques that commoners are not familiar with (this one applies mostly to hackers)
  • Honor/Respect (this is probably more relevant to Samurai than Ninjas, but lets just go with the flow anyway): to be humble enough to respect the fact that some peer out there may be better than themselves

But this is not enough to convince me that this is more than a tacky marketing scheme by Human Resources Agents. As programmer Jon argues, there are experienced professionals in other industries too, but they don’t get referred to as Ninja Doctors, or Ninja Lawyers. However programmer Anna points out that this is most likely because the programming culture is closely tied to the gaming sub-culture, whereas the other professions aren’t. However, I still feel that the term is being grossly misused just for its coolness factor.

Anyhow, let me end this post by quoting programmer JB King‘s G.I. Joe analogy, which absolutely cracked me up:

If you ever saw the G.I. Joe cartoon from the 1980s you may remember the character of Storm Shadow. He had a sword and some throwing stars but with just the right sequences of punches and kicks managed to take apart a tank in an episode. In a similar manner, programmers can get called in to do some work that requires them to pull out weapons you may not have thought they had.

December 1, 2010

Setting up SSH access to Bitbucket on Windows with PuttyGen

Setting up SSH access to Bitbucket on Windows with PuttyGen

Setting up SSH access to my Bitbucket Mercurial repository on Windows took a bit longer than I would have liked. Since Google doesn’t come up with any direct hits that give a step-by-step guide to exactly dealing with this issue, and since the Bitbucket documentation leaves the Windows user high and dry with a ‘This is not described in further detail here’ message, I’m going to go ahead and write one of my own.

If you don’t have a public/private encryption key pair, you first need to get those:

  • Download the Putty tools: Make sure you get at least PuttyGen and Pageant. They’re both included in the ‘Windows Installer for Everything…’
  • Run PuttyGen and click on Generate to create a new key

Setting up SSH access to Bitbucket on Windows with PuttyGen

  • You can change the ‘Key comment’ to anything you like. Something that includes the encryption method, date, username and computer is probably helpful e.g. rsa-key-20101130-user@home
  • The ‘Key passphrase’ is something that will be used to secure the private key that’s stored locally on your computer. Unless someone has the passphrase, they cannot access your private key. The PuttyGen documentation says

Choosing a good passphrase is difficult. Just as you shouldn’t use a dictionary word as a password because it’s easy for an attacker to run through a whole dictionary, you should not use a song lyric, quotation or other well-known sentence as a passphrase. DiceWare recommends using at least five words each generated randomly by rolling five dice, which gives over 2^64 possible passphrases and is probably not a bad scheme. If you want your passphrase to make grammatical sense, this cuts down the possibilities a lot and you should use a longer one as a result.

Now you can click on the ‘Save private key’ and ‘Save public key’ buttons to save the files to disk. Don’t close the dialog box yet as we’ll need it soon.

Now go to your Bitbucket home, and click on the Accounts button

Setting up SSH access to Bitbucket on Windows with PuttyGen

Scroll down to the SSH Keys section. Copy your public key from the PuttyGen window where it says ‘Public key for pasting into OpenSSH authorized_keys file’ and paste it in the textbox next to the ‘Add Key’ button. Now press ‘Add Key’ and Bitbucket should store the key for you.

To avoid having to type in your long passphrase every time you use your private key for commits, you need to keep the Pageant program running in the background. You can have it set up to start once per your Windows session so you only have to provide the passphrase once, and then it keeps running in the background. You can do this by typing

pageant private.ppk

from the command line (where private.ppk is the file where you saved your private key).

June 22, 2010

Eclipse PyDev slow start-up times

Eclipse PyDev slow start-up times

I just realized today that the 5-10 minute delay in starting up of Eclipse matches exactly with a same spike in my internet usage! What the hell is going on here?

I started noticing the delay in Eclipse after I installed the PyDev plugin. I haven’t really looked into the reason for the delay, and it might have nothing to do with PyDev, but that sure would be a hell of a coincidence.

I wonder what data is being sent/received which causes this. I wonder if Eclipse is sending over keyboard shortcut usage statistics to the server – although I remember switching that feature off.

Mysterious. And suspicious!

Update: Since then I’ve had several other installations (and re-installations) of PyDev on the same and other machines and I haven’t been able to reproduce the problem. It looks like PyDev was not to blame after all. I’m still not sure what caused the problem originally. Maybe it was some other rogue Eclipse plugin. Or just something messed up with my workstation’s settings. I’ll never know…

Obscure features of iOS4 on the iPhone

Here are some features in the new OS upgrade that weren’t immediately clear to me what they were doing

  • In the AppStore, some of the purchases have a plus sign next to them. This indicates that the app has an iPad version too.


  • Apart from the built-in spell-checker which underlines incorrect words with red squiggly lines, you can also select a word manually and in the pop-up that appears there will be an extra option called ‘Replace…’. Tapping ‘Replace…’ brings up suggestions for other words that you might have intended to type instead of the original.


I’ll add more if I find something else interesting.

May 20, 2010

Seting up Mercurial on a Mac with Murky and Bitbucket

Seting up Mercurial on a Mac with Murky and BitbucketI had quite some trouble setting up Mercurial/Murky to work the way I wanted it to, so I’m writing it down here so I can reference it in the future if I ever need to and maybe it can helps others too.

The default settings for Hg (Mercurial) don’t seem to be the most user-friendly. In particular I didn’t like the way the default pull/update/merge was working. Fortunately, you can tweak settings in Hg to make it work to your liking. You will need to edit the dot file .hgrc located in your home directory for this.

This is what my .hgrc file ended up looking like:

username = Ali <bitbucket.user@myemail.com>
merge = /Applications/kdiff3.app/Contents/MacOS/kdiff3

kdiff3.args = $base $local $other -o $output

The [ui] and [merge-tools] sections ensure that Mercurial uses the tool I specified for the merge operation. I found that the default merge was adding changes from both conflicting files together into one – the changes being placed on separate lines, separated by symbols like >, -, < (the same way that the command-line diff tools works). Its very hard to read through the changes this way. By specifying an external merge tool of your choice, hg will call that merge tool and let it handle the merging. In this case, I choose kdiff3, which seems to be a popular free cross-platform tool. The kdiff3 merge shows me both the files side by side with the changes highlighted in colour. Its easier to figure out what’s changed this way. Here’s some more information on Mercurial merge tools:http://mercurial.selenic.com/wiki/MergeProgram

In the [ui] section, I also included a username part. This ensures that when I push to Bitbucket, it links my push to my bitbucket account. Otherwise it will display the username and machine you are committing from as your username. Refer to the FAQ for more details.

The version of Murky that I’m using (v0.8.1) doesn’t let you do a hg push if you checked out your repository through https. You can still do it through the command line, but that is annoying. So I suggest cloning your repository through the ssh url that bitbucket provides. This is a known issue and might be fixed in the future.