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 parseQueryString = function(url) { | |
var aParams = {}; | |
if (url.match(/\?(.+)/i)) { | |
var queryStr = url.replace(/^(.*)\?([^\#]+)(\#(.*))?/g, '$2'); | |
if (queryStr.length > 0) { | |
var i, I, pairVar, aQueryStr = queryStr.split(/[;&]/); | |
I = aQueryStr.length; | |
for (i = 0; i < I; ++i) { | |
pairVar = aQueryStr[i].split('='); | |
aParams[decodeURIComponent(pairVar[0])] = (typeof(pairVar[1]) !== 'undefined' && pairVar[1]) ? decodeURIComponent(pairVar[1]) : ''; |
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
<!DOCTYPE html> | |
<html> | |
<head> | |
<meta charset="utf-8"> | |
<title>JSONTree example</title> | |
<link type="text/css" rel="stylesheet" href="jsontree.css"></link> | |
<script type="text/javascript" src="jsontree.js"></script> | |
</head> | |
<body> |
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
module.exports = { | |
"email": "<your email here>", | |
"password": "<your pass here>" | |
}; |
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
// process items in parallel thingy | |
var parallelCbs = function(items, itemFn, cb) { | |
var left = items.length; | |
var res = new Array(left); | |
var cb2 = function(err, res) { // to enforce the main cb is not called more than once | |
if (this.called) { return; } | |
this.called = true; | |
this.cb(err, res); | |
}.bind({cb:cb, called:false}); |
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 os = require('os'); | |
var getMyIPs = function() { | |
var ips = {}; | |
var ifaces = os.networkInterfaces(); | |
var onDetails = function(details) { | |
if (details.family === 'IPv4') { | |
ips[ dev ] = details.address; | |
} |
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 removeCycles = function(o) { | |
var seen = []; | |
var s = JSON.stringify(o, function(k, v) { | |
if (v !== null && typeof v === 'object') { | |
if (seen.indexOf(v) !== -1) { | |
//return; | |
v = '[removed]'; | |
} | |
else { |
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
'use strict'; | |
/*jshint esnext:true */ | |
let log = function(msg) { console.log(msg); }; | |
let now = function() { return Date.now(); }; | |
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 ctx = this; // this can be skipped if you don't care about the context | |
var argsL = arguments.length; | |
var args = new Array(argsL); // optimizable arguments-to-array | |
for(var i = 0; i < argsL; ++i) { | |
args[i] = arguments[i]; | |
} |
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 fetchFnComment = function(f) { | |
return f.toString() | |
.replace(/^[^\/]+\/\*!?/, '') | |
.replace(/\*\/[^\/]+$/, ''); | |
}; | |
var applyTemplate = function(targetEl, tpl, model) { | |
tpl = fetchFnComment(tpl); | |
for (var k in model) { | |
tpl = tpl.replace( new RegExp('({{'+k+'}})', 'g'), model[k] ); |