Skip to content

Instantly share code, notes, and snippets.

import time
import pymemcache.client
import pymemcache.serde
class PoliteClient(pymemcache.client.Client):
"""A sublcass of :class:`~pymemcache.client.Client`, which
waits a configurable period before attempting to reconnect
after a disconnect.
init_config:
instances:
- host: localhost
port: 10104
name: master
conf:
- include:
domain: hadoop
bean: hadoop:name=MasterStatistics,service=Master
>>> def foo(a, b, c):
... if a:
... return b
... return c
...
>>> dis.dis(foo)
2 0 LOAD_FAST 0 (a)
3 POP_JUMP_IF_FALSE 10
3 6 LOAD_FAST 1 (b)
Verifying I am +dcrosta on my passcard. https://onename.com/dcrosta
import random
class Foo(object):
def __init__(self, a, b):
self.a = a
self.b = b
foos = [
Foo(random.randint(0, 100), random.randint(100, 1000))
for _ in xrange(10000)
import time
class PageCategoryFilter(object):
def __init__(self, config):
self.mode = config["mode"]
self.categories = config["categories"]
def filter(self, bid_request):
if self.mode == "whitelist":
@dcrosta
dcrosta / gist:1142407
Created August 12, 2011 16:27
launchd plist for mongodb
We couldn’t find that file to show.
# report will be something like:
#
# { test_name: 'signup button',
# alternatives: ['Red', 'Green'],
# results: [
# { attempted: 248,
# completed: 12
# },
# {
# attempted: 226,
from flask import Flask
app = Flask(__init__)
@app.route('/', methods=['GET'])
def getindex():
return 'You did a GET'
@app.route('/', methods=['POST'])
def postindex():
return 'You did a POST'
>>> def adder(amt):
... def inner(start):
... return start + amt
... return inner
...
>>> plusone = adder(1)
>>> plusone(4)
5