Skip to content

Instantly share code, notes, and snippets.

View natekupp's full-sized avatar

Nate Kupp natekupp

View GitHub Profile
@natekupp
natekupp / example.py
Created September 26, 2015 19:08
impyla+multiprocessing crash example
import multiprocessing
import impala.dbapi
class Impala(obect):
def __init__(self, host, database, port, username, password, lock=None):
self.conn = impala.dbapi.connect(host=host,
port=port,
database=database,
user=username,
password=password,
@natekupp
natekupp / gist:1072750
Created July 8, 2011 20:37
Identifying the list indices of duplicate elements in a list
dups = [x for x in myList if myList.count(x) > 1]
indices = [i for i, x in enumerate(myList) if x in dups]
@natekupp
natekupp / gist:1010281
Created June 6, 2011 13:43
Use Case for Python Decorators
def timeout(seconds_before_timeout):
def decorate(f):
def handler(signum, frame):
raise TimeoutError()
def new_f(*args, **kwargs):
old = signal.signal(signal.SIGALRM, handler)
signal.alarm(seconds_before_timeout)
try:
result = f(*args, **kwargs)
finally: