NodeSchool

learnyounode!
 

Gainesville JavaScript
July 8th, 2015

Eran Schoellhorn

Frontend Developer @ 352 Inc.

me@eran.sh                   @EranSchoellhorn

 

 

?

 

 

Family Man

Chicken Farmer

Amatuer Professional Eater

  • Web/"Other" Application Platform
  • Uses JavaScript to control C++ stuff
  • Built on Chrome V8 Runtime

In Use:

  • Enterprise Applications: Netflix, Paypal, Microsoft, LinkedIn
  • Open Source Projects: Atom Editor, Meteor, Popcorn Time
  • Tools to Make Stuff: NPM, Gulp, BrowserSync, Bower

"Learn You The Node.js For Much Win!

An intro to Node.js via a set of self-guided workshops."

STEP One
INSTALL NODEJS

Go to nodejs.org, click Install, Install..

STEP TWO
INSTALL PACKAGE

Open Terminal, enter

 npm install -g learnyounode

STEP THREE
START!

Make a directory somewhere.

learnyounode

Go there. 

Enter                                   .

Use arrow keys to navigate, enter to select stuff.

Start with "HELLO WORLD"

EXERCISE 1

Create a node script that prints "HELLO WORLD" to the console

 $ node exercise1.js

 HELLO WORLD

HELLO WORLD

EXERCISE 2

Create a script that takes any number of numeric arguments

and prints their sum.

 $ node exercise2.js 1 1 1 

 3

BABY STEPS

EXERCISE 3

Create a script that prints the number of lines in a file. 
Accept a filename as an argument. 

 $ node exercise3.js exercise1.js

 1

MY FIRST I/O

EXERCISE 4

Create a script that prints the number of lines in a file.
Accept a filename as an argument. Use Async this time, Pal.

 $ node exercise4.js exercise1.js

 1

MY FIRST ASYNC I/O

EXERCISE 5

Create a script which lists all files in a given directory with a given extension. 

 $ node exercise5.js ~/Downloads zip

 roboto.zip
 pants.zip

FILTERED LS

EXERCISE 6

Move logic from previous exercise into an external module. Include module in main script using require()..

 $ node exercise6.js ~/Downloads zip

 roboto.zip
 pants.zip

MAKE IT MODULAR

EXERCISE 7

Create a script that takes a URL as an argument. When run, the script should console.log the response of the provided URL.

 $ node exercise7.js http://randomword.setgetgo.com/get.php

 gutturalism

HTTP CLIENT

EXERCISE 8

Do the same thing as before but first print the number of characters in the response, then print the whole response.

 $ node exercise8.js http://randomword.setgetgo.com/get.php

 11
 nonloving

HTTP COLLECT

EXERCISE 9

Take 3 URLS, get all their responses and then print to
console in order they were provided. 

 $ node exercise8.js http://randomword.setgetgo.com/get.php ...

 chiripa
 bibliothecarial
 tetrafolious

JUGGLING ASYNC

learnyounode

By Eran Schoellhorn

learnyounode

  • 1,650