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
#!/bin/bash | |
# | |
# pcap2wav | |
# Original Author: Michael Collins <[email protected]> | |
#Standard disclaimer: batteries not included, your mileage may vary... | |
# Updated by Avi Marcus <[email protected]> | |
# | |
# Accepts arg of pcap file w/only 2 RTP streams | |
# Creates a .<codec> file and a .wav file | |
# For codecs other than PCMA and PCMU the script calls fs_cli and does a little recording to create the wav file(s) |
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 NorthAmerica=require('./NorthAmerica.json'); | |
var fp = require('lodash/fp'); | |
function getRegionForAreaCode(areaCode){ | |
return fp.findKey(function(o) { | |
return o.includes(areaCode); | |
})(NorthAmerica); | |
} |
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
function upsert(table, data, update){ | |
if(!update) update=data; | |
var insert = knex(table).insert(data).toString(); | |
var update = knex(table).update(update).toString().replace(/^update .* set /i, ''); | |
return knex.raw(insert + ' on duplicate key update ' + update); | |
} | |
function replace(table, data){ | |
var insert = knex(table).insert(data).toString().replace(/^INSERT/i, 'REPLACE'); | |
return knex.raw(insert); |
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 _putItem = function (item, shouldCreateNewItem, shouldReturnInformationFromJoinedTable) { | |
return knex(...).update() | |
.then(function(affectedRows) { | |
if (affectedRows == 0 && shouldCreateNewItem) return knex.insert(...); | |
else if (shouldReturnInformationFromJoinedTable) return knex(...). ....leftJoin(..).select().first() | |
else return true; | |
}) | |
} |
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
function checkAndSetAccount(){ | |
var q = riot.route.query(); | |
if (Cookies.get('account')==q.account) return;//already done. | |
if (q.account) { | |
Cookies.set('account',q.account); | |
auth.trigger('switchAccount'); | |
} | |
if (!q.account && Cookies.get('account')!==Cookies.get('accountOriginal')) {//nothing in query string: need to set it | |
//console.log(window.location) | |
var newLocation=window.location.hash; |
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
//using a function-scope `data` variable to save the data | |
function getData(respondentId) { | |
var data={}; | |
return Respondent.findById(respondentId) | |
.then(respondent => { | |
data.respondent = respondent; | |
return Box.findById(respondent.box_id) | |
}) | |
.then(box => { | |
data.box = box |
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 myURL="mydomain.com"; | |
var restifyOptions={} | |
restifyOptions.certificate = fs.readFileSync('PathTo:fullchain.pem'); | |
restifyOptions.key = fs.readFileSync('PathTo:privkey.pem'); | |
var server = restify.createServer(restifyOptions); | |
var nonSecure = restify.createServer({name: 'redirectToSSL'}); | |
nonSecure.get(/.*/,function (req, res, next) { | |
res.redirect(301, 'https://' + myURL + req._url.href, next); |
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
This is free and unencumbered software released into the public domain. | |
Anyone is free to copy, modify, publish, use, compile, sell, or | |
distribute this software, either in source code form or as a compiled | |
binary, for any purpose, commercial or non-commercial, and by any | |
means. | |
In jurisdictions that recognize copyright laws, the author or authors | |
of this software dedicate any and all copyright interest in the | |
software to the public domain. We make this dedication for the benefit |
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
//This allows you to specify a certificate and a key and will create a server that just handles redirects, if you want it. | |
/*Using let's encrypt to create a free certificate: | |
cd /root/ | |
git clone https://github.com/letsencrypt/letsencrypt | |
cd letsencrypt | |
./letsencrypt-auto certonly --webroot -w /my/web/root --email [email protected] -d myDomain.com | |
//add ssl:certificate location of 'fullchain.pem' and ssl:key location of 'privkey.pem' | |
*/ |
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
it('should round up to the next billing interval', function(){ | |
var cases = [//number, expect, increment | |
{ n: 4000, e: 6, i:6 }, | |
{ n: 6001, e: 12, i:6 }, | |
{ n: 17999, e: 18, i:6 }, | |
{ n: 1, e: 6, i:6 }, | |
{ n: 62000, e: 66, i:6 }, | |
{ n: 1, e: 1, i:1 }, | |
{ n: 62000, e: 120, i:60 }, | |
]; |