View coercing.js
var n = Number(1); | |
var m = n; | |
n = null; | |
console.log(m); // 1 | |
var o = new Number(1); | |
var p = o; | |
o = null; | |
console.log(p); // {} |
View profile-proxy.js
function profile (o) { | |
for (var key in o) { | |
var field = o[key]; | |
if (typeof field == 'function') { | |
o[key] = Proxy.createFunction({}, | |
// call | |
function () { | |
var before = new Date; | |
var res = field.apply(o, arguments); | |
var spent = new Date - before; |
View upgrade_openwrt_backfire_to_attitude_adjustment_rspro.sh
# Upgrading from openwrt backfire to attitude adjustment 12.09 on the routerstation pro | |
# 1. | |
# download the sysupgrade file | |
# it can be used to upgrade from the luci ui | |
# it keeps your settings | |
wget http://downloads.openwrt.org/attitude_adjustment/12.09/ar71xx/generic/openwrt-ar71xx-generic-ubnt-rspro-squashfs-sysupgrade.bin | |
# 2. | |
# in luci, navigate to "backup / flash firmware" |
View hogan-custom-function-access-nested-context--like-in-mustache-templates.html
<!doctype html> | |
<meta charset=utf-8> | |
<title>hogan custom function access nested context</title> | |
<script src="hogan-3.0.1.js"></script> | |
<script> | |
var data = { | |
site: { | |
heading: "Site heading", |
View hogan-custom-function-access-nested-context.html
<!doctype html> | |
<meta charset=utf-8> | |
<title>hogan custom function access nested context</title> | |
<script src="hogan-3.0.1.js"></script> | |
<script> | |
var data = { | |
site: { | |
heading: "Site heading", |
View hogan-internal-access-nested-context.html
<!doctype html> | |
<meta charset=utf-8> | |
<title>hogan internal access nested context</title> | |
<script src="hogan-3.0.1.js"></script> | |
<script> | |
var data = { | |
site: { | |
heading: "Site heading", |
View home-brew-link-all-programs-after-mavericks.sh
▶ brew list -1 | while read line; do brew unlink $line; brew link $line; done | |
Unlinking /usr/local/Cellar/appledoc/2.2... 0 links removed | |
Linking /usr/local/Cellar/appledoc/2.2... 1 symlinks created | |
Unlinking /usr/local/Cellar/autoconf/2.69... 0 links removed | |
Linking /usr/local/Cellar/autoconf/2.69... 18 symlinks created | |
Unlinking /usr/local/Cellar/bash-completion/1.3... 184 links removed | |
Linking /usr/local/Cellar/bash-completion/1.3... 182 symlinks created | |
Unlinking /usr/local/Cellar/bgrep/0.2... 0 links removed | |
Linking /usr/local/Cellar/bgrep/0.2... 1 symlinks created | |
Unlinking /usr/local/Cellar/binutils/2.24... 49 links removed |
View testing-traceur-async-await-with-bluebird-promises.js
var wait = (ms) => new Promise((resolve, reject) => { | |
setTimeout(function () { | |
reject("doh"); | |
}, ms * 1000) | |
}) | |
async function f () { | |
try { | |
await wait(2); | |
} |
View quiescent-for-js.js
var React = require('react'); | |
var EventEmitter = require("events").EventEmitter; | |
function component (fn) { | |
var Component = React.createClass({ | |
render: function () { | |
return fn.call(this, this.props.value, this.props.statics); | |
}, | |
shouldComponentUpdate: function (nextProps) { | |
return this.props.value != nextProps.value; |
View omniscient-with-requestAnimationFrame.js
var React = require('react'), | |
component = require('../'), | |
immstruct = require('immstruct'), | |
Immutable = require('immutable'), | |
d3 = require('d3'); | |
var d = React.DOM; | |
var w = Math.max(document.documentElement.clientWidth, window.innerWidth || 0), | |
h = Math.max(document.documentElement.clientHeight, window.innerHeight || 0), |