Skip to content

Instantly share code, notes, and snippets.

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
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()
#!/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):
@teepark
teepark / patch_current_thread.py
Created November 28, 2012 19:56
patch_current_thread.py
#!/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
#!/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
import greenhouse
_count = 0
_local = greenhouse.Local()
def current_name():
global _count
if not hasattr(_local, "glet_id"):
_count += 1
_local.glet_id = _count
@teepark
teepark / gist:3616725
Created September 4, 2012 04:53
multiprocessing's threadpool on greenhouse emulation
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)
@teepark
teepark / gist:3616634
Created September 4, 2012 04:33
a greenhouse-based workalike to multiprocessing.pool.Pool.apply_async
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)
@teepark
teepark / level08-exploit.py
Created August 31, 2012 21:40
level 8 of the stripe CTF
#!/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
@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):