Skip to content

Instantly share code, notes, and snippets.

Sarah Mount snim2

Block or report user

Report or block snim2

Hide content and notifications from this user.

Learn more about blocking users

Contact Support about this user’s behavior.

Learn more about reporting abuse

Report abuse
View GitHub Profile
@snim2
snim2 / gist:192726
Created Sep 24, 2009
Generic Makefile for OCaml projects
View gist:192726
#
# Generic Makefile for OCaml projects.
#
# Sarah Mount
# September 2009.
#
# Code should be structured roughly like this:
#
# project /
# Makefile
@snim2
snim2 / fig.tex
Created Sep 24, 2009
Placement and scaling of figures with LaTeX and the graphicx package
View fig.tex
%%% Figure placement and scaling with LaTeX and graphicx.
%%%
%%% Sarah Mount.
%%%
%%% Replace all UPPERCASE text with your own.
%%% To change scaling, replace the "0.6\columnwidth" with your preferred size.
%%%
%%% "Hhtbp" is the preference of the author for figure placement:
%%% Place _H_ere > Place _h_ere if possible > place at _t_op of page >
%%% place at _b_ottom of page > place on a _p_age of figures.
@snim2
snim2 / dis-example.py
Created Sep 24, 2009
Using the Python disassembler to analyse uncaught exceptions
View dis-example.py
>>> import dis
>>> 1 / 0
Traceback (most recent call last):
File "<stdin>", line 1, in <module>
ZeroDivisionError: integer division or modulo by zero
>>> dis.dis()
1 0 LOAD_CONST 0 (1)
3 LOAD_CONST 1 (0)
--> 6 BINARY_DIVIDE
7 PRINT_EXPR
@snim2
snim2 / tab2space.el
Created Nov 1, 2009
Convert tabs to spaces in Emacs
View tab2space.el
;;; Turn tabs to spaces
(defun tabs-to-spaces (&optional begin end)
"Turn all tabs in a region into four spaces."
(interactive "r")
(save-excursion
(if mark-active
(replace-regexp "\t" " " nil (point) (mark))
(replace-regexp "\t" " " nil (point-min) (point-max))
)
)
@snim2
snim2 / csp-pygame.py
Created Nov 29, 2009
Use a python-csp process to render images to Pygame
View csp-pygame.py
@process
def Drawme(channel, _process=None):
import pygame
# Constants
WIDTH, HEIGHT = 512, 256
# Open window
pygame.init()
screen = pygame.display.set_mode((WIDTH, HEIGHT), 0)
QUIT = False
while not QUIT:
@snim2
snim2 / spaces2tabs4.el
Created Dec 12, 2009
Convert spaces to tabs in Emacs
View spaces2tabs4.el
(defun four-spaces-to-tab (&optional begin end)
"Replace four spaces with a tab in a region."
(interactive "r")
(save-excursion
(if mark-active
(replace-regexp " " "\t" nil (point) (mark))
(replace-regexp " " "\t" nil (point-min) (point-max))
)
)
)
@snim2
snim2 / camerastream.py
Created Dec 13, 2009
Display the output of a webcam using Python and Pygame
View camerastream.py
import pygame
import pygame.camera
from pygame.locals import *
DEVICE = '/dev/video0'
SIZE = (640, 480)
FILENAME = 'capture.png'
def camstream():
pygame.init()
@snim2
snim2 / howl.py
Created Dec 13, 2009
Access the Howl web service for the Internet of Things via the command line
View howl.py
#!/bin/env python
"""
Execute a single Howl command.
Usage:
$ python howl.py --help
Usage: howl.py [options]
View eclipse_fix.sh
# Fix Eclipse on Ubuntu Karmic
export GDK_NATIVE_WINDOWS=1
View listexn.py
#!/usr/bin/env python
def listexns(mod):
module = __import__(mod)
exns = []
for name in module.__dict__:
if (isinstance(module.__dict__[name], Exception) or
name.endswith('Error')):
exns.append(name)
for name in exns:
You can’t perform that action at this time.