Going Through Old (and Newish) Notes
Tomboy make it really easy to take notes, but that means they build up, so here’s a few that I’m cleaning out. All of the code ones are in Python.
| Note | Notes on the note |
|---|---|
|
Austerely simple Argh!! |
Pick one word. |
def no_cache(app):
def new_app(environ, start_response):
def new_start_response(status, headers):
start_response(status, headers + [('Cache-Control', 'no-cache')])
return app(environ, new_start_response)
return new_app
|
WSGI middleware to prevent caching |
|
Python switch def switch(expr1, rules, *args, **kwargs):
'''Somewhat like switch in C
Example:
switch('spam', {
'eggs': func1,
'spam': func2,
97: func3
switch.default: func4
}, 4, 7, foo='bar')
results in the call func2(4, 7, foo='bar')
'''
for expr2 in rules:
if expr1 == expr2 or callable(expr2) and expr2(expr1):
func = rules[expr2]
break
else:
func = rules[switch.default] # may raise KeyError. OK
return func(*args, **kwargs)
switch.default = object()
|
|
|
White Gold 1 Goldschlager |
Milk-based drinks aren’t very good, but I like the name I invented for this. |
|
Crush whitespace crush_whitespace = functools.partial(re.compile(r'\\s+').sub, (' ',))
|
|
|
WFNP/Minstrel Boy At 17 minutes and 49 seconds, Minstrel Boy is hardly a quote-unquote radio song. That's why, in the spirit of college radio, I am requesting this mellow, yet epic closing track of the sophomore album from Joe Strummer and the Mescaleros, 2001's Global a Go-Go. Usually reserved for an intimate hour listening through the whole album, Minstrel Boy is also appropriate at this hour, to lull New Paltz students to their peaceful beds, happy to be alive. |
I called my friend's college radio show to request the least radio friendly song possible. He made me stick to a script. |


