Skip to content

Instantly share code, notes, and snippets.

module CouchDB
def sync
changes = aof_get.uniq
if changes.length > 0
couch_create_database!
sync! changes
aof_del!
end
@lastcanal
lastcanal / LocalStorage.coffee
Created January 13, 2011 15:39
LocalStorage key patterns
class Crypt
constructor: (@key) ->
GibberishAES.size(128);
decrypt: (str) ->
return str unless str? and @key?
GibberishAES.dec(str, @key)
encrypt: (str) ->
#!/bin/zsh
setopt noglob
alias redis='redis-cli'
key=$1
function _load_fixtures(){
redis hset $key action bounce
for process (http node dmgr) redis sadd ${key}:processes $process
#!/bin/zsh
alias redis='redis-cli --raw'
# pop ID from queue
id=$(redis rpop "jobs:queue")
# check if we have an ID
if (( $#id > 0 )); then
echo "running workflow $(redis hget "job:${id}:data" process)" && sleep 2
setopt noglob
for env (IST UAT NFT PROD) do
keys=$(redis -n 1 --raw keys "servers:*:${env}*")
for hostname ($(redis sunion $keys)) do
bladelogic "acl_${hostname}" Server addPermission ${env}role $hostname ${env}user system
done
done
@lastcanal
lastcanal / 1.http.aof
Created November 24, 2011 21:09
status
SADD status:hostnames ab.local
HSET status:hostname:ab.local http running
ZADD status:hostname:ab.local:weight 5 http
package IO::Socket::StatusPublisher;
use strict;
use warnings;
use IO::Socket;
sub help {
die "Usage: $0 process status [weight] [hostname]\n"
. "\tprocess: name of process (http,dmgr,etc)\n"
. "\tstatus: status of process (start[ed],run[ning],stop[ped],term[inated])\n"
. "\tweight: (optional) number for size of the pie slice. defaults to 0\n"
package IO::Socket::StatusPublisher;
use strict;
use warnings;
use IO::Socket;
sub help {
die "Usage: $0 process status [weight] [hostname]\n"
. "\tprocess: name of process (http,dmgr,etc)\n"
. "\tstatus: status of process (start[ed],run[ning],stop[ped],term[inated])\n"
. "\tweight: (optional) number for size of the pie slice. defaults to 0\n"
all_servers =
UAT:
http: 'UAT1|UAT2'
node: 'UAT1|UAT2|UAT3'
dmgr: 'UAT1'
NFT:
http: 'NFT1|NFT2'
node: 'NFT1|NFT2'
dmgr: 'NFT1'