Friday, November 23, 2012

Window Management Goodness for OS X

Tristan Hume has an excellent article on improving window management in OS X, using Slate. Well worth the time to read that and configure Slate to your liking. I'm already feeling much more productive, all without spending on window management software - Slate is free!

Here's my .slate configuration file.

Sunday, November 4, 2012

Marco Tempest: A cyber-magic card trick

Marco Tempest has an excellent TED talk where he shows off a cyber-magic card trick using sleight of hand combined with OpenCV. Very cool! Check it out below.

Sunday, October 28, 2012

Google Maps, Heatmaps and Earthquakes

The US Geological Survey makes available a small dataset containing the M1+ earthquakes from around the world in the past 7 days. I used this data along with the heatmap visualization layer offered by the Google Maps API to present the earthquake data as a heatmap.

Check out Worldwide M1+ Earthquakes, Past 7 Days.

One caveat: due to cross origin issues, I am hosting a local copy of the data rather than getting it live from the USGS.

Sunday, October 21, 2012

Fun With Google Maps

Ever wondered what's on the opposite side of the world for any place? Then check out the Opposite Of The World. It's a "Hello World" exploration of the Google Maps JavaScript API that I wrote for fun. You can scroll and zoom through either map on the page and the other map will show you the opposite side of the world. It's quite basic now but I'm going to add markers and other overlays to make it more fun.

PS: You might be surprised to know that Malaysia, is on the opposite side of Ecuador!

Saturday, September 29, 2012

Raspberry Power

After sitting on the sidelines of the Raspberry Pi revolution for a few months, I recently picked up a model B from Newark. (There were a 100 units in stock a few days ago but as of this time, they are showing 0 in stock.) I wanted to complete the accessory setup with minimal wires and maximum portability. Newark offers a host of suggestions for each accessory but I decided to get parts separately.

Here's the setup I chose:

  1. SD Card: An old Patriot 4GB SDHC card but Fry's has a Samsung 8GB micro SDHC card (with the SD adapter) for $4.99.
  2. OS: Raspbian “wheezy” available from the Raspberry Pi downloads page.
  3. Keyboard/Mouse: The cheapest wireless keyboard/mouse combination at Fry's which happened to be an iConcepts 2.4GHz Wireless Keyboard and Optical Mouse for $14.99. The dongle that connects to USB is tiny!
  4. Wi-Fi: I decided to skip the wired interface and instead got the Patriot Mini Wireless-N USB Wi-Fi adapter for $14.99 at Fry's. The adapter is quite small (see picture of the full setup below).
  5. HDMI cable: Again, the cheapest at Fry's - a 6ft HDMI cable for $6.99.
  6. Power supply: This is one place where I didn't want anything that had to be connected to the mains. I want to use the Pi eventually for portable applications and the best alternative seemed to be the portable chargers for mobile phones. After some hunting, I settled on the Concept Green CG2000-B portable charger. This one came with the micro USB connector (in addition to mini USB and iPod/iPhone) making it ideal for the Pi. The CG2000 charges via USB (mini USB to USB port on a computer) and discharges via USB to micro USB. This one was $19.99 at Fry's but is also available online for a little cheaper.

All-in-all, that added $62 to the base $35 price of the Pi. Here's the end result:

I'm quite happy with the setup and now it's time to build something fun with it :-)

Sunday, July 29, 2012

Building QuantLib on OS X Mountain Lion

Here are the steps to install QuantLib, a free/open-source library for quantitative finance, on OS X Mountain Lion:

  1. Install MacPorts.
  2. Install Boost using MacPorts by running this command:
    sudo port install boost
    This will install Boost and its dependencies under /opt/local.
  3. Download and extract the QuantLib sources.

  4. Configure QuantLib by running:
    ./configure --with-boost-include=/opt/local/include --with-boost-lib=/opt/local/lib/
  5. Run make, followed by sudo make install.

Monday, July 23, 2012

Future Proofing

I am always disappointed to see web programmers code pages which display messages like the one below. Safari 6 is the latest (beta) release. ING can do better, especially if they are the "rebel with a cause" - see The Orange Code: How ING Direct Succeeded by Being a Rebel with a Cause.

Battle lines for HTTP/2.0

