Using Python's built-in defaultdict we can easily define a tree data structure:
def tree(): return defaultdict(tree)
That's it!
page.clipRect = page.evaluate(function() { | |
return document.getElementById(ELEMENT_ID).getBoundingClientRect(); | |
}); |
var page = require('webpage').create(), | |
address, output, size; | |
if (phantom.args.length < 2 || phantom.args.length > 3) { | |
console.log('Usage: rasterize.js URL filename'); | |
phantom.exit(); | |
} else { | |
address = phantom.args[0]; | |
output = phantom.args[1]; | |
page.viewportSize = { width: 1280, height: 1024 }; |
var parser = document.createElement('a'); | |
parser.href = "http://example.com:3000/pathname/?search=test#hash"; | |
parser.protocol; // => "http:" | |
parser.hostname; // => "example.com" | |
parser.port; // => "3000" | |
parser.pathname; // => "/pathname/" | |
parser.search; // => "?search=test" | |
parser.hash; // => "#hash" | |
parser.host; // => "example.com:3000" |
import HTMLParser | |
class IDParser(HTMLParser.HTMLParser): | |
"""Modified HTMLParser that isolates a tag with the specified id""" | |
def __init__(self, id): | |
self.id = id | |
self.result = None | |
self.started = False | |
self.depth = {} | |
self.html = None |
#!/usr/bin/env sh | |
## | |
# This is script with usefull tips taken from: | |
# https://github.com/mathiasbynens/dotfiles/blob/master/.osx | |
# | |
# install it: | |
# curl -sL https://raw.github.com/gist/2108403/hack.sh | sh | |
# |
import urllib2 | |
class HeadRequest(urllib2.Request): | |
def get_method(self): | |
return "HEAD" | |
class HEADRedirectHandler(urllib2.HTTPRedirectHandler): | |
""" | |
Subclass the HTTPRedirectHandler to make it use our | |
HeadRequest also on the redirected URL |
#!/usr/bin/env python | |
#-*- coding:utf-8 -*- | |
import sys | |
import urllib2 | |
# This script uses HEAD requests (with fallback in case of 405) | |
# to follow the redirect path up to the real URL | |
# (c) 2012 Filippo Valsorda - FiloSottile | |
# Released under the GPL license |
Using Python's built-in defaultdict we can easily define a tree data structure:
def tree(): return defaultdict(tree)
That's it!
Eventually platforms outgrow the single-source-tree model and become distributed systems. A common pattern in these distributed systems is distributed composition via event buffering. Here we motivate and describe this event buffering pattern.
#~/.mutt/aliases | |
alias nick Nicholas Levandoski <nick.levandoski@auglug.org> | |
alias tim Timothy Pitt <timothy.pitt@auglug.org> | |
alias steven Steven Jackson <sjackson@auglug.org> | |
alias kaleb Kaleb Hornsby <kaleb.hornsby@auglug.org> | |
alias alug-admin nick, tim, steven |