Skip to content

Instantly share code, notes, and snippets.

@Cosmo
Last active July 31, 2019 07:08
Show Gist options
  • Save Cosmo/3282cd9f2c47381b5ff8901eff7aac1f to your computer and use it in GitHub Desktop.
Save Cosmo/3282cd9f2c47381b5ff8901eff7aac1f to your computer and use it in GitHub Desktop.
Different ways to say "moin" (hello in german) in Ruby.
# July 16, 2019
"bdic".tr("a-e", "l-p")
# July 17, 2019
require 'zlib'
Zlib.inflate("x\x9C\xCB\xCD\xCF\xCC\x03\x00\x04E\x01\xB4")
# July 18, 2019
"$;6]I;@``\n".unpack1("u")
# July 19, 2019
"moim".succ
# July 20, 2019
Hash[{2=>"o", 4=>"n", 1=>"m", 3=>"i"}.sort_by { |k, v| k }].values.join
# July 21, 2019
m, o, i, n = "m", "o", "i", "n"
m+o+i+n
# July 22, 2019
["o", "m", "n", "i"].each_slice(2).map(&:reverse).join
# July 23, 2019
"h a l l o".split(/\w/).map { |l| l.size > 0 ? l.size.chr : nil }.join
# July 24, 2019
"mmmooiiiiiinnn".squeeze
# July 25, 2019
%W(n m o i).rotate.reduce(:+)
# July 26, 2019
%W(m o m o i o i m n i m n o m o).uniq.reduce(:+)
# July 27, 2019
(%W(f a m c o j v k t i z n y) & %W(x n i b l o p i w m q)).join
# July 28, 2019
%W(m i).zip(%W(o n)).join
# July 29, 2019
class MoinMaker
attr_accessor :content
def initialize
self.content = ""
end
def make
0.upto(13) do |i|
0.upto(15) do |j|
0.upto(9) do |k|
0.upto(14) do |l|
self.content = (96+i).chr + (96+j).chr + (96+k).chr + (96+l).chr
end
end
end
end
end
end
moinMaker = MoinMaker.new
moinMaker.make
puts moinMaker.content
# July 30, 2019
[false,true,true,false,true,true,false,true,false,true,true,false,true,true,true,true,false,true,true,false,true,false,false,true,false,true,true,false,true,true,true,false].each_slice(8).map { |s| s.map { |b| b ? "1" : "0" }.join.to_i(2).chr }.join
# July 31, 2019
["o", "m", "n", "i"].permutation.to_a[7].join
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment