This file contains 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
# Pickle with patch by Aaron Gallagher (habnabit) applied: | |
# http://bugs.python.org/issue3119 | |
"""Create portable serialized representations of Python objects. | |
See module cPickle for a (much) faster implementation. | |
See module copy_reg for a mechanism for registering custom picklers. | |
See module pickletools source for extensive comments. | |
Classes: |
This file contains 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 google.appengine.ext import db | |
from django.utils import simplejson | |
### Functions ### | |
def fetch_references(entities, attr): | |
"""Fetches and sets ReferenceProperty attributes in one db call""" | |
keys = [] | |
for entity in entities: | |
key = getattr(entity, '_' + attr) |
This file contains 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
function hsv_to_rgb(h, s, v) { | |
// http://nofunc.org/Color_Conversion_Library/ | |
var R, G, A, B, C, S=s/255, V=v/255, H=h/255; | |
if(S>0) { | |
if(H>=1) H=0; | |
H=6*H; F=H-Math.floor(H); | |
A=Math.round(255*V*(1-S)); | |
B=Math.round(255*V*(1-(S*F))); | |
C=Math.round(255*V*(1-(S*(1-F)))); | |
V=Math.round(255*V); |
This file contains 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 urllib2 | |
from urlparse import urljoin | |
import time | |
import BeautifulSoup | |
class Crawler: | |
def __init__(self, parser): | |
self.parser = parser | |
self.queue = set() |
This file contains 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 lib import BeautifulSoup | |
import urllib2 | |
from urlparse import urljoin | |
import difflib | |
import re | |
def get_title_name(self): | |
imdb_title = self.title_id | |
url = urllib2.urlopen("http://imdb.com/title/" + imdb_title) | |
string = url.read() |
This file contains 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 sys | |
import imp | |
import urllib2 | |
PATHS = [ | |
"http://www.crummy.com/software/BeautifulSoup/download/", | |
] | |
for path in PATHS: | |
sys.path.append(path) |
This file contains 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 urllib | |
from django.utils import simplejson | |
def suggest(prefix, lang='en'): | |
url = 'http://' + lang + '.wikipedia.org/w/api.php?action=opensearch' | |
url += '&search=' + urllib.quote(prefix) + '&format=json' | |
json = urllib.urlopen(url).read() | |
data = simplejson.loads(json) | |
results = data[1] |
This file contains 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
# Python imports | |
import urllib | |
import urllib2 | |
# Local imports | |
try: | |
import simplejson | |
except ImportError: | |
from django.utils import simplejson |
This file contains 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
# clone hexagon repository | |
git clone git+ssh://git@git.isohunt.com/int/zeta-code | |
# install postgres | |
http://www.robbyonrails.com/articles/2008/01/22/installing-ruby-on-rails-and-postgresql-on-os-x-third-edition | |
# uninstall prev postgres (optional) | |
sudo port uninstall postgresql84 | |
sudo port clean postgresql84 | |
sudo port uninstall postgresql84-server |
OlderNewer