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 / 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 / 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-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 / 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;
@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 / benchmark.cpp
Last active August 29, 2015 14:06
UTF32 compare benchmark
/*
Compile with gcc, because clang does not support alignment of stack values (and does not even warn about that).
g++-mp-4.8 -march=native -mtune=native -std=c++11 benchmark.cpp -O3 -o benchmark
Results on my computer:
naive: 22.6027 (1)
hadd: 10.0168 (0.443169)
hadd_2: 9.88255 (0.437228)
movemask: 9.85698 (0.436097)
@simonwagner
simonwagner / heartbeat.c
Created April 9, 2014 13:35
OpenSSL Heartbeat Bug Explanation
int
dtls1_process_heartbeat(SSL *s)
{
unsigned char *p = &s->s3->rrec.data[0], *pl;
unsigned short hbtype;
unsigned int payload;
unsigned int padding = 16; /* Use minimum padding */
/* Read type and payload length first */
hbtype = *p++;
@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 / 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