diff --git a/mlpfansite.js b/mlpfansite.js new file mode 100644 index 0000000000000000000000000000000000000000..9032bd64ef554999201635f06966694e94e341e1 --- /dev/null +++ b/mlpfansite.js @@ -0,0 +1,8 @@ +var http = require('http'); + +function requestHandler(request, response) { + response.writeHead(200, {'Content-Type': 'text/html'}); + response.end('<h1>MLP Fan Site</h1>'); +} + +http.createServer(requestHandler).listen(1337, '127.0.0.1'); diff --git a/slides/event-loop.md b/slides/event-loop.md index 9dc87277ae2503d96092fcfafb4e7ca02d001509..eee8d6fb7706538a2e7b948bd4f59dce5ad78957 100644 --- a/slides/event-loop.md +++ b/slides/event-loop.md @@ -1,5 +1,6 @@ ## Event Loop -* Async calls enqueued on event loop -* Node single-thread will dequeue and process +* Async calls enqueued on event loop with a callback +* Node single-thread will dequeue and run callback * When there's nothing left to do, node will sleep +* Everything should be asynch as possible! \ No newline at end of file diff --git a/slides/list.json b/slides/list.json index c15eacd7215fe1e94b5a41d20ff5f6a59f2cd038..70acff922c6bd30a6ac89dafd32885b3294acc7e 100644 --- a/slides/list.json +++ b/slides/list.json @@ -16,5 +16,9 @@ "outline-pt2.md", "the-javascript-part.md", "what-is-a-callback.md", - "event-loop.md" + "event-loop.md", + "simple-server-example.md", + "popular-modules.md", + "other-crazy-things-you-can-do.md", + "takeaways.md" ] \ No newline at end of file diff --git a/slides/other-crazy-things-you-can-do.md b/slides/other-crazy-things-you-can-do.md new file mode 100644 index 0000000000000000000000000000000000000000..406e80e3090414efea4acd6bd97df7681186732e --- /dev/null +++ b/slides/other-crazy-things-you-can-do.md @@ -0,0 +1,7 @@ +## Other crazy things you can do + +* Program arduino (node-serialport) +* Write standalone apps with html + js (node-webkit) + * Probably shouldn't do this +* Write node plugins in c++ (node-gyp) +* Feel smug + hipster \ No newline at end of file diff --git a/slides/popular-modules.md b/slides/popular-modules.md new file mode 100644 index 0000000000000000000000000000000000000000..bb69216b160e2e5abae9c212b30c303b223e91b2 --- /dev/null +++ b/slides/popular-modules.md @@ -0,0 +1,10 @@ +## Popular modules + +* http://expressjs.com/ -- minimalist web framework +* http://gruntjs.com/ -- task runner +* http://yeoman.io/ -- project scaffolding/generator +* http://browserify.org/ -- frontend module system/bundling + +<br> + +...and many more! \ No newline at end of file diff --git a/slides/simple-server-example.md b/slides/simple-server-example.md new file mode 100644 index 0000000000000000000000000000000000000000..b5e118941badbfa6c1fd8f74534cf2a4411f2970 --- /dev/null +++ b/slides/simple-server-example.md @@ -0,0 +1,12 @@ +## Simple server example again + +```javascript +var http = require('http'); +function requestHandler(request, response) { + response.writeHead(200, {'Content-Type': 'text/html'}); + response.end('<h1>MLP Fan Site</h1>'); +} +http.createServer(requestHandler).listen(1337, '127.0.0.1'); +``` +* Each request to the server is enqueued +* Uses `requestHandler` as the callback \ No newline at end of file diff --git a/slides/takeaways.md b/slides/takeaways.md new file mode 100644 index 0000000000000000000000000000000000000000..0ad1c4330182ff0f8b087839bf484d26edf8d143 --- /dev/null +++ b/slides/takeaways.md @@ -0,0 +1,11 @@ +## Takeaways + +Nodejs... + +* is fast +* is simple +* uses a popular language +* lets the OS worry about concurrency +* has plenty of support + good docs +* isn't php + diff --git a/slides/the-javascript-part.md b/slides/the-javascript-part.md index 3a2cb5c029eccc8369135815339da3126cc29e86..3e18c55e571a5b620b3cc573f774ccae5a0bd11c 100644 --- a/slides/the-javascript-part.md +++ b/slides/the-javascript-part.md @@ -1,9 +1,7 @@ ## The javascript part * Javascript is one of the most popular languages in the world - -<img src="pics/github_new.png" style="width: 400px"> - * Lots of people with knowledge of javascript * Ergo, lots of people familiar with async + callbacks -* Nodejs uses lots of async + callbacks \ No newline at end of file +* Nodejs designer wanted a language with callbacks + event loop concept +* Google V8 ayy lmao \ No newline at end of file diff --git a/slides/the-problem.md b/slides/the-problem.md index c7c8aa1f03a972da717a822df203274bb4d437c2..10df93060946ccbe85111d146786d9d76c07cb8b 100644 --- a/slides/the-problem.md +++ b/slides/the-problem.md @@ -3,7 +3,7 @@ * Servers have to handle lots of requests * majority of I/O is disk bound -``` +```javascript var result = database.query("kittens"); // twaddle fingers send(result); diff --git a/slides/the-solution.md b/slides/the-solution.md index ae754ff78f04a9eedd8e20d5ba67696892e823aa..c5e50e911dc217f78a8c89fdb0508c70d5bdbbd3 100644 --- a/slides/the-solution.md +++ b/slides/the-solution.md @@ -10,3 +10,4 @@ database.query("kittens", function (data) { // do other servery things ``` +*we'll explore callbacks and javascript language features later* diff --git a/slides/what-is-a-callback.md b/slides/what-is-a-callback.md index e00d09e58e62bda9ce0d0567d7a8a670aae02dfa..4164bce5a5e4a45a6f881794b1a2b7857e2a3e54 100644 --- a/slides/what-is-a-callback.md +++ b/slides/what-is-a-callback.md @@ -3,9 +3,6 @@ Callbacks are functions that are passed as parameters to other functions, and then called within those functions -LinkedList implementation requires a function pointer to free a payload, -same idea - ``` function helloCaller(helloFn, name) { helloFn(name); diff --git a/slides/why-node-is-awesome.md b/slides/why-node-is-awesome.md index b310ecd6f6b1e13c488f58aa25405f81ac13553b..2637f926bd22060400a544ecf3b6375fb809ce8e 100644 --- a/slides/why-node-is-awesome.md +++ b/slides/why-node-is-awesome.md @@ -1,5 +1,7 @@ ## Why node is awesome +Simple http server + ```javascript var http = require('http');