Skip to content

Commit

Permalink
Initial commit.
Browse files Browse the repository at this point in the history
  • Loading branch information
mikeal committed May 25, 2011
0 parents commit 80a0657
Show file tree
Hide file tree
Showing 30 changed files with 447 additions and 0 deletions.
1 change: 1 addition & 0 deletions AdvancedWindmill.key/Contents/PkgInfo
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
????????
Binary file added AdvancedWindmill.key/QuickLook/Thumbnail.jpg
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Binary file added AdvancedWindmill.key/index.apxl.gz
Binary file not shown.
Binary file added AdvancedWindmill.key/thumbs/st0.tiff
Binary file not shown.
Binary file added AdvancedWindmill.key/thumbs/st1.tiff
Binary file not shown.
Binary file added AdvancedWindmill.key/thumbs/st2.tiff
Binary file not shown.
Binary file added AdvancedWindmill.key/thumbs/st3.tiff
Binary file not shown.
Binary file added CouchDB Everything.key
Binary file not shown.
Binary file added CouchDB@Mozilla.key
Binary file not shown.
Binary file added CouchDBAndPython.key
Binary file not shown.
Binary file added EventsVsCallbacks.key
Binary file not shown.
Binary file added NoSQL-Frankfurt.key
Binary file not shown.
Binary file added NodeCamp2010.key
Binary file not shown.
Binary file added NodeStreams.key
Binary file not shown.
Binary file added NodejsCouchDB.key
Binary file not shown.
Binary file added WindmillRocksSlides.key.zip
Binary file not shown.
6 changes: 6 additions & 0 deletions node-intro/01.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,6 @@
var fs = require('fs');

fs.readFile('hello.txt', function (error, buffer) {
if (error) throw error;
console.log(buffer.toString());
})
7 changes: 7 additions & 0 deletions node-intro/02.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,7 @@


(function () {
process.nextTick(function () {
throw 'asdf';
})
})()
23 changes: 23 additions & 0 deletions node-intro/03.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,23 @@
var events = require('events');

process.nextTick(function () {
console.log('nextTick');
})

var e = new events.EventEmitter();

e.emit('one');

e.on('one', function () {console.log('one')});
e.on('two', function () {console.log('two')});
e.on('three', function () {console.log('three')});
e.on('four', function () {console.log('four')});

e.on('two', function () {
e.emit('three');
})
e.on('three', function () {
e.emit('four');
})

e.emit('two');
27 changes: 27 additions & 0 deletions node-intro/04.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,27 @@
var http = require('http')
, path = require('path')
, fs = require('fs')
, request = require('request')
;

http.createServer(function (req, resp) {
var p = path.join(__dirname, req.url);
if (req.method === 'GET') {
resp.writeHead(200);
fs.createReadStream(p).pipe(resp);
} else if (req.method == 'PUT') {
var s = fs.createWriteStream(p);
req.pipe(s);
s.on('end', function () {
resp.writeHead(201);
resp.end();
})
}
}).listen(8888)

request('http://localhost:8888/hello.txt', function (e, resp, body) {
console.log(body);
})

var notes = fs.createReadStream(path.join(__dirname, 'notes.txt'))
notes.pipe(request.put('http://localhost:8888/newfile.txt'))
27 changes: 27 additions & 0 deletions node-intro/05.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,27 @@
var http = require('http')
, path = require('path')
, fs = require('fs')
, request = require('request')
;

http.createServer(function (req, resp) {
var p = path.join(__dirname, req.url);
if (req.method == 'PUT') {
setTimeout(function () {
var s = fs.createWriteStream(p);
req.pipe(s);
s.on('end', function () {
console.log('write end');
resp.writeHead(201); resp.end();
})
}, 1 * 1000)
req.on('end', function () { console.log('request end'); })
}
}).listen(8888)

var notes = fs.createReadStream(path.join(__dirname, 'notes.txt'));
notes.pipe(request.put('http://localhost:8888/newfile-2.txt'));

notes.on('end', function () {
console.log('read end')
})
29 changes: 29 additions & 0 deletions node-intro/06.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,29 @@
var http = require('http')
, path = require('path')
, fs = require('fs')
, request = require('request')
;

s = http.createServer();
s.on('request', function (req, resp) {
var p = path.join(__dirname, req.url);
if (req.method == 'PUT') {
setTimeout(function () {
var s = fs.createWriteStream(p);
req.pipe(s);
s.on('end', function () {
console.log('write end');
resp.writeHead(201); resp.end();
})
}, 1 * 1000)
req.on('end', function () { console.log('request end'); })
}
})
s.listen(8888)

var notes = fs.createReadStream(path.join(__dirname, 'notes.txt'));
notes.pipe(request.put('http://localhost:8888/newfile-2.txt'));

notes.on('end', function () {
console.log('read end')
})
33 changes: 33 additions & 0 deletions node-intro/07.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,33 @@
var http = require('http')
, path = require('path')
, fs = require('fs')
, morestreams = require('morestreams')
, request = require('request')
;

s = http.createServer();
s.on('request', function (req, resp) {
var p = path.join(__dirname, req.url);
if (req.method == 'PUT') {

var buf = new morestreams.BufferedStream();
req.pipe(buf);

setTimeout(function () {
var s = fs.createWriteStream(p);
buf.pipe(s);
s.on('end', function () {
console.log('write end');
resp.writeHead(201); resp.end();
})
}, 1 * 1000)
}
})
s.listen(8888)

var notes = fs.createReadStream(path.join(__dirname, 'notes.txt'));
notes.pipe(request.put('http://localhost:8888/newfile-3.txt'));

notes.on('end', function () {
console.log('read end')
})
1 change: 1 addition & 0 deletions node-intro/hello.txt
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
hello world!
Empty file added node-intro/newfile-2.txt
Empty file.
97 changes: 97 additions & 0 deletions node-intro/newfile-3.txt
Original file line number Diff line number Diff line change
@@ -0,0 +1,97 @@











Callbacks
---------
- IO
- event loop
- before/after nextTick()

























EventEmitter
------------
- blocks on processing
- happens in one eventsys call




















































97 changes: 97 additions & 0 deletions node-intro/newfile.txt
Original file line number Diff line number Diff line change
@@ -0,0 +1,97 @@











Callbacks
---------
- IO
- event loop
- before/after nextTick()

























EventEmitter
------------
- blocks on processing
- happens in one eventsys call




















































1 change: 1 addition & 0 deletions node-intro/node_modules/morestreams

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

1 change: 1 addition & 0 deletions node-intro/node_modules/request

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

Loading

0 comments on commit 80a0657

Please sign in to comment.