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 xml.etree import ElementTree | |
tree = ElementTree.fromstring( | |
"""<?xml version="1.0"?> | |
<result> | |
<mediaid>[MediaID]</mediaid> | |
<source>[SourceFile]</source> | |
<status>[MediaStatus]</status> | |
<description>[ ErrorDescription]</description> <!-- Only in case of Status = Error --> | |
<format> |
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 re | |
import urllib | |
def uca_sort(l, locale='en', _re_nums=re.compile('<tt class="count">(\d+):</tt>')): | |
"""Uses the ICU demo site to sort a list""" | |
url = 'http://demo.icu-project.org/icu-bin/locexp' | |
url += '?_=' + locale + '&d_=en&x=col' | |
data = 'str=' + '\n'.join(l) | |
html = urllib.urlopen(url, data).read() | |
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
# clone hexagon repository | |
git clone git+ssh://[email protected]/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 |
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
# Python imports | |
import urllib | |
import urllib2 | |
# Local imports | |
try: | |
import simplejson | |
except ImportError: | |
from django.utils import simplejson |
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 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 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 sys | |
import imp | |
import urllib2 | |
PATHS = [ | |
"http://www.crummy.com/software/BeautifulSoup/download/", | |
] | |
for path in PATHS: | |
sys.path.append(path) |
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 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 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 urllib2 | |
from urlparse import urljoin | |
import time | |
import BeautifulSoup | |
class Crawler: | |
def __init__(self, parser): | |
self.parser = parser | |
self.queue = set() |
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
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); |