This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
#!/usr/gnu/bin/sed -rf | |
s_\|\s*(\[\S+\s*)?([^\|]+)\]?\s*\|\|([^\|]+)\|\|.*_"\2" <\3>, _ | |
s_ "_"_g | |
s_]"_"_ | |
s_< _<_ | |
s_ >_>_ | |
s_\s*\(at\)\s*_@_g | |
s_\s*\(dot\)\s*_._g | |
s_\s*\[dot\]\s*_._g |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
# http://github.com/c42/goldberg/raw/master/Gemfile | |
source 'http://rubygems.org' | |
gem 'rails', '3.0.5' | |
gem 'sqlite3', '~> 1.3.3', :platforms => :ruby | |
gem 'haml', '~> 3.0.25' | |
platform :jruby do |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
enum OS { | |
DOS('PC DOS 2000 License'), WIN('Genuine Windows 7 Professional 32'); | |
private final String text | |
private OS(text) { this.text = text } | |
public static parseText(text) { OS.values().find { it.text == text } } | |
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
'''Hooks for lettuce to run a test pylons app''' | |
from lettuce import * | |
from paste.fixture import TestApp | |
import pylons.test | |
from paste.deploy.loadwsgi import loadapp | |
from paste.script.appinstall import SetupCommand |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
def prime_generator(): | |
potential = 2 | |
primes = [] | |
while True: | |
while any(potential % x == 0 for x in primes): | |
potential += 1 | |
yield potential | |
primes.append(potential) |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
// if you're going to send back... | |
{ | |
'status' : 'Failure', | |
'message' : 'Resource creation failed', | |
'errors' : ['Problems creating resource in the system'] | |
} | |
// ... you might as well just save everyone the trouble and send back... | |
{ 'shit happened': true } |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
#!/usr/bin/env python | |
class Foo(object): | |
def explicit_method(self): | |
return 'called explicit method' | |
def __getattr__(self, name): | |
def method_missing(*args, **kwargs): | |
return 'called %s with %d arguments %s & %d keywords %s' % (name, len(args), args, len(kwargs), kwargs) | |
return method_missing |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
facTramp = { n, r = 1 -> if (n < 3) { r * n } else { facTramp.trampoline(n - 1, r * n) } }.trampoline() | |
facIter = { n -> (2g..n).inject(1){ a, e -> a * e } } | |
assert facTramp(100g) == facIter(100g) |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
#!/usr/bin/env python | |
# dear pythonista, | |
# if... | |
__builtins__.open == 'foo' | |
# ... is allowed yet results in... | |
print __builtins__.open #=> <built-in function open> |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
#!/usr/bin/env python | |
True, False = False, True | |
if False: | |
print 'what the!?!?!?' |