Monday, December 31, 2012

The Law of Comparative Advantage

Heard about Comparative Advantage on the CBC Ideas program, episode The Screw That Changed The World. The colourful analogy was: although Winston Churchill was a good bricklayer, he is better off to run the country and pay someone else to build his walls. Similarly, the brick layer is better off building walls, whilst paying W.C. to run the country. It's food for thought for someone like myself, who likes to dabble a bit in everything.

Monday, December 24, 2012

Nokia N8 Upgrade to Belle 111.040.1511

I've been putting off any changes to my N8 until I had a lot of spare time in case anything should go wrong. Up to today, I was running a custom Belle firmware (don't remember the details) that I had modified slightly (default analog clock, fixed some errors with the little icons along the top, etc). It was reliable and fast, and I loved the customizability. But a few months ago, the Store stopped working. It would load, but I couldn't go to the screen with My Stuff to check for updates, and I couldn't download new content.

Removing the custom firmware took a little research. The generally accepted procedure is to flash the N8 with the 11.5 Scandinavian version, after which you can install whatever you like: Anna, Belle, etc. Problem is, v11.5 no longer appears in Navifirm. After some hunting, I finally found a copy on the N8FanClub site.

Flashing the N8 did not take long at all.

  • Close all applications and make a full backup using Nokia Suite.
  • Power down the N8.
  • Remove the microSD card and the SIM (this may not be really necessary because I forgot once, and nothing happened. Still, may not be a bad idea).
  • Uninstall Nokia Suite to prevent it from popping up every time the N8 is reconnected to the computer.
  • Install Phoenix.
  • Copy the Scandi firmware to Phoenix\Products\RM-596.
  • Start Phoenix, select the port the N8 is connected to.
  • Press ctrl-R to rescan.
  • Select Flashing -> Firmware Update and press the button with the three dots.
  • Choose firmware 0598984 Scandinavian DG.
  • Press the Refurbish button.
  • After programming the phone is complete, it was necessary to manually power up the phone and abort Phoenix. For some reason, it was waiting for a communications check with the phone, but the phone stayed powered down. Fortunately, the phone didn't brick. Once the N8 powered up, it was clearly running older firmware and was ok. Yay.
  • Rename the Scandi RM-596 directory, to save it for next time.
  • Download the new firmware and put it in Phoenix\Products\RM-596. At first I downloaded and flashed 111.030.609 since that was the most recent version for my phone (059C8T6), but when I realized that it was an old version of Belle, I threw it out. Reflashed to Scandi 11.5, and grabbed nam_0599218. The product code doesn't match (0599218 vs 059C8T6), but I did confirm that nam = North America. It seemed like a low risk substitute. If anything went wrong, I could just reflash, right?
  • With the new firmware in the RM-596 directory, restart Phoenix and connect the N8.
  • Select the right USB port, press ctrl-R, and select Flashing -> Firmware Update again.
  • Select the button with the three dots. The new firmware (0599218 nam) should appear).
  • This time select Update Software.
  • After about 5 minutes, the phone has been updated.
  • Restore the phone from backup, and enjoy setting up your N8 again.

The curious thing is that after I upgraded with the nam 599218 firmware, my phone still shows Product Code = 059C8T6. Unexpected, but I can live with that.

Lamb Korma

A creamy stew with tender chunks of lamb. Lamb shanks take a long time to cook, but are cheap, flavourful, and yield a gelatin-rich broth. Based on this recipe from IndiaCurry.com.

Onion paste

  • 4 medium sized onions, halved and peeled
  • 8 cloves garlic, peeled
  • 2 inches ginger, peeled
Whiz in a food processor and set aside.

Nut paste

  • 1/2 cup almonds
  • 1/4 cup cashews
The quantity and ratio of nuts is approximate and open to adjustment. Chop the nuts in a food processor, adding water a little at a time until a slurry forms. From 1/2 cup to 1 cup of water will be needed. Set aside in a covered container. This nut paste won't be needed until the korma is almost done.

Spice load

  • 1 tsp cumin seeds
  • 8 black cardamom pods (crack open, save insides, discard shells)
  • 16 pepper corns
  • 14 cloves
  • 1-2 dried hot peppers (optional)
  • 4 cinnamon sticks, 3" long, each broken in half
Except for the cinnamon sticks, grind the spices with a mortar and pestle and set aside. The recipe takes a long time to cook, so a medium-coarse grind is enough. Be sure to crack open all the peppercorns, as they never seem to disintegrate on their own.

Yogurt thickener

  • 2 cups yogurt
  • 2 tsp flour
Whisk together and set aside.

The main event

Ingredients
  • 5-6 lbs lamb shanks, bone in. (Have the butcher cut each lamb shank into 3 pieces.)
    • Alternately, an equal mix of lamb shanks and lamb shoulder. If using this, debone the shoulder and add that meat later so it doesn't disintegrate during the long cooking time.
    • If the lamb shanks did not get cut by the butcher, a hack saw works too. Just make sure to clean it before and after.
  • Bacon fat saved from previous fry ups, or ghee, or olive oil
  • 1 tsp cumin seeds
  • 1/2 cup red wine (optional)
  • 2 cups water (approximate)
Preparation
  1. Brown the lamb (while still frozen is ok, but watch for leftover bits of plastic wrapping) with the bacon fat in a large, heavy bottom pot and set aside.
  2. Let the pot cool for a few minutes.
  3. Add another spoon of bacon fat if necessary, and fry the cumin seeds for about a minute on medium heat.
  4. Add the onion paste, and fry until some of the moisture has evaporated. It will start turning greenish brown.
  5. Add the ground spices and broken cinnamon sticks, and fry for another 2 minutes.
  6. Add the lamb (shanks, bones, and tougher cuts as applicable) and mix well.
  7. Turn off the heat and stir in the yogurt / flour mixture. Slowly heat the mixture up to a bubble. Gradual heat is needed so the yogurt does not curdle. (Note: I use a medium heat and stir frequently. I've never seen the yogurt curdle yet.)
  8. Stir in the red wine and add water until the lamb is almost covered. Gently bring the mixture to a bubble again. Cover and simmer, stirring occasionally.
  9. After about an hour, consider adding the tender cuts of lamb if you used them.
  10. After about 1.5 to 2 hours since cooking began, the meat will start falling off the bones. Debone or cut the meat off some of the larger chunks manually, to reduce cooking time. If desired, remove the bones, but scoop or push any marrow back into the pot.
  11. Optional: add raw, chopped potatoes, carrots, or other vegetables, and simmer until they are done. Cooked chickpeas can also be added.
  12. Once the lamb is tender and once the vegetables (if any) are done, but before the lamb falls apart, stir in the nut paste to thicken the broth. Simmer an additional 5-10 minutes on low heat.
  13. Season with salt and pepper to taste.
Serve with (basmati) rice.

Tuesday, December 11, 2012

2005 Impreza headlight bulb replacement (again)

Two days short of a year after I replaced the Sylvania XVs on my Impreza, I had to do it again. I hadn't been paying attention, so one bulb may have burned out long ago. I just know that I had to drive home well after sunset with neither bulb working. The cool thing is while I was checking for a blown fuse at work before heading out, a fellow Subie driver wandered over to see if I needed help.

Once again, I chose the Sylvania XVs over the generic H1s at Canadian Tire, for a cost of $10 extra per pair. I like how bright they are, but I'll be on the lookout for bulbs that last longer.

It was not as warm this time, but at least it wasn't windy or raining. Also, I've upgraded my headlamp to a Petzl Tikka XP2, so the lighting situation was better.

Saturday, July 28, 2012

Lenovo x220t trackpoint problem and solution

So, it happens that the x220's screen rests on the trackpoint when it's flipped around in tablet mode. If the display wiggles enough to nudge the trackpoint, the cursor will drift away and refuse to go where the pen is pointing for 5-10 seconds. Pretty annoying, wouldn't you say? Took me awhile to figure out what was going on, too!

My "fix" is an AutoHotkey script to disable the trackpoint. I then configured the screen rotation button so that a long press triggers the script. Here's the AutoHotkey script:


; Enable either trackpoint or touchpad (toggle the setting)
#z::
Run C:\Program Files\ThinkPad\UltraNav Utility\UNAVOSD.EXE
Sleep 200
PixelGetColor, touchPadOnlyEnabled, 30, 135
if ( touchPadOnlyEnabled = 0xffffff )
{
  Click 300, 100 ; enable trackpoint
}
else ; trackpoint or both are enabled
{
  Click 300, 135 ; enable touchpad only
}
return

That is saved to "AutoHotkey.ahk" in My Documents. The file was actually created by AutoHotkey when I asked it to create a sample script. I just gutted it and added the above code. When the Left-Windows key is pressed together with the Z key, the action is triggered.

How it works is:

  • Run the Lenovo UltraNav Device Settings program, UNAVOSD.EXE. This is the same program that's run when you press Fn-F8. It requires that both the trackpoint and the trackpad be enabled in the BIOS.
  • Sleep for some time to let the on screen display (OSD) appear.
  • Peek at the UltraNav OSD to see if just the touchpad is enabled.
  • Enable just the trackpoint or just the touchpad depending on the pixel value retrieved in the previous step.

There are a few weaknesses about this script:

  • It enables only the trackpoint or the touchpad. I never enable both, but it's easy to change the logic if you like. FWIW, the coordinates of the "enable both" option is near x=300, y=65.
  • The script relies on hard-coded coordinate values and pixel color values. A change to the UltraNav OSD could break the script.
  • It relies on a sleep which may not be appropriate for slower computers.

To configure the screen rotation button, go to Control Panel -> Hardware and Sound -> Tablet PC Settings -> Set tablet buttons to perform certain tasks (aka the Buttons tab) -> Change. In the dialog, change "Press and hold" to "Press a key or key combination". Then enter the key sequence in the Keys field.

Hope that helps!

Monday, February 20, 2012

Ruby on Rails, Part 1: Installation

Installing Ruby on Rails in Ubuntu 11.10 involves basically these things:

  1. Install Ruby:
    • sudo apt-get install ruby
    • After this, you should be able to use "irb", interactive ruby.
  2. Install RubyGems:
    • sudo apt-get install rubygems
    • This will make it easier to work with ruby, um, gems.
  3. Install Rails:
    • gem install rails
    • The version of rails I've installed (3.1) seems to assume sqlite will also be installed, so:
    • sudo apt-get install libsqlite3-dev
    • Then, rails server wouldn't run because it "could not find javascript runtime", so:
    • sudo apt-get install nodejs

Because I wanted to use mysql, git, and vim:

  1. Install MySQL:
    • sudo apt-get install mysql-server
    • sudo apt-get install libmysqlclient-dev
  2. Install git:
    • sudo apt-get install git
  3. Install the rails extension for vim:
    • sudo apt-get install vim-rails

After all this, I was able to run initialize a new project named foo:

rails new foo

And create a database in mysql:

$ mysql -u root
mysql> create database test;
mysql> show databases;
mysql> exit