Trying to follow this gist

https://gist.github.com/kr/299535bbf56bf3016cba