-
Doesn't output stdout or stderr of task commands automatically, so you have to do something like this:
{print} = require 'util' {spawn} = require 'child_process' task 'build', 'Build js/ from src/', -> coffee = spawn 'coffee', ['-c', '-o', 'js', 'src'] coffee.stderr.on 'data', (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 formData = $('#myform').serializeArray(); | |
_.merge.apply(_, formData.map(function(o) { var kvp={}; kvp[o.name] = o.value; return kvp; })) |
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
app.use(auth({ | |
clientID: 'FACEBOOK_APP_ID', | |
clientSecret: 'FACEBOOK_APP_SECRET', | |
sessionSecret: 'SESSION_SECRET', | |
userCollection: 'User', | |
callback: '/callback', | |
login: '/login', | |
// login: function(done) { | |
// auth.login({ | |
// role: req.query.role |
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
// NOTE: The below is pseudo-code. You may need to make some adjustments to | |
// function signatures to use an asynchronous library like async.js | |
// these functions can be made truly asynchronous by accepting a callback | |
// this is preferrably to daisy chaining them, which is too tight a coupling | |
dv.get.gdp = function(cb) { | |
d3.csv('data/gdp.csv', function(error, data) { | |
dv.setup.massage(data, 'gdp'); | |
cb(error, 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
// 1. BROKEN ASYNC CODE | |
var getDocuments = function(done) { | |
var ids = [1,2,3,4,5]; | |
var results = []; | |
db.open() | |
for(var i=0; i<ids.length; i++) { | |
db.findById(ids[i], function(err, doc) { |
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
./dateparse.js dates.txt out.txt |
Andrew | pastyche.herokuapp.com |
---|---|
Arvind | getmeprepped.herokuapp.com |
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
// This is probably the cleanest approach, but forces you to use | |
// privateMethod.call(this) syntax. | |
// MyClass module | |
(typeof module !== 'undefined' ? module.exports : window).MyClass = (function() { | |
// private | |
var sayHi = function() { | |
return 'Hi ' + this.name; | |
}; |
"null values returned by callback-based functions are the root of why programming with callbacks is hard: callback-based functions do not return anything, and so are hard to compose. A function with no return value is executed only for its side effects – a function with no return value or side effects is simply a black hole. So programming with callbacks is inherently imperative, it is about sequencing the execution of side-effect-heavy procedures rather than mapping input to output by function application. It is about manual orchestration of control flow rather than solving problems through value relationships. It is this that makes writing correct concurrent programs difficult."
OlderNewer