Public Gists by simonw

gist: 229186 Python script for telling i...
Gravatar
Sun Nov 08 01:06:27 -0800 2009
1
2
3
#!/usr/bin/env python
"is_hard.py - tell if two files are hard links to the same thing"
 
Gravatar
Sat Oct 10 19:25:22 -0700 2009
1
2
3
# Python logging handler for stashing most recent 100 log items in a redis list
 
import logging
Gravatar
Mon Sep 21 15:56:57 -0700 2009
1
2
3
import httplib2, simplejson
h = httplib2.Http()
 
Gravatar
Sat Sep 05 16:43:52 -0700 2009
1
2
3
svn co svn://svn.xapian.org/xapian/branches/geospatial xapian-geo
sudo apt-get install build-essential m4 perl python zlib1g-dev uuid-dev wget
sudo apt-get install libpcre3-dev
gist: 180228 Returns a list of differenc...
Gravatar
Thu Sep 03 03:22:15 -0700 2009
1
2
3
def json_diffs(a, b, path='_'):
    errors = []
    if type(a) != type(b):
Gravatar
Tue Aug 25 02:44:45 -0700 2009
1
2
3
import datetime, time
 
def to_isoformat(dt):
Gravatar
Sat Aug 15 02:12:30 -0700 2009
1
2
3
import freebase, json
 
freebase.search('tiger',
Gravatar
Sat Aug 15 01:58:54 -0700 2009
1
2
3
import freebase # http://code.google.com/p/freebase-python/
 
def bulk_lookup(ids):
gist: 167784 A working recipe for instal...
Gravatar
Fri Aug 14 04:43:10 -0700 2009
1
2
3
cd /tmp
wget http://codespeak.net/lxml/lxml-2.2.2.tgz
tar -xzvf lxml-2.2.2.tgz
Gravatar
Fri Aug 14 04:14:48 -0700 2009
1
2
3
$ mkvirtualenv lxml-install-env
New python executable in lxml-install-env/bin/python
Installing setuptools...asy......... done.
Gravatar
Sat Jun 13 06:22:06 -0700 2009
1
2
3
<script type="text/javascript">
(function(loc) {
    if (loc.pathname == '/') {
Gravatar
Thu Jun 11 04:08:41 -0700 2009
1
2
3
# Django: validate that an uploaded file is a valid PDF
 
import pyPdf # from http://pybrary.net/pyPdf/
Gravatar
Mon May 25 13:31:51 -0700 2009
1
2
3
# In settings.py:
 
import os
Gravatar
Fri May 22 00:05:58 -0700 2009
1
2
3
# Code for using http://developer.yahoo.com/geo/placemaker/
import urllib, httplib2
 
gist: 104413 Turn a BeautifulSoup form i...
Gravatar
Thu Apr 30 04:19:59 -0700 2009
1
2
3
def extract_form_fields(self, soup):
    "Turn a BeautifulSoup form in to a dict of fields and default values"
    fields = {}
Gravatar
Thu Apr 30 02:39:02 -0700 2009
1
2
3
http://sugg.search.yahoo.net/sg/?output=jsonp&nresults=10&command=django
http://sugg.search.yahoo.net/sg/?output=json&nresults=10&command=django
http://sugg.search.yahoo.net/sg/?output=xml&nresults=10&command=django
Gravatar
Wed Apr 29 04:11:22 -0700 2009
1
2
3
(*
  Open a new tab in Safari (and move focus to the URL bar)
  I have this configured as a Quicksilver trigger for ctrl+alt+T
gist: 93982 singpolyma's bit.ly version...
Gravatar
Sun Apr 12 05:32:27 -0700 2009
1
2
3
/* Expanded form of a bookmarklet for extracting rev=canonical OR tinyurling a page */
(function(){
var url=document.location;
gist: 93591 Expanded form of a bookmark...
Gravatar
Sat Apr 11 08:19:10 -0700 2009
1
2
3
/* Expanded form of a bookmarklet for extracting rev=canonical OR tinyurling a page */
(function(){
    var url=document.location;
gist: 93522 Convert numbers from base 1...
Gravatar
Sat Apr 11 03:32:44 -0700 2009
1
2
3
"""
Convert numbers from base 10 integers to base X strings and back again.