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
[ | |
{"keys": ["alt+up"], "command": "move", "args": {"by": "stops", "empty_line": true, "forward": false}}, | |
{"keys": ["alt+down"], "command": "move", "args": {"by": "stops", "empty_line": true, "forward": true}}, | |
{"keys": ["shift+alt+up"], "command": "move", "args": {"by": "stops", "empty_line": true, "forward": false, "extend": true}}, | |
{"keys": ["shift+alt+down"], "command": "move", "args": {"by": "stops", "empty_line": true, "forward": true, "extend": true}}, | |
] |
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
function require(scripts, callback) { | |
var i, xhr, head, events = { | |
onload: function(e) { | |
var tag = document.createElement('script') | |
tag.textContent = xhr.responseText | |
head.appendChild(tag) | |
next() | |
}, | |
onerror: function(e, message) { | |
console.error(`require script ${i+1} of ${scripts.length}: |
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
(function() { | |
var Validator = (function() { | |
var Validator = function(options) { | |
... | |
}; | |
Validator.prototype.foo = function foo() { | |
... | |
}; |
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
//////////////////////////// | |
// using inline closure | |
//////////////////////////// | |
(function() { | |
arr = [] | |
for (i = 0; i < 10; i++) | |
arr[i] = (function(i) { | |
return function() { console.log("I am #" + i) } | |
})(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
Function.prototype.uncurrying = function() { | |
var _this = this; | |
return function() { | |
return Function.prototype.call.apply(_this, arguments); | |
}; | |
}; | |
/*var push = Array.prototype.push.uncurrying(); | |
var a = []; | |
push(a, 1, 2, 'zensh'); |
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
// Reloading modules from the repl in Node.js | |
// Benjamin Gleitzman ([email protected]) | |
// | |
// Inspired by Ben Barkay | |
// http://stackoverflow.com/a/14801711/305414 | |
// | |
// Usage: `node reload.js` | |
// You can load the module as usual | |
// var mymodule = require('./mymodule') | |
// And the reload it when needed |
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> | |
<script> | |
'use strict' | |
// this 'use strict' only applies within this <script> tag | |
</script> | |
<script> |
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
function if_else() { | |
if (window.foo) { | |
window.foo.bar = 'never gets here because we explicitly checked for window.foo first' | |
} else {} | |
} | |
// this will always be slower because it creates an exception | |
// and then navigates that exception to the first catch block | |
function try_catch() { | |
try { |
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 Data = function() { | |
var warehouse = {}; | |
var count = 1; | |
return { | |
reset: function() { | |
count = 1; | |
warehouse = {}; | |
}, | |
set: function (dom, data) { | |
if (!dom.__data) { |
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 is function scoped & hoisted | |
let is block scoped & not hoisted | |
const is block scoped & not hoisted | |
*/ | |
(() => { | |
'use strict' | |
const tests = [ | |
() => { |
OlderNewer