This file contains hidden or 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
s = '01101000 01100001 01110000 01110000 01111001 00100000 01100010 01100100 01100001 01111001 00100000' | |
a = [] | |
for x in s.split(' '): | |
a.append(chr(eval('0b' + x))) | |
print ''.join(a) | |
happy bday |
This file contains hidden or 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
class ABExtension(jinja2.ext.Extension): | |
"{% abtest 'testname', 'sidename' %} ... {% endabtest %}" | |
tags = frozenset(['abtest']) | |
def parse(self, parser): | |
token = parser.stream.next() | |
testname = parser.parse_expression() | |
parser.stream.expect('comma') | |
sidename = parser.parse_expression() |
This file contains hidden or 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 | |
# vim: fileencoding=utf8:et:sta:ai:sw=4:ts=4:sts=4 | |
import os | |
import sys | |
import gevent.http | |
def handle(request): |
This file contains hidden or 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 | |
# vim: fileencoding=utf8:et:sta:ai:sw=4:ts=4:sts=4 | |
import logging | |
import threading | |
import weakref | |
import greenhouse | |
# ensure greenhouse patching is enabled |
This file contains hidden or 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 | |
# vim: fileencoding=utf8:et:sta:ai:sw=4:ts=4:sts=4 | |
import greenhouse | |
_STOP = object() | |
class RequestSender(object): | |
def __init__(self, hub): | |
self._hub = hub |
This file contains hidden or 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
import greenhouse | |
_count = 0 | |
_local = greenhouse.Local() | |
def current_name(): | |
global _count | |
if not hasattr(_local, "glet_id"): | |
_count += 1 | |
_local.glet_id = _count |
This file contains hidden or 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
from greenhouse import emulation | |
mp_pool = emulation.patched("multiprocessing.pool") | |
def cb(x): | |
print 'callback:', x | |
tp = mp_pool.ThreadPool() | |
tp.apply_async(lambda a, b: a * b, (4, 5), {}, cb) | |
greenhouse.pause_for(0.1) |
This file contains hidden or 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
from greenhouse import pool | |
def async_pool(size): | |
def handler(func, args=(), kwargs=None, callback=None): | |
result = func(*args, **(kwargs or {})) | |
if callback is not None: | |
callback(result) | |
return pool.OneWayPool(handler, size) |
This file contains hidden or 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 | |
# vim: fileencoding=utf8:et:sta:ai:sw=4:ts=4:sts=4 | |
import json | |
import Queue | |
import os | |
import socket | |
import sys | |
import threading | |
import urllib2 |
This file contains hidden or 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
@app.get(r'^/$') | |
def index(http): | |
return 'homepage' | |
@app.get(r'^/phail$') | |
def phailure(http): | |
raise Exception("I have no idea what I'm doing") | |
@app.handle_500 | |
def on_failure(http): |