Skip to content

Instantly share code, notes, and snippets.

View fnchooft's full-sized avatar

Fabian N.C. van 't Hooft fnchooft

View GitHub Profile
@fnchooft
fnchooft / gist:f95dd13c76b9c8ed38abb29159cf1cd5
Created February 2, 2017 11:21
Bash function for history lookups
# for setting history length see HISTSIZE and HISTFILESIZE in bash(1)
HISTSIZE=100000
HISTFILESIZE=200000
function h() {
if [ -z "$1" ]
then
history
else
history | grep "$@"
alias l='ls -CF'
alias o='gvfs-open'
alias v='ls -lh'
alias vv="du --max-depth=1 -k | sort -nr | cut -f2 | xargs -d '\n' du -sh"
alias ducks='du -ck | sort -nr | head'
alias nocomment='grep -Ev '\''^(#|$)'\'''
alias.lol=log --oneline --decorate --all --graph --date-orde
alias.lo=log --oneline --decorate --graph --date-order
merge.tool=meld
diff.tool=meld
diff.guitool=meld
#GIT
PS1='[${debian_chroot:+($debian_chroot)}\[\033[01;32m\]\u@\h\[\033[00m\] \[\033[01;34m\]\W\[\033[00m\]$(__git_ps1)]\$ '
export GIT_PS1_SHOWDIRTYSTATE=1
export GIT_PS1_SHOWUNTRACKEDFILES=1
export GIT_PS1_SHOWUPSTREAM=1
@fnchooft
fnchooft / Redis_Stats.md
Created February 1, 2017 00:30 — forked from thomasdarimont/Redis_Stats.md
Example for computing various running statistics with Lua in Redis backed by a hash

Running statistics with Redis and Lua

This is an example for computing running statistics with Lua backed by a hash in Redis. We support counting, average (with and without exponential smoothing), stddev, variance, min, max, sum of observed values. An example for approximating a running median can be found here: https://gist.github.com/thomasdarimont/fff68191d45a001b2d84

Data structure

We use a hash for storing various statistic value under the key "stats_value" in redis. Note: If you need a specific alpha value for smoothing the average, then set the desired alpha -> e.g. alpha 0.7. If alpha is 0.0 then no smoothing is applied.

@fnchooft
fnchooft / getmsgpackasjson.lua
Created February 1, 2017 00:24 — forked from fritzy/getmsgpackasjson.lua
Redis scripts to set JSON in, store as MSGPack, and get JSON out.
--EVAL 'this script' 1 some-key
local key = KEYS[1];
local value = redis.call('GET', key);
local jvalue = cjson.encode(cmsgpack.unpack(value));
return jvalue;