Skip to content

Instantly share code, notes, and snippets.

@munk
munk / merge_scans.sh
Last active December 17, 2015 11:59
An OSX script for converting and joining jpegs to pdfs. Useful for combining scans into documents for a paperless office.
#!/bin/bash
MAX=$[$2+1]
for ((i = $1; i < $MAX; i++)) do
#echo "sips -s format pdf \"Scan $i.jpeg\" --out \"Scan$i.pdf\""
sips -s format pdf "Scan $i.jpeg" --out "Scan$i.pdf"
done
PDFconcat="/System/Library/Automator/Combine PDF Pages.action/Contents/Resources/join.py"
@munk
munk / orphans.py
Created May 19, 2013 16:21
Some tools for a mongo course, written in python using an obfuscated functional style with emacs lambda substitution
from pymongo import Connection as Cn
from itertools import chain as ch
collection = λ D, C: Cn()[D][C]
orphans = λ c, d, j, k: {[i[j] for i in c]} - {ch(*[a[k] for a in d])}
remove = λ d, k, c: map(d[k].remove, c)
verify = λ k, t: filter(λ i: k in i[t], c)
@munk
munk / Selenium Error Message
Created May 21, 2013 14:17
Selenium Error Message
Window not found. The browser window may have been closed.
Command duration or timeout: 78 milliseconds
Build info: version: '2.32.0', revision: '6c40c18', time: '2013-04-09 17:22:56'
System info: os.name: 'Windows 7', os.arch: 'amd64', os.version: '6.1', java.version: '1.6.0_31'
Session ID: f02673c6-11e6-45c0-8a32-f6dbe927695a
Driver info: org.openqa.selenium.firefox.FirefoxDriver
Capabilities [{platform=XP, acceptSslCerts=true, javascriptEnabled=true, browserName=firefox, rotatable=false, locationContextEnabled=true, version=20.0.1, cssSelectorsEnabled=true, databaseEnabled=true, handlesAlerts=true, browserConnectionEnabled=true, nativeEvents=true, webStorageEnabled=true, applicationCacheEnabled=true, takesScreenshot=true}]
@munk
munk / gist:6957451
Created October 13, 2013 02:33
Blinking lights function for Arduino. Written by Ms Margot.
void redAndGreen() {
int redPins[] = {3,5,7,9};
int greenPins[] = {2,4,6,8};
int delayTime = 1000;
for (int i=0;i<4;i++) { //turn on red, turn off green
digitalWrite(redPins[i], HIGH);
digitalWrite(greenPins[i], LOW);
}
delay(delayTime);
@munk
munk / gist:0037b08de35d946be6cf
Created May 1, 2014 15:48
Play Framework Firefox Stacktrace
$ play test
[info] Loading project definition from /home/usmcs/workspace/todolist/project
[info] Set current project to todolist (in build file:/home/usmcs/workspace/todolist/)
[info] ApplicationSpec
[info] Application should
[info] + send 404 on a bad request
[info] + render the index page
[info] Total for specification ApplicationSpec
[info] Finished in 956 ms
[info] 2 examples, 0 failure, 0 error
@munk
munk / matplotlib_example.py
Created June 1, 2014 22:25
Plotting dict of lists
import matplotlib.pyplot as plt
data = {'a': [1, 2, 3],
'b': [9, 4, 2],
'c': [10, 12, 13]}
fig, ax = plt.subplots()
for name, value in data.items():
ax.plot(value, label=name)
:tddium:
:java:
:java_version: java-6-openjdk
:gradle_version: '1.11'
:tests:
- type: junit
mode: parallel
prefix: 'Demo'
files:
- include: 'test/*Test*.java' # Within prefix
(require 'mine-jabber)
;; Username & nickname fields from https://banno.hipchat.com/account/xmpp
(setq hipchat-username "")
(setq hipchat-nickname "")
(setq hipchat-password "")
(setq hipchat-autojoin-rooms
'("aggregation" "assets" "banno_talk" "banno_cms" "data_services" "emacs" "grip" "kernel" "southen" "troll_talk" "webdev" "design_talk"))
@munk
munk / mongolog.py
Created September 17, 2014 18:21
Mongo Log Parser to find open connections
#!/usr/bin/env python
import sys
import logging
import datetime
def parse_connection(line):
tokens = line.split()
kind = 'OPEN' if "connection accepted from" in line else 'CLOSE'
connection_id = tokens[9] if kind is 'OPEN' \
  1. General Background and Overview