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
// if you convert to everything returning asynquence sequences | |
ASQ( get("/api/google/sheets/resources") ) | |
.val( JSON.parse ) | |
.seq( handlebar.bind(null,"#template", "#output") ) | |
.seq( pourover ) | |
.seq( linkify ) | |
.or(function(err) { | |
console.error(err); | |
}); |
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
//In asynquence-contrib | |
var emptyItems = [], | |
sq = ASQ(); | |
sq.map(emptyItems, function(item, done){ | |
// do some things to item | |
item.values = []; | |
done(item); | |
}); |
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 segmentArray(arr,segmentSize) { | |
segmentSize = Math.max(1,Math.min(+segmentSize||0,arr.length)); | |
return Array.apply(null,{length:Math.ceil(arr.length / segmentSize)}).map(function(_,i){ | |
return arr.slice(i*segmentSize,(i+1)*segmentSize); | |
}); | |
} | |
// lift `serviceCall(..)` | |
function promiseServiceCall(v) { | |
return new Promise(function(resolve,reject){ |
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
<script src='LABjs/LAB.min.js'></script> | |
<script> | |
<!-- | |
$LAB | |
.setOptions({BasePath:'/syntaxhighlight/js/'}) | |
.script('shCore.js', | |
'shBrushCpp.js', | |
'shBrushCss.js', | |
'shBrushJScript.js', | |
'shBrushPython.js', |
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
// 1: how could you rewrite the following to make it shorter? | |
if (foo) { | |
bar.doSomething(el); | |
} else { | |
bar.doSomethingElse(el); | |
} | |
// ------------------------------------ |
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
for (var i = 0, j = foo.length; i < j; i++) { | |
// do stuff | |
} | |
for (var i = foo.length; i;) { | |
// first usage in loop: blah[--i] | |
// do stuff slightly faster in reverse order | |
} |
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'; | |
class Person { | |
constructor({ | |
firstName: this.firstName = '<FIRSTNAME_UNKNOWN>', | |
lastName: this.lastName = '<LASTNAME_UNKNOWN>' | |
} = {}) {} | |
printName() { | |
console.log(this.lastName, ',', this.firstName); | |
} | |
} |
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 fs = require("fs"); | |
var jParser = require("jParser"); | |
var eof = false; | |
fs.readFile("sample.jpg",function(err,data) { | |
if (!err) { | |
var view = new jDataView(data, undefined, undefined, false); | |
var parser = new jParser(view,{ | |
// JPG |
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
/* | |
* Forked Zakas' attempt at a `type()` "class" maker/extender utility. | |
* Mainly, this approach automatically calls a type's super-type (if any) | |
* `constructor` upon construction of the type, if you didn't specify | |
* a `constructor` for the type itself. | |
*/ | |
function type(prototype, declaration) { | |
function mixin(receiver, supplier) { | |
if (Object.getOwnPropertyDescriptor) { |
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
/* | |
* Forked Zakas' attempt at a `type()` "class" maker/extender utility. | |
* This variation just makes and links objects, without the unnecessity | |
* of using constructor functions. You can however specify `init()` | |
* functions to use upon creation of the object. NOTE: because there are | |
* no more constructor functions, comparisons with `instanceof` and | |
* `constructor` no longer apply. | |
*/ | |
function make(delegateTo, declaration) { |
OlderNewer