NK

On Judging a Dev by Their Tools

I have always found that developers who spend time perfecting their tools turn out to be very passionate with their work. After all, it takes a lot of time, trial and error, to figure out the work flow that works best for you.

However that is not to say that devs who do not spend time on their tools are not passionate – there can be a host of reasons why they haven’t focused on building their tools. It’s an asymmetrical indicator.

Consider two devs that both using Vim. One has morphed a boilerplate into their own unique set of key bindings, while the other is still using the boilerplate in stock. Obviously the former has shown ‘effort’ and is likely to enjoy what they do. However no judgement should be made on the latter, perhaps the original key bindings were perfect, or they were too busy focusing on more important things. Who knows.

There are so many asymmetrical indicators that are too easily taken to be symmetrical. Just a random example from my head: a thick French accent indicates that someone is likely to be French, but not having one does not indicate that they are not.

This Is How I Will Social Media.

There are so many different places to communicate with the world nowadays. I find it difficult enough to share things on my blog, let alone on Twitter, Facebook, Coderwall etc. So from now on I will be doing this:

  1. Write stuffs on my blog.
  2. Share the link on suitable social media.
  3. Don’t worry about having to update everything individually.

How to Upgrade Node on Heroku Ruby Buildpack.

This was a real royal pain in the ass. I encountered a problem where ruby-stylus no longer supported the version of Node that came with the default ruby build pack. Steps below are really only for my own reference, if you’re interested in something more detailed please let me know :)

You’ll need an S3 account, gem install vulcan, and fork the ruby buildpack repo.

Create a bucket on S3 for your binaries. Make sure you use US Standard.

Find the version of node that you want, 0.10.17 wasn’t compiling for me so I resorted to using 0.9.9 You can view a list here.

Run this to create the Heroku server that will be used to compile your binaries.

1
vulcan create vulcan-YOURAPPNAME

Update lib/language_pack/ruby.rb, look for NODE_VERSION and put the appropriate version in.

lib/language_pack/ruby.rb
1
NODE_VERSION = "0.9.9"

Update lib/language_pack/base.rb, look for VENDOR_URL and put your S3 bucket URL in.

lib/language_pack/base.rb
1
VENDOR_URL = "https://s3.amazonaws.com/yourbucketname"

Open up Rakefile, update your S3_BUCKET_NAME to the bucket you just created. Make sure that the line that downloads the node package looks like this:

Rakefile
1
2
3
4
5
6
7
8
9
10
11
12
desc "install node"
task "node:install", :version do |t, args|
  version = args[:version]
  name    = "node-#{version}"
  prefix  = "/app/vendor/node-v#{version}"
  Dir.mktmpdir("node-") do |tmpdir|
    Dir.chdir(tmpdir) do |dir|
      FileUtils.rm_rf("#{tmpdir}/*")

      sh "curl http://nodejs.org/dist/v#{version}/node-v#{version}.tar.gz -s -o - | tar vzxf -"

# ...

Newer distros of node are all under the URL format above. Again take a look at this link to see if it applies to you.

Grant List and View permissions of your new bucket to everyone (Heroku will need to use this bucket to download binaries.)

We need to make sure that we send the correct AWS credentials when uploading to the bucket:

1
2
export S3_SECRET_ACCESS_KEY=youaccesskey
export S3_ACCESS_KEY_ID=accesskeyid

Finally we can compile node on the Vulcan Heroku App and store it on our S3 account:

1
rake node:install[0.9.9]

Since we are using our new amazon bucket to serve binaries, it will also need to have copies of some of the other binaries:

1
2
3
4
5
6
# Not sure if all of the below are needed
# Same versions specified in lib/language_pack/rubyrb
rake libffi:install[3.0.10]
rake libyaml:install[0.1.4]
rake ruby:install[2.0.0-p247] # Go get a coffee
rake gem:install[bundler,1.3.2]

To use your new build pack run this:

1
heroku config:set BUILDPACK_URL=https://github.com/yourorg/yourbuildbpackrepo.git

Modifying the build pack seems interesting, there are probably a host of other handy things you can do with it.

Modding the Happy Hacking Keyboard

After reading this post about hacking your HHKB, I set out to do the same thing. Now that I have the finished product, I can truly say that it is freaking awesome to have a keyboard with all your favorite keybindings set in the hardware. Basically I can now ‘plug and go’ into any computer and it just works.

Being able to do this goes beyond the already awesome feel and sound of the HHKB. A modded board is a whole different beast and this is what keyboard nirvana feels like. No more feeling awkward about working on other computers! Just bring your extremely portable modded keyboard ;)

Shamefully, as a programmer I’ve never been much of an electronics guy, although I intend to change that. Originally I was gonna go with a Teensy 2 and try to hack all the hardware together, but after finding this post on Geekhack I decided against risking my precious as a guinea pig for my first ever hardware mod, instead I purchased a complete board from a guy who goes by hasu on GeekHack. If you would like a more detailed guide about how to build this mod yourself, Grumpy Lemming’s guide is a really good start.

Installation was surprisingly easy using Hasu’s board. Everything was in the right place – the board has a hole for the screw in the same spot as the original board. He even made use of the dip switch location to expose the bootloader reset button!

