Skip to content

Instantly share code, notes, and snippets.

@p7k
p7k / gist:4238388
Created December 8, 2012 03:02
greenlet throttling decorator | rate limiting gevent | with semaphores
from functools import wraps
from timeit import default_timer
import gevent
from gevent.queue import Queue
def gevent_throttle(calls_per_sec=0):
"""Decorates a Greenlet function for throttling."""
interval = 1. / calls_per_sec if calls_per_sec else 0
def decorate(func):
blocked = [False] # has to be a list to not get localised inside the while loop
@mxcl
mxcl / uninstall_homebrew.sh
Created August 26, 2011 11:25
Uninstall Homebrew
#!/bin/sh
# Just copy and paste the lines below (all at once, it won't work line by line!)
# MAKE SURE YOU ARE HAPPY WITH WHAT IT DOES FIRST! THERE IS NO WARRANTY!
function abort {
echo "$1"
exit 1
}
set -e
@arantius
arantius / mdns-tivo-forgery.py
Created June 6, 2011 00:52
The files I used to reverse engineer, and proof-of-concept, the TiVo to iPad protocol.
#!/usr/bin/env python
"""An mDNS daemon designed to appear, to the iPad app, to be a TiVo Premiere."""
import Zeroconf
import socket
local_ip = socket.gethostbyname(socket.gethostname())
local_ip = socket.inet_aton(local_ip)