This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
-- @desc: Publish a message to all SET member channels | |
-- @usage: redis-cli EVAL "$(cat SPUBLISH.lua)" 1 <setKey> <message> | |
-- @return: number of SET member channels | |
local function SPUBLISH(key, msg) | |
local members = redis.call("SMEMBERS", key) | |
for _,member in ipairs(members) do | |
redis.call("PUBLISH", member, msg) | |
end |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
-- @desc: Clamp a value between a min & max | |
-- @usage: redis-cli EVAL "$(cat SETCLAMP.lua)" 1 <key> <min> <max> | |
-- @return: clamped value | |
local function SETCLAMP(key, min, max) | |
local valStr = redis.call("GET", key) | |
if not valStr then return end | |
local val = tonumber(valStr) | |
if val > max then |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
-- @desc: Sum the provided key values | |
-- @usage: redis-cli EVAL "$(cat MGETSUM.lua)" N <key1> <key2> ... <keyN> | |
-- @return: sum | |
local function MGETSUM(keys) | |
local sum = 0 | |
for _,key in ipairs(keys) do | |
local val = redis.call('GET', key) or 0 | |
sum = sum + tonumber(val) |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
-- @desc: Get size of multiple ZSETs | |
-- @usage: redis-cli EVAL "$(cat MZCARD.lua)" N <zset1> <zset2> ... <zsetN> | |
-- @return: list of sizes | |
local function MZCARD(keys) | |
local sizes = {} | |
for _,key in ipairs(keys) do | |
table.insert(sizes, redis.call("ZCARD", key)) | |
end | |
return sizes |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
-- @desc: Determine which keys exist from a list | |
-- @usage: redis-cli EVAL "$(cat MEXISTS.lua)" N <key1> <key2> ... <keyN> | |
-- @return: list of existence in binary representation (ex/ {0, 1, 1, 0}) | |
local function MEXISTS(keys) | |
local exists = {} | |
for _,key in ipairs(keys) do | |
table.insert(exists, redis.call("EXISTS", key)) | |
end | |
return exists |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
-- @desc: Copy a key without knowing its type | |
-- @usage: redis-cli EVAL "$(cat COPY.lua)" 2 <key> <destKey> | |
local function COPY(key, dest) | |
local keyType = redis.call("TYPE", key) | |
if keyType == "set" then redis.call("SUNIONSTORE", dest, key) | |
elseif keyType == "zset" then redis.call("ZUNIONSTORE", dest, 1, key) | |
elseif keyType == "list" then redis.call("SORT", key, "BY", "NOSORT", "STORE", dest) | |
elseif keyType == "string" then redis.call("SET", dest, redis.call("GET", key)) |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
"use strict"; | |
var util = require('util'), | |
Punctual = require('punctual'); | |
/** | |
* Define a simple TaskRunner for logging to console | |
*/ | |
function ConsolePrinter(){ |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
#!/bin/bash | |
# Get filename from cmd-line arg | |
filename=$1 | |
# Fetch all remote branches locally and setup tracking | |
for branch in `git branch -a | grep remotes | grep -v HEAD | grep -v master`; do | |
git branch --track ${branch##*/} $branch | |
done |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
#!/bin/bash | |
for branch in `git branch -a | grep remotes | grep -v HEAD | grep -v master`; do | |
git branch --track ${branch##*/} $branch | |
done |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
#!/bin/bash | |
#set -x | |
# Shows you the largest objects in your repo's pack file. | |
# Written for osx. | |
# | |
# @see http://stubbisms.wordpress.com/2009/07/10/git-script-to-show-largest-pack-objects-and-trim-your-waist-line/ | |
# @author Antony Stubbs | |
# set the internal field spereator to line break, so that we can iterate easily over the verify-pack output |