How to Type

25 Aug 2014

When I was in college I relearned to play the piano. It’s not that i had forgotten or even played especially badly, but I was in some sense doing it all wrong. The process of relearning was at times deeply upsetting as my body continued to complain, hey, I’ve got this! if i tried to get it to do something different. And the rewards only became clear years after as I continued to teach myself in the afterlife of my schooling. Here are some of them:

  • greatly reduced risk of injury
  • freedom from discomfort and cramping
  • penalty for not playing every day greatly reduced
  • need to play hours of advanced technical studies in order to stay in top form greatly reduced
  • increased sensation of freedom and joy in all movements
  • greater sensitivity and range of expression

What’s maybe surprising is how few of these directly address any elements of musicality. It’s enormously reassuring to me to think that someone was looking out for my well-being at a time when clearly i wasn’t. Not injuring myself, I am finding, is increasingly appearing at the top of my list of goals for just about any endeavor that has a risk of injury.

If you’ve ever suffered an RSI as a result of typing, I’m going to urge you to hold a similar attitude whenever you sit at the keyboard. Were you pairing programming with me, I’d want for you to experience the same freedom and joy as you type that I feel when playing a musical instrument. Even above, say, not violating the law of demeter or single responsibility principle. If that doesn’t surprise you, do read on. You may even be interested in how i synthesized the principles of touch typing, ergonomic keyboards, the Alexander Technique and emacs in pursuit of these goals as a software developer.

The Posture

The Alexander Technique has a great deal to say about posture. Too much, in fact, to cover fully here. But here are some points that have served me well over many years as a keyboardist:

  • Use a chair and desk that allow you to sit up straight with the spine elongated and curved in the lumbar and neck.
  • Sit (or stand!) at the desk so that the arms may hang down freely from the shoulders, the elbows dangling at the side.
  • When striking a key, avoid resting the wrists on the desk, or raising them too high. From the side, the top of the forearm down to the knuckle will describe almost a straight line, the underside curved, like a bridge.
  • The hand is strong, relaxed and curved, as if formed around a ball.

What I learned from touch typing

  • When pressing shift, control or meta (also known as the alt or option key) in combination with another key, avoid pressing both with the same hand. And by avoid I mean don’t ever, ever do that.

The keyboard

  • If your keyboard does not have a shift, control and meta key on both sides, then it is defective by design. Get a better keyboard, or rebind the keys (I’m looking squarely at you, MacBook).
  • For greater ease in pressing the control key, use an ergonomic keyboard that allows you to use the palm of your hand. Emacs pinkie be gone!
  • Use an ergonomic/split keyboard that allows your hands and arms to be square and roughly a shoulder’s width apart, not bunched in the middle of your desk.
  • Up to a point, the more resistance the keys offer, the easier it will be. If you can’t relax the hand and arms without depressing keys by mistake, consider trying another.

The Alexander Technique

  • Type from the shoulders. The greatest movement will begin in the upper body, the smallest movement will be performed by the fingers themselves. Hardly move your fingers at all.
  • Do not extend the fingers in order to press a key that lies outside of the home row. Move the hand and arm to accommodate.
  • You unavoidably need to create tension in order to perform a movement. Learn to observe that tension, and release it after the execution of each movement.
  • Practice, sitting down away from the desk, by holding one arm by the wrist using the other hand at chest height, the elbow by the side. Relax the arm completely by holding the complete weight in the supporting hand (even better - have someone else support you). Observe the sensations you feel and try to recreate them at all times. Remove the supporting hand and let the arm freefall into the lap.
  • Try to imagine this movement as you lift the arm and let it fall as you depress a key. At the moment of impact, a small amount of tension is needed to form your bridge in order to strike the key accurately. Immediately after, this tension can be completely released, as when resting in the lap.
  • Practice alternately forming that strong bridge-like position in the hands and arms and then allowing them to relax completely.
  • The hand and arm is heavy enough to depress a key using gravity alone. You will gradually learn to type by transferring this weight from key to key in a fluid and effortless motion.

Padrino with Sidekiq

30 Jul 2014

I recently added sidekiq to a padrino app. Mounting the sinatra app wasn’t completely straightforward, and I didn’t find everything I needed in one place. So here’s an attempt to do just that.

First, add sidekiq to your gemfile, and bundle install:

# Gemfile
# Project requirements
gem 'sidekiq'
bundle install

Now, tell padrino to mount the app, and stub some methods to make it play nice:

# config/apps.rb
require 'sidekiq/web'

class Sidekiq::Web < ::Sinatra::Base
  class << self
    def dependencies; []; end
    def setup_application!; end
    def reload!; end
  end
end

Padrino.mount(
  'Sidekiq',
  app_class: 'Sidekiq::Web',
  app_root: Sidekiq::Web.root
).to('/sidekiq')

Now, create a workers directory in your app, and add all workers to the load paths:

# app/workers/sample_worker.rb
class SampleWorker
  include Sidekiq::Worker
  sidekiq_options retry: false

  def perform
    # Lots of hard working code....
  end
end
# config/boot.rb
Padrino.before_load do
  Padrino.dependency_paths << Padrino.root('app/workers/*.rb')
  Padrino.set_load_paths('app/workers')
end

Add the following to your rackup config file:

# config.ru
require 'sidekiq/web'
map('/sidekiq') { run Sidekiq::Web }

Add workers.rb to your config directory and tell it how to find your workers:

# config/workers.rb
path = File.expand_path('../../workers/*.rb', __FILE__)
Dir[path].each { |file| require file }

Finally, add a Procfile with the following content:

# Procfile
web: bundle exec thin start -p $PORT
worker: bundle exec sidekiq -r ./config/workers.rb

Choco

30 May 2014

One of the first things I knew I had to do when I switched to emacs was to have it use my favorite color theme, choco. Choco was created by Ludvig Widman for the TextMate editor and later adapted for gedit.

Now, I feel guilty for possibly putting too much emphasis on aesthetics, but I do love choco and it’s for a number of reasons:

  • It is dark, and I will often look at it all day. anything lighter feels like staring at a lightbulb.
  • Just looking at its combination of colors makes me intensely happy, and I’ve never experienced that with any other theme, and maybe anything in art or nature (okay, okay…)
  • Yes, I love chocolate. which in turn makes me intensely happy
  • It reminds me, for various reasons, of games from childhood, such as super mario world, super mario kart, and m.c. kids, which in turn makes me intensely happy

If anything, adding the theme to emacs seemed like the perfect introductory elisp project. Among the more delightful things I learned along the way was that ruby-mode ships with ruby. Alright!

The results are here. Contributions are welcome!