answer to gist: https://gist.github.com/tsnow/a7233daf4b2efe064a8f