add bin script

Taken from @latentflip's #56 but fixed merge conflicts from `0.3.4`

Closes #56