Your SlideShare is downloading. ×
0
hacking with node.JS
hacking with node.JS
hacking with node.JS
hacking with node.JS
hacking with node.JS
hacking with node.JS
hacking with node.JS
hacking with node.JS
hacking with node.JS
hacking with node.JS
hacking with node.JS
hacking with node.JS
hacking with node.JS
hacking with node.JS
hacking with node.JS
hacking with node.JS
hacking with node.JS
hacking with node.JS
hacking with node.JS
hacking with node.JS
hacking with node.JS
hacking with node.JS
hacking with node.JS
hacking with node.JS
hacking with node.JS
hacking with node.JS
hacking with node.JS
hacking with node.JS
Upcoming SlideShare
Loading in...5
×

Thanks for flagging this SlideShare!

Oops! An error has occurred.

×
Saving this for later? Get the SlideShare app to save on your phone or tablet. Read anywhere, anytime – even offline.
Text the download link to your phone
Standard text messaging rates apply

hacking with node.JS

7,585

Published on

Getting started with node.JS

Getting started with node.JS

Published in: Technology
1 Comment
5 Likes
Statistics
Notes
No Downloads
Views
Total Views
7,585
On Slideshare
0
From Embeds
0
Number of Embeds
1
Actions
Shares
0
Downloads
77
Comments
1
Likes
5
Embeds 0
No embeds

Report content
Flagged as inappropriate Flag as inappropriate
Flag as inappropriate

Select your reason for flagging this presentation as inappropriate.

Cancel
No notes for slide
  • Demo hello-world.js and hello-world.phpThen hello-world-2.js Actually there isn't a lot new here. But then again, there was nothing new about node either. Node uses non-blocking IO for fast scalable servers. That's been known about for years among the C community. It uses event based, single thread javascript for logic. That's exactly what the browser has. Add these together and we all see the huge splash it's made. It's the unique combination of some simple but complimentary ideas that really make these projects zing.
  • Re – usability of code. Give example of YUIExecute JS based on device.
  • Hello-server.js
  • Show npm search, install,ls, uninstallShow search.npmjs.orgMath.js
  • Transcript

    • 1.
    • 2. #hacking withnode.JS<br />HarshaVashisht<br />http://www.harsharv.com<br />@harsharv<br />Picture Source: http://bethesignal.org/blog/2011/01/06/speaking-lca2011-html5-nodejs/<br />
    • 3. What is node.js?<br />
    • 4. Node is an exciting new platform developed byRyan Dahl.<br />
    • 5. It is a lot of sugar on v8<br />
    • 6. It allows JavaScript developers to create extremely high performance servers by leveraging Google&apos;s V8 JavaScript engine, and asynchronous I/O.<br />
    • 7. Never wait it the motto<br />
    • 8. Recap… What is Node.js?<br /><ul><li>Node is an exciting new platform developed by Ryan Dahl.
    • 9. It allows JavaScript developers to create extremely high performance servers by leveraging Google&apos;s V8 JavaScript engine, and asynchronous I/O.
    • 10. Node is a lot of Sugar written on V8
    • 11. Never wait is the motto. Either to fetch a page from the web or fetch data from a DB.</li></li></ul><li>let us look at…<br />
    • 12. DUCK! There will be code…<br />Lets see cod<br />
    • 13. LAMP STACK<br />1. Order<br />2. Waits for the food<br />to be cooked<br />3.Food is ready<br />4. Serve<br />
    • 14. Node JS<br />1. Order<br />2. Places the order<br />with the cook<br />3. Immediately moves on to take the order from the next table<br />4. Cook notifies that the food is <br />ready<br />5. Food is served<br />
    • 15. commonjs<br />CommonJS is a community driven effort to standardize packaging of JavaScript libraries, known as modules. Modules written which comply to this standard provide portability between other compliant frameworks such as narwhal, and in some cases even browsers.*<br />* Conditions Apply<br />
    • 16. Why node.js?<br />
    • 17. Global objects<br /><ul><li>Require
    • 18. Module/ export
    • 19. Process</li></li></ul><li>Require<br />This is used to specify that a module is required.<br />Example:<br />var operation = require(“pow”)<br />
    • 20. Module/ exports<br />This is used to package JavaScript libraries and expose the functionality to be used else where.<br />Example:<br />exports.pow = function (a, b) { <br /> …<br />}<br />
    • 21. process<br /><ul><li>The process object is a global object and can be accessed from anywhere.
    • 22. It is an instance of EventEmitter.
    • 23. Can be thought as an equivalent to Window object in the browser</li></ul>Examples:<br /><ul><li>process.cwd()
    • 24. process.exit(1)
    • 25. process.argv
    • 26. process.on(&apos;exit&apos;, function () { </li></ul> ...}<br /><ul><li>process.on(&apos;uncaughtException&apos;, function (err) {</li></ul> …}<br />
    • 27. Simple http server<br />/* File Name: hello-server.js */<br />/* Include the http module. */<br />var http = require(&apos;http&apos;);<br />/* Create a server which accepts Request - req and returns Response - res */<br />http.createServer(function (req, res) {<br /> /* Set the HTTP header for the response. */<br /> res.writeHead(200, {&apos;Content-Type&apos;: &apos;text/plain&apos;});<br /> /* End the HTTP response */<br />res.end(&apos;Hello Worldn&apos;);<br />}).listen(9000, &quot;127.0.0.1&quot;);<br />/* Print a message to indicate that the server is running. */<br />console.log(&apos;Server running at http://127.0.0.1:9000/&apos;);<br />
    • 28. Modules lets right some<br />
    • 29. Calculate power of a number<br />exports.pow = function (a, b) {<br /> /* Check if a number is passed. */<br /> if (isNaN (a-0) || isNaN (b-0)) {<br /> return null;<br /> }<br />varans = 1;<br />for (vari = 1; i &lt;= b; i++) {<br />ans *= a;<br /> }<br /> return ans;<br />}<br />Link: https://github.com/harsharv/OpenHackDay2011/blob/master/hello-server.js<br />
    • 30. twitter search module<br />https://github.com/harsharv/OpenHackDay2011/blob/master/twitter.js<br />https://github.com/harsharv/OpenHackDay2011/blob/master/mashup.js<br />
    • 31. Npm – node package manager<br /><ul><li>npm is the package manager for the Node JavaScript platform
    • 32. It puts modules in place so that node can find them, and manages dependency conflicts intelligently.</li></li></ul><li>More about npm<br /><ul><li>Install NPM</li></ul>curl http://npmjs.org/install.sh | sh<br /><ul><li>Browse the packages of NPMhttp://search.npmjs.org/</li></li></ul><li>Npm basic commands<br /><ul><li>npm search
    • 33. npmls
    • 34. npm install yui3
    • 35. npm uninstall yui3</li></li></ul><li>Yui3 and node.js<br />
    • 36. resources<br /><ul><li>http://nodejs.org/
    • 37. http://npmjs.org/
    • 38. http://www.yuiblog.com/blog/2010/04/05/running-yui-3-server-side-with-node-js/
    • 39. http://developer.yahoo.com/yui/3/
    • 40. http://github.com/davglass/nodejs-yui
    • 41. http://github.com/davglass/yui-express
    • 42. http://github.com/harsharv/OpenHackDay2011</li></li></ul><li>Harsha R. Vashishtmail@harsharv.com<br />http://www.harsharv.comhttp://twitter.com/harsharv<br />http://www.facebook.com/harsharvhttp://www.slideshare.net/harsharv<br />http://github.com/harsharv/<br />

    ×