Skip to content

Instantly share code, notes, and snippets.

View deepak's full-sized avatar

Deepak Kannan deepak

View GitHub Profile
LOOKUP_CHAIN = [:params, :user, :session, :http, :default]
# hairy and cryptic
def self.set_by
lookup = LOOKUP_CHAIN.each
begin
meth = lookup.next
end while !(locale = send("by_#{meth}", meth) rescue nil);
locale
end
@deepak
deepak / functions.sh
Created August 28, 2012 05:40 — forked from foca/functions.sh
# cd into a matching gem directory. Pass a grep compatible
# regular expression. If you don't pass anything, it goes
# to the root gem directory.
cdgem ()
{
local gempath=$(gem env gemdir)/gems;
if [[ $1 == "" ]]; then
pushd $gempath;
return;
fi;
module Boolean
end
class TrueClass
include Boolean
end
class FalseClass
include Boolean
end