Upgrade to Pro — share decks privately, control downloads, hide ads and more …

Humans Networks and Chaos

shapeshed
February 13, 2012

Humans Networks and Chaos

An introduction to Node.js

shapeshed

February 13, 2012
Tweet

More Decks by shapeshed

Other Decks in Technology

Transcript

  1. Room You are in a with 2 exits Left or

    right? Monday, 13 February 12
  2. Scenario: Player Turns Left Given I am asked to turn

    left or right When I choose to turn left Then I should see “Eaten by a dragon” Scenario: Player Turns Right Given I am asked to turn left or right When I choose to turn left Then I should see “You found the Princess” Monday, 13 February 12
  3. Xbox Controller Internet Map scenarios for this Game Servers Databases

    Chat Servers Voice Servers Load balancers Message queues .. more 8 million controllers Monday, 13 February 12
  4. Still ok? Browser Server App Servers Databases Chat Servers Voice

    Servers Load balancers Message queues 3rd party APIs ..more Unlimited things Millions of users. Phones, Tablets, TVs Billboards, Fridges more.. Monday, 13 February 12
  5. var http = require('http'); http.createServer(function (req, res) { res.writeHead(200, {'Content-Type':

    'text/plain'}); res.end('Hello World\n'); }).listen(1337, "127.0.0.1"); console.log('Server running at http:// 127.0.0.1:1337/'); HelloWorld Monday, 13 February 12
  6. HelloWorld var http = require('http'); http.createServer(function (req, res) { res.writeHead(200,

    {'Content-Type': 'text/plain'}); res.end('Hello World\n'); }).listen(1337, "127.0.0.1"); console.log('Server running at http:// 127.0.0.1:1337/'); Monday, 13 February 12
  7. var urls = db.query("select * from urls"); urls.each(function () {

    var page = http.get(url); save(page); }); db.query("select * from urls", function (urls) { urls.each(function(url) { http.get(url, function (page) { save(page); }); }); }); Jacek Becela http://www.slideshare.net/jacekbecela/introduction-to-nodejs Monday, 13 February 12
  8. var urls = db.query("select * from urls"); urls.each(function () {

    var page = http.get(url); save(page); }); db.query("select * from urls", function (urls) { urls.each(function(url) { http.get(url, function (page) { save(page); }); }); }); http://www.slideshare.net/jacekbecela/introduction-to-nodejs Blocking Blocking Blocking Monday, 13 February 12
  9. var urls = db.query("select * from urls"); urls.each(function () {

    var page = http.get(url); save(page); }); db.query("select * from urls", function (urls) { urls.each(function(url) { http.get(url, function (page) { save(page); }); }); }); http://www.slideshare.net/jacekbecela/introduction-to-nodejs Blocking Blocking Blocking Callbacks Monday, 13 February 12
  10. Where next? Express (gateway drug) - http://expressjs.com Socket.io (fast high)

    - http://socket.io/ dnode (blows mind) - https://github.com/substack/dnode UK Training http://leftlogic.com/training#node Monday, 13 February 12