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 | |
# | |
# lets you run xcode from any subdirectory of your project | |
# | |
function findproj { | |
if [ "/" != "$1" ]; then | |
p=$(basename $1/*.xcodeproj); | |
if [ "*.xcodeproj" = "$p" ]; then | |
up=$(dirname $1); | |
if [ "/" != "$up" ]; 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
function (doc) { | |
// DOESN'T WORK: | |
var version = /(\d+)\.?(\d+)?\.?(\d+)?/.exec("1.3"); | |
emit(version); | |
} |
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 | |
URL="http://127.0.0.1:5984" | |
DBNAME_A="deletion_conflicts_test_a" | |
DBNAME_B="deletion_conflicts_test_b" | |
echo "setup" | |
curl -H 'Content-Type:application/json' -X DELETE "$URL/$DBNAME_A" | |
curl -H 'Content-Type:application/json' -X DELETE "$URL/$DBNAME_B" | |
curl -H 'Content-Type:application/json' -X PUT "$URL/$DBNAME_A" |
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 | |
DB_URL=http://localhost:5984 | |
DB_READS_300=$(curl -sg $DB_URL'/_stats/couchdb/database_reads?range=300' \ | |
| python -m 'json.tool' \ | |
| grep current \ | |
| sed -e 's/[^0-9\.]//g' \ | |
|| echo 0) | |
DB_READS_SEC=$(echo "scale=4; $DB_READS_300/300" | bc) |
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 | |
(cat | awk '{ | |
if ($1 ~ /^[0-9]/) { | |
cmd = "sipcalc " $1; | |
address = ""; mask = ""; bits = ""; | |
while (cmd | getline > 0) { | |
if ($1 == "Network" && $2 == "address") | |
address = $4; | |
else if ($1 == "Network" && $2 == "mask" && $3 == "-") | |
mask = $4; |
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
<?php | |
function main() { | |
$limit = 100; | |
$offset = 0; | |
$iter = new NextIteratorCallbackIterator(function() use ($orm, $limit, &$offset) { | |
printf("selecting next bunch at offset %d\n", $offset); | |
$recs = $orm->select($filter, $sorting, $limit , $offset); |
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 -e | |
usage() { | |
cat <<USAGE | |
usage: $(basename $0) REPL_JSON COUCH_URL [ --cancel | --advance SEQ ] [ --cycle [SLEEP] ] | |
USAGE | |
} | |
usageHelp() { | |
usage; |
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 -e | |
usage() { | |
echo "Usage: $(basename $0) [ -i|--internal ] [ -s|--skip-cached ] [ --name NAME | --prefix PREFIX ] [-- options]" | |
echo " -i | --internal use internal IPs instead of external" | |
echo " -e | --external use external IPs instead of internal (default)" | |
echo " -s | --skip-cached skip the cached result of ec2-describe-instances, it gets cached for max 1 hour" | |
echo " --name NAME filter the output by instance NAME" | |
echo " --prefix PREFIX filter the output by instance name PREFIX" |
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 | |
# | |
# NOTE: there is now a better way using the new IP-Ranges endpoint: https://ip-ranges.amazonaws.com/ip-ranges.json | |
# see the offical blog post: https://aws.amazon.com/blogs/aws/aws-ip-ranges-json/ | |
# | |
(wget -q -O - 'https://forums.aws.amazon.com/forum.jspa?forumID=30&state=hashArgs' \ | |
| grep "Amazon EC2 Public IP Ranges" \ | |
| sed -e 's!.*href="\(.*\)".*!\1!' \ | |
| xargs -I% wget -q -O - "https://forums.aws.amazon.com/%&state=hashArgs" \ | |
| sed -E 's/<[^>]+>//g' \ |
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
function (head, req) { | |
var CACHED_COUNT=0; | |
var CACHED_REV=1; | |
var CURRENT_COUNT=2; | |
var row; | |
var lastRow = null; | |
function currAdd(curr, row) { | |
var k = row.key[0]; | |
var t = row.key[1]; | |
curr['key'] = k; |