Over the past month, several interested parties have revealed their expressions of interest regarding the proposals for the HTTP/2.0 standard. Under consideration are primarily the SPDY and HTTP Speed+mobility proposals. The battle lines have been drawn, and as usual Microsoft wants to push their own agenda.

There's also an interesting debate about whether HTTP/2.0 should always use TLS.

Sunday, July 15, 2012

Windows 8 - Delete Progress Dialog

Windows 8 has a fancy delete progress dialog window for long-running delete operations. It shows:

  • the number of items being deleted,
  • percentage complete,
  • instantaneous speed of deletion (items/second),
  • a graph of historical speed of deletion for this operation,
  • estimated time remaining, and
  • items remaining (count and size)

Get your copy of Windows 8 here: Microsoft Windows 8 Pro Pack 5VR-00001.

Monday, July 9, 2012

HTML5 Test - Safari on iOS 6

Safari on iOS 6 continues to improve on the HTML5 Test. With iOS 6 Beta 2, Safari scores 360/500.

Major areas lacking are:

  • Video subtitle support
  • Drag and drop (probably intentional on the iPhone)
  • Microdata
  • WebGL 3D context
  • Filesystem (again, probably intentional)
  • IndexedDB
  • Access to the webcam
  • Web notifications
  • Full screen support (not really applicable to an iPhone)
For comparison, here's Safari on iOS 4 from over two years ago.

Objective-C Literals

Mike Ash has a really good article on Objective-C Literals. Good to see that we can finally have some abbreviated syntax for boxing, and array and dictionary literals. The syntax makes it very much like JSON. Waiting for these changes to appear in Xcode.

Monday, July 2, 2012


If you are using a Mac with a small-ish SSD these days, there's a good chance that you are running low on disk space. A fair bit of an OS X install is multilingual files and if you are using just 1 or 2 languages, you could get rid of the language support files for all other languages.

Enter Monolingual, a tool which cleans up all the languages that aren't of interest. On an OS X Lion install, that's worth at least a couple of GB.

Monolingual can also remove files for architectures that aren't in use (e.g. getting rid of ARM and PowerPC files on an Intel Mac.

Download Monolingual here.

Sunday, March 11, 2012

Employee Stock Options

Having gone through the CS193p course, I decided to build a simple iOS app and take it all the way through to sale (for free) at the Apple App Store. Turned out to be a pretty painless process and my app is now live on the App Store. The app tracks the value of employee stock options using live stock data from Yahoo! Finance (retrieved via the YQL data table "").

Here are a couple of screenshots of the app:

Sunday, February 26, 2012

Fetching Stock Data From Yahoo For iOS Applications

Yahoo! provides a great service called Yahoo! Query Language (YQL) which provides a SQL-like interface to a whole bunch of Web services. YQL queries can also be performed via REST. A wide range of services can be accessed through YQL including Yahoo! Finance.

A convenient way to play with YQL and explore the available Web services, is to use the YQL Console. The bottom right of the console lists all the data tables, grouped by provider. (Be sure to click "Show Community Tables" to view all the available tables.) The yahoo provider includes the data table This table provides access to stock quotes from Yahoo! Finance. As an example, here's the YQL console showing a query for stock data for AAPL. The console helpfully shows the REST URL for the query at the bottom.

Armed with the REST URL, it is trivial to write code in Objective-C/iOS to fetch quote data. Here's some code that takes in an NSArray of ticker symbols (NSStrings) and returns a NSDictionary with tickers as keys and quotes (realtime bid) as values.

#define QUOTE_QUERY_SUFFIX @")&format=json&"

