Skip to content

Instantly share code, notes, and snippets.

View goerz's full-sized avatar

Michael Goerz goerz

View GitHub Profile
@goerz
goerz / REAME.markdown
Last active August 29, 2015 14:01
Lecture on Immortality

This is the handout of a lecture on immortality that I gave at Hofstra University on March 5th, 2007

@goerz
goerz / clostest_unitary.ipynb
Last active August 29, 2015 14:01
Finding the Closest Unitary for a Given Matrix
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
@goerz
goerz / quicksort.py
Created November 3, 2013 03:42
A reference implementation of the Quicksort algorithm. Should be easy to translate to other languages.
#!/usr/bin/env python
""" Reference implementation of Quicksort on an integer array """
__author__ = 'Michael Goerz'
import numpy as np
import numpy.random as nprnd
import random
import math
@goerz
goerz / greader2pinboard.py
Last active December 15, 2015 08:09
Script for importing Google Reader starred items (from starred.json file obtained from Google Checkout) into Pinboard. The import on the Pinboard website didn't work for me.
#!/usr/bin/env python
import json
from html2text import html2text
import pinboard
import time
import sys
username = 'pinboardusername'
password = 'secret'
@goerz
goerz / gist:5157942
Last active September 14, 2018 06:07
Script that is an adaption of the code found at http://n2.nabble.com/Loss-of-local-file-links-td2209604.html It adds a Local-File field to the BibTeX file with the relative path of the referenced file.
#!/usr/bin/env python
""" Add/update Local-File field to BibDesk-organized BibTeX file """
import sys
import base64
import re
import shutil
from Foundation import *
key_pattern = re.compile(r'^(?P<indent>\s*)Bdsk-File-1 = \{(?P<key>.*)\}[,}]$')
@goerz
goerz / pre-commit
Created November 3, 2012 12:03
Default git pre-commit hook
#!/bin/sh
#
# An example hook script to verify what is about to be committed.
# Called by git-commit with no arguments. The hook should
# exit with non-zero status after issuing an appropriate message if
# it wants to stop the commit.
#
# To enable this hook, make this file executable.
# This is slightly modified from Andrew Morton's Perfect Patch.
@goerz
goerz / run.pbs
Created January 23, 2012 15:40
Example PBS file
#!/bin/bash
#PBS -N example
#PBS -j oe
#PBS -l nodes=1:ppn=1
#PBS -l mem=1000m
#PBS -l walltime=16:00:00
#PBS -l cput=16:00:00
######PBS -l file=1g
@goerz
goerz / printenv.pbs
Created January 23, 2012 14:54
PBS/TORQUE script to print node environment
#!/bin/bash
#PBS -N pbstest
#PBS -j oe
#PBS -l nodes=1:ppn=1
#PBS -l walltime=00:00:10
#PBS -l mem=10mb
#PBS -o pbstest.out
echo "####################################################"
echo "User: $PBS_O_LOGNAME"
@goerz
goerz / mountstick.pl
Created August 1, 2010 19:26
mountstick.pl
#!/usr/bin/perl -w
use strict;
my @devicelist = </dev/sdb?>; # order is important: first found device ist default
my %mountpaths = ( qr"/dev/sd??" => '/mnt' ); # default paths
my $UID = 'goerz'; # the user id the device is mounted as
my $GID = 'users'; # the group id the device is mounted as
my $FMASK = '000'; # the permissions of the mounted device (masked)
my $UMOUNT = '/home/goerz/bin/umountstick'; # the name of the script that should be written for umounting
my $TRFILE = '/home/goerz/.usbmounts'; # file used for tracking which devices are mounted
@goerz
goerz / scan.pl
Created August 1, 2010 18:47
scan.pl: A script that wraps sane to scan to a pdf file, A4, black-and-white.
#!/usr/bin/perl -w
use strict;
use threads;
# (c) 2007 Michael Goerz <[email protected]>
# usage:
# scan [pdffile]
# Prerequisites:
# iText (http://www.lowagie.com/iText/)