I hereby claim:
- I am danielhfrank on github.
- I am df (https://keybase.io/df) on keybase.
- I have a public key whose fingerprint is 6627 401D 1986 3A54 3235 A733 5B08 4339 A82D F24E
To claim this, I am signing this object:
| #!/usr/bin/env python | |
| # encoding: utf-8 | |
| """ | |
| untitled.py | |
| Created by Daniel Frank on 2011-10-24. | |
| Copyright (c) 2011 __MyCompanyName__. All rights reserved. | |
| """ | |
| import sys |
| #====== Decorator to use memcached for locking ======= | |
| def mc_lock(namespace, on_lock_failed) : | |
| ''' | |
| This uses memcached to provide a lock on a key before performing some operation. | |
| The first argument provided to the decorated function will be the key. | |
| It will be preceded by $namespace to ensure uniqueness | |
| on_lock_failed is a function that will be called if we fail to acquire the lock | |
| ''' |
| package main | |
| // Seems like this could be problematic when extending a type in a 3rd party module... | |
| import ( | |
| "fmt" | |
| ) | |
| type Shredder interface { | |
| Shred() |
| from collections import defaultdict | |
| class ArgDefaultDict(defaultdict): | |
| def __missing__(self, key): | |
| self[key] = self.default_factory(key) | |
| return self[key] |
| class X(object): | |
| def __str__(self): | |
| return 'x' | |
| def my_print_arg(*args): | |
| print args[0] | |
| def print_arg(*args): | |
| print args[0] |
| class UnitIntervalScaler(object): | |
| def fit(self, xs): | |
| self._floor = np.min(xs) | |
| self._range = np.max(xs) - self._floor | |
| return self | |
| def transform(self, x): | |
| return (x - self._floor) / self._range |
| def retry_with_backoff(method): | |
| """ | |
| The idea was to use this to decorate a method that makes some kind of request and has a callback | |
| kwarg. The callback will be decorated to retry the calling function a few times, | |
| with backoff, if it receives an error. | |
| """ | |
| @functools.wraps(method) | |
| def caller_wrapper(self, *args, **kwargs): | |
| callback = kwargs['callback'] | |
| attempts = kwargs.pop('attempts', 0) |
| def passthrough_errors(method): | |
| @functools.wraps(method) | |
| def wrapper(*args, **kwargs): | |
| callback = kwargs['callback'] | |
| data = args[0] | |
| # Check if an error is being passed in, somehow | |
| error = None | |
| if isinstance(data, tornado.httpclient.HTTPResponse) and data.error: | |
| error = data.error |
I hereby claim:
To claim this, I am signing this object:
| #!/usr/bin/env sh | |
| while [ `hub ci-status` = "pending" ]; do | |
| sleep 5 | |
| done | |
| terminal-notifier -message "Build finished" |