+ (NSDictionary *)fetchQuotesFor:(NSArray *)tickers
NSMutableDictionary *quotes;
if (tickers && [tickers count] > 0) {
NSMutableString *query = [[NSMutableString alloc] init];
[query appendString:QUOTE_QUERY_PREFIX];
for (int i = 0; i < [tickers count]; i++) {
            NSString *ticker = [tickers objectAtIndex:i];
            [query appendFormat:@"%%22%@%%22", ticker];
            if (i != [tickers count] - 1) [query appendString:@"%2C"];
        [query appendString:QUOTE_QUERY_SUFFIX];
        // NSLog(@"Query: %@", query);
        NSData *jsonData = [[NSString stringWithContentsOfURL:[NSURL URLWithString:query] encoding:NSUTF8StringEncoding error:nil] dataUsingEncoding:NSUTF8StringEncoding];
        NSError *error = nil;
        NSDictionary *results = jsonData ? [NSJSONSerialization JSONObjectWithData:jsonData options:0 error:&error] : nil;
        if (error) NSLog(@"[%@ %@] JSON error: %@", NSStringFromClass([self class]), NSStringFromSelector(_cmd), error.localizedDescription);
        // NSLog(@"[%@ %@] received %@", NSStringFromClass([self class]), NSStringFromSelector(_cmd), results);
        NSArray *quoteEntries = [results valueForKeyPath:@"query.results.quote"];
        quotes = [[NSMutableDictionary alloc] initWithCapacity:[quoteEntries count]];
        for (NSDictionary *quoteEntry in quoteEntries) {
            [quotes setValue:[quoteEntry valueForKey:@"BidRealtime"] forKey:[quoteEntry valueForKey:@"symbol"]];
    return quotes;

Saturday, January 21, 2012

Arctic Woolly Bear Moth

The Arctic Woolly Bear Moth (Gynaephora groenlandica) is a fascinating creature. It is a moth that is found in the Acrtic circle. As a caterpillar, it emerges in spring and feeds on leaves during the short Arctic spring. Towards the end of spring, when temperatures start to drop, the caterpillar slows down its metabolism and practically freezes. It reawakens the next spring to repeat the cycle. This growth-freeze cycle continues for 7 to 14 years! After a decade it spins itself a cocoon and then finally emerges as a moth. BBC's "Frozen Planet" showed this moth on episode 2. Here are a few pictures of the caterpillar and moth from the show.

Thursday, January 19, 2012

Amazon DynamoDB

Amazon has a added a new offering to AWS: Amazon DynamoDB. This is a fully managed NoSQL database. One of the most interesting items to catch my eye was this: "All data items are stored on Solid State Disks (SSDs) and are automatically replicated across multiple Availability Zones in a Region to provide built-in high availability and data durability." Does this mean that Amazon is now the largest owner of SSDs? I wonder who they buy from. Amazon's pricing structure for this service is a little weird. They have introduced the concept of "Write Capacity" (one write per second for items of up to 1KB in size) and "Read Capacity" (one strongly consistent read per second or two eventually consistent reads per second of items of up to 1KB in size). Why not just define pricing in terms of data reads and writes per second per KB? With the added bonus of Amazon Elastic MapReduce (EMR) integration, this should be a useful service for all NoSQL users.

Tuesday, January 17, 2012

Monday, January 16, 2012

Raspberry Pi

The Raspberry Pi is a credit-card sized $25-$35 ARM GNU/Linux computer that can be plugged into a TV and a keyboard. Here's a picture of the connectors on the device.

The device is stil under development but here's a rendering fo what it will look like. Should be an interesting alternative to Arduinos but make take a while before it has a good community around it. There's already a lot of interest and activity on the forums. Looking forward to being able to purchase it.

Saturday, January 14, 2012

Madeira Airport (FNC)

Madeira Airport (FNC) in Funachal, Madeira, Portugal is an amazing airport. A portion of the runway is built out over the ocean on a series of 180 columns, each 70m tall! Tons of pictures here.

Wednesday, January 11, 2012

10 Years of Blogging

Hard to imagine that it has been 10 years since I signed up on Blogger and started blogging! My first post, which has since been moved to a different blog, was on "War and Peace" and Altavista's Babel Fish. Surprisingly the original link to Babel Fish - - still works and redirects to Yahoo's Babel Fish.

Monday, January 9, 2012

Windows 7 on VirtualBox: Random Freeze

Running a Windows 7 guest via VirtualBox on OSX Lion, I noticed that the guest VM would periodically freeze up. The freezes occurred once every few minutes and would unfreeze within half a minute. It was quite annoying and after many months of back-and-forth on the VirtualBox forum, it seems like there is a solution. The solution is to use the Chipset PIIX3 (instead of ICH9) in the virtual machine's motherboard settings