Skip to content

Instantly share code, notes, and snippets.

View lavie's full-sized avatar

assaf lavie

View GitHub Profile
@lavie
lavie / snagurl.py
Created February 14, 2012 18:19
Upload image to imgurl and copy remote URL into clipboard
import sys
import urllib2
from json import loads
from urllib import urlencode
import base64
print sys.argv
LOG_FILE = 'uploads.log'
DEV_KEY = 'YOUR KEY HERE' # from http://imgur.com/register/api_anon
@asimihsan
asimihsan / gist:2266588
Created March 31, 2012 16:35
python retry decorator
import pymongo.errors
# Retry decorator with exponential backoff
def retry(tries=5, delay=0.1, backoff=2):
"""Retries a function or method until it returns True.
delay sets the initial delay in seconds, and backoff sets the factor by which
the delay should lengthen after each failure. backoff must be greater than 1,
or else it isn't really a backoff. tries must be at least 0, and delay
greater than 0.