Skip to content

Instantly share code, notes, and snippets.

@snim2
snim2 / Python Notepad Bookmarklet
Last active December 11, 2015 23:18 — forked from jakeonrails/Ruby Notepad Bookmarklet
Stick this in the URL bar of a browser to open up an in-browser syntax highlighted text editor
data:text/html, <style type="text/css">#e{position:absolute;top:0;right:0;bottom:0;left:0;}</style><div id="e"></div><script src="http://d1n0x3qji82z53.cloudfront.net/src-min-noconflict/ace.js" type="text/javascript" charset="utf-8"></script><script>var e=ace.edit("e");e.setTheme("ace/theme/Cobalt");e.getSession().setMode("ace/mode/python");</script>
@snim2
snim2 / assertpatch.diff
Created September 17, 2012 16:59
BitBake recipe for LibHid (author: Matthew Murray)
--- swig/hid_wrap.c 2009-01-22 15:57:51.000000000 +0000
+++ swig/hid_wrap2.c 2009-01-27 15:00:29.000000000 +0000
@@ -1987,7 +1987,7 @@
int newmemory = 0;
*ptr = SWIG_TypeCast(tc,vptr,&newmemory);
if (newmemory == SWIG_CAST_NEW_MEMORY) {
- assert(own);
+ // assert(own);
if (own)
*own = *own | SWIG_CAST_NEW_MEMORY;
@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?
@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 / 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 / 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 / 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 / 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 / Makefile
Last active April 23, 2022 05:53
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 / 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
#