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
action = curry(goUp, 'hill') | |
[jack, jill].map(action) | |
for person in [jack, jill] | |
person.goUp('hill') |
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 doInner(i) { | |
console.log(i, 'doInner'); | |
process.nextTick(function() { | |
// runs after everything else is done | |
console.log(i, 'nextTick'); | |
}); | |
} | |
function doOuter(i) { | |
console.log(i, 'doOuter before inner'); |
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 EventEmitter = require('events').EventEmitter; | |
// Constructor emits before client subscribed | |
function StreamLibrary(resourceName) { | |
// should use process.nextTick here to delay the firing of the event | |
this.emit('start'); | |
// read from the file, and for every chunk read, do: | |
this.emit('data', chunkRead); | |
} | |
StreamLibrary.prototype.__proto__ = EventEmitter.prototype; // inherit from EventEmitter |
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 doSomething(i, callback) { | |
console.log(i, 'doSomething before callback'); | |
// this is in fact synchronous, since don't use nextTick | |
callback(); | |
console.log(i, 'doSomething after callback'); | |
process.nextTick(function() { | |
// you might think this yeilds to the next "doSomething", | |
// but in fact it runs after everything else is done | |
console.log(i, 'nextTick'); | |
}); |
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 (1 == '1') console.log('1. 1 == "1"'); | |
if (1 === '1') {} else console.log('2. 1 is not === "1" (types different)'); | |
var a = 'a'; | |
var a1 = a; | |
var a2 = 'a'; | |
if (a == a1) console.log('3. a == a1'); | |
if (a == a2) console.log('4. a == a2'); | |
if (a === a2) console.log('5. even a ==== a2 (equal value and type)'); |
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 items = ['0', '000', 0, 1, '001', 'a', 'z', 'A', 'Z', '!', null, undefined]; | |
console.log('sorted', items.sort()); | |
// defaults to string sort null becomes 'null' | |
// sorted [ '!', '0', 0, '000', '001', 1, 'A', 'Z', 'a', null, 'z', undefined ] | |
console.log('string sort', items.sort(function(a, b) { | |
if (a < b) { | |
console.log(typeof(a), a, '<', typeof(b), b, '== 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
#!/usr/bin/env _coffee | |
console.log 'hello ...' | |
setTimeout _, 100 | |
console.log '... world' | |
doSomething = (isError, cb) -> | |
process.nextTick -> | |
if isError | |
cb(new Error('error'), isError) | |
else |
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
#COUNT TERM ONE TERM TWO TERM THREE |TERM THREE PREDICTION | |
----------------------------------------------------------------------------- | |
# 1 aunt likes baking | programming | |
# 2 aunt likes piano | baking | |
# 3 aunt eats vegetables | | |
# 4 uncle eats chocolate | vegetables | |
# 5 uncle likes bikes | programming | |
# 6 uncle eats coffee | chocolate | |
# 7 uncle likes running | bikes | |
# 8 uncle eats cereal | coffee |
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
#COUNT TERM ONE TERM TWO TERM THREE |TERM THREE PREDICTION | |
----------------------------------------------------------------------------- | |
# 1 fish showed fish | heart | |
# 2 ignite showed fire | fish | |
# 3 ignite showed match | fire | |
# 4 grain showed wheat | fire | |
# 5 development showed construction | fish | |
# 6 development showed code | construction | |
# 7 labor showed worker | fire | |
# 8 influence showed speaker | fire |
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
#!/usr/bin/env node | |
'use strict'; | |
var when = require('when'); | |
var phantom = require('phantom'); | |
exports.takeShot = function takeShot(url, outputFilePath) { | |
return when.promise(function(resolve, reject) { |