Skip to content

Instantly share code, notes, and snippets.

@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 / 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 / genstats.sh
Created August 28, 2011 15:45
Simple BASH script to generate statistics from a Mercurial branch. Uses activity 1.2
#!/bin/bash
#
# Simple script to generate statistics from a Mercurial branch.
#
# Sarah Mount s.mount@wlv.ac.uk
#
@snim2
snim2 / Makefile
Last active April 3, 2025 17:54
Makefile for multiple single file C programs
#
# Minimal Makefile which compiles multiple C files into individual executables.
#
#
# - Sarah Mount, November 2011
#
CC=gcc
RM=rm
@snim2
snim2 / kasabi_json2csv.py
Created December 18, 2011 12:32
Convert Kasabi JSON to CSV. This parser is designed to parse the results of http://kasabi.com/ SPARQL queries and write them out as CSV files for use with a spreadsheet.
#!/usr/bin/env python
"""
Convert Kasabi JSON to CSV.
This parser is designed to parse the results of http://kasabi.com/ SPARQL
queries and write them out as CSV files for use with a spreadsheet.
You can see an example SPARQL query here:
@snim2
snim2 / parse_sensors.py
Created January 21, 2012 12:25
Parse the output of the Ubuntu sensors utility
#!/usr/bin/env python
# -*- coding: utf-8 -*-
"""
This script parses the output of the Ubuntu 'sensors' utility.
The output of sensors looks like this on my machine:
acpitz-virtual-0
Adapter: Virtual device
@snim2
snim2 / SyncBufferExample.scala
Created February 6, 2012 11:47
Simple Scala examples using synchronized.
import scala.collection.mutable._
class WorkerBee2 (val iterations : Int, var bins : ArrayBuffer[Int]) extends Runnable {
def run() : Unit = {
for(i <- 0 until iterations) {
for (j <- 0 until bins.length) {
// This compiles but misses some iterations:
bins.update(j, bins(j) + 1)
}
@snim2
snim2 / pyexn.py
Created February 11, 2012 21:01
Exception example in Python
class MyExn(Exception):
def __init__(self, value):
self.value = value
def __str__(self):
return "MyExn raised with value " + str(self.value)
def example():
try:
raise MyExn(0)
except MyExn, e:
@snim2
snim2 / shparse.py
Created July 12, 2012 22:26
Parse simple tokens from a string such that it can be recreated.
#!/usr/bin/env python
#
# Parse simple tokens from a string such that it can be recreated.
#
__author__ = 'Sarah Mount <s.mount@wlv.ac.uk>'
__date__ = '12 July 2012'
ws = [' ', '\n', '\t']
@snim2
snim2 / heilmeyer.txt
Created August 28, 2012 21:58
Heilmeyer's catechism
Heilmeyer's Catechism:
1. What is the problem, why is it hard?
2. How is it solved today?
3. What is the new technical idea; why can we succeed now?
4. What is the impact if successful?
5. How will the program be organized?
6. How will intermediate results be generated?
7. How will you measure progress?
8. What will it cost?