Skip to content

Instantly share code, notes, and snippets.

@mhl
mhl / gist:2700917
Created May 15, 2012 11:14
beautify-javascript.bash
#!/bin/bash
D=$(dirname $(readlink -nf $BASH_SOURCE))
SD=$(readlink -nf $D/../httpdocs)
# The js-beautify directory. (It can be cloned from
# https://github.com/einars/js-beautify .)
JSB=~/js-beautify/
if [ ! -e "$JSB/beautify-cl.js" ]
@mhl
mhl / convert-stitching-results.py
Created February 23, 2012 14:13
Convert TileConfiguration.registered.txt to a format TrakEM2 can load
#!/usr/bin/env python
# This script takes the output of Stephan Preibisch's stitching plugins
# for 3D stacks and outputs tab separated data suitable for loading
# into TrakEM2. What TrakEM2 expects is described here:
#
# http://www.ini.uzh.ch/~acardona/trakem2_manual.html#importing_list
import sys, re
#!/usr/bin/python
import re, csv, sys, urllib, urllib2, time, cgi
from collections import defaultdict
spreadsheet_url = 'https://docs.google.com/spreadsheet/ccc?key=0Am9Hd8ELMkEsdDg4QVd6d0JGeS1WQ0VpTnNBSm5xS2c&output=csv'
season_output = defaultdict(list)
decision_data = {
@mhl
mhl / git-show-all-objects.sh
Created September 12, 2011 16:05
A script to show all the objects in a git repository
#!/bin/sh
set -e
cd "$(git rev-parse --show-cdup)"
# Find all the objects that are in packs:
for p in .git/objects/pack/pack-*.idx
do
@mhl
mhl / wilson-interval.rb
Created July 1, 2011 17:10
Naive pairwise comparisons power
#!/usr/bin/ruby -w
require 'statistics2'
class Numeric
def to_percent
"#{(self * 100).round}%"
end
end
@mhl
mhl / git-fetch-and-fast-forward-all-branches.sh
Created April 22, 2011 11:35
An example script to show how to fetch from all default remotes and do any fast-forwards of local branches from upstream possible
#!/bin/sh
set -e
CURRENT_BRANCH="$(git symbolic-ref HEAD)"
CURRENT_BRANCH_UPSTREAM="$(git rev-parse --symbolic-full-name @{u} 2> /dev/null)"
# Update the remote-tracking branches for every remote for which
# remote.<name>.skipDefaultUpdate is not true:
git remote update default
@mhl
mhl / Convert_Traces_to_SWC.py
Created March 26, 2011 05:39
Batch convert Simple Neurite Tracer's .traces files to SWC format
import os
import re
from tracing import PathAndFillManager
# An example script showing how to convert all the .traces
# files in a directory to SWC files. (The .traces format
# is the native file format of Simple Neurite Tracer.)
def run():
d = IJ.getDirectory("Choose your directory of .traces files...")
@mhl
mhl / squash-all.bash
Created March 11, 2011 06:38
A script that squashes your entire branch down to a single commit
#!/bin/bash
# A script that squashes your entire current branch down to a single commit,
# if this repository has a single root commit. This will change the object
# name of the root commit. This is for an answer to the Stack Overflow
# question: http://stackoverflow.com/questions/5266340/
if [ -n "$(git status --porcelain)" ]
then
echo "git status wasn't clean - refusing to run..."
@mhl
mhl / SWC_Display.py
Created February 22, 2011 14:00
In Fiji display SWC files in the 3D Viewer
import re
import os
from java.awt import Color
from ij3d import Image3DUniverse
univ = Image3DUniverse(512, 512)
univ.show()
# d = '/home/mark/painting-demo/static/data'
Checking prerequisites of (fiji.build.SubFake) jars/weka.jar <- fiji jars/Fiji.jar ...
Building (fiji.build.SubFake) jars/weka.jar <- fiji jars/Fiji.jar ...
Building in modules/weka/
Checking prerequisites of (fiji.build.ExecuteProgram) weka.jar <- weka/dist/weka.jar
Checking prerequisites of (fiji.build.ExecuteProgram) weka/dist/weka.jar <-
Building (fiji.build.ExecuteProgram) weka/dist/weka.jar <-
Executing: '../../fiji' '--ant' '-f' 'weka/build.xml' 'exejar'
Found that JAVA_HOME was: '/usr/lib/jvm/java-6-openjdk/'
Buildfile: weka/build.xml