Skip to content

Instantly share code, notes, and snippets.

View vadimg's full-sized avatar

Vadim Graboys vadimg

View GitHub Profile
@vadimg
vadimg / gist:3344325
Created August 13, 2012 21:49
nginx access log GET request extractor
#!/usr/bin/env python
import sys
import re
def iterpings(filename):
for line in open(filename):
m = re.search(r'] GET (.*?) ', line)
if m is not None:
yield m.group(1)
@vadimg
vadimg / timeout.py
Created June 9, 2012 22:16
python timeout decorator
import threading
import functools
import logging
def timeout(duration, default=None):
def decorator(func):
class InterruptableThread(threading.Thread):
def __init__(self, args, kwargs):
threading.Thread.__init__(self)
self.args = args