Skip to content

Instantly share code, notes, and snippets.

View markuman's full-sized avatar
🐧
Linux Only - fail fast, move on

Markus Bergholz markuman

🐧
Linux Only - fail fast, move on
  • Lekker Energie GmbH
  • Berlin
View GitHub Profile
#!/bin/bash
USERNAME="markuman"
URL="https://api.github.com/users/${USERNAME}/repos";
# ♥ pipes ♥
curl -s "$URL" | grep '"url":' | grep -v '"https://api.github.com/users/markuman",'| sed s/,//g| sed s/\"//g| awk '{ print $2 }' | sed s/api.//g | sed s,/repos,,g > /tmp/list
while read p; do
git clone $p
NAME=$(basename "$p")
@markuman
markuman / gist:121299a27c2099bf3f99
Created July 23, 2015 17:02
quick&dirty influxdb for GNU Octave and Matlab
function ret = influxquery(QUERY, URL = "http://localhost:8086/query")
% ugly part
command=['curl --silent -G ' URL ' --data-urlencode "db=mydb" --data-urlencode "q=' QUERY '"'];
[output, ret] = system(command);
% requires jsonlab http://iso2mesh.sf.net/cgi-bin/index.cgi?jsonlab
ret = loadjson(ret);
endfunction
@markuman
markuman / gist:6bcaca0a4d668220ff2b
Last active August 29, 2015 14:26 — forked from mikeyk/gist:1329319
Testing storage of millions of keys in Redis
#! /usr/bin/env python
import redis
import random
import pylibmc
import sys
r = redis.Redis(host = 'localhost', port = 6389)
mc = pylibmc.Client(['localhost:11222'])
@markuman
markuman / unixtime.lua
Created August 6, 2015 16:49
date string to unixtime in redis with lua
local function YearInSec(y)
-- returns seconds of a year
if ((y % 400) == 0) or (((y % 4) == 0) and ((y % 100) ~= 0)) then
return 31622400 -- 366 * 24 * 60 * 60
else
return 31536000 -- 365 * 24 * 60 * 60
end
end
@markuman
markuman / iso2utf8.sh
Created September 15, 2015 06:36
converts all ISO-8859 files to UTF-8
#!/bin/bash
function convert(){
ENCODING=$(file "$1" |awk '{print$2}')
if [[ "$ENCODING" = "ISO-8859" ]]; then
iconv -f iso-8859-15 -t utf-8 "$1" > tmp.file
mv tmp.file "$1"
rm tmp.file
fi
@markuman
markuman / redis+lua+random.lua
Created October 1, 2015 19:27
Nine Nine Nine 1/4
127.0.0.1:6379> eval 'return string.format("%f", math.random())' 0
"0.170828"
127.0.0.1:6379> eval 'return string.format("%f", math.random())' 0
"0.170828"
@markuman
markuman / redis+lua+time+random
Created October 1, 2015 19:31
Nine Nine Nine 2/4
127.0.0.1:6379> eval 'local seed = redis.call("TIME") return seed[1] .. "." .. seed[2]' 0
"1443727915.340182"
127.0.0.1:6379> eval 'local seed = redis.call("TIME") math.randomseed(tonumber(seed[1] .. "." .. seed[2])) return string.format("%f", math.random())' 0
"0.743658"
127.0.0.1:6379> eval 'local seed = redis.call("TIME") math.randomseed(tonumber(seed[1] .. "." .. seed[2])) return string.format("%f", math.random())' 0
"0.580878"
127.0.0.1:6379> eval 'local seed = redis.call("TIME") math.randomseed(tonumber(seed[1] .. "." .. seed[2])) return string.format("%f", math.random())' 0
"0.451681"
@markuman
markuman / redis+lua+time+set
Created October 1, 2015 19:33
Nine Nine Nine 3/4
127.0.0.1:6379> eval 'local seed = redis.call("TIME") math.randomseet(tonumber(seed[1] .. "." .. seed[2])) return redis.call("SET", "mykey", string.format("%f", math.random()))' 0
(error) ERR Error running script (call to f_a26eed7f7bc45da4442c1a93ab5d56b42e72aff3): @user_script:1: @user_script: 1: Write commands not allowed after non deterministic commands
@markuman
markuman / redis+lua+info+set.lua
Created October 1, 2015 19:35
Nine Nine Nine 4/4
127.0.0.1:6379> eval 'local seed = redis.call("INFO") math.randomseed(tonumber(string.match(seed, "uptime_in_seconds:(%d+)")) + tonumber(string.match(seed, "total_commands_processed:(%d+)"))) return string.format("%f", math.random())' 0
"0.219070"
127.0.0.1:6379> eval 'local seed = redis.call("INFO") math.randomseed(tonumber(string.match(seed, "uptime_in_seconds:(%d+)")) + tonumber(string.match(seed, "total_commands_processed:(%d+)"))) return string.format("%f", math.random())' 0
"0.074487"
127.0.0.1:6379> eval 'local seed = redis.call("INFO") math.randomseed(tonumber(string.match(seed, "uptime_in_seconds:(%d+)")) + tonumber(string.match(seed, "total_commands_processed:(%d+)"))) return redis.call("SET", "mykey", string.format("%f", math.random()))' 0
OK
-- local seed = redis.call("INFO")
-- math.randomseed(tonumber(
-- string.match(seed, "uptime_in_seconds:(%d+)")) +
@markuman
markuman / invisibleplot.m
Created October 2, 2015 08:40
multiple silent/invisible plots
% multiple silent/invisible plots
a = figure;
set(a,'visible','off');
x=0:0.1:2*pi;
for i = 2:4;
plot(x,sin(i*x));
print("-djpeg", strcat(sprintf("%03d", i-1), ".jpg"));
set(a,'visible','off');