Skip to content

Instantly share code, notes, and snippets.

@automatthew
automatthew / README
Created February 4, 2009 22:18
DEPRECATED: dollarspots owns your loadpath
Stop putting "require 'rubygems'" in your project files. Just madly require
away, assuming that whatever you need will be found in the load path.
Install dollarspots.rb early in your loadpath. It checks the pwd for a file
named .dollarspots.rb and loads it if found. Use .dollarspots.rb files locally
in projects to jigger with your loadpath such that your reckless requires
actually work. Note that this may involve saying "require 'rubygems'".
Call ruby with -rdollarspots, or set "rdollarspots" as your RUBYOPT.
To get TextMate's RubyMate facilities to work you'll need to edit the RUBYOPT
@automatthew
automatthew / methodizer.rb
Created October 14, 2008 20:08
Distinguish origin of Ruby methods
# "local" methods are those defined directly on a constant,
# as opposed to those inherited or mixed in
class Module
def local_class_methods
self.methods.select { |m| self.method(m).owner == self }
end
def local_instance_methods
self.instance_methods.select { |m| self.instance_method(m).owner == self }
@automatthew
automatthew / gist:569
Created July 22, 2008 01:22 — forked from dyoder/domain.rb
domain name class; QUESTIONABLE
# first we will give Domains a little help
class Domain < String
def subdomain( rank = 1 ) ; self.split('.')[0..(rank-1)].join('.') ; end
def level( rank ) ; self.split('.')[(rank*-1)..-1].join('.') ; end
def top_level ; level(1) ; end
end
# now we can treat them like strings but also access domain components naturally