Skip to content

Instantly share code, notes, and snippets.


Till Dettmering dettmering

View GitHub Profile
dettmering /
Created Feb 14, 2014
Bash: Renames groups of images (329L_**_000x.tif) with a combined md5 hash of the group (329L_**-bac8dacd79_000x.tif)
# Rename image files with md5 hash
mkdir out
for f in *.tif
splt=(${f//_/ })
c=$(cat ${splt[0]}\_${splt[1]}\_* | md5) # 329L_23_*
dettmering / ml.R
Last active Aug 29, 2015
Machine learning template for R
View ml.R
registerDoMC(cores = 4) # use multiple cores
col.of.interest <- c(
'response', 'A', 'B', 'C'
dettmering /
Last active Aug 31, 2015
Compile R on Raspberry Pi
# This can take a while. Run in a screen environment.
# Modify for the version you want to install.
sudo apt-get install screen gfortran libreadline6-dev libx11-dev libxt-dev
cd ~
dettmering / bahncard-vs-auto.Rmd
Last active Sep 20, 2015
Wochenendpendeln mit Bahn + BahnCard 50 oder Auto—was ist billiger?
View bahncard-vs-auto.Rmd
```{r echo = FALSE, results = 'show'}
# Vergleich Pendeln mit Auto vs. Bahn mit BahnCard 50
# Fahrten pro Jahr (Wochenenden pro Jahr abzgl. Urlaub/Feiertage)
n.fahrten <- (52 - 7) * 2 # Fahrten in eine Richtung
dettmering / gist:4045392
Created Nov 9, 2012
Bash: Add all EPS files in the directory to a TeX file
View gist:4045392
# Puts all eps files in folder in figure environment
rm figures.tex
echo "\documentclass[a4paper,10pt]{article}
\usepackage{graphicx} % support the \includegraphics command and options
dettmering /
Created Nov 9, 2012
Shell: Recalculate bounding box of EPS files
# This script recalculates all bounding boxes of all eps files in the same folder
# requires epstool
for f in *.eps
g=$(echo $f | sed 's/\(.*\)\..*/\1/')
echo Processing $f ...
epstool --copy --bbox $g.eps $g-new.eps
dettmering / gist:4587442
Last active Dec 11, 2015
LaTeX: TikZ playground.
View gist:4587442
\renewcommand*\familydefault{\sfdefault} %% Only if the base font of the document is to be sans serif
dettmering / gist:4943573
Last active Dec 13, 2015
LaTeX: Template for generating PDF with figures for paper submission
View gist:4943573
\pagenumbering{gobble} % removes page numbering
dettmering / gist:5070274
Last active Dec 14, 2015
Python: Generate heat map
View gist:5070274
def rgb(r,g,b): # Just returns r, g, b in this case. Can be used to reformat RGB values if necessary.
return r,g,b
def heat(min, max, val, type): # Takes min and max values and the value to be heatmapped. Type is the look up table, see below.
min = float(min)
max = float(max)
val = float(val)
val = (val - min) / (max - min) # normalize val to min and max
dettmering / gist:5075213
Last active Dec 14, 2015
Bash: Parse all GD files in folder
View gist:5075213
# This script creates eps files from all .gd or .exec files in a directory.
if [ ! -d "img/" ];
mkdir img
rm img/*-gd.eps
touch execfile # Create execfile
You can’t perform that action at this time.