Moved code to a gist.