Skip to content

Instantly share code, notes, and snippets.

View stefan-mees's full-sized avatar

Stefan Mees stefan-mees

  • Wooga
  • Germany / Berlin
View GitHub Profile
select
concat(
BIT_AND(1054420290, 255)
, concat('.'
, concat(BIT_AND(floor(BIT_OR(1054420290, 255) / 256), 255)
, concat('.'
, BIT_AND(floor(BIT_OR(1054420290, 65535) / 65536), 255)
, concat('.'
, BIT_AND(floor(BIT_OR(1054420290, 16777215) / 16777216), 255)
)))))
(for i in `find ./ -type f`; do export version=`head -c 100 $i | strings | awk '/^4\.[0-9]+/'`; echo "$i:$version"; done;) > /tmp/cache_versions.txt
@stefan-mees
stefan-mees / gist:8042413
Last active January 1, 2016 04:42
riak ops cheatsheet
%% get config at runtime
rpc:call(node(), application, get_all_env, [bitcask]).
%% set config at runtime for a node
rpc:call(node(), application, set_env, [bitcask, merge_window, always]).
%% get config for all nodes in a cluster
rpc:multicall(application, get_all_env, [bitcask]).
%% set config for all nodes in a cluster
rpc:multicall(application, set_env, [bitcask, merge_window, always]).
@stefan-mees
stefan-mees / gist:122d88308bbe5e9e43ab
Last active December 25, 2015 19:19
debug stuck ruby
require 'socket'
require 'timeout'
while true
Dir.glob('/home/ubuntu/applications/xx/shared/sockets/*.sock').each do |socket|
instance = $1 if socket =~ /([^\/]+)\.sock$/
s = nil
begin
Timeout.timeout(0.5) do
@stefan-mees
stefan-mees / gist:5803315
Last active December 18, 2015 15:19
aws s3 add expire / cache header to existing objects
AWS.config({
:access_key_id => 'xxxxx',
:secret_access_key => 'xxxxx',
})
bucket_name = 'xxxxx'
s3 = AWS::S3.new()
bucket = s3.buckets[bucket_name]
@stefan-mees
stefan-mees / steps to reproduce memory leaks with falcon patch
Last active December 14, 2015 05:49
Track down memory leak with falcon patch
p `cat /proc/#{Process.pid}/status | grep VmRSS`
"VmRSS:\t 30256 kB\n"
100_000.times {String.public_instance_methods}
GC.start
p `cat /proc/#{Process.pid}/status | grep VmRSS`
"VmRSS:\t 625820 kB\n"
ruby redis_keys.rb zipmap
redis-cli info | grep used_memory_human
used_memory_human:18.54M
ruby redis_keys.rb hash
redis-cli info | grep used_memory_human
used_memory_human:69.92M
ruby redis_keys.rb plain
redis-cli info | grep used_memory_human