Skip to content

Instantly share code, notes, and snippets.

@austinhyde
Created June 22, 2015 18:52
Show Gist options
  • Save austinhyde/3fd49df507bdbfe90144 to your computer and use it in GitHub Desktop.
Save austinhyde/3fd49df507bdbfe90144 to your computer and use it in GitHub Desktop.

Revisions

  1. austinhyde created this gist Jun 22, 2015.
    17 changes: 17 additions & 0 deletions convert-percentage
    Original file line number Diff line number Diff line change
    @@ -0,0 +1,17 @@
    $ 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*")'