Skip to content

Instantly share code, notes, and snippets.

Johannes Buchner JohannesBuchner

Block or report user

Report or block JohannesBuchner

Hide content and notifications from this user.

Learn more about blocking users

Contact Support about this user’s behavior.

Learn more about reporting abuse

Report abuse
View GitHub Profile
@JohannesBuchner
JohannesBuchner / pbar.py
Last active Dec 16, 2015
Python progressbar
View pbar.py
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
JohannesBuchner / caching.py
Last active Dec 17, 2015
joblib caching for expensive functions
View caching.py
import joblib
import os
cachedir = 'cache'
if not os.path.isdir(cachedir): os.mkdir(cachedir)
mem = joblib.Memory(cachedir=cachedir, verbose=True)
@mem.cache
def my_long_function(i):
return i + i
@JohannesBuchner
JohannesBuchner / installMultiNest.sh
Last active Dec 23, 2015
install {,Py,R}MultiNest
View installMultiNest.sh
#!/bin/bash
#
# 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
JohannesBuchner / publishPython.sh
Created Sep 20, 2013
tool for publishing sphinx documentation on github and releasing packages on PyPI
View publishPython.sh
#!/bin/bash
# Author: Johannes Buchner (C) 2013
# tool for publishing sphinx documentation on github
# and releasing packages on PyPI
case "$1" in
doc)
# see https://help.github.com/articles/creating-project-pages-manually
make -C doc/ html &&
git checkout gh-pages &&
@JohannesBuchner
JohannesBuchner / thunderbird_build_notes.txt
Last active Dec 24, 2015
Thunderbird/Mozilla build notes
View thunderbird_build_notes.txt
Follow https://developer.mozilla.org/en-US/docs/Simple_Thunderbird_build
comm-central/.mozconfig:
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
View runProcess.py
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')
View updateGentoo.sh
#!/bin/bash
#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
JohannesBuchner / howlong.py
Last active Dec 27, 2015
ETA from external programs
View howlong.py
"""Estimate Time until completion of a process.
Usage: <statusprog> | howlong.py <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.
Example:
for((i=0;i<20;i++)); do echo $i; sleep 1; done | python howlong.py 20
@JohannesBuchner
JohannesBuchner / install.rst
Last active Dec 29, 2015
Prepare VirtualBox image
View install.rst

Installation notes for Virtual machine

Contains

  • BXA
  • MultiNest
  • PyMultiNest
  • Sherpa
  • Xspec
@JohannesBuchner
JohannesBuchner / toy.py
Last active Aug 29, 2015
Toy linefitting
View toy.py
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
numpy.random.seed(1)
outputfiles_basename = "mnchains_toy_"
You can’t perform that action at this time.