Skip to content

Instantly share code, notes, and snippets.

@snim2
snim2 / template_example.html
Created August 7, 2011 15:52
How to use repeated sections using a go-based web framework, such as go for appengine
{.section SharedStreams}
{.repeated section SharedStreams}
<h3><a href="{Url}">{Name|html}</a></h3>
<p>{Description|html}</p>
{.end}
{.or}
<p>No users have shared data streams with you, why not <a href="/newstream">create one</a> of your own!</p>
{.end}
@snim2
snim2 / autoupdate.py
Created April 20, 2011 20:01
Automatically update an app from a remote Mercurial repository
#!/usr/bin/env python
"""
Basic app which can be updated directly from a Mercurial repository.
Copyright (C) Sarah Mount, 2011.
This program is free software; you can redistribute it and/or
modify it under the terms of the GNU General Public License
as published by the Free Software Foundation; either version 2
@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 *
@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 / 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" />

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

Here’s a little ditty..

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

(()__ _ ___ _ _ ___,_)_ _ _
>>> class Foo:
...
...
File "<stdin>", line 3
^
IndentationError: expected an indented block
>>> class Foo:
... def __init__(self):
... return
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.
"""
@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
@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)