Initial commit.
Moved from Gist: https://gist.github.com/ydnar/666f0bf5945d76592616