Skip to content

Instantly share code, notes, and snippets.

View philippkeller's full-sized avatar

Philipp Keller philippkeller

View GitHub Profile
@philippkeller
philippkeller / flatten.py
Created October 18, 2018 10:03
flatten json using flatten_json
#!/usr/bin/env python3
import flatten_json
import sys
import json
if __name__ == '__main__':
if len(sys.argv) < 3:
print(f'usage: {sys.argv[0]} in.csv out.csv')
f_out = open(sys.argv[2], 'w')
@philippkeller
philippkeller / private.xml
Last active September 12, 2018 19:48 — forked from behrends/private.xml
Karabiner Umlauts (alt+u ⇒ ü, etc.)
<?xml version="1.0"?>
<root>
<item>
<name>Easy access for Umlauts</name>
<identifier>private.easy_umlaut_access</identifier>
<autogen>
--KeyToKey--
KeyCode::A, ModifierFlag::OPTION_L | ModifierFlag::SHIFT_L,
KeyCode::U, ModifierFlag::OPTION_L, KeyCode::A, ModifierFlag::SHIFT_L
</autogen>
@philippkeller
philippkeller / scanbd.conf
Created January 19, 2018 22:03
initial scanbd.conf
/*
* $Id: scanbd.conf 213 2015-10-05 06:52:50Z wimalopaan $
*
* scanbd - KMUX scanner button daemon
*
* Copyright (C) 2008 - 2015 Wilhelm Meier (wilhelm.meier@fh-kl.de)
*
* This program is free software; you can redistribute it and/or modify
* it under the terms of the GNU General Public License as published by
* the Free Software Foundation; either version 2 of the License, or
@philippkeller
philippkeller / scanbd.conf
Last active January 19, 2018 13:09
sample scanbd.conf
global {
# log to console. put to 'false' once you're done with testing
debug = true
# 1=error, 2=warn, 3=info, 4-7=debug
# 3 was sufficient for me (shows when script is triggered)
debug-level = 3
scriptdir = /etc/scanbd/scripts
@philippkeller
philippkeller / memleak.py
Created December 30, 2017 14:00
memory leak
import time
import tracemalloc
import pympler.muppy, pympler.summary
import gc
import sys
tracemalloc.start()
collection = []
start = time.time()
@philippkeller
philippkeller / interval_count.py
Created December 30, 2017 07:56
Stackoverflow count warm/cold by 5 minute interval
import datetime
with open("myfile.csv") as f:
window_from = None
window_to = None
warm = cold = 0
for line in f:
milliseconds, topics = line.split(",")
if milliseconds == 'milliseconds':
continue
@philippkeller
philippkeller / test_min_value.sh
Created December 29, 2017 17:15
Test thread data races
min=40000
for i in {1..10000}; do
a=$(./test)
min=$((a<min?a:min));
done
echo $min
import multiprocessing
import queue
import time
def worker(input, output):
for line in iter(input.get, None):
output.put(len(line))
if __name__ == '__main__':
num_processes = 3
@philippkeller
philippkeller / Default (Windows).sublime-keymap
Created June 1, 2017 13:44
Make Sublime Keybindings on Windows same as on MacOS
/*
* these keybindings are taken over from OSX with:
* - super (aka mac key) replaced by alt (because alt is at the same position as the mac key)
* - keybindings with super+alt removed (except the layout keycombos like super-alt-2 to make two columns are replaced by alt-2, etc.)
* - ctrl-a, ctrl-e, etc which are provideed by Mac (aka Emacs keybindings) are added additionally
* - fixed some of the keybindings commands (e.g. on Windows it's prompt_open_file, on Mac it was prompt_open)
*/
[
/* "Emacs" keybindings which come on mac but not on windows, added "by hand" */
{ "keys": ["ctrl+a"], "command": "move_to", "args": {"to": "bol", "extend": false} },
@philippkeller
philippkeller / bench.rs
Created March 9, 2017 06:08
Benchmarking libc::random vs. XorShiftRng
#![feature(test)]
#![feature(rand)]
extern crate test;
extern crate rand;
use rand::Rng;
extern "C" {
pub fn random() -> i64;