Skip to content

Instantly share code, notes, and snippets.

View liaden's full-sized avatar

Joel Johnson liaden

  • OmadaHealth
  • Atlanta
View GitHub Profile
@liaden
liaden / gist:8543292ac7a02a2fb7fc
Last active August 29, 2015 14:11
because singletons are bad
# before
class X
# imperative, affects system state, depends on globals
def self.x
puts Config.data
end
end
X.x
class Object
# as inspired by bash
def tee(*functions)
self.tap do
args.map { |arg| arg.call(self) }
end
end
end
class SomeClass
letters = "ABCDEFGHIJKLMNOPRSTUVWXYZ"
map = {}
letters.each_char.each_with_index do |c, i|
map[c] = letters[(i+13)%26]
end
map.keys.each do |k|
map[k.downcase] = map[k].downcase
end