Skip to content

Instantly share code, notes, and snippets.

@austinhyde
Created June 22, 2015 18:52
Show Gist options
  • Star 1 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save austinhyde/3fd49df507bdbfe90144 to your computer and use it in GitHub Desktop.
Save austinhyde/3fd49df507bdbfe90144 to your computer and use it in GitHub Desktop.
CLI convert percentage to Unicode box
$ echo 0 | ruby -ne 'puts (n=($_.to_f*8).ceil)==0?" ":[[8,[0,n].max].min+0x2580].pack("U*")'
$ echo .25 | ruby -ne 'puts (n=($_.to_f*8).ceil)==0?" ":[[8,[0,n].max].min+0x2580].pack("U*")'
$ echo .3 | ruby -ne 'puts (n=($_.to_f*8).ceil)==0?" ":[[8,[0,n].max].min+0x2580].pack("U*")'
$ echo .4 | ruby -ne 'puts (n=($_.to_f*8).ceil)==0?" ":[[8,[0,n].max].min+0x2580].pack("U*")'
$ echo .8 | ruby -ne 'puts (n=($_.to_f*8).ceil)==0?" ":[[8,[0,n].max].min+0x2580].pack("U*")'
$ echo 1 | ruby -ne 'puts (n=($_.to_f*8).ceil)==0?" ":[[8,[0,n].max].min+0x2580].pack("U*")'
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment