Paste this to your browser url bar:
data:text/html,
function add(){var a,v,n,f;a=[].slice.call(arguments),v=a[0]||0;if(a.length){n=a.slice(1).reduce(function(s,x){return s+x},v),f=add.bind(0,n);f.valueOf=function(){return n};return f}return v} | |
function test(a, b) { | |
if (a == b) { | |
console.log('OK'); | |
} else { | |
console.log(a + ' != ' + b); | |
} | |
} |
<!DOCTYPE html> | |
<html> | |
<head> | |
<title></title> | |
</head> | |
<body> | |
<ul id="list"> | |
<li>nope</li> | |
</ul> | |
<input type="button" id="btn" value="change"> |
var l10n = { | |
translate: function(el) { | |
console.log("l10n.translate() called for ", el); | |
} | |
}; | |
function makeL10n(ViewClass) { | |
var oldRender = ViewClass.prototype.render; | |
ViewClass.prototype.render = function renderL10n() { | |
oldRender.apply(this, arguments); |
var casper = require("casper").create(); | |
var arr1 = [], arr2 = [], arr3 = []; | |
casper.start("http://foo.bar/", function() { | |
arr1.push("plop1"); | |
}); | |
casper.thenOpen("http://bar.foo/", function() { | |
arr2.push("plop2"); | |
}); |
While trying to explain Flux to a friend using words, I realized that a diagram's worth a thousand of them, and went with this.
+---------------------+
| |
| Dispatcher |
+-->| +---------------+
| +----------|----------+ |
var client = require("rest/client/jsonp"); | |
client({ | |
path: 'http://ajax.googleapis.com/ajax/services/search/web?v=1.0', | |
params: { q: 'javascript' } | |
}).then(function(response) { | |
console.log("success", response); | |
}).catch(function(response) { | |
console.error("errored", response); | |
}); |
var client = require("rest").wrap(require("rest/interceptor/jsonp")); | |
client({path: 'http://ajax.googleapis.com/ajax/services/search/web?v=1.0', params: { q: 'javascript' } }).then(function (response) { | |
console.log(response); | |
}); |
var Dexie = require("dexie"); | |
var db = new Dexie("articles2"); | |
db.version(1).stores({articles: "id++,title,archived"}); | |
db.open(); | |
db.on("error", function(err) { | |
console.error(err); | |
}); | |
db.articles.add({title: "plop", archived: "true"}).catch(console.error.bind(console)).then(function(id) { | |
console.log(id); |