Initial commit: port from gist.