Initial commit.

Copied from https://gist.github.com/davatron5000/9144421