Skip to content

Instantly share code, notes, and snippets.

Keybase proof

I hereby claim:

  • I am dcrosta on github.
  • I am dcrosta (https://keybase.io/dcrosta) on keybase.
  • I have a public key ASAQuXx8EHZPizgcpBHawcB0kva5JXCAN-74HvWotp4aJgo

To claim this, I am signing this object:

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)
Verifying I am +dcrosta on my passcard. https://onename.com/dcrosta
>>> 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)
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":
init_config:
instances:
- host: localhost
port: 10104
name: master
conf:
- include:
domain: hadoop
bean: hadoop:name=MasterStatistics,service=Master
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.
>>> api.host_tags('my.hostname.com')
['role:base', 'env:prod', 'role:bidder']
>>> api.host_tags('my.hostname.com')
['role:base', 'env:prod']
>>> api.host_tags('my.hostname.com')
['role:base', 'env:prod', 'role:bidder']
>>> api.host_tags('my.hostname.com')
['region:us-east-1', 'role:hdat', 'role:base', 'availability-zone:us-east-1c', 'image:ami-1624987f', 'security-group:sg-a89e60c1', 'instance-type:m1.xlarge', 'name:[redacted]', 'kernel:aki-88aa75e1', 'env:qa', 'security-group:sg-71968219']
>>> api.host_tags('my.hostname.com')
['role:base', 'env:prod', 'role:bidder']
init_config:
instances:
- host: localhost
port: 10101
name: master
conf:
- include:
domain: hadoop
bean: hadoop:name=MasterStatistics,service=Master
init_config:
instances:
- host: localhost
port: 10101
name: regionserver
conf:
- include:
domain: hadoop
bean: name=RegionServerStatistics,service=RegionServer