Skip to content

Instantly share code, notes, and snippets.

@jorrel
jorrel / inherit_from_self.rb
Created February 16, 2009 09:25 — forked from jcoglan/inherit_from_self.rb
cool, I'll have one
# Subclass of Module, used for storing methods copied from other
# modules and classes. This lets classes shuffle their methods off
# into a module to we can place other modules in front of the
# class's own methods
class StashModule < Module
class << self
def [](id)
@modules[id]
end
@jorrel
jorrel / bench.rb
Created January 23, 2009 07:19 — forked from wycats/bench.rb
Cool memoization by wycats. I love the method_added hook and the replaceable 'kind'
require "rubygems"
require "rbench"
RBench.run(500) do
report("memoed") do
Foo.memoed("hello")
end
report("unmemoed") do
Foo.unmemoed("hello")
end