Skip to content

Instantly share code, notes, and snippets.

@snim2
snim2 / howl.py
Created December 13, 2009 21:46
Access the Howl web service for the Internet of Things via the command line
#!/bin/env python
"""
Execute a single Howl command.
Usage:
$ python howl.py --help
Usage: howl.py [options]
# Fix Eclipse on Ubuntu Karmic
export GDK_NATIVE_WINDOWS=1
@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
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 *
@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}