On Mac OSX
To find the local network (WIFI usually) address ipconfig getifaddr en0
ipconfig getifaddr en0
192.168.0.8
/** | |
Example: timeout with message, just like Q.promise.timeout | |
foo() | |
.timeout(500, 'promise timed out!') | |
.then(function () { | |
console.log('foo has been resolved!'); | |
}) | |
.fail(function (msg) { | |
console.log('failed with value:', msg); |
// __proto__ DOES NOT WORK | |
var foo = Object.create(null); | |
foo.__proto__ = { | |
bar: 'bar' | |
}; | |
foo; // { [__proto__]: { bar: 'bar' } } | |
foo.bar; // undefined | |
// __proto__ works | |
var foo = {}; |
var _ = require('lodash'); | |
var fp = require('functional-pipeline'); | |
var items = [{ | |
toString: function () { | |
return 'foo'; | |
} | |
}, { | |
toString: function () { | |
return 'bar'; |
var calc = new function () { | |
this.add = function add(a, b) { return a + b; }; | |
this.sub = function sub(a, b) { | |
return this.add(a, -b); | |
}; | |
}; | |
console.log(calc.add(2, 3)); // 5 | |
console.log(calc.sub(2, 3)); // -1 | |
var subtract = calc.sub; | |
console.log(subtract(2, 4)); // exception: this.add is undefined |
file_path=bower_components/angular-bindonce/bindonce.js | |
before_commit=$(git rev-parse --verify 14f0b9d) | |
file_blob=$(git hash-object -w "$file_path") | |
echo "before commit $before_commit" | |
echo "file blog $file_blob" | |
git filter-branch \ | |
--index-filter ' |
/* | |
Using ServiceWorker, every request (except from iframes) can be intercepted and the javascript | |
could be changed before returning the result. Here is an example that if "*foo.js" is | |
requested, downloads it, but then returns 'console.log("hi there");' | |
Related: https://github.com/bahmutov/service-turtle/issues/7 | |
*/ | |
var allowJavaScriptFromAnywhere = { | |
'Access-Control-Allow-Origin': '*', | |
'Content-Type': 'text/javascript; charset=utf-8' |
// I am trying to open PouchDB normally, but this fails in Firefox Incognito mode | |
var db = new PouchDB('test'); | |
// InvalidStateError | |
// I see the idb error callback being called if the open request fails | |
exports.idbError = function (callback) { | |
return function (event) { | |
var message = (event.target && event.target.error && | |
event.target.error.name) || event.target; | |
callback(errors.error(errors.IDB_ERROR, message, event.type)); | |
}; |
// NOTE does not work in strict mode | |
function parent(a, b) { | |
console.log('in parent, a', a, 'b', b); | |
var parentArguments = arguments; | |
function child() { | |
console.log('in child, a', a, 'b', b); | |
console.log('is parentArguments === c.args?', parentArguments === c.args); | |
console.log('parentArguments', parentArguments); | |
return a + b; |
QUnit.extend( QUnit, { | |
expectSuccess: function (promise, message) { | |
if (!promise) { | |
QUnit.push(false, 'undefined promise', 'promise object', 'missing a promise'); | |
QUnit.start(); | |
} else { | |
promise.then(function onSuccess(successMessage) { | |
QUnit.push(true, null, null, successMessage); | |
QUnit.start(); | |
}, function onFailure(errorMessage) { |
On Mac OSX
To find the local network (WIFI usually) address ipconfig getifaddr en0
ipconfig getifaddr en0
192.168.0.8