Skip to content

Instantly share code, notes, and snippets.

@snim2
snim2 / listexn-raised.py
Created May 16, 2010 13:08
Find exception names in a Python module
#!/usr/bin/env python
import compiler.ast
import compiler.visitor as visitor
__author__ = 'Sarah Mount <s.mount@wlv.ac.uk>'
__date__ = 'May 2010'
class ExceptionFinder(visitor.ASTVisitor):
@snim2
snim2 / backup.sh
Created August 6, 2010 16:51
How to backup / restore a Debian based Linux system, used, for example, when moving to a new machine
$ dpkg --get-selections > ~/Dropbox/installed-packages.log
@snim2
snim2 / hilite.el
Created September 1, 2010 21:39
Highlight phrases starting with TODO, FIXME, etc. in emacs.
(defun hilite-todos ()
(highlight-lines-matching-regexp "\\<\\(FIXME\\|WRITEME\\|WRITEME!\\|TODO\\|BUG\\):?"
'hi-green-b)
)
(add-hook '$WHATEVER-mode-hook 'hilite-todos)
@snim2
snim2 / translate.py
Created September 2, 2010 00:36
Translate text on the command-line using Google translate
#!/usr/bin/env python
"""
Use Google to translate text in one language to another.
Original code from here:
http://thebigbrowser.blogspot.com/2010/08/use-google-translate-from-console.html
by coldpizza
def intellisplit(base_string):
"""Intelligently split and capitalise a string.
Turns variable names which may be underscored or
in CamelCase into something human readable.
e.g. foo_bar should become Foo bar
fooBar should become Foo bar
etc.
"""
>>> class Foo:
...
...
File "<stdin>", line 3
^
IndentationError: expected an indented block
>>> class Foo:
... def __init__(self):
... return

$ telnet elephant.org Trying 194.106.49.114… Connected to elephant.org. Escape character is ‘^]’.

Here’s a little ditty..

_ _ _ ( `\ ( ) ( ) ( )_ /’\_/`\ ( )

(()__ _ ___ _ _ ___,_)_ _ _
@snim2
snim2 / webchat.html
Created October 19, 2010 12:59
Web page that uses the Phono service to talk to a Jabber chatbot.
<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
<html xmlns="http://www.w3.org/1999/xhtml" xml:lang="en">
<head>
<title>Live chat example</title>
<meta http-equiv="Content-Type" content="text/html; charset=utf-8" />
<meta name="robots" content="All" />
<meta name="copyright" content="University of Wolverhampton" />
<link id="theme" rel="stylesheet" type="text/css" href="/css/style.css" title="theme" />
@snim2
snim2 / timeit.sh
Created January 8, 2011 23:00
Simple shell script to generate readable performance data
#!/usr/bin/env sh
# (C) Sarah Mount http://snim2.org
#
# Execute a given command and print performance information in a readable manner.
#
# Example:
#
# ./timeit.sh gcc hello.c
@snim2
snim2 / screenie.py
Created February 2, 2011 02:53
Captures screenshots and displays them
#!/usr/bin/env python
#
# Capture and display screenshots.
# Requires ImageMagick, PIL and PyGame.
#
import os
import pygame
from pygame.locals import *