Skip to content

Instantly share code, notes, and snippets.

View klieret's full-sized avatar
💭
🦊

Kilian Lieret klieret

💭
🦊
View GitHub Profile

Use basf2 installation:

Set up basf2

cd /cvmfs/belle.cern.ch/ubuntu1604/
source tools/setup_belle2
cd releases/build-2017-10-16/
setuprel

Rerun those commands every time you start working agai!

@klieret
klieret / cachedCalc.wl
Last active May 17, 2021 21:36
Cache the result of Mathematica calculations and load it again later.
cachedCalc::usage="Cache the result of a calculation into a .mx file at \
<notebook directory>/<notebook name>/<variable name>.mx
Arg1: variable (variable as symbol or variable name as string)
Arg2: expression (how to calculate value of the variable)
Arg3: forceRecalculate (bool; default False; recalculate even if found in Cache).
Optional arguments:
quiet (bool: should debug messages be printed?)
maxAge (date difference object: if the cache is older than that age, a \
@klieret
klieret / monsky.py
Created December 28, 2017 07:13
Monsky's theorem: Coloring the plane
#!/usr/bin/python3
""" Illustrates the coloring of the plane used for Monsky's theorem. """
from PIL import Image
import argparse
import os
import sys
@klieret
klieret / unevaluated.wl
Last active September 19, 2021 23:11
Print Mathematica expressions without evaluating them & use that for a handy debug print statement to print internal variables together with their names.
debugPrint::usage="Arg 1 (bool): If False, do nothing. If True and Arg 2 is \
a string, then the string is simply printed. If True and Arg 2 is not a string, then \
first the unevaluated expression is printed, followed by the evaluated expression. \
Additionally given rules influence the styling of the output.
Arg 3 (bool): Strip suffixes like $1234 (signalling internal variables)";
unevaluatedExpression::usage="Print the argument without any kind of evaluation in \
the same way it is given here as an argument
Arg 2(bool): Strip suffixes like $1234 (signalling internal variables)";
@klieret
klieret / texexpression.py
Last active January 4, 2018 14:28
Fixes/Workarounds for bugs in Mathematica's LaTeX Export: Problems with Subsuperscript and with nonsensical \left and \right tags.
#!/usr/bin/env pyton3
import re
import sys
subsup_regex = re.compile(r"\\text\{Subsuperscript\}\[([^\],]*),([^\],]*),([^\],]*)\]")
minimal_braces = True
@klieret
klieret / superComplexContourPlot.wl
Last active January 13, 2018 09:38
Complex contour Plot together with 1D Plot projections of real and imaginary part
(* ::Package:: *)
(* ::Code::Initialization::Plain:: *)
superComplexContourPlot::usage="Plots a contour plot of a real expression in a complex variable,
together with 1D projections of the depedence on the real/imaginary part of the variable.
Arg 1: Expression to plot
Arg 2: Variable to plot
Opt 3: Plot label (def: '')
Opt 5: {min real part, max real part} (def: {1,1})
Opt 6: {min im part, max im part} (def: {1,1})";
#!/bin/bash
# Moves one file but searches through LaTeX source
# and also changes all path references to the file
# Arg 1: Current location of the file
# Arg 2: Target location of the file
set -e
latex_dir=""
#!/bin/bash
# script to go through all figures, search all of our *.tex
# files to see if the figure is still included, and
# if not, print it to standard output
# pipe to rm to delete the unused ones then.
set -e
latex_dir=""
@klieret
klieret / random_file_tree.py
Last active June 9, 2020 17:43
Create a random file tree in python, e.g. random subfolders and random files.
#!/usr/bin/env python3
""" AVAILABLE AS A PACKAGE ON github.com/klieret/randomfiletree """
import sys
import os
import random
import string
from pathlib import Path