Skip to content

Instantly share code, notes, and snippets.

@andrepiske
Created September 7, 2021 11:49
Show Gist options
  • Select an option

  • Save andrepiske/91d7c9506ec8f4f0c2265f54c2071158 to your computer and use it in GitHub Desktop.

Select an option

Save andrepiske/91d7c9506ec8f4f0c2265f54c2071158 to your computer and use it in GitHub Desktop.
Unlolify (ASCII)
def unlolify(n);s=n.to_s(2);s.rjust((s.length/8.0).ceil*8,'0').split('').each_slice(8).to_a.map{|x|x.join.to_i(2).chr}.join;end
def lolify(s);s.split('').map{|x|x.ord.to_s(2).rjust(8,'0')}.join;end
# > unlolify(lolify('Hello, world!').to_i(2))
# => "Hello, world!"
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment