Skip to content

Instantly share code, notes, and snippets.

@coder36
Created January 13, 2015 14:14
Show Gist options
  • Select an option

  • Save coder36/6d3e84c22f1b4da386ce to your computer and use it in GitHub Desktop.

Select an option

Save coder36/6d3e84c22f1b4da386ce to your computer and use it in GitHub Desktop.
Hello World encoding to binary and back
"Hello world".bytes.map { |b| b.to_s(2).rjust(8, '0') }.join.to_i(2).to_s(2).scan(/.+?(?=.{8}*\z)/).map {|s| s.to_i(2).chr}.join
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment