Saturday, January 15, 2011

Workaround for a broken down key on a MacBook Pro

Recently, I had the shocking revelation that my MacBook Pro's down key stopped working. It's a lot like they say about losing your pinky finger, you don't realize how much you need it until its gone. Man, I loved that down key. With the possible exception of the space bar, I probably use the down key more than any key on my keyboard (which may be why it wimped out on me).

The "guru" at the Apple Store told me that fixing it would require an entire replacement of my keyboard, at a cost of ¥30,000. Ouch.

That's just the excuse I needed to buy a new MacBook Air, but the frugal side of me insisted that I explore other options. Like a person losing a pinky finger accomplishing pinky tasks with a ring finger, I could go on if I found a suitable substitute key.

After doing a bit of Googling, it turns out many Mac adapters miss using their "home" and "end" keys. There were quite a few sites explaining how to customize the Mac keyboard to do all sorts of crazy things, including mapping "home" and "end" keys.

This is done by creating the "~/Library/KeyBindings/DefaultKeyBinding.dict" file, which allows Cocoa-based applications (like textmate) to recognize customized key allocations. Here's a good example.

So I followed the same process for the "down" key.

First, open up "Terminal" and type the following.

And add this bit of text.

In case you're not familiar with "vi", this is done by first typing "a", then copying/pasting the code above, then hitting "escape", then typing ":wq".

This was all done, mind you, without the use of a "down" key. Tricky business.

If you're curious, the commands ("moveDown:", etc) are all listed on Apple's developer center - here's the link

Now, "ctrl+(up arrow)" mimics the use of the down key. Similarly, adding the "command" key or "shift" key on top of this also allows you to go to the end of a document, and highlight.

Mind you, this only works for Cocoa-based applications. For now, this will have to do.

Saturday, January 8, 2011

Kyoto Cabinet/Kyoto Tycoon for Python and Mac Snow Leapord

Just playing around with Kyoto Cabinet/Tycoon, the successor to Tokyo Cabinet/Tokyo Tyrant, with apparently better support for concurrency.

Getting it up and running was a breeze in Python/Mac Snow Leapord. I just followed these steps:

Following this tutorial from Kelvin Wong, the steps are the same for Kyoto Cabinet/Kyoto Tyrant as they are for their counterparts in Tokyo.
  1. Get MacPorts
  2. Open a terminal window and enter the following:
  3. Start the Kyoto Cabinet server, by entering the following:
  4. For now, leave the server running. Download and unzip KAMEDAkyosuke's Python implementation of Tycoon.
  5. Save the "" file in a folder called "PyTycoon".
  6. Open a new terminal window, and cd to "/path/to/PyTycoon/..". Run the following code:
If you look at the server instance, you should see a response like the following, indicating that the key was successfully retrieved from the database.

Wallah! Python is now talking to Kyoto Tycoon.