I want to avoid turning this post into a guide, if you get the completed board from Hasu it is extremely straightforward. For complete instructions on how to set this up with a Teensy again check out Grumpy Lemming’s post. Instead I want to focus on describing how I feel this new board has benefited me as a programmer, and why I think every programmer that likes to tweak their workflow should try something like this out.

I’m sure that possibilities are limited only to your imagination, but here are a few of my favorite tweaks that can be easily programmed with the tmk_keyboard repo.

#1 – Dual-purpose modifier keys

What has been the most powerful aspect of this for me are dual purpose modifier keys. For example, the following makes the left control key act as <ESC> when tapped, and <CTRL> when held down.

1
2
3
4
static const uint16_t PROGMEM fn_actions[] = {
  // LControl with tap Esc*
  [2] = ACTION_MODS_TAP_KEY(MOD_LCTL, KC_ESC)
};

When working in VIM, you no longer have to reach up to the edge of the keyboard in order to hit escape, just tap control on your home row :) This may take some getting used to but I promise your fingers will thank you for it!

I realize the same thing can be achieved using something like KeyRemap4Macbook. But overall the flexibility, portability and feel-rightness makes this a superior option!

#2 – Numpad on the home row

The HHKB doesn’t have a numpad. But even when I had a board that did, I rarely used it – it was just too far away. With my current setup I have a numpad centered around J on my home row. When I hold tab (using the same dual-purpose modifier strategy as before), the numpad layer is switched on, something like this:

1
2
3
4
5
6
7
8
9
10
11
12
13
/* Layer 4: Numpad mode
  * ,-----------------------------------------------------------.
  * |Esc|   |   |   |   |   |   |   |   |   |   |   |   |   |   |
  * |-----------------------------------------------------------|
  * |FN0  |  |   |   |   |   | 7 | 8 | 9 | = |   |   |   |Backs|
  * |-----------------------------------------------------------|
  * |Contro|   |   |   |   |   | 4 | 5 | 6 | + |   |   |Return  |
  * |-----------------------------------------------------------|
  * |Shift   |   |   |   |   |   | 1 | 2 | 3 | - |   |Shift |   |
  * `-----------------------------------------------------------'
  *       |Alt|Gui  |           0           |Gui  |Alt|
  *       `-------------------------------------------'
  */

With this setup, numeric input can finally feel like it’s part of the ‘vi-flow’!

#3 – Vi Mode

Although HHKB has some nice arrow key bindings, it never feels right after prolonged use of VIM. My letter f key is now also dual purpose, and when held down it activates vi-mode:

1
2
3
4
5
6
7
8
9
10
11
12
13
/* Layer 2: Vi mode
  * ,-----------------------------------------------------------.
  * |Esc| F1| F2| F3| F4| F5| F6| F7| F8| F9|F10|F11|F12|Ins|Del|
  * |-----------------------------------------------------------|
  * |Tab  |  |   |   |   |   |   |   |PgU|   |   |   |   |Backs|
  * |-----------------------------------------------------------|
  * |Contro|   |   |PgD|FN0|   |Lef|Dow|Up |Rig|   |   |Return  |
  * |-----------------------------------------------------------|
  * |Shift   |   |   |   |   |   |   |   |   |   |   |Shift |   |
  * `-----------------------------------------------------------'
  *       |Alt|Gui  |         Space         |Gui  |Alt|
  *       `-------------------------------------------'
  */

#4 – Mouse Bindings

Yep, you can control the cursor with your keyboard! This is really just a cool-show-off kinda thing but there have been some cases where it actually gets useful, e.g changing focus between scrollable panes on a website. Again, this time I made the escape button on the top left dual purpose – press for <esc>, hold for mouse mouse. In mouse mode hjkl control movement, and the space bar is left click. Like so:

1
2
3
4
5
6
7
8
9
10
11
12
13
14
/* Layer 3: Mouse mode
  * ,-----------------------------------------------------------.
  * |FN0| F1| F2| F3| F4| F5| F6| F7| F8| F9|F10|F11|F12|Ins|Del|
  * |-----------------------------------------------------------|
  * |Tab  |   |   |   |   |   |MwL|MwD|MwU|MwR|   |   |   |Backs|
  * |-----------------------------------------------------------|
  * |Contro|   |   |   |   |   |McL|McD|McU|McR|   |   |Return  |
  * |-----------------------------------------------------------|
  * |Shift   |   |   |   |   |Mb3|Mb2|Mb1|Mb4|Mb5|   |Shift |   |
  * `-----------------------------------------------------------'
  *      |Alt |Gui  |          Mb1          |Gui  |Alt|
  *      `--------------------------------------------'
  * Mc: Mouse Cursor / Mb: Mouse Button / Mw: Mouse Wheel 
  */

There must be plenty of other tweaks and hacks that I haven’t thought of. I’m still continuously tweaking the key mappings in search of that holy grail of key-bindings – it’s been such an enjoyable experience.

Updates

Here are some other tweaks that I’ve adopted so far:

  • LSFT becomes left parenthesis on tap, RSFT is right parenthesis. This one actually came with the tmk_keyboard repo as an existing macro, since there is no real key code to send for the parenthesis’.

  • Remap esc to tilde, I still can’t get used to the replaced tilde for escape next to the 1 key, since I’ve got tap LCTL for escape now, no longer need the original one.