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
javascript: (function() { | |
var url = 'http://journeyplanner.tfl.gov.uk/user/XSLT_TRIP_REQUEST2'; | |
var default_location = "MY_DEFAULT_LOCATION"; | |
var input = '%s'; | |
var matches = input.match(/(^\s*(.*)\s*>\s*(.*)\s*$|^\s*(.*)\s*<\s*(.*)\s*$)/); | |
if( ! matches) { | |
window.location = url; |
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
<?php | |
/* | |
* Postcode validation function | |
* Based on code by John Gardner: http://www.braemoor.co.uk/software/postcodes.shtml | |
* Converted to use PCRE rather than the now deprecated POSIX regular expressions by | |
* David Evans. | |
* | |
* Optional second argument is set to the properly capitalised and spaced version of | |
* the postcode. |
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
have fab && { | |
_fab_completion() | |
{ | |
COMPREPLY=() | |
local cur tasks | |
tasks=$(fab --shortlist 2>/dev/null) | |
_get_comp_words_by_ref cur | |
COMPREPLY=( $(compgen -W "${tasks}" -- ${cur}) ) |
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
<?php | |
/* | |
Plugin Name: Gist Embed | |
Description: Embed Gists from Github with robust caching | |
Author: David Evans | |
Version: 0.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
# For more explanation and usage examples, see: | |
# http://www.drhevans.com/blog/posts/331-comparing-large-data-sets-in-python/ | |
from itertools import imap, izip, count, repeat, tee | |
import heapq | |
def full_outer_join(*iterables, **kwargs): | |
""" | |
Perform a full outer join on a sequence of sorted iterables, where the | |
key function supplies the join condition. |
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
# Apt-install various things necessary for Ruby, guest additions, | |
# etc., and remove optional things to trim down the machine. | |
apt-get -y update | |
apt-get -y remove apparmor | |
apt-get -y install linux-headers-$(uname -r) build-essential | |
apt-get -y install zlib1g zlib1g-dev libxml2 libxml2-dev libxslt-dev libssl-dev openssl libreadline5-dev | |
apt-get clean | |
# Remove this file to avoid dhclient issues with networking | |
rm -f /etc/udev/rules.d/70-persistent-net.rules |
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 substitute { | |
if [ -z "$1" -o -z "$2" ]; then | |
echo "Usage: substitue FROM_STRING TO_STRING [OPTION]..." | |
echo | |
echo "Replace all occurances of FROM_STRING (a sed-compatible regular" | |
echo "expression) with TO_STRING in all files for which ack-grep matches" | |
echo "FROM_STRING." | |
echo | |
echo "Any additional options are passed directly to ack-grep (e.g.," | |
echo " --type=html would only run the substitution on html files)." |
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 site-packages directory of currently active virtualenv in Nautlius | |
# (Relies on virtualenvwrapper) | |
function opensitepackages { | |
virtualenvwrapper_verify_workon_home || return 1 | |
virtualenvwrapper_verify_active_environment || return 1 | |
typeset site_packages="`virtualenvwrapper_get_site_packages_dir`" | |
\gnome-open "$site_packages"/$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
""" | |
Utility (Linux only) to ensure subprocesses exit when their parents do by sending | |
a specified signal when the parent dies. | |
Usage: | |
subprocess.Popen(['some-executable'], preexec_fn=on_parent_exit('SIGHUP')) | |
""" | |
import signal |
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
# The MIT License (MIT) | |
# | |
# Copyright (c) 2013 David Evans | |
# | |
# Permission is hereby granted, free of charge, to any person obtaining a copy of | |
# this software and associated documentation files (the "Software"), to deal in | |
# the Software without restriction, including without limitation the rights to | |
# use, copy, modify, merge, publish, distribute, sublicense, and/or sell copies of | |
# the Software, and to permit persons to whom the Software is furnished to do so, | |
# subject to the following conditions: |
OlderNewer