Skip to content

Instantly share code, notes, and snippets.

View mriehl's full-sized avatar
💭
i bims

Maximilien Riehl mriehl

💭
i bims
View GitHub Profile
### Keybase proof
I hereby claim:
* I am mriehl on github. * I am mriehl (https://keybase.io/mriehl) on keybase. * I have a public key ASDEQGqmaGy03RdRm8G6OjKrJ-Xh33umCHnePSvs1mwuTQo
@mriehl
mriehl / dotcopter.yml
Last active August 16, 2017 14:20
push branch and merge it (almost) automatically when CI is green using github API
---
files:
"/usr/local/bin/fbpush":
src: "fbpush.sh"
type: LINK

Latency numbers every programmer should know

L1 cache reference ......................... 0.5 ns
Branch mispredict ............................ 5 ns
L2 cache reference ........................... 7 ns
Mutex lock/unlock ........................... 25 ns
Main memory reference ...................... 100 ns             
Compress 1K bytes with Zippy ............. 3,000 ns  =   3 µs
Send 2K bytes over 1 Gbps network ....... 20,000 ns  =  20 µs
SSD random read ........................ 150,000 ns  = 150 µs

Read 1 MB sequentially from memory ..... 250,000 ns = 250 µs

@mriehl
mriehl / client.py
Last active August 29, 2015 14:06
Talk to localhost:8080/wamp with the WAMP protocol in batched json
###############################################################################
##
## Copyright (C) 2014 Tavendo GmbH
##
## Licensed under the Apache License, Version 2.0 (the "License");
## you may not use this file except in compliance with the License.
## You may obtain a copy of the License at
##
## http://www.apache.org/licenses/LICENSE-2.0
##
@mriehl
mriehl / gist:5626039
Created May 22, 2013 08:19
randomcowsay.sh Like cowsay (wrapper) but randomizes the animal. Randomization code is from http://rosettacode.org/wiki/Pick_random_element#Bash
#!/bin/bash
rand() {
printf $(( $1 * RANDOM / 32767 ))
}
rand_element () {
local -a th=("$@")
unset th[0]
printf $'%s\n' "${th[$(($(rand "${#th[*]}")+1))]}"
}