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 generateChart(figures) { | |
// figures is an object mapping labels to numbers | |
var cht = 'p'; // Chart type: pie | |
var chs = '460x200'; // Image dimensions | |
var chd = []; // Chart data | |
var chl = []; // Corresponding labels | |
var min = 0; | |
var max = 0; | |
$.each(figures, function(label, value) { | |
chl[chl.length] = label; |
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
/* jQuery methods for accessing HTML comments and comment text | |
Only tested in Safari. */ | |
jQuery.fn.comments = function() { | |
return this.contents().filter(function() { | |
return this.nodeType == 8; | |
}) | |
}; | |
jQuery.fn.commentText = function() { | |
var s = []; |
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
# Compile nginx standalone without root access | |
mkdir ~/installed | |
mkdir ~/installed/nginx | |
mkdir ~/src | |
cd ~/src | |
# PCRE dependency - we'll compile against this statically | |
wget http://kent.dl.sourceforge.net/sourceforge/pcre/pcre-7.8.tar.gz | |
tar -xzvf pcre-7.8.tar.gz |
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
""" | |
Convert numbers from base 10 integers to base X strings and back again. | |
Sample usage: | |
>>> base20 = BaseConverter('0123456789abcdefghij') | |
>>> base20.from_decimal(1234) | |
'31e' | |
>>> base20.from_decimal('31e') | |
1234 |
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
/* Expanded form of a bookmarklet for extracting rev=canonical OR tinyurling a page */ | |
(function(){ | |
var url=document.location; | |
var links=document.getElementsByTagName('link'); | |
var found=0; | |
for(var i = 0, l; l = links[i]; i++) { | |
if (l.getAttribute('rev') == 'canonical' || (/alternate short/).exec(l.getAttribute('rel'))) { | |
found=l.getAttribute('href'); | |
break; | |
} |
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
/* Expanded form of a bookmarklet for extracting rev=canonical OR tinyurling a page */ | |
(function(){ | |
var url=document.location; | |
var links=document.getElementsByTagName('link'); | |
var found=0; | |
for(var i = 0, l; l = links[i]; i++) { | |
if (l.getAttribute('rev') == 'canonical' || (/alternate short/).exec(l.getAttribute('rel'))) { | |
found=l.getAttribute('href'); | |
break; | |
} |
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
(* | |
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 | |
*) | |
tell application "Safari" to activate | |
tell application "System Events" | |
tell process "Safari" | |
click menu item "New Tab" of menu "File" of menu bar 1 | |
end tell |
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
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 |
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
def extract_form_fields(self, soup): | |
"Turn a BeautifulSoup form in to a dict of fields and default values" | |
fields = {} | |
for input in soup.findAll('input'): | |
# ignore submit/image with no name attribute | |
if input['type'] in ('submit', 'image') and not input.has_key('name'): | |
continue | |
# single element nome/value fields | |
if input['type'] in ('text', 'hidden', 'password', 'submit', 'image'): |
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
# Code for using http://developer.yahoo.com/geo/placemaker/ | |
import urllib, httplib2 | |
h = httplib2.Http() | |
URL = 'http://wherein.yahooapis.com/v1/document' | |
API_KEY = 'your-Yahoo-API-key' | |
def placemaker(text, doctype='text/plain'): | |
head, response = h.request(URL, 'POST', headers={ |
OlderNewer