Skip to content

Instantly share code, notes, and snippets.


Johannes Buchner JohannesBuchner

View GitHub Profile
JohannesBuchner /
Last active Dec 16, 2015
Python progressbar
import progressbar
pbar = progressbar.ProgressBar(widgets=[progressbar.Percentage(),
progressbar.Counter('%5d'), progressbar.Bar(), progressbar.ETA()])
for obj in pbar(to_handle):
# deal with object
JohannesBuchner /
Last active Dec 17, 2015
joblib caching for expensive functions
import joblib
import os
cachedir = 'cache'
if not os.path.isdir(cachedir): os.mkdir(cachedir)
mem = joblib.Memory(cachedir=cachedir, verbose=True)
def my_long_function(i):
return i + i
JohannesBuchner /
Last active Dec 23, 2015
install {,Py,R}MultiNest
# necessary packages:
# sudo apt-get install python-{scipy,numpy,matplotlib,progressbar} ipython libblas{3,-dev} liblapack{3,-dev} libatlas{3-base,-dev} cmake build-essential git gfortran r-base r-base-dev
echo 'checking installed software requirements'
for c in R cmake; do
if ! hash $c; then echo "install '$c' first"; exit 1; fi
JohannesBuchner /
Created Sep 20, 2013
tool for publishing sphinx documentation on github and releasing packages on PyPI
# Author: Johannes Buchner (C) 2013
# tool for publishing sphinx documentation on github
# and releasing packages on PyPI
case "$1" in
# see
make -C doc/ html &&
git checkout gh-pages &&
JohannesBuchner / thunderbird_build_notes.txt
Last active Dec 24, 2015
Thunderbird/Mozilla build notes
View thunderbird_build_notes.txt
ac_add_options --enable-application=mail
ac_add_options --with-ccache=/usr/bin/ccache
ac_add_options --enable-calendar
#ac_add_options --disable-debug
ac_add_options --enable-debug
import subprocess
def runscript(name):
args = ('./interact', name,)
p = subprocess.Popen(args)
# p.communicate() # set stdin/stdout/stderr=subprocess.PIPE
if p.wait() != 0:
raise Exception('return value of startup script was non-zero')
#rm /usr/portage/distfiles/*
renice +20 -p $$
ionice -c3 -p $$
pgrep emerge >/dev/null || rm /var/tmp/portage/*-* -rf
emerge-webrsync && eix-update
ARGS="--quiet-build --load-average=10 --jobs=3"
JohannesBuchner /
Last active Dec 27, 2015
ETA from external programs
"""Estimate Time until completion of a process.
Usage: <statusprog> | <n>
<statusprog> is a program that writes a line to stdout from time to time.
The line is the number of items completed so far.
<n> is the total number of items to complete.
for((i=0;i<20;i++)); do echo $i; sleep 1; done | python 20
JohannesBuchner / install.rst
Last active Dec 29, 2015
Prepare VirtualBox image
View install.rst

Installation notes for Virtual machine


  • BXA
  • MultiNest
  • PyMultiNest
  • Sherpa
  • Xspec
JohannesBuchner /
Last active Aug 29, 2015
Toy linefitting
import numpy
from numpy import log, isnan, isfinite, sin, cos, tan, abs, any, pi
import scipy, scipy.stats
import pymultinest
import json
import sys
import matplotlib.pyplot as plt
outputfiles_basename = "mnchains_toy_"