SlideShare a Scribd company logo
NYC Data Science Academy
Node.JS in Action
(Copyright materials, all right reserved)
Sign up for Node.js beginner class at www.nycdatascience.com
or email vivian.zhang@supstat.com
NYC Data Science Academy
Overview
 Deployment of Node.js on AWS EC2 Instance
 Use Bootstrap Framework for our page
 Rules of Routes, Session and MongoDB, Error Handling and Visiting Control
 Web Scrapper
 Save JSON data into MongoDB
NYC Data Science Academy
AWS Security Group
 You should Add HTTP Rules
 For convenience, you could allow All TCP rules
NYC Data Science Academy
Installation on Ubuntu
 Our machine is Ubuntu 12.04 LTS, 64 bits
 We install node and express from apt-get
 Check if we are having the right configuration
$ sudo add-apt-repository ppa:chris-lea/node.js
$ sudo apt-get update
$ sudo apt-get install nodejs
$ sudo npm install express@3 -g
$ sudo apt-get install unzip
$ sudo apt-get install build-essential
$ node -v
v0.10.26
$ npm -v
1.4.3
$ express -V
3.5.1
NYC Data Science Academy
Start Our first Project
 In ~/ directory, we can start our first express project
 If you see the notification, then it is OK!
 Visit your public address on port 3000 and you will see
$ express -e nodejs-demo
$ cd nodejs-demo
$ sudo npm install
$ node app.js
NYC Data Science Academy
Supervisor
 If we modify our code, we need to restart our server. That is inconvenient.
 By supervisor, we can modify our code and the server will restart automatically.
$ sudo npm install supervisor -g
$ supervisor app.js
Running node-supervisor with
program 'app.js'
--watch '.'
--extensions 'node,js'
--exec 'node'
Starting child process with 'node app.js'
Watching directory '/home/ubuntu/nodejs-demo' for changes.
Express server listening on port 3000
NYC Data Science Academy
Intro to the working directory
 node_modules: Store all the dependent libraries(every project manage its own
dependencies).
 package.json: Project dependencies configuration and developer information
 app.js: Application starting file
 public: Static files(css,js,img)
 routes: Routes files(C in MVC, controller)
 Views: Page files(Ejs template)
NYC Data Science Academy
Support html files
 And rename views/index.ejs to views/index.html
 Add the following lines in app.js, see next page for codes
 Visit your website
$ mv views/index.ejs views/index.html
NYC Data Science Academy
Support html files
var express = require('express');
var routes = require('./routes');
var user = require('./routes/user');
var http = require('http');
var path = require('path');
var ejs = require('ejs');
var app = express();
// all environments
app.set('port', process.env.PORT || 3000);
app.set('views', path.join(__dirname, 'views'));
// app.set('view engine', ‟ejs');
app.engine('.html', ejs.__express);
app.set('view engine', 'html');
app.use(express.favicon());
app.use(express.logger('dev'));
NYC Data Science Academy
Use Bootstrap Framework
 Bootstrap Framework is one of the most popular frameworks for front-end.
 Download it from http://getbootstrap.com/ and unzip.
 And we also need jQuery.
 Check whether your “~/nodejs-demo/public/stylesheets” has three .css files and
