This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| from django import forms | |
| import datetime | |
| import base64 | |
| import hmac, sha, simplejson | |
| from django.utils.safestring import mark_safe | |
| """ | |
| http://developer.amazonwebservices.com/connect/entry.jspa?externalID=1434 |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| # http://github.com/simonw/django-signed/raw/master/django_signed/baseconv.py | |
| from baseconv import BaseConverter | |
| class Base32Converter(BaseConverter): | |
| # Human-friendly, see http://www.crockford.com/wrmg/base32.html | |
| replacements = { | |
| 'o': '0', | |
| 'O': '0', | |
| 'I': '1', | |
| 'i': '1', |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| # Scrape two months worth of horoscopes from shine.yahoo.com | |
| from BeautifulSoup import BeautifulSoup as Soup | |
| import urllib, datetime | |
| URL = "http://shine.yahoo.com/astrology/%s/daily-extended/%s/" | |
| signs = ( | |
| 'aries', | |
| 'leo', |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| /* Use this to cause a function to fire no more than once every 'ms' milliseconds. | |
| For example, an expensive mousemove handler: | |
| $('body').mouseover(ratelimit(function(ev) { | |
| // ... | |
| }, 250)); | |
| */ | |
| function ratelimit(fn, ms) { | |
| var last = (new Date()).getTime(); |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| Save the supervisord.initscript script as /etc/init.d/supervisord | |
| Run /usr/sbin/update-rc.d -f supervisord defaults |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| """ | |
| Import Yahoo! GeoPlanet in to MongoDB. | |
| This creates a geoplanet collection containing documents like this: | |
| { | |
| '_id': woeid, | |
| 'name': name, | |
| 'iso': iso, | |
| 'language': language, |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| import itertools | |
| def x_at_a_time(iterator, x): | |
| def fn((item, i)): | |
| return i / x | |
| it = itertools.groupby(itertools.izip(iterator, itertools.count()), fn) | |
| for key, group in it: | |
| yield list(p[0] for p in group) |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| from baseconv import BaseConverter | |
| class Base32Converter(BaseConverter): | |
| # Human-friendly, see http://www.crockford.com/wrmg/base32.html | |
| replacements = { | |
| 'o': '0', | |
| 'O': '0', | |
| 'I': '1', | |
| 'i': '1', | |
| 'L': '1', |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| from django.http import HttpResponse | |
| from django.utils import simplejson | |
| import re | |
| callback_re = re.compile(r'^[a-zA-Z_][a-zA-Z0-9_]+$') | |
| def api_response(request, status_code, info): | |
| info['status'] = status_code | |
| if request.GET.get('format', '') == 'html': | |
| return HttpResponse( |