Skip to content

Instantly share code, notes, and snippets.

/**
* a very crude implmentation of python's format() for javascript,
* supporting simple replacement fields, eg::
*
* >>> format('{0} is {1}', 'javascript', 'cool')
* "javascript is cool"
*
* works for my purposes, but no where close to implementing full
* capabilities as described at::
* http://docs.python.org/library/string.html#formatstrings
@andrewwatts
andrewwatts / flot_v_raphael.html
Created January 13, 2010 06:34
flot vs raphael performance
<!DOCTYPE HTML>
<html>
<head>
<title>flot vs raphael</title>
<script type="text/javascript" src="jquery.min.js"></script>
<script type="text/javascript" src="jquery.flot.min.js"></script>
<script type="text/javascript" src="raphael.js"></script>
<script type="text/javascript" src="g.raphael-min.js"></script>
@andrewwatts
andrewwatts / after.bashrc
Created May 2, 2010 18:53
Before and after .bashrc files for installing python on dreamhost
# ~/.bashrc: executed by bash(1) for non-login shells.
export EDITOR=vi
# terminal colors
LS_COLORS='no=00:fi=00:di=01;36:ln=01;93:pi=40;33:so=01;35:do=01;35:bd=40;33;01:
cd=40;33;01:or=40;31;01:ex=01;32:*.tar=01;31:*.tgz=01;31:*.arj=01;31:*.taz=01;31
:*.lzh=01;31:*.zip=01;31:*.z=01;31:*.Z=01;31:*.gz=01;31:*.bz2=01;31:*.deb=01;31:
*.rpm=01;31:*.jar=01;31:*.jpg=01;35:*.jpeg=01;35:*.gif=01;35:*.bmp=01;35:*.pbm=0
1;35:*.pgm=01;35:*.ppm=01;35:*.tga=01;35:*.xbm=01;35:*.xpm=01;35:*.tif=01;35:*.t
@andrewwatts
andrewwatts / config.log
Created May 13, 2010 17:33
config.log showing glib errors from `brew install irssri`
This file contains any messages produced by compilers while
running configure, to aid debugging if configure makes a mistake.
It was created by irssi configure 0.8.14, which was
generated by GNU Autoconf 2.63. Invocation command line was
$ ./configure --prefix=/usr/local/Cellar/irssi/0.8.14 --disable-debug --disable-dependency-tracking --with-modules --enable-ssl --enable-ipv6 --with-perl=yes
## --------- ##
## Platform. ##
@andrewwatts
andrewwatts / xmltool.py
Created September 30, 2010 06:50
a python xmltool in the spirit of python's json.tool
#!/usr/bin/env python
# encoding: utf-8
"""
In the spirit of python's json.tool, provide a command line
utility to pretty print XML.
Usage ():
$ echo "<book><title>Oliver Twist</title></book>" | python -m xmltool
<?xml version="1.0" encoding="utf-8"?>
@andrewwatts
andrewwatts / middleware.py
Created October 22, 2010 16:00
Django middleware that sets a tracking id (fetched from a ticket server) as a cookie in the http response.
'''
Django middleware that sets a tracking id (fetched from a ticket server) as a
cookie in the http response.
This assumes you have setup a couple k/v stores as ticket servers and that
you know the key. For demonstration purposes only, here is how one might do it
with redis:
# start a redis server on default port (6379)
$ redis-server /usr/local/etc/redis.conf &> /dev/null &
@andrewwatts
andrewwatts / fabfile.py
Created December 3, 2010 21:05
simple fabfile to testing goosemo's multiprocessing fabric branch
from fabric.api import *
env.roledefs['servers'] = [
'ec2-184-72-2-243.us-west-1.compute.amazonaws.com',
'ec2-204-236-153-163.us-west-1.compute.amazonaws.com',
]
@roles('servers')
def poke():
local("whoami")
@andrewwatts
andrewwatts / ec2_hosts.py
Created December 21, 2010 06:46
print an /etc/hosts file to stdout with ec2 instances
#! /usr/bin/env python
# ##########
#
# Usage:
# ec2_hosts.py
#
# Then copy results to /etc/hosts
#
# ##########
@andrewwatts
andrewwatts / etc_defaults_ircd-hybrid
Created December 29, 2010 00:25
/etc/init.d/ircd-hybrid, /etc/default/ircd-hybrid, /etc/logrotate.d/ircd-hybrid and postinst form ircd-hybrid deb package
# Start ircd-hybrid when invoked via init.d shell script.
START=yes
@andrewwatts
andrewwatts / hybserv
Created December 29, 2010 22:39
/etc/init.d/hybserv and postinst from hybserv deb package
#! /bin/sh
# hybserv Start/stop Hybserv 2 IRC Services
# Version: hybserv 1.8.0 17-Mar-2003 joshk@triplehelix.org
# Version: hybserv 1.9.2 05-Sep-2006 ag@roxor.cx
### BEGIN INIT INFO
# Provides: hybserv
# Required-Start: $syslog ircd-hybrid
# Required-Stop: $syslog ircd-hybrid