Skip to content

Instantly share code, notes, and snippets.

#!/usr/bin/python2.6
# This script "unsubmodulizes" a git repository - i.e. it takes a git
# repository with submodules and replaces the submodules with the
# history of the submodule merged into a subdirectory of the same
# name. I knocked this up quickly as an answer to this stackoverflow
# question:
#
# http://stackoverflow.com/questions/4542729/undo-submodulization-in-git
#
@mhl
mhl / Process_Diadem_Neuromuscular.clj
Created August 4, 2010 16:41
A clojure script for Fiji to help process the Diadem Neuromuscular data set
(import '(ij.io DirectoryChooser))
(import '(java.io File))
(import '(java.io FileWriter))
(import '(ij.plugin FolderOpener))
(import '(ij IJ))
(import '(ij.io FileSaver))
;; d should be a java.io.File object
(defn files-in-directory [d]
@mhl
mhl / meld-compare-refs.py
Created July 29, 2010 16:46
Extract the trees from two commits to a temporary directory and run meld on them
#!/usr/bin/python3.1
# This is script that extracts the trees of two commits to temporary
# directories and then runs meld on both directories, so you can compare
# them using meld's nice recursive browsing interface.
#
# This is for an answer to this question:
# http://stackoverflow.com/questions/2006032/view-differences-of-branches-with-meld
from subprocess import call, Popen, PIPE, check_call
@mhl
mhl / extract-tree-from-git.py
Created July 29, 2010 15:37
A script to extract a tree from a git repository
#!/usr/bin/python3.1
from subprocess import call, Popen, PIPE, check_call
import re
import sys
import os
import errno
# !! n.b. You probably shouldn't be using this - it's vastly faster and safer to use
# one of the other methods mentioned here:
@mhl
mhl / enweb.py
Created July 27, 2010 11:59
A script for uploading a local file to be web visible, outputting a URL
#!/usr/bin/python3.1
import sys
import os
import urllib.parse
from subprocess import call
if len(sys.argv) != 2:
print("Usage: {} [FILE-OR-DIRECTORY]".format(sys.argv[0]),file=sys.stderr)
sys.exit(1)
--- Polar_Transformer.original.java 2008-03-10 21:52:08.000000000 +0100
+++ Polar_Transformer.java 2010-06-25 15:27:13.171811587 +0200
@@ -73,37 +73,56 @@
if (showDialog(ipInitial))
{
-
- widthInitial = ipInitial.getWidth();
- heightInitial = ipInitial.getHeight();
- if (ipInitial instanceof ColorProcessor) isColor = true;
@mhl
mhl / merge-pwsafe-from.py
Created June 11, 2010 07:54
Grab ~/.pwsafe.dat over ssh and merge it with your local version
#!/usr/bin/python3.1
import sys
import re
import tempfile
from subprocess import call, check_call
import os
def print_usage():
print("Usage: {} user@host".format(sys.argv[0]))
@mhl
mhl / gist:293827
Created February 3, 2010 17:56
Usernames from my git svn import of ukparse
$ git log --format="%an"|sort|uniq
fjmd1
frabcus
goatchurch
heathd
louise
mark
sams
solidgoldpig
sym
@mhl
mhl / pdf-pages-with-graphics.py
Created January 13, 2010 10:36
Split a PDF into pages with graphics and those without
#!/usr/bin/python2.5
# This script attempts to take a PDF file and split it into two PDF
# files, one of which has all the images and the other which has
# everything else. You can select pages by whether they contain
# /Subtype /Image (bitmaps in my case) or /XObject which seems to
# catch bitmaps and included PDF files (which are most diagrams
# exported to PDF in my case).
import os
@mhl
mhl / stupid-emusic.sh
Created January 13, 2010 10:13
Tiny eMusic Download Script
#!/bin/sh
if [ $# -ne 1 ]
then
echo Usage: $0 "<path-to-download.emx>"
exit 1
fi
for i in $(xml_grep 'TRACKURL' $1|sed 's/.*\(http.*mp3\).*/\1/'|egrep http)
do