Skip to content

Instantly share code, notes, and snippets.

@mrkvm
mrkvm / .tmux.conf
Created October 21, 2012 05:11
Current tmux.conf. Much of it borrowed from Pragmatic's tmux book.
# Make tmux use C-a instead of C-b (just like screen!)
unbind C-b
set -g prefix C-a
bind C-a send-prefix
# Reload config file
bind r source-file ~/.tmux.conf \; display "Config Reloaded"
# Reset the escape time
set -sg escape-time 1
@mrkvm
mrkvm / redis_manifesto.txt
Created October 21, 2012 17:06
Redis Manifesto
http://oldblog.antirez.com/post/redis-manifesto
Use Redis SETBIT / GETBIT for stats
SETBIT key offset value
etc.
Redis containers are best for indexing.
Don't bother putting a password on Redis. You should have secured it another way.
In Redis 2.6, use Lua scripting in place of WATCH/MULTI/EXEC, which can be considered
more or less deprecated.
ZSETs (sorted sets) are the most useful container in Redis.
@mrkvm
mrkvm / redis_examples.txt
Created October 21, 2012 19:00
A very, very simple Redis PUB/SUB example
# Redis PUB/SUB example:
# client 1:
redis 127.0.0.1:6379> subscribe beartalk
Reading messages... (press Ctrl-C to quit)
1) "subscribe"
2) "beartalk"
3) (integer) 1
# ...wait around for message...
-- iterate over Redis hash in Lua.
local results = redis.call("HGETALL", KEYS[1]);
if results ~= 0 then
for key, value in ipairs(results) do
-- do something here
end
end
-- Set a key containing JSON in Redis
local key = KEYS[1];
local name = ARGV[1];
local value = ARGV[2];
local data = redis.call('GET', key);
local json;
if not data then
json = {};