whether „~/nodejs-demo/public/javascripts‟ has two .js files.
$ cd ~/
$ wget https://github.com/twbs/bootstrap/releases/download/v3.1.1/bootstrap-
3.1.1-dist.zip
$ unzip bootstrap-3.1.1-dist.zip
$ cd ~/bootstrap-3.1.1-dist
$ cp css/*.min.css ~/nodejs-demo/public/stylesheets/
$ cd js/
$ wget http://code.jquery.com/jquery-1.9.1.min.js
$ cp *.min.js ~/nodejs-demo/public/javascripts
$ cd ~/nodejs-demo
$ ls public/javascripts
$ ls public/stylesheets
NYC Data Science Academy
Split index.html
 We want a common header and footer by spliting index.html into header.html,
index.html and footer.html
 First, we add these two news files in foldr views/
NYC Data Science Academy
header.html
 We edit the header.html like this
<!DOCTYPE html>
<html lang="en">
<head>
<meta charset="utf-8">
<title><%=: title %></title>
<!-- Bootstrap -->
<link href="/stylesheets/bootstrap.min.css" rel="stylesheet" media="screen">
<!-- <link href="css/bootstrap-responsive.min.css" rel="stylesheet" media="screen"> --
>
</head>
<body screen_capture_injected="true">
$ vi ~/nodejs-demo/views/header.html
NYC Data Science Academy
footer.html
 We edit the footer.html like this
<script src="/javascripts/jquery-1.9.1.min.js">
</script>
<script src="/javascripts/bootstrap.min.js">
</script>
</body>
</html>
$ vi ~/nodejs-demo/views/footer.html
NYC Data Science Academy
index.html
 Through ejs(emmeded javascript), we can include our header and footer in
index.html
 modify index.html
<% include header.html %>
<h1><%= title %>
</h1>
<p>Welcome to <%= title %>
</p>
<% include footer.html %>
$ rm ~/nodejs-demo/views/index.html
$ vi ~/nodejs-demo/views/index.html
NYC Data Science Academy
Routes of our demo website
 Routes: pages, authorization and action
 / : index.html, No need to login to visit.
 /home : home.html, Need to login to visit.
 /login : login.html, redirect to home.html with correct username and password
 /logout : No corresponding html file
 redirect back to index.html after logout
 We can add routes to enable these features.
NYC Data Science Academy
Add routes
 In app.js, we edit it by “vi ~/nodejs-demo/app.js”
 Note: app.get is get request, app.post is post request, get.all is request for this
path.
app.get('/', routes.index);
//app.get('/users', user.list);
app.get('/login', routes.login);
app.post('/login', routes.doLogin);
app.get('/logout', routes.logout);
app.get('/home', routes.home);
NYC Data Science Academy
Add routes
 Then we edit routes/index.js by by “vi ~/nodejs-demo/routes/index.js”
NYC Data Science Academy
Add routes
exports.index = function(req, res){
res.render('index', { title: 'Express' });
};
exports.login = function(req, res){
res.render('login', { title: 'User Login'});
};
exports.doLogin = function(req, res){
var user={
username:'admin',
password:'admin'
}
if(req.body.username===user.username && req.body.password===user.password){
res.redirect('/home');
}
res.redirect('/login');
};
exports.logout = function(req, res){
res.redirect('/');
};
exports.home = function(req, res){
var user={
username:'admin',
password:'admin'
}
res.render('home', { title: 'Home',user: user});
};
NYC Data Science Academy
Add pages
 Create new home page by “vi ~/nodejs-demo/views/home.html” , see page 20
 Create new login page by “vi ~/nodejs-demo/views/login.html”, see page 21
NYC Data Science Academy
Create home.html
<% include header.html %>
<h1>Welcome <%= user.username %>!</h1>
<a class="btn" href="/logout">Logout</a>
<% include footer.html %>
NYC Data Science Academy
Create login.html
<% include header.html %>
<link href="/stylesheets/signin.css" rel="stylesheet">
<div class="container">
<form class="form-signin" method="post">
<h2 class="form-signin-heading">Please sign in</h2>
<input type="text" class="form-control" id="username" name="username"
required autofocus>
<input type="password" class="form-control" id="password"
name="password" required>
<button class="btn btn-lg btn-primary btn-block" type="submit">Sign
in</button>
</form>
</div>
<% include footer.html %>
NYC Data Science Academy
Add pages
 And we edit index.html by „vi ~/nodejs-demo/views/index.html‟
<% include header.html %>
<h1><%= title %>
</h1>
<p>Welcome to <%= title %>
<a href="/login">Signin</a>
</p>
<% include footer.html %>
NYC Data Science Academy
Improve the look
 This is what we see at /login.html:
 Is there anyway we can make it better?
NYC Data Science Academy
Edit the Bootstrap Style
 We create signin.css file to public/stylesheets/ by
 “vi ~/nodejs-demo/public/stylesheets/signin.css”
 Copy/past left side and right side into the file
body {
padding-top: 40px;
padding-bottom: 40px;
background-color: #eee;
}
.form-signin {
max-width: 330px;
padding: 15px;
margin: 0 auto;
}
.form-signin .form-signin-heading,
.form-signin .checkbox {
margin-bottom: 10px;
}
.form-signin .checkbox {
font-weight: normal;
}
.form-signin .form-control {
position: relative;
font-size: 16px;
height: auto;
padding: 10px;
-webkit-box-sizing: border-box;
-moz-box-sizing: border-box;
box-sizing: border-box;
}
.form-signin .form-control:focus {
z-index: 2;
}
.form-signin input[type="text"] {
margin-bottom: -1px;
border-bottom-left-radius: 0;
border-bottom-right-radius: 0;
}
.form-signin input[type="password"] {
margin-bottom: 10px;
border-top-left-radius: 0;
border-top-right-radius: 0;
}
NYC Data Science Academy
Edit the Bootstrap Style
 Then the website looks like:
 Use admin and admin to login!
NYC Data Science Academy
Session
 In “routes/index.js” file , when we call function “exports.doLogin”, if username and
password are correct, we will redirect to home.
 In the same file, when we call function “exports.home”, we render the page and pass
username to the home.html by the following specific:
 Why can't we assign the username to session so that we do not need pass to each
page again?
res.redirect('/home');
res.render('home', { title: 'Home',user: user});
NYC Data Science Academy
Storage of data
 On local drive, we store user credentials into cookie files.
 On server side, we also store session and user credentials in database, like Redis,
MongoDB.
 MongoDB pass the username object to each page instead of asking node.js passing
the username object between pages.
NYC Data Science Academy
Edit app.js
 The Order of Commands Matters !!!
NYC Data Science Academy
Edit app.js
app.set('view engine', 'html');
app.use(express.favicon());
app.use(express.logger('dev'));
app.use(express.bodyParser());
app.use(express.json());
app.use(express.urlencoded());
app.use(express.methodOverride());
app.use(express.cookieParser());
app.use(express.cookieSession({secret :
'nycdatascience.com'}));
app.use(express.session({
secret : 'nycdatascience.com',
store: store,
cookie: { maxAge: 900000 }
}));
app.use(function(req, res, next){
res.locals.user = req.session.user;
next();
});
app.use(app.router);
app.use(express.static(path.join(__dirname, 'public')));
var express = require('express');
var routes = require('./routes');
var user = require('./routes/user');
var http = require('http');
var path = require('path');
var ejs = require('ejs');
var SessionStore = require("session-
mongoose")(express);
var store = new SessionStore({
url: "mongodb://localhost/session",
interval: 120000
});
var app = express();
NYC Data Science Academy
MongoDB on Ubuntu
 Following the official document, we successfully installed MongoDB
 http://docs.mongodb.org/manual/tutorial/install-mongodb-on-ubuntu/
$ sudo apt-key adv --keyserver hkp://keyserver.ubuntu.com:80 --recv 7F0CEB10
$ echo 'deb http://downloads-distro.mongodb.org/repo/ubuntu-upstart dist 10gen' |
sudo tee /etc/apt/sources.list.d/mongodb.list
$ sudo apt-get update
$ sudo apt-get install mongodb-org
$ sudo service mongod start
NYC Data Science Academy
Installing Mongoose
 We need to install Mongoose: how node.js connect with MongoDB
 Then /login page is accessible
$ sudo npm install session-mongoose
$ npm install mongoose
NYC Data Science Academy
Edit index.js
 We need to edit index.js to support session by „vi ~/nodejs-demo/routes/index.js‟
NYC Data Science Academy
Edit index.js
exports.doLogin = function(req, res){
var user={
username:'admin',
password:'admin'
}
if(req.body.username===user.username && req.body.password===user.password){
req.session.user=user;
return res.redirect('/home');
}
else{
return res.redirect('/login');
}
};
exports.logout = function(req, res){
req.session.user=null;
res.redirect('/');
};
exports.home = function(req, res){
//delete first 5 lines, change last line
res.render('home', { title: 'Home'});
}
NYC Data Science Academy
Error Handling
 We want to tell user if they have entered the wrong information
 Edit app.js by „vi ~/nodejs-demo/app.js‟
app.use(function(req, res, next){
res.locals.user = req.session.user;
var err = req.session.error;
delete req.session.error;
res.locals.message = '';
if (err) res.locals.message = '<div class="alert alert-error">' + err +'</div>';
next();
});
app.use(app.router);
app.use(express.static(path.join(__dirname, 'public')));
NYC Data Science Academy
Error Handling
 Edit login.html by „vi ~/nodejs-demo/views/login.html‟
<% include header.html %>
<link href="/stylesheets/signin.css" rel="stylesheet">
<div class="container">
<form class="form-signin" method="post">
<%- message %>
<h2 class="form-signin-heading">Please sign in</h2>
<input type="text" class="form-control" id="username" name="username" required autofocus>
<input type="password" class="form-control" id="password" name="password" required>
<button class="btn btn-lg btn-primary btn-block" type="submit">Sign in</button>
</form>
</div>
<% include footer.html %>
NYC Data Science Academy
Error Handling
 Edit index.js by by „vi ~/nodejs-demo/routes/index.js‟
exports.doLogin = function(req, res){
var user={
username:'admin',
password:'admin'
}
if(req.body.username===user.username && req.body.password===user.password){
req.session.user=user;
return res.redirect('/home');
} else {
req.session.error='Wrong Username or Password!';
return res.redirect('/login');
}
};
NYC Data Science Academy
Error Handling
 Let's have a try:
NYC Data Science Academy
Website safety
 Our website is almost ready, but it is not safe yet.
 We can access /home without login.
NYC Data Science Academy
Refine model of our demo website
 /: anybody could visit
 Still remember app.get, app.post and app.all?
 /login: use app.all to take care of the requests of visiting /login. We call
notAuthentication function(If session.user is not null, then the user has logined in.)
first to check whether user's been logged in
 /logout: use app.get to take care of the requests of visiting /logout. We call
authentication function(If session.user is null, it will hint “please sign in”).
 /home: use app.get to take care of the requests of visiting /home. We call
authentication function(If session.user is null, it will hint “please sign in”).
NYC Data Science Academy
Edit app.js
 We add two functions and make use of them.
NYC Data Science Academy
Edit app.js
app.use(app.router);
app.use(express.static(path.join(__dirname,
'public')));
function authentication(req, res, next) {
if (!req.session.user) {
req.session.error='Please Sign In to
Visit';
return res.redirect('/login');
}
next();
}
function notAuthentication(req, res, next) {
if (req.session.user) {
req.session.error='Logged in';
return res.redirect(‟/home‟);
}
next();
}
// development only
if ('development' == app.get('env')) {
app.use(express.errorHandler());
}
app.get('/', routes.index);
//app.get('/users', user.list);
app.all('/login', notAuthentication);
app.get('/login', routes.login);
app.post('/login', routes.doLogin);
app.get('/logout', authentication);
app.get('/logout', routes.logout);
app.get('/home', authentication);
app.get('/home', routes.home);
NYC Data Science Academy
Safety check
 Let's check if it works.
 We have done it!
 Go to /home and /logout page while you are not logined in
 Go to login page while you are logined in
NYC Data Science Academy
Add some content?
 So, how to add content to our database?
 Why not use informations from other websites?
NYC Data Science Academy
Install libraries
 We need to install jsdom, jQuery, xmlhttprequest, request, htmlparser
$ sudo npm install jsdom
$ sudo npm install jQuery
$ sudo npm install xmlhttprequest
$ sudo npm install request
$ sudo npm install htmlparser
NYC Data Science Academy
What is valuable?
 Our event webpage!
 http://www.meetup.com/NYC-Open-Data/events/163300552/
NYC Data Science Academy
Add codes
 Add myUtil.js by „vi ~/nodejs_demo/myUtil.js‟
 It is used as getter function to scrap certain web page.
var MyUtil = function () {
};
var http = require('http');
var request = require('request');
MyUtil.prototype.get=function(url,callback){
request(url, function (error, response, body) {
if (!error && response.statusCode == 200) {
callback(body,response.statusCode);
}
})
}
module.exports = new MyUtil();
NYC Data Science Academy
Add codes
 And edit index.js
 Add the following codes
in the end.
var myUtil = require('../myUtil.js');
var $ = require('jQuery');
exports.index = function(req, res){
var url="http://www.meetup.com/NYC-Open-Data/events/163300552/";
console.log(url);
myUtil.get(url,function(content,status){
console.log("status:="+status);
res.send(content);
});
};
NYC Data Science Academy
Content Downloaded
 Then we visit the index page:
NYC Data Science Academy
Extract useful information
 We keep modify routes/index.js and use XPath command to extract event name and
event start time:
 Refresh the page, http://ec2-54-86-42-76.compute-1.amazonaws.com:3000/
 In the console, we can see that the name and time are correct
NYC Data Science Academy
Extract useful information
var myUtil = require('../myUtil.js');
var $ = require('jQuery');
exports.index = function(req, res){
var url="http://www.meetup.com/NYC-Open-Data/events/163300552/";
console.log(url);
myUtil.get(url,function(content,status){
console.log("status:="+status);
var events={}
events.name = $(content).find('h1[itemprop="name"]').text();
events.time = $(content).find('time[id="event-start-time"]').text();
console.log(events);
res.send(content);
});
};
NYC Data Science Academy
Use MongoDB to save JSON data
 We first create a unique folder for our database operations
 Then we create a file models/Event.js:
$ mkdir models
NYC Data Science Academy
Use MongoDB to save JSON data
 Then we add the model for events: Event.js
var mongoose = require('mongoose')
mongoose.connect('mongodb://localhost/nodejs');
exports.mongoose = mongoose;
var Schema = mongoose.Schema;
var EventSchema = new Schema({
name : String,
time : String,
});
var Event = mongoose.model("Event", EventSchema);
var EventExport = function(){};
module.exports = new EventExport();
EventExport.prototype.save = function(obj, callback) {
var instance = new Event(obj);
instance.save(function(err){
callback(err);
});
};
NYC Data Science Academy
Use MongoDB to save JSON data
 Finally, we edit index.js to call the save method:
NYC Data Science Academy
Use MongoDB to save JSON data
var myUtil = require('../myUtil.js');
var Event = require('../models/Event.js')
var $ = require('jQuery');
exports.index = function(req, res){
var url="http://www.meetup.com/NYC-Open-Data/events/163300552/";
console.log(url);
myUtil.get(url,function(content,status){
console.log("status:="+status);
var events={}
events.name = $(content).find('h1[itemprop="name"]').text();
events.time = $(content).find('time[id="event-start-time"]').text();
console.log(events);
var json = events;
Event.save(json, function(err){
if (err){
res.send({'success':false,'err':err});
} else {
res.send({'success':true});
}
});
res.send(content);
});
};
NYC Data Science Academy
Use MongoDB to save JSON data
 Refresh our page, the content on the page and console is still the same.How about
the database?
 We use
 to interact with MongoDB
 Then type the following command:
 That is our data!
$ mongo
> use nodejs
switched to db nodejs
> show collections
events
system.indexes
> db.events.find()
{ "_id" : ObjectId("535526ee43059424331b16a9"), "name" : "Node.js Workshop II:
toolkit to make your work efficiently", "time" : "Monday, April 21, 2014 7:00 PM",
"__v" : 0 }
NYC Data Science Academy
FAQ

More Related Content

What's hot

TDC2017 | Florianopolis - Trilha DevOps How we figured out we had a SRE team ...
TDC2017 | Florianopolis - Trilha DevOps How we figured out we had a SRE team ...TDC2017 | Florianopolis - Trilha DevOps How we figured out we had a SRE team ...
TDC2017 | Florianopolis - Trilha DevOps How we figured out we had a SRE team ...
tdc-globalcode
 
Node JS Express : Steps to Create Restful Web App
Node JS Express : Steps to Create Restful Web AppNode JS Express : Steps to Create Restful Web App
Node JS Express : Steps to Create Restful Web App
Edureka!
 
WordPress as the Backbone(.js)
WordPress as the Backbone(.js)WordPress as the Backbone(.js)
WordPress as the Backbone(.js)
Beau Lebens
 
Node.js Express
Node.js  ExpressNode.js  Express
Node.js Express
Eyal Vardi
 
An introduction to Vue.js
An introduction to Vue.jsAn introduction to Vue.js
An introduction to Vue.js
Javier Lafora Rey
 
Chrome enchanted 2015
Chrome enchanted 2015Chrome enchanted 2015
Chrome enchanted 2015
Chang W. Doh
 
[Bristol WordPress] Supercharging WordPress Development
[Bristol WordPress] Supercharging WordPress Development[Bristol WordPress] Supercharging WordPress Development
[Bristol WordPress] Supercharging WordPress Development
Adam Tomat
 
SocketStream
SocketStreamSocketStream
SocketStream
Paul Jensen
 
An Introduction to Vuejs
An Introduction to VuejsAn Introduction to Vuejs
An Introduction to Vuejs
Paddy Lock
 
WordPress mit Composer und Git verwalten
WordPress mit Composer und Git verwaltenWordPress mit Composer und Git verwalten
WordPress mit Composer und Git verwalten
Walter Ebert
 
Finally, Professional Frontend Dev with ReactJS, WebPack & Symfony (Symfony C...
Finally, Professional Frontend Dev with ReactJS, WebPack & Symfony (Symfony C...Finally, Professional Frontend Dev with ReactJS, WebPack & Symfony (Symfony C...
Finally, Professional Frontend Dev with ReactJS, WebPack & Symfony (Symfony C...
Ryan Weaver
 
The Point of Vue - Intro to Vue.js
The Point of Vue - Intro to Vue.jsThe Point of Vue - Intro to Vue.js
The Point of Vue - Intro to Vue.js
Holly Schinsky
 
Mojolicious, real-time web framework
Mojolicious, real-time web frameworkMojolicious, real-time web framework
Mojolicious, real-time web frameworktaggg
 
Ruby MVC from scratch with Rack
Ruby MVC from scratch with RackRuby MVC from scratch with Rack
Ruby MVC from scratch with Rack
DonSchado
 
Sanjeev ghai 12
Sanjeev ghai 12Sanjeev ghai 12
Sanjeev ghai 12
Praveen kumar
 
JavaScript performance patterns
JavaScript performance patternsJavaScript performance patterns
JavaScript performance patterns
Stoyan Stefanov
 
Bower power
Bower powerBower power
Bower power
Eric Carlisle
 
Building web framework with Rack
Building web framework with RackBuilding web framework with Rack
Building web framework with Rack
sickill
 
Rails Girls: Programming, Web Applications and Ruby on Rails
Rails Girls: Programming, Web Applications and Ruby on RailsRails Girls: Programming, Web Applications and Ruby on Rails
Rails Girls: Programming, Web Applications and Ruby on Rails
DonSchado
 
[jqconatx] Adaptive Images for Responsive Web Design
[jqconatx] Adaptive Images for Responsive Web Design[jqconatx] Adaptive Images for Responsive Web Design
[jqconatx] Adaptive Images for Responsive Web DesignChristopher Schmitt
 

What's hot (20)

TDC2017 | Florianopolis - Trilha DevOps How we figured out we had a SRE team ...
TDC2017 | Florianopolis - Trilha DevOps How we figured out we had a SRE team ...TDC2017 | Florianopolis - Trilha DevOps How we figured out we had a SRE team ...
TDC2017 | Florianopolis - Trilha DevOps How we figured out we had a SRE team ...
 
Node JS Express : Steps to Create Restful Web App
Node JS Express : Steps to Create Restful Web AppNode JS Express : Steps to Create Restful Web App
Node JS Express : Steps to Create Restful Web App
 
WordPress as the Backbone(.js)
WordPress as the Backbone(.js)WordPress as the Backbone(.js)
WordPress as the Backbone(.js)
 
Node.js Express
Node.js  ExpressNode.js  Express
Node.js Express
 
An introduction to Vue.js
An introduction to Vue.jsAn introduction to Vue.js
An introduction to Vue.js
 
Chrome enchanted 2015
Chrome enchanted 2015Chrome enchanted 2015
Chrome enchanted 2015
 
[Bristol WordPress] Supercharging WordPress Development
[Bristol WordPress] Supercharging WordPress Development[Bristol WordPress] Supercharging WordPress Development
[Bristol WordPress] Supercharging WordPress Development
 
SocketStream
SocketStreamSocketStream
SocketStream
 
An Introduction to Vuejs
An Introduction to VuejsAn Introduction to Vuejs
An Introduction to Vuejs
 
WordPress mit Composer und Git verwalten
WordPress mit Composer und Git verwaltenWordPress mit Composer und Git verwalten
WordPress mit Composer und Git verwalten
 
Finally, Professional Frontend Dev with ReactJS, WebPack & Symfony (Symfony C...
Finally, Professional Frontend Dev with ReactJS, WebPack & Symfony (Symfony C...Finally, Professional Frontend Dev with ReactJS, WebPack & Symfony (Symfony C...
Finally, Professional Frontend Dev with ReactJS, WebPack & Symfony (Symfony C...
 
The Point of Vue - Intro to Vue.js
The Point of Vue - Intro to Vue.jsThe Point of Vue - Intro to Vue.js
The Point of Vue - Intro to Vue.js
 
Mojolicious, real-time web framework
Mojolicious, real-time web frameworkMojolicious, real-time web framework
Mojolicious, real-time web framework
 
Ruby MVC from scratch with Rack
Ruby MVC from scratch with RackRuby MVC from scratch with Rack
Ruby MVC from scratch with Rack
 
Sanjeev ghai 12
Sanjeev ghai 12Sanjeev ghai 12
Sanjeev ghai 12
 
JavaScript performance patterns
JavaScript performance patternsJavaScript performance patterns
JavaScript performance patterns
 
Bower power
Bower powerBower power
Bower power
 
Building web framework with Rack
Building web framework with RackBuilding web framework with Rack
Building web framework with Rack
 
Rails Girls: Programming, Web Applications and Ruby on Rails
Rails Girls: Programming, Web Applications and Ruby on RailsRails Girls: Programming, Web Applications and Ruby on Rails
Rails Girls: Programming, Web Applications and Ruby on Rails
 
[jqconatx] Adaptive Images for Responsive Web Design
[jqconatx] Adaptive Images for Responsive Web Design[jqconatx] Adaptive Images for Responsive Web Design
[jqconatx] Adaptive Images for Responsive Web Design
 

Similar to Nodejs.meetup

09 - express nodes on the right angle - vitaliy basyuk - it event 2013 (5)
09 - express nodes on the right angle - vitaliy basyuk - it event 2013 (5)09 - express nodes on the right angle - vitaliy basyuk - it event 2013 (5)
09 - express nodes on the right angle - vitaliy basyuk - it event 2013 (5)
Igor Bronovskyy
 
Exploring Symfony's Code
Exploring Symfony's CodeExploring Symfony's Code
Exploring Symfony's Code
Wildan Maulana
 
Love at first Vue
Love at first VueLove at first Vue
Love at first Vue
Dalibor Gogic
 
Rails 3 overview
Rails 3 overviewRails 3 overview
Rails 3 overviewYehuda Katz
 
Reactive application using meteor
Reactive application using meteorReactive application using meteor
Reactive application using meteor
Sapna Upreti
 
Refresh Austin - Intro to Dexy
Refresh Austin - Intro to DexyRefresh Austin - Intro to Dexy
Refresh Austin - Intro to Dexy
ananelson
 
以Vue開發電子商務網站
架構與眉角
以Vue開發電子商務網站
架構與眉角以Vue開發電子商務網站
架構與眉角
以Vue開發電子商務網站
架構與眉角
Mei-yu Chen
 
HTML5: huh, what is it good for?
HTML5: huh, what is it good for?HTML5: huh, what is it good for?
HTML5: huh, what is it good for?Remy Sharp
 
Single Page Web Applications with WordPress REST API
Single Page Web Applications with WordPress REST APISingle Page Web Applications with WordPress REST API
Single Page Web Applications with WordPress REST API
Tejaswini Deshpande
 
Php frameworks
Php frameworksPhp frameworks
Php frameworks
Anil Kumar Panigrahi
 
CodeIgniter PHP MVC Framework
CodeIgniter PHP MVC FrameworkCodeIgniter PHP MVC Framework
CodeIgniter PHP MVC Framework
Bo-Yi Wu
 
nodejs_at_a_glance.ppt
nodejs_at_a_glance.pptnodejs_at_a_glance.ppt
nodejs_at_a_glance.ppt
WalaSidhom1
 
GHC
GHCGHC
GHC
AidIQ
 
AngularJS training - Day 1 - Basics: Why, What and basic features of AngularJS
AngularJS training - Day 1 - Basics: Why, What and basic features of AngularJSAngularJS training - Day 1 - Basics: Why, What and basic features of AngularJS
AngularJS training - Day 1 - Basics: Why, What and basic features of AngularJS
murtazahaveliwala
 
Angular server side rendering - Strategies & Technics
Angular server side rendering - Strategies & Technics Angular server side rendering - Strategies & Technics
Angular server side rendering - Strategies & Technics
Eliran Eliassy
 
Streamlining Your Applications with Web Frameworks
Streamlining Your Applications with Web FrameworksStreamlining Your Applications with Web Frameworks
Streamlining Your Applications with Web Frameworks
guestf7bc30
 
Let's play with adf 3.0
Let's play with adf 3.0Let's play with adf 3.0
Let's play with adf 3.0
Eugenio Romano
 
The Future of Responsive Design Standards
The Future of Responsive Design StandardsThe Future of Responsive Design Standards
The Future of Responsive Design Standards
Brian Fegan
 

Similar to Nodejs.meetup (20)

09 - express nodes on the right angle - vitaliy basyuk - it event 2013 (5)
09 - express nodes on the right angle - vitaliy basyuk - it event 2013 (5)09 - express nodes on the right angle - vitaliy basyuk - it event 2013 (5)
09 - express nodes on the right angle - vitaliy basyuk - it event 2013 (5)
 
Exploring Symfony's Code
Exploring Symfony's CodeExploring Symfony's Code
Exploring Symfony's Code
 
Having Fun with Play
Having Fun with PlayHaving Fun with Play
Having Fun with Play
 
Love at first Vue
Love at first VueLove at first Vue
Love at first Vue
 
Rails 3 overview
Rails 3 overviewRails 3 overview
Rails 3 overview
 
Reactive application using meteor
Reactive application using meteorReactive application using meteor
Reactive application using meteor
 
Refresh Austin - Intro to Dexy
Refresh Austin - Intro to DexyRefresh Austin - Intro to Dexy
Refresh Austin - Intro to Dexy
 
以Vue開發電子商務網站
架構與眉角
以Vue開發電子商務網站
架構與眉角以Vue開發電子商務網站
架構與眉角
以Vue開發電子商務網站
架構與眉角
 
HTML5: huh, what is it good for?
HTML5: huh, what is it good for?HTML5: huh, what is it good for?
HTML5: huh, what is it good for?
 
Single Page Web Applications with WordPress REST API
Single Page Web Applications with WordPress REST APISingle Page Web Applications with WordPress REST API
Single Page Web Applications with WordPress REST API
 
Php frameworks
Php frameworksPhp frameworks
Php frameworks
 
CodeIgniter PHP MVC Framework
CodeIgniter PHP MVC FrameworkCodeIgniter PHP MVC Framework
CodeIgniter PHP MVC Framework
 
nodejs_at_a_glance.ppt
nodejs_at_a_glance.pptnodejs_at_a_glance.ppt
nodejs_at_a_glance.ppt
 
GHC
GHCGHC
GHC
 
AngularJS training - Day 1 - Basics: Why, What and basic features of AngularJS
AngularJS training - Day 1 - Basics: Why, What and basic features of AngularJSAngularJS training - Day 1 - Basics: Why, What and basic features of AngularJS
AngularJS training - Day 1 - Basics: Why, What and basic features of AngularJS
 
Angular server side rendering - Strategies & Technics
Angular server side rendering - Strategies & Technics Angular server side rendering - Strategies & Technics
Angular server side rendering - Strategies & Technics
 
Streamlining Your Applications with Web Frameworks
Streamlining Your Applications with Web FrameworksStreamlining Your Applications with Web Frameworks
Streamlining Your Applications with Web Frameworks
 
Let's play with adf 3.0
Let's play with adf 3.0Let's play with adf 3.0
Let's play with adf 3.0
 
The Future of Responsive Design Standards
The Future of Responsive Design StandardsThe Future of Responsive Design Standards
The Future of Responsive Design Standards
 
Asp.net
Asp.netAsp.net
Asp.net
 

More from Vivian S. Zhang

Why NYC DSA.pdf
Why NYC DSA.pdfWhy NYC DSA.pdf
Why NYC DSA.pdf
Vivian S. Zhang
 
Career services workshop- Roger Ren
Career services workshop- Roger RenCareer services workshop- Roger Ren
Career services workshop- Roger Ren
Vivian S. Zhang
 
Nycdsa wordpress guide book
Nycdsa wordpress guide bookNycdsa wordpress guide book
Nycdsa wordpress guide book
Vivian S. Zhang
 
We're so skewed_presentation
We're so skewed_presentationWe're so skewed_presentation
We're so skewed_presentation
Vivian S. Zhang
 
Wikipedia: Tuned Predictions on Big Data
Wikipedia: Tuned Predictions on Big DataWikipedia: Tuned Predictions on Big Data
Wikipedia: Tuned Predictions on Big Data
Vivian S. Zhang
 
A Hybrid Recommender with Yelp Challenge Data
A Hybrid Recommender with Yelp Challenge Data A Hybrid Recommender with Yelp Challenge Data
A Hybrid Recommender with Yelp Challenge Data
Vivian S. Zhang
 
Kaggle Top1% Solution: Predicting Housing Prices in Moscow
Kaggle Top1% Solution: Predicting Housing Prices in Moscow Kaggle Top1% Solution: Predicting Housing Prices in Moscow
Kaggle Top1% Solution: Predicting Housing Prices in Moscow
Vivian S. Zhang
 
Data mining with caret package
Data mining with caret packageData mining with caret package
Data mining with caret package
Vivian S. Zhang
 
Xgboost
XgboostXgboost
Streaming Python on Hadoop
Streaming Python on HadoopStreaming Python on Hadoop
Streaming Python on Hadoop
Vivian S. Zhang
 
Kaggle Winning Solution Xgboost algorithm -- Let us learn from its author
Kaggle Winning Solution Xgboost algorithm -- Let us learn from its authorKaggle Winning Solution Xgboost algorithm -- Let us learn from its author
Kaggle Winning Solution Xgboost algorithm -- Let us learn from its author
Vivian S. Zhang
 
Xgboost
XgboostXgboost
Nyc open-data-2015-andvanced-sklearn-expanded
Nyc open-data-2015-andvanced-sklearn-expandedNyc open-data-2015-andvanced-sklearn-expanded
Nyc open-data-2015-andvanced-sklearn-expanded
Vivian S. Zhang
 
Nycdsa ml conference slides march 2015
Nycdsa ml conference slides march 2015 Nycdsa ml conference slides march 2015
Nycdsa ml conference slides march 2015
Vivian S. Zhang
 
THE HACK ON JERSEY CITY CONDO PRICES explore trends in public data
THE HACK ON JERSEY CITY CONDO PRICES explore trends in public dataTHE HACK ON JERSEY CITY CONDO PRICES explore trends in public data
THE HACK ON JERSEY CITY CONDO PRICES explore trends in public data
Vivian S. Zhang
 
Max Kuhn's talk on R machine learning
Max Kuhn's talk on R machine learningMax Kuhn's talk on R machine learning
Max Kuhn's talk on R machine learning
Vivian S. Zhang
 
Winning data science competitions, presented by Owen Zhang
Winning data science competitions, presented by Owen ZhangWinning data science competitions, presented by Owen Zhang
Winning data science competitions, presented by Owen Zhang
Vivian S. Zhang
 
Using Machine Learning to aid Journalism at the New York Times
Using Machine Learning to aid Journalism at the New York TimesUsing Machine Learning to aid Journalism at the New York Times
Using Machine Learning to aid Journalism at the New York Times
Vivian S. Zhang
 
Introducing natural language processing(NLP) with r
Introducing natural language processing(NLP) with rIntroducing natural language processing(NLP) with r
Introducing natural language processing(NLP) with r
Vivian S. Zhang
 
Bayesian models in r
Bayesian models in rBayesian models in r
Bayesian models in r
Vivian S. Zhang
 

More from Vivian S. Zhang (20)

Why NYC DSA.pdf
Why NYC DSA.pdfWhy NYC DSA.pdf
Why NYC DSA.pdf
 
Career services workshop- Roger Ren
Career services workshop- Roger RenCareer services workshop- Roger Ren
Career services workshop- Roger Ren
 
Nycdsa wordpress guide book
Nycdsa wordpress guide bookNycdsa wordpress guide book
Nycdsa wordpress guide book
 
We're so skewed_presentation
We're so skewed_presentationWe're so skewed_presentation
We're so skewed_presentation
 
Wikipedia: Tuned Predictions on Big Data
Wikipedia: Tuned Predictions on Big DataWikipedia: Tuned Predictions on Big Data
Wikipedia: Tuned Predictions on Big Data
 
A Hybrid Recommender with Yelp Challenge Data
A Hybrid Recommender with Yelp Challenge Data A Hybrid Recommender with Yelp Challenge Data
A Hybrid Recommender with Yelp Challenge Data
 
Kaggle Top1% Solution: Predicting Housing Prices in Moscow
Kaggle Top1% Solution: Predicting Housing Prices in Moscow Kaggle Top1% Solution: Predicting Housing Prices in Moscow
Kaggle Top1% Solution: Predicting Housing Prices in Moscow
 
Data mining with caret package
Data mining with caret packageData mining with caret package
Data mining with caret package
 
Xgboost
XgboostXgboost
Xgboost
 
Streaming Python on Hadoop
Streaming Python on HadoopStreaming Python on Hadoop
Streaming Python on Hadoop
 
Kaggle Winning Solution Xgboost algorithm -- Let us learn from its author
Kaggle Winning Solution Xgboost algorithm -- Let us learn from its authorKaggle Winning Solution Xgboost algorithm -- Let us learn from its author
Kaggle Winning Solution Xgboost algorithm -- Let us learn from its author
 
Xgboost
XgboostXgboost
Xgboost
 
Nyc open-data-2015-andvanced-sklearn-expanded
Nyc open-data-2015-andvanced-sklearn-expandedNyc open-data-2015-andvanced-sklearn-expanded
Nyc open-data-2015-andvanced-sklearn-expanded
 
Nycdsa ml conference slides march 2015
Nycdsa ml conference slides march 2015 Nycdsa ml conference slides march 2015
Nycdsa ml conference slides march 2015
 
THE HACK ON JERSEY CITY CONDO PRICES explore trends in public data
THE HACK ON JERSEY CITY CONDO PRICES explore trends in public dataTHE HACK ON JERSEY CITY CONDO PRICES explore trends in public data
THE HACK ON JERSEY CITY CONDO PRICES explore trends in public data
 
Max Kuhn's talk on R machine learning
Max Kuhn's talk on R machine learningMax Kuhn's talk on R machine learning
Max Kuhn's talk on R machine learning
 
Winning data science competitions, presented by Owen Zhang
Winning data science competitions, presented by Owen ZhangWinning data science competitions, presented by Owen Zhang
Winning data science competitions, presented by Owen Zhang
 
Using Machine Learning to aid Journalism at the New York Times
Using Machine Learning to aid Journalism at the New York TimesUsing Machine Learning to aid Journalism at the New York Times
Using Machine Learning to aid Journalism at the New York Times
 
Introducing natural language processing(NLP) with r
Introducing natural language processing(NLP) with rIntroducing natural language processing(NLP) with r
Introducing natural language processing(NLP) with r
 
Bayesian models in r
Bayesian models in rBayesian models in r
Bayesian models in r
 

Recently uploaded

Executive Directors Chat Leveraging AI for Diversity, Equity, and Inclusion
Executive Directors Chat  Leveraging AI for Diversity, Equity, and InclusionExecutive Directors Chat  Leveraging AI for Diversity, Equity, and Inclusion
Executive Directors Chat Leveraging AI for Diversity, Equity, and Inclusion
TechSoup
 
Chapter 3 - Islamic Banking Products and Services.pptx
Chapter 3 - Islamic Banking Products and Services.pptxChapter 3 - Islamic Banking Products and Services.pptx
Chapter 3 - Islamic Banking Products and Services.pptx
Mohd Adib Abd Muin, Senior Lecturer at Universiti Utara Malaysia
 
How libraries can support authors with open access requirements for UKRI fund...
How libraries can support authors with open access requirements for UKRI fund...How libraries can support authors with open access requirements for UKRI fund...
How libraries can support authors with open access requirements for UKRI fund...
Jisc
 
STRAND 3 HYGIENIC PRACTICES.pptx GRADE 7 CBC
STRAND 3 HYGIENIC PRACTICES.pptx GRADE 7 CBCSTRAND 3 HYGIENIC PRACTICES.pptx GRADE 7 CBC
STRAND 3 HYGIENIC PRACTICES.pptx GRADE 7 CBC
kimdan468
 
The Challenger.pdf DNHS Official Publication
The Challenger.pdf DNHS Official PublicationThe Challenger.pdf DNHS Official Publication
The Challenger.pdf DNHS Official Publication
Delapenabediema
 
1.4 modern child centered education - mahatma gandhi-2.pptx
1.4 modern child centered education - mahatma gandhi-2.pptx1.4 modern child centered education - mahatma gandhi-2.pptx
1.4 modern child centered education - mahatma gandhi-2.pptx
JosvitaDsouza2
 
Acetabularia Information For Class 9 .docx
Acetabularia Information For Class 9  .docxAcetabularia Information For Class 9  .docx
Acetabularia Information For Class 9 .docx
vaibhavrinwa19
 
The Diamond Necklace by Guy De Maupassant.pptx
The Diamond Necklace by Guy De Maupassant.pptxThe Diamond Necklace by Guy De Maupassant.pptx
The Diamond Necklace by Guy De Maupassant.pptx
DhatriParmar
 
A Strategic Approach: GenAI in Education
A Strategic Approach: GenAI in EducationA Strategic Approach: GenAI in Education
A Strategic Approach: GenAI in Education
Peter Windle
 
BÀI TẬP BỔ TRỢ TIẾNG ANH GLOBAL SUCCESS LỚP 3 - CẢ NĂM (CÓ FILE NGHE VÀ ĐÁP Á...
BÀI TẬP BỔ TRỢ TIẾNG ANH GLOBAL SUCCESS LỚP 3 - CẢ NĂM (CÓ FILE NGHE VÀ ĐÁP Á...BÀI TẬP BỔ TRỢ TIẾNG ANH GLOBAL SUCCESS LỚP 3 - CẢ NĂM (CÓ FILE NGHE VÀ ĐÁP Á...
BÀI TẬP BỔ TRỢ TIẾNG ANH GLOBAL SUCCESS LỚP 3 - CẢ NĂM (CÓ FILE NGHE VÀ ĐÁP Á...
Nguyen Thanh Tu Collection
 
Supporting (UKRI) OA monographs at Salford.pptx
Supporting (UKRI) OA monographs at Salford.pptxSupporting (UKRI) OA monographs at Salford.pptx
Supporting (UKRI) OA monographs at Salford.pptx
Jisc
 
The Diamonds of 2023-2024 in the IGRA collection
The Diamonds of 2023-2024 in the IGRA collectionThe Diamonds of 2023-2024 in the IGRA collection
The Diamonds of 2023-2024 in the IGRA collection
Israel Genealogy Research Association
 
TESDA TM1 REVIEWER FOR NATIONAL ASSESSMENT WRITTEN AND ORAL QUESTIONS WITH A...
TESDA TM1 REVIEWER  FOR NATIONAL ASSESSMENT WRITTEN AND ORAL QUESTIONS WITH A...TESDA TM1 REVIEWER  FOR NATIONAL ASSESSMENT WRITTEN AND ORAL QUESTIONS WITH A...
TESDA TM1 REVIEWER FOR NATIONAL ASSESSMENT WRITTEN AND ORAL QUESTIONS WITH A...
EugeneSaldivar
 
The approach at University of Liverpool.pptx
The approach at University of Liverpool.pptxThe approach at University of Liverpool.pptx
The approach at University of Liverpool.pptx
Jisc
 
Thesis Statement for students diagnonsed withADHD.ppt
Thesis Statement for students diagnonsed withADHD.pptThesis Statement for students diagnonsed withADHD.ppt
Thesis Statement for students diagnonsed withADHD.ppt
EverAndrsGuerraGuerr
 
Synthetic Fiber Construction in lab .pptx
Synthetic Fiber Construction in lab .pptxSynthetic Fiber Construction in lab .pptx
Synthetic Fiber Construction in lab .pptx
Pavel ( NSTU)
 
Biological Screening of Herbal Drugs in detailed.
Biological Screening of Herbal Drugs in detailed.Biological Screening of Herbal Drugs in detailed.
Biological Screening of Herbal Drugs in detailed.
Ashokrao Mane college of Pharmacy Peth-Vadgaon
 
Model Attribute Check Company Auto Property
Model Attribute  Check Company Auto PropertyModel Attribute  Check Company Auto Property
Model Attribute Check Company Auto Property
Celine George
 
Exploiting Artificial Intelligence for Empowering Researchers and Faculty, In...
Exploiting Artificial Intelligence for Empowering Researchers and Faculty, In...Exploiting Artificial Intelligence for Empowering Researchers and Faculty, In...
Exploiting Artificial Intelligence for Empowering Researchers and Faculty, In...
Dr. Vinod Kumar Kanvaria
 
Unit 8 - Information and Communication Technology (Paper I).pdf
Unit 8 - Information and Communication Technology (Paper I).pdfUnit 8 - Information and Communication Technology (Paper I).pdf
Unit 8 - Information and Communication Technology (Paper I).pdf
Thiyagu K
 

Recently uploaded (20)

Executive Directors Chat Leveraging AI for Diversity, Equity, and Inclusion
Executive Directors Chat  Leveraging AI for Diversity, Equity, and InclusionExecutive Directors Chat  Leveraging AI for Diversity, Equity, and Inclusion
Executive Directors Chat Leveraging AI for Diversity, Equity, and Inclusion
 
Chapter 3 - Islamic Banking Products and Services.pptx
Chapter 3 - Islamic Banking Products and Services.pptxChapter 3 - Islamic Banking Products and Services.pptx
Chapter 3 - Islamic Banking Products and Services.pptx
 
How libraries can support authors with open access requirements for UKRI fund...
How libraries can support authors with open access requirements for UKRI fund...How libraries can support authors with open access requirements for UKRI fund...
How libraries can support authors with open access requirements for UKRI fund...
 
STRAND 3 HYGIENIC PRACTICES.pptx GRADE 7 CBC
STRAND 3 HYGIENIC PRACTICES.pptx GRADE 7 CBCSTRAND 3 HYGIENIC PRACTICES.pptx GRADE 7 CBC
STRAND 3 HYGIENIC PRACTICES.pptx GRADE 7 CBC
 
The Challenger.pdf DNHS Official Publication
The Challenger.pdf DNHS Official PublicationThe Challenger.pdf DNHS Official Publication
The Challenger.pdf DNHS Official Publication
 
1.4 modern child centered education - mahatma gandhi-2.pptx
1.4 modern child centered education - mahatma gandhi-2.pptx1.4 modern child centered education - mahatma gandhi-2.pptx
1.4 modern child centered education - mahatma gandhi-2.pptx
 
Acetabularia Information For Class 9 .docx
Acetabularia Information For Class 9  .docxAcetabularia Information For Class 9  .docx
Acetabularia Information For Class 9 .docx
 
The Diamond Necklace by Guy De Maupassant.pptx
The Diamond Necklace by Guy De Maupassant.pptxThe Diamond Necklace by Guy De Maupassant.pptx
The Diamond Necklace by Guy De Maupassant.pptx
 
A Strategic Approach: GenAI in Education
A Strategic Approach: GenAI in EducationA Strategic Approach: GenAI in Education
A Strategic Approach: GenAI in Education
 
BÀI TẬP BỔ TRỢ TIẾNG ANH GLOBAL SUCCESS LỚP 3 - CẢ NĂM (CÓ FILE NGHE VÀ ĐÁP Á...
BÀI TẬP BỔ TRỢ TIẾNG ANH GLOBAL SUCCESS LỚP 3 - CẢ NĂM (CÓ FILE NGHE VÀ ĐÁP Á...BÀI TẬP BỔ TRỢ TIẾNG ANH GLOBAL SUCCESS LỚP 3 - CẢ NĂM (CÓ FILE NGHE VÀ ĐÁP Á...
BÀI TẬP BỔ TRỢ TIẾNG ANH GLOBAL SUCCESS LỚP 3 - CẢ NĂM (CÓ FILE NGHE VÀ ĐÁP Á...
 
Supporting (UKRI) OA monographs at Salford.pptx
Supporting (UKRI) OA monographs at Salford.pptxSupporting (UKRI) OA monographs at Salford.pptx
Supporting (UKRI) OA monographs at Salford.pptx
 
The Diamonds of 2023-2024 in the IGRA collection
The Diamonds of 2023-2024 in the IGRA collectionThe Diamonds of 2023-2024 in the IGRA collection
The Diamonds of 2023-2024 in the IGRA collection
 
TESDA TM1 REVIEWER FOR NATIONAL ASSESSMENT WRITTEN AND ORAL QUESTIONS WITH A...
TESDA TM1 REVIEWER  FOR NATIONAL ASSESSMENT WRITTEN AND ORAL QUESTIONS WITH A...TESDA TM1 REVIEWER  FOR NATIONAL ASSESSMENT WRITTEN AND ORAL QUESTIONS WITH A...
TESDA TM1 REVIEWER FOR NATIONAL ASSESSMENT WRITTEN AND ORAL QUESTIONS WITH A...
 
The approach at University of Liverpool.pptx
The approach at University of Liverpool.pptxThe approach at University of Liverpool.pptx
The approach at University of Liverpool.pptx
 
Thesis Statement for students diagnonsed withADHD.ppt
Thesis Statement for students diagnonsed withADHD.pptThesis Statement for students diagnonsed withADHD.ppt
Thesis Statement for students diagnonsed withADHD.ppt
 
Synthetic Fiber Construction in lab .pptx
Synthetic Fiber Construction in lab .pptxSynthetic Fiber Construction in lab .pptx
Synthetic Fiber Construction in lab .pptx
 
Biological Screening of Herbal Drugs in detailed.
Biological Screening of Herbal Drugs in detailed.Biological Screening of Herbal Drugs in detailed.
Biological Screening of Herbal Drugs in detailed.
 
Model Attribute Check Company Auto Property
Model Attribute  Check Company Auto PropertyModel Attribute  Check Company Auto Property
Model Attribute Check Company Auto Property
 
Exploiting Artificial Intelligence for Empowering Researchers and Faculty, In...
Exploiting Artificial Intelligence for Empowering Researchers and Faculty, In...Exploiting Artificial Intelligence for Empowering Researchers and Faculty, In...
Exploiting Artificial Intelligence for Empowering Researchers and Faculty, In...
 
Unit 8 - Information and Communication Technology (Paper I).pdf
Unit 8 - Information and Communication Technology (Paper I).pdfUnit 8 - Information and Communication Technology (Paper I).pdf
Unit 8 - Information and Communication Technology (Paper I).pdf
 

Nodejs.meetup

  • 1. NYC Data Science Academy Node.JS in Action (Copyright materials, all right reserved) Sign up for Node.js beginner class at www.nycdatascience.com or email vivian.zhang@supstat.com
  • 2. NYC Data Science Academy Overview  Deployment of Node.js on AWS EC2 Instance  Use Bootstrap Framework for our page  Rules of Routes, Session and MongoDB, Error Handling and Visiting Control  Web Scrapper  Save JSON data into MongoDB
  • 3. NYC Data Science Academy AWS Security Group  You should Add HTTP Rules  For convenience, you could allow All TCP rules
  • 4. NYC Data Science Academy Installation on Ubuntu  Our machine is Ubuntu 12.04 LTS, 64 bits  We install node and express from apt-get  Check if we are having the right configuration $ sudo add-apt-repository ppa:chris-lea/node.js $ sudo apt-get update $ sudo apt-get install nodejs $ sudo npm install express@3 -g $ sudo apt-get install unzip $ sudo apt-get install build-essential $ node -v v0.10.26 $ npm -v 1.4.3 $ express -V 3.5.1
  • 5. NYC Data Science Academy Start Our first Project  In ~/ directory, we can start our first express project  If you see the notification, then it is OK!  Visit your public address on port 3000 and you will see $ express -e nodejs-demo $ cd nodejs-demo $ sudo npm install $ node app.js
  • 6. NYC Data Science Academy Supervisor  If we modify our code, we need to restart our server. That is inconvenient.  By supervisor, we can modify our code and the server will restart automatically. $ sudo npm install supervisor -g $ supervisor app.js Running node-supervisor with program 'app.js' --watch '.' --extensions 'node,js' --exec 'node' Starting child process with 'node app.js' Watching directory '/home/ubuntu/nodejs-demo' for changes. Express server listening on port 3000
  • 7. NYC Data Science Academy Intro to the working directory  node_modules: Store all the dependent libraries(every project manage its own dependencies).  package.json: Project dependencies configuration and developer information  app.js: Application starting file  public: Static files(css,js,img)  routes: Routes files(C in MVC, controller)  Views: Page files(Ejs template)
  • 8. NYC Data Science Academy Support html files  And rename views/index.ejs to views/index.html  Add the following lines in app.js, see next page for codes  Visit your website $ mv views/index.ejs views/index.html
  • 9. NYC Data Science Academy Support html files var express = require('express'); var routes = require('./routes'); var user = require('./routes/user'); var http = require('http'); var path = require('path'); var ejs = require('ejs'); var app = express(); // all environments app.set('port', process.env.PORT || 3000); app.set('views', path.join(__dirname, 'views')); // app.set('view engine', ‟ejs'); app.engine('.html', ejs.__express); app.set('view engine', 'html'); app.use(express.favicon()); app.use(express.logger('dev'));
  • 10. NYC Data Science Academy Use Bootstrap Framework  Bootstrap Framework is one of the most popular frameworks for front-end.  Download it from http://getbootstrap.com/ and unzip.  And we also need jQuery.  Check whether your “~/nodejs-demo/public/stylesheets” has three .css files and whether „~/nodejs-demo/public/javascripts‟ has two .js files. $ cd ~/ $ wget https://github.com/twbs/bootstrap/releases/download/v3.1.1/bootstrap- 3.1.1-dist.zip $ unzip bootstrap-3.1.1-dist.zip $ cd ~/bootstrap-3.1.1-dist $ cp css/*.min.css ~/nodejs-demo/public/stylesheets/ $ cd js/ $ wget http://code.jquery.com/jquery-1.9.1.min.js $ cp *.min.js ~/nodejs-demo/public/javascripts $ cd ~/nodejs-demo $ ls public/javascripts $ ls public/stylesheets
  • 11. NYC Data Science Academy Split index.html  We want a common header and footer by spliting index.html into header.html, index.html and footer.html  First, we add these two news files in foldr views/
  • 12. NYC Data Science Academy header.html  We edit the header.html like this <!DOCTYPE html> <html lang="en"> <head> <meta charset="utf-8"> <title><%=: title %></title> <!-- Bootstrap --> <link href="/stylesheets/bootstrap.min.css" rel="stylesheet" media="screen"> <!-- <link href="css/bootstrap-responsive.min.css" rel="stylesheet" media="screen"> -- > </head> <body screen_capture_injected="true"> $ vi ~/nodejs-demo/views/header.html
  • 13. NYC Data Science Academy footer.html  We edit the footer.html like this <script src="/javascripts/jquery-1.9.1.min.js"> </script> <script src="/javascripts/bootstrap.min.js"> </script> </body> </html> $ vi ~/nodejs-demo/views/footer.html
  • 14. NYC Data Science Academy index.html  Through ejs(emmeded javascript), we can include our header and footer in index.html  modify index.html <% include header.html %> <h1><%= title %> </h1> <p>Welcome to <%= title %> </p> <% include footer.html %> $ rm ~/nodejs-demo/views/index.html $ vi ~/nodejs-demo/views/index.html
  • 15. NYC Data Science Academy Routes of our demo website  Routes: pages, authorization and action  / : index.html, No need to login to visit.  /home : home.html, Need to login to visit.  /login : login.html, redirect to home.html with correct username and password  /logout : No corresponding html file  redirect back to index.html after logout  We can add routes to enable these features.
  • 16. NYC Data Science Academy Add routes  In app.js, we edit it by “vi ~/nodejs-demo/app.js”  Note: app.get is get request, app.post is post request, get.all is request for this path. app.get('/', routes.index); //app.get('/users', user.list); app.get('/login', routes.login); app.post('/login', routes.doLogin); app.get('/logout', routes.logout); app.get('/home', routes.home);
  • 17. NYC Data Science Academy Add routes  Then we edit routes/index.js by by “vi ~/nodejs-demo/routes/index.js”
  • 18. NYC Data Science Academy Add routes exports.index = function(req, res){ res.render('index', { title: 'Express' }); }; exports.login = function(req, res){ res.render('login', { title: 'User Login'}); }; exports.doLogin = function(req, res){ var user={ username:'admin', password:'admin' } if(req.body.username===user.username && req.body.password===user.password){ res.redirect('/home'); } res.redirect('/login'); }; exports.logout = function(req, res){ res.redirect('/'); }; exports.home = function(req, res){ var user={ username:'admin', password:'admin' } res.render('home', { title: 'Home',user: user}); };
  • 19. NYC Data Science Academy Add pages  Create new home page by “vi ~/nodejs-demo/views/home.html” , see page 20  Create new login page by “vi ~/nodejs-demo/views/login.html”, see page 21
  • 20. NYC Data Science Academy Create home.html <% include header.html %> <h1>Welcome <%= user.username %>!</h1> <a class="btn" href="/logout">Logout</a> <% include footer.html %>
  • 21. NYC Data Science Academy Create login.html <% include header.html %> <link href="/stylesheets/signin.css" rel="stylesheet"> <div class="container"> <form class="form-signin" method="post"> <h2 class="form-signin-heading">Please sign in</h2> <input type="text" class="form-control" id="username" name="username" required autofocus> <input type="password" class="form-control" id="password" name="password" required> <button class="btn btn-lg btn-primary btn-block" type="submit">Sign in</button> </form> </div> <% include footer.html %>
  • 22. NYC Data Science Academy Add pages  And we edit index.html by „vi ~/nodejs-demo/views/index.html‟ <% include header.html %> <h1><%= title %> </h1> <p>Welcome to <%= title %> <a href="/login">Signin</a> </p> <% include footer.html %>
  • 23. NYC Data Science Academy Improve the look  This is what we see at /login.html:  Is there anyway we can make it better?
  • 24. NYC Data Science Academy Edit the Bootstrap Style  We create signin.css file to public/stylesheets/ by  “vi ~/nodejs-demo/public/stylesheets/signin.css”  Copy/past left side and right side into the file body { padding-top: 40px; padding-bottom: 40px; background-color: #eee; } .form-signin { max-width: 330px; padding: 15px; margin: 0 auto; } .form-signin .form-signin-heading, .form-signin .checkbox { margin-bottom: 10px; } .form-signin .checkbox { font-weight: normal; } .form-signin .form-control { position: relative; font-size: 16px; height: auto; padding: 10px; -webkit-box-sizing: border-box; -moz-box-sizing: border-box; box-sizing: border-box; } .form-signin .form-control:focus { z-index: 2; } .form-signin input[type="text"] { margin-bottom: -1px; border-bottom-left-radius: 0; border-bottom-right-radius: 0; } .form-signin input[type="password"] { margin-bottom: 10px; border-top-left-radius: 0; border-top-right-radius: 0; }
  • 25. NYC Data Science Academy Edit the Bootstrap Style  Then the website looks like:  Use admin and admin to login!
  • 26. NYC Data Science Academy Session  In “routes/index.js” file , when we call function “exports.doLogin”, if username and password are correct, we will redirect to home.  In the same file, when we call function “exports.home”, we render the page and pass username to the home.html by the following specific:  Why can't we assign the username to session so that we do not need pass to each page again? res.redirect('/home'); res.render('home', { title: 'Home',user: user});
  • 27. NYC Data Science Academy Storage of data  On local drive, we store user credentials into cookie files.  On server side, we also store session and user credentials in database, like Redis, MongoDB.  MongoDB pass the username object to each page instead of asking node.js passing the username object between pages.
  • 28. NYC Data Science Academy Edit app.js  The Order of Commands Matters !!!
  • 29. NYC Data Science Academy Edit app.js app.set('view engine', 'html'); app.use(express.favicon()); app.use(express.logger('dev')); app.use(express.bodyParser()); app.use(express.json()); app.use(express.urlencoded()); app.use(express.methodOverride()); app.use(express.cookieParser()); app.use(express.cookieSession({secret : 'nycdatascience.com'})); app.use(express.session({ secret : 'nycdatascience.com', store: store, cookie: { maxAge: 900000 } })); app.use(function(req, res, next){ res.locals.user = req.session.user; next(); }); app.use(app.router); app.use(express.static(path.join(__dirname, 'public'))); var express = require('express'); var routes = require('./routes'); var user = require('./routes/user'); var http = require('http'); var path = require('path'); var ejs = require('ejs'); var SessionStore = require("session- mongoose")(express); var store = new SessionStore({ url: "mongodb://localhost/session", interval: 120000 }); var app = express();
  • 30. NYC Data Science Academy MongoDB on Ubuntu  Following the official document, we successfully installed MongoDB  http://docs.mongodb.org/manual/tutorial/install-mongodb-on-ubuntu/ $ sudo apt-key adv --keyserver hkp://keyserver.ubuntu.com:80 --recv 7F0CEB10 $ echo 'deb http://downloads-distro.mongodb.org/repo/ubuntu-upstart dist 10gen' | sudo tee /etc/apt/sources.list.d/mongodb.list $ sudo apt-get update $ sudo apt-get install mongodb-org $ sudo service mongod start
  • 31. NYC Data Science Academy Installing Mongoose  We need to install Mongoose: how node.js connect with MongoDB  Then /login page is accessible $ sudo npm install session-mongoose $ npm install mongoose
  • 32. NYC Data Science Academy Edit index.js  We need to edit index.js to support session by „vi ~/nodejs-demo/routes/index.js‟
  • 33. NYC Data Science Academy Edit index.js exports.doLogin = function(req, res){ var user={ username:'admin', password:'admin' } if(req.body.username===user.username && req.body.password===user.password){ req.session.user=user; return res.redirect('/home'); } else{ return res.redirect('/login'); } }; exports.logout = function(req, res){ req.session.user=null; res.redirect('/'); }; exports.home = function(req, res){ //delete first 5 lines, change last line res.render('home', { title: 'Home'}); }
  • 34. NYC Data Science Academy Error Handling  We want to tell user if they have entered the wrong information  Edit app.js by „vi ~/nodejs-demo/app.js‟ app.use(function(req, res, next){ res.locals.user = req.session.user; var err = req.session.error; delete req.session.error; res.locals.message = ''; if (err) res.locals.message = '<div class="alert alert-error">' + err +'</div>'; next(); }); app.use(app.router); app.use(express.static(path.join(__dirname, 'public')));
  • 35. NYC Data Science Academy Error Handling  Edit login.html by „vi ~/nodejs-demo/views/login.html‟ <% include header.html %> <link href="/stylesheets/signin.css" rel="stylesheet"> <div class="container"> <form class="form-signin" method="post"> <%- message %> <h2 class="form-signin-heading">Please sign in</h2> <input type="text" class="form-control" id="username" name="username" required autofocus> <input type="password" class="form-control" id="password" name="password" required> <button class="btn btn-lg btn-primary btn-block" type="submit">Sign in</button> </form> </div> <% include footer.html %>
  • 36. NYC Data Science Academy Error Handling  Edit index.js by by „vi ~/nodejs-demo/routes/index.js‟ exports.doLogin = function(req, res){ var user={ username:'admin', password:'admin' } if(req.body.username===user.username && req.body.password===user.password){ req.session.user=user; return res.redirect('/home'); } else { req.session.error='Wrong Username or Password!'; return res.redirect('/login'); } };
  • 37. NYC Data Science Academy Error Handling  Let's have a try:
  • 38. NYC Data Science Academy Website safety  Our website is almost ready, but it is not safe yet.  We can access /home without login.
  • 39. NYC Data Science Academy Refine model of our demo website  /: anybody could visit  Still remember app.get, app.post and app.all?  /login: use app.all to take care of the requests of visiting /login. We call notAuthentication function(If session.user is not null, then the user has logined in.) first to check whether user's been logged in  /logout: use app.get to take care of the requests of visiting /logout. We call authentication function(If session.user is null, it will hint “please sign in”).  /home: use app.get to take care of the requests of visiting /home. We call authentication function(If session.user is null, it will hint “please sign in”).
  • 40. NYC Data Science Academy Edit app.js  We add two functions and make use of them.
  • 41. NYC Data Science Academy Edit app.js app.use(app.router); app.use(express.static(path.join(__dirname, 'public'))); function authentication(req, res, next) { if (!req.session.user) { req.session.error='Please Sign In to Visit'; return res.redirect('/login'); } next(); } function notAuthentication(req, res, next) { if (req.session.user) { req.session.error='Logged in'; return res.redirect(‟/home‟); } next(); } // development only if ('development' == app.get('env')) { app.use(express.errorHandler()); } app.get('/', routes.index); //app.get('/users', user.list); app.all('/login', notAuthentication); app.get('/login', routes.login); app.post('/login', routes.doLogin); app.get('/logout', authentication); app.get('/logout', routes.logout); app.get('/home', authentication); app.get('/home', routes.home);
  • 42. NYC Data Science Academy Safety check  Let's check if it works.  We have done it!  Go to /home and /logout page while you are not logined in  Go to login page while you are logined in
  • 43. NYC Data Science Academy Add some content?  So, how to add content to our database?  Why not use informations from other websites?
  • 44. NYC Data Science Academy Install libraries  We need to install jsdom, jQuery, xmlhttprequest, request, htmlparser $ sudo npm install jsdom $ sudo npm install jQuery $ sudo npm install xmlhttprequest $ sudo npm install request $ sudo npm install htmlparser
  • 45. NYC Data Science Academy What is valuable?  Our event webpage!  http://www.meetup.com/NYC-Open-Data/events/163300552/
  • 46. NYC Data Science Academy Add codes  Add myUtil.js by „vi ~/nodejs_demo/myUtil.js‟  It is used as getter function to scrap certain web page. var MyUtil = function () { }; var http = require('http'); var request = require('request'); MyUtil.prototype.get=function(url,callback){ request(url, function (error, response, body) { if (!error && response.statusCode == 200) { callback(body,response.statusCode); } }) } module.exports = new MyUtil();
  • 47. NYC Data Science Academy Add codes  And edit index.js  Add the following codes in the end. var myUtil = require('../myUtil.js'); var $ = require('jQuery'); exports.index = function(req, res){ var url="http://www.meetup.com/NYC-Open-Data/events/163300552/"; console.log(url); myUtil.get(url,function(content,status){ console.log("status:="+status); res.send(content); }); };
  • 48. NYC Data Science Academy Content Downloaded  Then we visit the index page:
  • 49. NYC Data Science Academy Extract useful information  We keep modify routes/index.js and use XPath command to extract event name and event start time:  Refresh the page, http://ec2-54-86-42-76.compute-1.amazonaws.com:3000/  In the console, we can see that the name and time are correct
  • 50. NYC Data Science Academy Extract useful information var myUtil = require('../myUtil.js'); var $ = require('jQuery'); exports.index = function(req, res){ var url="http://www.meetup.com/NYC-Open-Data/events/163300552/"; console.log(url); myUtil.get(url,function(content,status){ console.log("status:="+status); var events={} events.name = $(content).find('h1[itemprop="name"]').text(); events.time = $(content).find('time[id="event-start-time"]').text(); console.log(events); res.send(content); }); };
  • 51. NYC Data Science Academy Use MongoDB to save JSON data  We first create a unique folder for our database operations  Then we create a file models/Event.js: $ mkdir models
  • 52. NYC Data Science Academy Use MongoDB to save JSON data  Then we add the model for events: Event.js var mongoose = require('mongoose') mongoose.connect('mongodb://localhost/nodejs'); exports.mongoose = mongoose; var Schema = mongoose.Schema; var EventSchema = new Schema({ name : String, time : String, }); var Event = mongoose.model("Event", EventSchema); var EventExport = function(){}; module.exports = new EventExport(); EventExport.prototype.save = function(obj, callback) { var instance = new Event(obj); instance.save(function(err){ callback(err); }); };
  • 53. NYC Data Science Academy Use MongoDB to save JSON data  Finally, we edit index.js to call the save method:
  • 54. NYC Data Science Academy Use MongoDB to save JSON data var myUtil = require('../myUtil.js'); var Event = require('../models/Event.js') var $ = require('jQuery'); exports.index = function(req, res){ var url="http://www.meetup.com/NYC-Open-Data/events/163300552/"; console.log(url); myUtil.get(url,function(content,status){ console.log("status:="+status); var events={} events.name = $(content).find('h1[itemprop="name"]').text(); events.time = $(content).find('time[id="event-start-time"]').text(); console.log(events); var json = events; Event.save(json, function(err){ if (err){ res.send({'success':false,'err':err}); } else { res.send({'success':true}); } }); res.send(content); }); };
  • 55. NYC Data Science Academy Use MongoDB to save JSON data  Refresh our page, the content on the page and console is still the same.How about the database?  We use  to interact with MongoDB  Then type the following command:  That is our data! $ mongo > use nodejs switched to db nodejs > show collections events system.indexes > db.events.find() { "_id" : ObjectId("535526ee43059424331b16a9"), "name" : "Node.js Workshop II: toolkit to make your work efficiently", "time" : "Monday, April 21, 2014 7:00 PM", "__v" : 0 }
  • 56. NYC Data Science Academy FAQ