Skip to content

Instantly share code, notes, and snippets.

@J-O-N
J-O-N / couch_dump.sh
Created July 20, 2012 23:33
Tools to dump/restore a couch database - mysql style!
#!/bin/bash
# An awesome tool to dump a couch database - mysqldump style!
# 2600hz - The Future of Cloud Telecom
COUCH_URL=$1
DB=$2
DOC_IDS=`curl -s -X "GET" "$COUCH_URL/$DB/_all_docs" | sed -n -e 's/^.*"id":"\([^"]\+\)".*$/\1/p'`
DOC_COUNT=`echo "$DOC_IDS" | wc -l`
@J-O-N
J-O-N / copy_doc.sh
Created June 27, 2012 21:32
A tool for copying couch documents between databases/clusters
#!/bin/bash
# A tool to copy couch documents between databases/clusters
# 2600hz - The Future of Cloud Telecom
DB1=$1
DB2=$2
shift 2
DOC_IDS=$@
TEMP_FILE=/tmp/copy_doc.tmp
@J-O-N
J-O-N / sipify.sh
Created June 22, 2012 22:22
A tool for viewing FreeSWITCH SIP logs
#!/bin/bash
# A useful tool for viewing FreeSWITCH SIP logs
# 2600hz - The Future of Cloud Telecom
awk 'BEGIN{I=0};/^(send|recv).*$/{SIPPACKET=1}; SIPPACKET==1{PACKET[I++]=$0;}; SIPPACKET==1&&/^\ +(Call-ID:).*$/{CALLID=$2}; SIPPACKET==0{print $0}; /^\ +-+$/{PRINT=(SIPPACKET==1?(PRINT==1?0:1):0);SIPPACKET=(PRINT==1?1:0);if(SIPPACKET==0){for(i=0;i<I;i++){print CALLID, PACKET[i]; delete PACKET[i];}I=0;CALLID="";}};' "$@" <&0
@J-O-N
J-O-N / jcouch.js
Created June 14, 2012 21:17
A helper object to $.couch
var jcouch = {
new: function(db_name, options) {
return {
config: $.extend(true, {
async: false
},
typeof options === 'object' ? options : {}
),
db: $.couch.db(decodeURIComponent(db_name)),
@J-O-N
J-O-N / c2c.js
Created March 2, 2012 02:48
C2C
var c2c = {
realm: 'somerealm.sip.2600hz.com',
ext_regex: /^79\d\d$/,
init: function() {
winkstart.registerResources('voip', {
'c2c.create': {
url: '{api_url}/accounts/{account_id}/clicktocall',
dataType: 'application/json',
verb: 'PUT'
@J-O-N
J-O-N / make_parent.js
Created March 2, 2012 02:47
make parent
var make_parent = {
accounts_db: $.couch.db('accounts'),
parent_id: '9a07ed4820fd17b54efbf53dcaece757',
get_accounts: function(callback) {
var THIS = this;
THIS.accounts_db.view('accounts/listing_by_realm', {
success: function(data) {
callback(data.rows);