Skip to content

Instantly share code, notes, and snippets.

View simonwagner's full-sized avatar

Simon Wagner simonwagner

  • Munich, Germany
View GitHub Profile
@simonwagner
simonwagner / .gitconfig
Created March 14, 2014 17:04
Fixup alias for simply fixing a commit.
#This will the fixup command to git
#git fixup $commit will use your current index to fixup the specified commit
#This is done by doing git commit --fixup $commit and then using rebase with autosquash
#Based upon http://stackoverflow.com/a/21148981/460564
[alias]
fixup = "!sh -c '(git diff-files --quiet || (echo Unstaged changes, please commit or stash with --keep-index; exit 1)) && COMMIT=$(git rev-parse $1) && git commit --fixup=$COMMIT && git rebase -i --autosquash $COMMIT~1' -"
@simonwagner
simonwagner / ale2csv.py
Last active May 30, 2023 23:54
Convert Avid ALE files to CSV
#!/usr/bin/env python
from collections import OrderedDict
from itertools import dropwhile, izip
import csv
import argparse
import os.path
argparser = argparse.ArgumentParser()
argparser.add_argument("ale_file", metavar="ALE", type=argparse.FileType(mode="rb"))
argparser.add_argument("csv_file", metavar="CSV", type=argparse.FileType(mode="wb"), nargs="?", default=None)
@simonwagner
simonwagner / git-graph.py
Last active April 19, 2023 16:09
Git graph renderer
import sys
import os
import fnmatch
from itertools import chain
from inspect import getframeinfo, stack
import math
from collections import OrderedDict
import pygit2 as git
import cairocffi as cairo
@simonwagner
simonwagner / gist:209f14446989f4c9d617f02778ca5b97
Created January 28, 2019 14:23
Convert raw float32 RGBA bytes to TIFF
convert -endian LSB -depth 32 -define quantum:format=floating-point -size 512x512 -alpha on rgba:/tmp/rgba.dat /tmp/rgb.tiff
@simonwagner
simonwagner / git-submodule-replay
Created May 5, 2017 10:23
Replay commits from submodule in main git repository
#!/bin/sh
#Replay commits from submodule in main git repository
#For each commit in the submodule in range, create a commit in the
#main repository that adds the commit of the submodule with the same
#commit message as the submodule
SUBMODULE=$1
RANGE=$2
@simonwagner
simonwagner / nrange.cpp
Created January 3, 2016 18:04
Calculate how many numbers have the bit i set in the range 0-n (excluding n)
#include <iostream>
#include <limits>
#include <functional>
#include <chrono>
using namespace std;
#define likely(x) __builtin_expect (!!(x), 1)
#define unlikely(x) __builtin_expect (!!(x), 0)
@simonwagner
simonwagner / epidemiologie_WS13
Created January 12, 2014 17:49
Epidemiologie
#Epidemiologie
> Epidemionlogie befasst sich mit der Untersuchung der Verteulung von Krankheiten und deren Einflussfakturen in menschlichen Bevölkerungsgruppen und deren Umsetzung zur Kontrole des Gesundheitswesens
##Klassische Epidemiologie
* Risikofaktoren im Zusammenhang mit dem gehäuften Auftreten einer Krankheit mit Hilfe einer gezielten Untersuchung
* Anlässe
* geographische Unterschiede
* Auftreten von Clustern (meistens nur bei relativ seltenen Erkrankungen)
* zeitliche Veränderungen
#!/usr/bin/env python
"""
Test case for a bug in networkx.algorithms.maximal_matching version 1.8.1
It seems that depending on the order of the nodes in the edges ( (a,b) vs (b,a) )
maximal_matching does return different results.
"""
import networkx as nx
@simonwagner
simonwagner / Makefile
Created June 22, 2013 15:07
Nearly perfect automatic Makefile for C++11. Simply drop it into your source folder and you are done.
TARGET = program
CXXFLAGS += -g -std=c++11
.PHONY: default all clean
default: $(TARGET)
all: default
SOURCES = $(wildcard **/*.cpp) $(wildcard *.cpp)
OBJECTS = $(patsubst %.cpp, %.o, $(SOURCES))
@simonwagner
simonwagner / lock.cpp
Created April 16, 2015 22:43
Broken recursive_timed_mutex in libstdc++ for GCC 4.8
#include <cstdint>
#ifdef MAKE_IT_WORK
#undef _GLIBCXX_USE_CLOCK_MONOTONIC //if this is undefined, the 'correct' clock will be used
#endif
#include <mutex>
extern "C" {
using mutex = std::recursive_timed_mutex;