This file contains hidden or 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
/** | |
* npm install --save lodash redis node-redis-scripty | |
* | |
* Usage: | |
* let hmsetex = require('./hmsetex.js') | |
* let key = 'your-key'; | |
* let fields = { some_field: 'test', another_field: 'foo' }; | |
* hmsetex(key, fields).then(handleResult).catch(handleError); | |
*/ | |
const _ = require('lodash'); |
This file contains hidden or 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
local key = KEYS[1] | |
local args = ARGV | |
local call = redis.call | |
if call("EXISTS", key) == 0 then | |
return nil | |
end | |
return call("HMSET", key, unpack(args)) |
This file contains hidden or 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
// usage: promisify(function([args..., cb]) { /* do stuff with args then cb */ })() | |
exports.promisify = function(fn) { | |
return function(...args) { | |
return new Promise((resolve, reject) => { | |
fn(...args, (err, result) => { | |
if (err) return reject(err); | |
resolve(result); | |
}); | |
}); | |
}; |
This file contains hidden or 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
/* | |
Migrate documents from one elasticsearch endpoint to another. | |
To squeeze out extra performance, disable index refresh and replicas on the target cluster: | |
curl -XPUT 'http://elasticsearch:9200/_settings' -d '{ | |
"index" : { | |
"refresh_interval" : "-1", | |
"number_of_replicas": "0" | |
} |
This file contains hidden or 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
/** | |
* A Connection handler for Amazon ES. | |
* | |
* Uses the aws-sdk to make signed requests to an Amazon ES endpoint. | |
* Define the Amazon ES config and the connection handler | |
* in the client configuration: | |
* | |
* var es = require('elasticsearch').Client({ | |
* hosts: 'https://amazon-es-host.us-east-1.es.amazonaws.com', | |
* connectionClass: require('http-aws-es'), |
This file contains hidden or 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
/** | |
* A Connection handler for Amazon ES. | |
* | |
* Uses the aws-sdk to make signed requests to an Amazon ES endpoint. | |
* Define the Amazon ES config and the connection handler | |
* in the client configuration: | |
* | |
* var es = require('elasticsearch').Client({ | |
* hosts: 'https://amazon-es-host.us-east-1.es.amazonaws.com', | |
* connectionClass: require('http-aws-es'), |
This file contains hidden or 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
-- | |
-- Set a lock | |
-- | |
-- KEYS[1] - key | |
-- KEYS[2] - ttl in ms | |
-- KEYS[3] - lock content | |
local key = KEYS[1] | |
local ttl = KEYS[2] | |
local content = KEYS[3] |
This file contains hidden or 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
# Sweep a git submodule out of the working copy | |
remove_submodule() { | |
SMD_PATH=$1 | |
if [ ! -d $SMD_PATH ]; then | |
echo "$SMD_PATH does not exist" | |
return 1 | |
fi | |
git config -f .git/config --remove-section submodule.$SMD_PATH | |
git config -f .gitmodules --remove-section submodule.$SMD_PATH |
This file contains hidden or 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
# View list of connections and their states | |
netstat -tan | grep ':80 ' | awk '{print $6}' | sort | uniq -c | |
# List all connections and timers | |
ss -rota | less |
This file contains hidden or 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
local keys | |
keys = redis.call('keys', KEYS[1]) | |
local ret=0 | |
local type | |
for k,v in pairs(keys) do | |
redis.call('del', v) | |
ret = ret+1 | |
end | |
return ret |