Skip to content

Instantly share code, notes, and snippets.

🎯
Focusing

Antonio Lima themiurgo

Block or report user

Report or block themiurgo

Hide content and notifications from this user.

Learn more about blocking users

Contact Support about this user’s behavior.

Learn more about reporting abuse

Report abuse
View GitHub Profile
@themiurgo
themiurgo / geocoder.py
Created Jul 18, 2012
A Google Geocoder with a MongoDB memoizer. For the ratelim module, look at https://gist.github.com/3006305
View geocoder.py
import collections
import time
import requests
import pymongo
import ratelim
import textwrap
G_GEO_SUCCESS = 200
G_GEO_SERVER_ERROR = 500
G_GEO_MISSING_QUERY = 601
@themiurgo
themiurgo / elapsed_since_last_update.sh
Created Jun 29, 2012
Seconds elapsed since last update of a file
View elapsed_since_last_update.sh
# FILL FILENAME
# Return the seconds from last modification of a file, among a list of files
file=$(ls FILENAME -hant --time-style +%s | head -n1 | awk '{print $6}' ) ; now=$(date +%s); echo $((now-file))
@themiurgo
themiurgo / ratelim.py
Created Jun 27, 2012
Rate limit decorator
View ratelim.py
import time
import datetime
class rate_limited(object):
def __init__(self, max_calls, time_interval):
assert max_calls > 0
assert time_interval > 0
self.__last_reset = None
self.__max_calls = max_calls
self.__time_interval = time_interval # seconds
You can’t perform that action at this time.