Skip to content

Instantly share code, notes, and snippets.

View snim2's full-sized avatar

Sarah Mount snim2

View GitHub Profile
@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 / .travis.yml
Last active August 31, 2023 20:03
Travis-CI recipe for testing LaTeX projects compiled by a Makefile
install:
- sudo apt-get install texlive-latex-recommended texlive-latex-extra texlive-fonts-recommended
- sudo apt-get install chktex
script:
- make
- chktex -W # Print version information.
- chktex -q -n 6 *.tex chapters.*.tex 2>/dev/null | tee lint.out
# If lint output is non-empty report an error.
- test ! -s lint.out
@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 / listexn-raised.py
Created May 16, 2010 13:08
Find exception names in a Python module
#!/usr/bin/env python
import compiler.ast
import compiler.visitor as visitor
__author__ = 'Sarah Mount <s.mount@wlv.ac.uk>'
__date__ = 'May 2010'
class ExceptionFinder(visitor.ASTVisitor):
@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 / camerastream.py
Created December 13, 2009 00:00
Display the output of a webcam using Python and Pygame
import pygame
import pygame.camera
from pygame.locals import *
DEVICE = '/dev/video0'
SIZE = (640, 480)
FILENAME = 'capture.png'
def camstream():
pygame.init()
@snim2
snim2 / pre-commit.py
Created September 5, 2013 00:50
A git pre-commit hook to test Python code for PEP8 compliance, and run unit tests via the pytest framework
#!/usr/bin/env python
"""
Git pre-commit hook to enforce PEP8 rules and run unit tests.
Copyright (C) Sarah Mount, 2013.
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 / 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)
}
#!/bin/sh
#
# This script automatically runs 'make' whenever any of the LaTeX files in
# this directory are saved. Open the PDF file you want to view in the
# background, and run this script in the shell. Every time you save a
# LaTeX file, the LaTeX will be recompiled and an updated version of the PDF
# will be displayed in your PDF viewer.
#
@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)