(Direct link to the gist.)