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/sh | |
# Utility for switching between Unix screens. Gives you a warning if you | |
# try to attach to a screen while already attached. | |
# Note that when you create a screen, you can give it a name with the -S option. | |
# Usage: | |
# scr -- Get a list of existing screens. | |
# scr foo -- Attach to a screen with name matching "foo" e.g. 23560.myfooscreen. | |
if [ "$#" -eq 0 ] ; then | |
# Get a list of existing screens. |
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 | |
# Move all keys in Redis db $1 to db $2 | |
if [ $# != 2 ] ; then | |
echo "Usage: $0 <db1> <db2>" | |
exit 1 | |
fi | |
from=$1 | |
to=$2 | |
testarg () { | |
regex='^(0|[1-9][0-9]*)$' |
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
// This allows us to assert that an object has the specified key. | |
// Alternatively we could say expect(obj.key).toExist() | |
// but the problem is that if the test fails, we only see: "Expected undefined to exist" | |
// and we don't know which property is missing. | |
expect.extend({ | |
toHaveProperty(prop){ | |
expect.assert(prop in this.actual, "Expected object to have property %s", prop) | |
}, | |
}); |
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/sh | |
# I had a bunch of credentials files in a directory, and wanted to be able to | |
# cycle quickly between them so that I could log into a service with different | |
# identities. This script does the job by creating a symlink: | |
# credentials => creds.foo | |
# Every time you call it, it sets the symlink to the next file in the list. | |
# It's probably way overkill, but it was an interesting learning exercise writing it! | |
# This may need tweaking to work on your version of Linux. | |
setlink() { |
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
var path = []; | |
function searchObj(obj,str) { | |
try { | |
if (typeof obj === "string") { | |
if (obj.toLowerCase().indexOf(str.toLowerCase()) >= 0) { | |
console.log(path.join("/") + " : " + obj); | |
} | |
} else if (obj && typeof obj === "object" && obj.constructor.name === 'Object') { | |
// Note: we want to avoid HTMLElements, circular structures etc. hence check constructor name | |
for (var k in obj) { |