From e503a6f15d12c9efa05508b3971503f8e07be6fd Mon Sep 17 00:00:00 2001 From: Stefan Dierauf <sdierauf@cs.washington.edu> Date: Thu, 19 Feb 2015 14:05:35 -0800 Subject: [PATCH] added more slides --- mlpfansite.js | 8 ++++++++ slides/event-loop.md | 5 +++-- slides/list.json | 6 +++++- slides/other-crazy-things-you-can-do.md | 7 +++++++ slides/popular-modules.md | 10 ++++++++++ slides/simple-server-example.md | 12 ++++++++++++ slides/takeaways.md | 11 +++++++++++ slides/the-javascript-part.md | 6 ++---- slides/the-problem.md | 2 +- slides/the-solution.md | 1 + slides/what-is-a-callback.md | 3 --- slides/why-node-is-awesome.md | 2 ++ 12 files changed, 62 insertions(+), 11 deletions(-) create mode 100644 mlpfansite.js create mode 100644 slides/other-crazy-things-you-can-do.md create mode 100644 slides/popular-modules.md create mode 100644 slides/simple-server-example.md create mode 100644 slides/takeaways.md diff --git a/mlpfansite.js b/mlpfansite.js new file mode 100644 index 0000000..9032bd6 --- /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 9dc8727..eee8d6f 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 c15eacd..70acff9 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 0000000..406e80e --- /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 0000000..bb69216 --- /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 0000000..b5e1189 --- /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 0000000..0ad1c43 --- /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 3a2cb5c..3e18c55 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 c7c8aa1..10df930 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 ae754ff..c5e50e9 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 e00d09e..4164bce 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 b310ecd..2637f92 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'); -- GitLab