Skip to content

Instantly share code, notes, and snippets.

View trek's full-sized avatar
🏳️‍🌈

Trek Glowacki trek

🏳️‍🌈
View GitHub Profile
# Sets up expectation so that times aren't off by moments
Time.should_receive(:now).and_return(@current_time)
@current_time.should_receive(:to_i).and_return(1214619134)
class Me
def who
self
end
def holdit
self.method(:who)
end
end
var Foo = function Request(options) { this.initialize.apply(this, arguments) };
OPTIONS = new Hash({'format': false, 'async': true})
@xhr[:onreadystatechange] = self.on_state_change
this.$xhr.$onreadystatechange = this.onStateChange();
return $nil
if ($T(type.match((/DOMMouseScroll|mousewheel/)))) { var wheel = ($T(nativeEvent.wheelDelta) ? (nativeEvent.wheelDelta / (120)) : ($T(_a=nativeEvent.detail)?_a:(0).-() / (3))); };
// a = nativeEvent.detail.-()
class BalanceError(Exception):
value = "Sorry you only have $%6.2f in your account"
class BankAccount:
def __init__(self, initialAmount):
self.balance = initialAmount
print "Account created with balance %5.2f" % self.balance
def deposit(self, amount):
self.balance = self.balance + amount
@trek
trek / routes.py
Created September 25, 2008 20:17
from routes import *
from routes.util import url_for
m = Mapper()
m.resource('blog', 'blogs')
m.create_regs(['blogs'])
url_for('blog', id=2) # outputs '/blogs/2'
m.match('/blogs/2') # no match
if foreigner = terrorist
imprison(foreigner)
else
release(foreigner)
end