(by @andrestaltz)
If you prefer to watch video tutorials with live-coding, then check out this series I recorded with the same contents as in this article: Egghead.io - Introduction to Reactive Programming.
(by @andrestaltz)
If you prefer to watch video tutorials with live-coding, then check out this series I recorded with the same contents as in this article: Egghead.io - Introduction to Reactive Programming.
| // we need the fs module for moving the uploaded files | |
| var fs = require('fs'), | |
| EventEmitter = require('events').EventEmitter; | |
| var uploadQueue = new EventEmitter(); | |
| uploadQueue.on('upload', function(tmp_path, target_path) { | |
| // move the file from the temporary location to the intended location | |
| fs.rename(tmp_path, target_path, function(err) { | |
| if (err) throw err; | |
| // delete the temporary file, so that the explicitly set temporary upload dir does not get filled with unwanted files |
| var exec = require('child_process').exec, | |
| url = "http://google.com/", | |
| timeout = "3", | |
| data="?q=test"; | |
| var time = process.hrtime(); | |
| exec('curl --max-time ' + timeout + ' -d \'' + data + '\' ' + url, function (error, stdout, stderr) { | |
| var diff = process.hrtime(time); | |
| //console.log('stdout: ' + stdout); | |
| //console.log('stderr: ' + stderr); |
| ### | |
| Module dependencies | |
| ### | |
| require.paths.unshift "#{__dirname}/lib/support/express-csrf/" | |
| require.paths.unshift "#{__dirname}/lib/support/node_hash/lib/" | |
| express = require 'express' | |
| app = module.exports = express.createServer() | |
| RedisStore = require 'connect-redis' |