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
var inString = ~string.indexOf('search') ? 'yep!' : 'nope'; |
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
var crypto = require('crypto'); | |
var createHash = function(algo, data, digest){ | |
if(!digest) | |
digest = 'hex'; | |
return crypto.createHash(algo).update(data).digest(digest); | |
} |
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
cd $(git rev-parse --show-toplevel) |
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 |
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
# 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
-- | |
-- 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
/** | |
* 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
/* | |
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" | |
} |