Skip to content

Instantly share code, notes, and snippets.

View h3h's full-sized avatar

Bradford Fults h3h

View GitHub Profile
@h3h
h3h / thing.rb
Created April 12, 2010 15:51
Sharing a value slot across multiple objects.
class Thing
@@things = {}
def initialize
@pointer = self.hash
end
def set(x)
@@things[@pointer] = x
end
@h3h
h3h / gist:321336
Created March 4, 2010 02:35
bash aliases for running test/spec tests
# test/spec test runner
function ts()
{
ruby $1 -r s 2>/dev/null | grep -v "^HelperTestCase" | grep -v "dummy (e"
}
# test/spec test runner (with test name)
function tsn()
{
ruby $1 -r s -n "/$2/" 2>/dev/null | grep -v "^HelperTestCase" | grep -v "dummy (e"
autodetach on
defkanji euc
deflogin on
startup_message off
defscrollback 100000
defshell -bash
chdir
term "xterm"
escape ^Tt
encoding UTF-8 UTF-8
class Time
def within?(time_period)
self >= Time.now && self <= Time.now + time_period
end
end
# >> (Time.now + 55.hours).within? 2.days
# false
# >> (Time.now + 45.hours).within? 2.days
# true