Skip to content

Instantly share code, notes, and snippets.

@JohannesBuchner
JohannesBuchner / rsync_on_change.sh
Created December 15, 2015 16:59
rsync loop that updates remote directory when local directory changes (using inotify)
while true
do
rsync -avz ./ user@host:remote/directory/
inotifywait -r ./
done
@JohannesBuchner
JohannesBuchner / rsyncprogress.py
Last active June 18, 2023 18:51
Progress bar for rsync
"""
Progress bar for rsync
========================
Shows file progress and total progress as a progress bar.
Usage
---------
Run rsync with -P and pipe into this program. Example::
@JohannesBuchner
JohannesBuchner / photo-panning-video.diascope
Created October 18, 2015 18:04
Diascope file to create Ken Burns effects (zoom&pan) and transitions across 5 nice photos.
format pal quality=1 aspect=4:3 mpeg2sound=ac3 mpeg2=3,192
# later: quality=1 interlaced
set dur=sec
set resize=resize
set title_offset=20%,80% title_area=15%
# http://computoser.com/track/722
# http://computoser.com/track/6340
audio spacy.mp3
#set label=green
@JohannesBuchner
JohannesBuchner / methodchoice.rst
Last active August 29, 2015 14:25
Method decision tree for parameter estimation and model comparison

Method decision tree

  • Write down your problem mathematically/statistically; stripping out astronomy-specific details from your model (e.g. pre-compute redshifts, weights, etc.)
  • Ideally, shorten and simplify it down to primitives of math and statistics, which can be implemented in any language.

For the following decision tree, keep in mind that typically, one first thinks

  • I just want to quickly find the best fit on this.

Enumerated List Bug Demo

First

  1. foo (should be 1.)
  2. bar (should be 2.)

Second

@JohannesBuchner
JohannesBuchner / statistics-minimal.rst
Last active July 31, 2016 08:47
ArXiV minimal statistics checklist

ArXiV minimal statistics checklist

This checklist help you identify and fix common errors/misinterpretation in your analysis, or of a paper you are refereeing.

  1. If you use p-values (from a KS test, Pearson correlation, etc.).
  1. What do you think a low p-value says?
  1. You have absolutely disproved the null hypothesis (e.g. "no correlation" is ruled out, the data are not sampled from this model, there is no difference between the population means).
@JohannesBuchner
JohannesBuchner / console-progress.py
Last active August 29, 2015 14:23
Console progress bar -- takes stdin from arbitrary commands and plots a progress bar
"""
SYNOPSIS: ./myprog | python console-progress.py
example for myprog:
#!/bin/bash
echo 100
for i in $(seq 1 100)
do
sleep 1
@JohannesBuchner
JohannesBuchner / pvalue.py
Created June 20, 2015 19:24
p-value reliability
import matplotlib.pyplot as plt
import numpy
import scipy.stats
# http://www.medpagetoday.com/Blogs/TheMethodsMan/52171
def calc_reliability(p, power=0.8, frac_true=0.1):
"""
Given this p-value, power of the test and fraction of hypotheses that
are actually true.
@JohannesBuchner
JohannesBuchner / overlapgauss.py
Created June 20, 2015 19:00
Probability that two measurements actually have the same value
import numpy
import matplotlib.pyplot as plt
import scipy.stats
# two gaussian uncertainties with width sigma
# at distance delta
# what is the probability that they actually have the same value?
def compute_bayes(delta, border=5):
a = scipy.stats.norm()
@JohannesBuchner
JohannesBuchner / codememoize.py
Last active August 29, 2015 14:21
For tests/builds that should only re-run when code or data files have changed (memoized tests)
"""
Memoizes a given function, given its code dependencies (loaded modules and
additional data files)
Example::
import douglasadams
def costlyfunction():
# compute answer to the universe and everything
return douglasadams.compute_answer() == 42