Skip to content

Instantly share code, notes, and snippets.

@danp
Created April 12, 2013 02:07
Show Gist options
  • Select an option

  • Save danp/5368741 to your computer and use it in GitHub Desktop.

Select an option

Save danp/5368741 to your computer and use it in GitHub Desktop.
line-based `hexdump -C` like thing
puts $_.chars.map {|c| if !/\A[[:graph:]]\z/.match(c) then c = "" end; "%2s" % c }.join(" ")
puts $_.chars.map {|c| "%02x" % c.ord }.join(" ")
$ git remote -v | ruby -lan line_based_hexdump_c.rb
o r i g i n h t t p s : / / g i t h u b . c o m / k r / h k ( f e t c h )
6f 72 69 67 69 6e 09 68 74 74 70 73 3a 2f 2f 67 69 74 68 75 62 2e 63 6f 6d 2f 6b 72 2f 68 6b 20 28 66 65 74 63 68 29
o r i g i n h t t p s : / / g i t h u b . c o m / k r / h k ( p u s h )
6f 72 69 67 69 6e 09 68 74 74 70 73 3a 2f 2f 67 69 74 68 75 62 2e 63 6f 6d 2f 6b 72 2f 68 6b 20 28 70 75 73 68 29
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment