Skip to content

Instantly share code, notes, and snippets.

View keybase.md

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:

View jit_test.py
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)
View gist:3d65d0595ee3d99035ae
Verifying I am +dcrosta on my passcard. https://onename.com/dcrosta
View bare_if.py
>>> 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)
View class_func_closure_bench.py
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":
View jmx.yaml
init_config:
instances:
- host: localhost
port: 10104
name: master
conf:
- include:
domain: hadoop
bean: hadoop:name=MasterStatistics,service=Master
View polite_client.py
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.
View gist:5117132
>>> 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']
View jmx.yaml
init_config:
instances:
- host: localhost
port: 10101
name: master
conf:
- include:
domain: hadoop
bean: hadoop:name=MasterStatistics,service=Master
View jmx.yaml
init_config:
instances:
- host: localhost
port: 10101
name: regionserver
conf:
- include:
domain: hadoop
bean: name=RegionServerStatistics,service=RegionServer