Skip to content

Instantly share code, notes, and snippets.

@da3mon
Created January 16, 2013 19:15
Show Gist options
  • Save da3mon/4549888 to your computer and use it in GitHub Desktop.
Save da3mon/4549888 to your computer and use it in GitHub Desktop.
#!/usr/bin/env ruby -wKU
# encoding: UTF-8
class Flip
# sɹǝɔuɐʃɐqpɐoʃ ƃuıʞɔnɟノ(ಠ 益ಠ ノ) -> (ノಠ益ಠ)ノ彡fucking loadbalancers
# add arg support for flipping, reverse flipping, copying to clipboard, text, table, face style
TABLE = {
"a" => "\220\311", "b" => "q", "c" => "\224\311", "d" => "p", "e" => "\235\307", "f" => "\237\311", "g" => "\203\306", "h" => "\245\311", "i" => "\261\304",
"j" => "\276\311", "k" => "\236\312", "l" => "\203\312", "m" => "\257\311", "n" => "u", "r" => "\271\311", "t" => "\207\312", "v" => "\214\312", "w" => "\215\312",
"y" => "\216\312", "." => "\231\313", "[" => "]", "(" => ")", "{" => "}", "?" => "\277\302", "!" => "\241\302", "\"" => ",", "<" => ">", "_" => "\276\200\302",
";" => "\233\330", "\277\200\302" => "\200\201\302", "\205\201\302" => "\206\201\302", "\264\210\342" => "\265\210\342"
}
def self.create(*text)
new(text).flip
end
attr_reader :table
def initialize(*text)
@flipped, @text = "", text.join(" ")
mirror_table
end
def flip
@text.each_char do |char|
@flipped += table.keys.include?(char) ? table[char] : char
end
@flipped.reverse!
end
private
def mirror_table
@table ||= TABLE.inject({}) { |h,(k,v)| h[v] = k; h[k] = v; h }
end
end
if __FILE__ == $PROGRAM_NAME
puts Flip.create(*ARGV)
end
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment