Download Konservasi dan Rehabilitasi Lahan Gambut untuk Penurunan. Emisi Carbon: Aplikasi ...... Namun demikian eksploitasi HRG yang berlebihan tanpa disertai upaya konservasi ...... dipulihkan melalui kegiatan reklamasi dan rehabilitasi. Areal
Download Konservasi dan Rehabilitasi Lahan Gambut untuk Penurunan. Emisi Carbon: Aplikasi ...... Namun demikian eksploitasi HRG yang berlebihan tanpa disertai upaya konservasi ...... dipulihkan melalui kegiatan reklamasi dan rehabilitasi. Areal
Download meluncurkan 6 produk Asuransi Mikro Generik (Si Bijak, Si Peci, Rumahku, Stop ... Separuh perusahaan asuransi jiwa yang belum memasarkan asuransi mikro.
Download Konservasi dan Rehabilitasi Lahan Gambut untuk Penurunan. Emisi Carbon: Aplikasi ...... Namun demikian eksploitasi HRG yang berlebihan tanpa disertai upaya konservasi ...... dipulihkan melalui kegiatan reklamasi dan rehabilitasi. Areal
Patterns are formalized best practices that the programmer must implement themselves in the application. Object-oriented design patterns typically show relationships and interactions between classes or objects, without specifying the final applicatio
If you are searched for the book Gpz750r workshop manual in pdf form, then you've come to right site. We present utter option of this ebook in txt, DjVu, ePub, doc
o Kitab-kitab Takhrij Al-Hadits o Kitab-kitab Fiqh Kontemporer ... o Makalah-makalah ilmiah . Cara Memberi Rujukan •Setiap Nukilan Bahasa dan Istilah
http://www.careers.unsw.edu.au/careerEd/workshops/downloads/resumeWriting-activities-v1.pdf - 1 - Resume Writing Workshop Activities The following activities can be
/pagina 2 Arduino? Arduino is een open-source ontwikkelbord, waarmee het mogelijk wordt om informatica te koppelen aan fysieke objecten. Het is dus een apparaat
1 Welcome to Olympus hank you for attending the Olympus Australia Endoscope Cleaning and Maintenance Workshop. We trust that you will enjoy this opportunity to
Macintosh and PC computers, Instructor's Guide, and more. Springer-Verlag can be contacted at: 1-800-Springer, or .... from an instructor's guide and answers for selected activities to sample exams and syllabi. Acknowledgments: ..... Activity 5- 2: P
MISRA C:2012 Workshop 2 3 rryphss.co This disclaimer is in MISRA-C:2004 and, less prominently, in MISRA-C:2012. However it should be printed as a poster on the office
Download 18 Mei 2016 ... Bimbingan Teknik Pengunaan Aplikasi Jurnal Online bagi ... Peraturan Menteri Pendidikan Nasional No. 22 .... Contoh tampilan jurnal (1) ...
maintenance products workshop, service and safety hard resilient sealant oil concentrate diesel combustion glue glue glue putty cartridge assembly paste carburetor
Download Introduction: Our ice carvers will give your delegates a full introduction and outline the procedures that will take place throughout the workshop. Demonstration: Our professional ice sculptor will demonstrate (show off!) carving techn
Kefir Workshop. Kefir Manual for 1l of Culture. The milk kefir grain culture most likely originated in the Caucasus mountains. To ferment milk into kefir, use lukewarm whole-fat cow milk poured into a wide mouth jar, leaving a quarter of the volume e
Download Cara membuka Powerpoint adalah melalui tombol [Start]>[All. Programs]>[ Microsoft Office]>Powerpoint. .... Dalam PowerPoint, Anda dapat memasukkan teks ke Text box atau kotak teks. Text box ada dua macam, ada yang ... akan langsung dita
BARRANCA TAX LAW – CPE Seminars – 2011 tel (732) 687-0346 * email: [email protected] * www.barrancataxlaw.com Accounting for Income Taxes:
Preceptor Workshop: Overview. Clinical preceptors provide the WOCNEP student with the clinical experiences necessary to ... Adult education implies that the nurse seeking WOC nursing education is autonomous, self- directed, and able to ..... without
Pinnacle Business Link Ltd. 2 Benefits of Entrepreneurship Development Workshops EDWs are designed to develop various competencies for the beneficiaries as follows:
Download Introduction: Our ice carvers will give your delegates a full introduction and outline the procedures that will take place throughout the workshop. Demonstration: Our professional ice sculptor will demonstrate (show off!) carving techn
Student Workshop Respect: It ... during which children are highly receptive to moral values, eager to figure out how and why they ... Later that night, out trick
MIR srl Spirolab / Spirolab II - Service Manual Warning: Batteries may explode if defective or damaged or disposed of in fire. Do not short-circuit the batteries!
If looking for a book Mitsubishi 4m40 workshop manual price in pdf form, then you have come on to the faithful site. We present the complete edition of this ebook in
Node.js Workshop
Tom Hughes-Croucher Chief Evangelist / Node Tech Lead @sh1mmer [email protected]
Overview • • • • • • • • •
Running order
Introduction Why Server-Side JavaScript? What is Node? Using Node Understanding Node Node Ecosystem Programming Style More Complex applications Deploying Node apps to the cloud
Introduction • Tom Hughes-Croucher • Chief Evangelist at Joyent • Node.js core contributor • Author of "Up and Running with Node.js"
Scalable Server-Side Code with JavaScript
Node
Up and Running
Tom Hughes-Croucher
Major update this week
Why Server-Side JavaScript?
JavaScript programmers 3>2>1
Massive Code base of jQuery and other JS libraries
Laziness or “I’m sick of writing stuff twice” I could have said efficiency, but I think we all secretly long to sit around in our underwear.
Progressive Enhancement is free* Remember WWCD (What Would Crockford Do)
*close enough
TL;DR: SSJS is Awesome Like a Unicorn riding a Narwhal
If SSJS is so awesome why is it "new"?
1. Professionalism
“Yahoo!'s corporate motto is: Don't be eval().“
2. JavaScript Runtimes
Runtimes • V8 (Google), C++ • Spider Monkey (Mozilla), C++ • Rhino (Mozilla), Java
V8
Spider Monkey
JavaScript Performance
8x
Sep 08!
Mar 11!
Anatomy of SSJS
Node
{ !
Runtime != Browser
No DOM (By default, anyway)
Summary • Benefits of SSJS • Lots of JavaScript expertise • Lots of web code in JS libraries • Write once, run anywhere • Progressive Enhancement • Why SSJS happened now • Professionalism in JavaScript • New generation of JavaScript runtimes
Nave • Installs and versions Node • Allows Node shells with specific versions • Allows you to get 'latest' <-- Stable • May add 'unstable' option in future
Manual Installation
Go to http://nodejs.org/#download and get the URL of the current stable release
Enki:~ $ wget -q http://nodejs.org/dist/nodev0.4.10.tar.gz Enki:~ $ tar xzf node-v0.4.10.tar.gz Enki:~ $ cd node-v0.4.10 Enki:~/node-v0.4.10 $
Local or system?
Local
Enki:~/node-v0.4.10 $ mkdir ~/local Enki:~/node-v0.4.10 $ ./configure --prefix=~/local Checking for program g++ or c++ : /usr/bin/g++ Checking for program cpp : /usr/bin/cpp ... Checking for fdatasync(2) with c++ : no 'configure' finished successfully (3.466s)
> console.log('Hello World'); Hello World > .help .clear Break, and also clear the local context. .exit Exit the prompt .help Show repl options > .clear Clearing context... > .exit Enki:~ $
Enki:~ $ node > var foo = "bar"; > foo; 'bar' > .clear Clearing context... > foo ReferenceError: foo is not defined at [object Context]:1:1 at Interface. (repl:98:19) at Interface.emit (events:27:15) at Interface._ttyWrite (readline:295:12) at Interface.write (readline:132:30) at Stream. (repl:79:9) at Stream.emit (events:27:15) at IOWatcher.callback (net:489:16)
var http = require('http'); http.createServer(function (req, res) { res.writeHead(200, {'Content-Type': 'text/plain'}); res.end('Hello World\n'); }).listen(8124, "127.0.0.1"); console.log('Server running at http://127.0.0.1:8124/');
var http = require('http'); //include the http library
http.createServer(function (req, res) { }).listen(8124, "127.0.0.1"); //create an http server //when ‘stuff’ happens call this anonymous function //listen on port 8124 of the IP 127.0.0.1
http.createServer(function (req, res) { res.writeHead(200, {'Content-Type': 'text/plain'}); res.end('Hello World\n'); }) //when ‘stuff’ happens my function fires //I get a request object and a response object //I write to the response object header //HTTP status 200 and content-type ‘text/plain’ //close the response with the body: //Hello World
console.log('Server running at http://127.0.0.1:8124/'); //write Server is running at http://127.0.0.1:8124/ //to the console
Interactive Debugging
Enki:~/Code/node-examples $ node --debug helloworld.js debugger listening on port 5858 Server running at http://127.0.0.1:8124/
Exercise • Fetch the NYTimes.com and output the contents to the console
• Create a web server • Create an HTTP client • POST data to your web server • Output the POST data to console
Events
object.on('event', function() { //stuff } );
EventEmitter
EventEmitter • manage "event handlers" • list of functions to be called per event
• provide mechanism to trigger events
var util = require('util'), EE = require('events').EventEmitter; util.inherits(MyClass, EE); var myObj = new MyClass(); //nb using first class functions myObj.on('something', function);
math.js exports.add = function() { var sum = 0, i = 0, args = arguments, l = args.length; while (i < l) { sum += args[i++]; } return sum; };
increment.js var add = require('math').add; exports.increment = function(val) { return add(val, 1); }; var inc = require('increment').increment; var a = 1; inc(a); // 2
Protip exports.awesome = function() { //yay my code is awesomesauce }; var exports.fail = function() { //exports is a global //by redeclaring it as //a local variable //your code _will_ fail };
Exercise • Create a CommonJS module called "fish" • Provide functions to: • swim • mouth breath • flop around • Import your module into a node project • Call the various functions
Node Package Manager (NPM)
NPM is written in JavaScript for Node
Enki:~ $ cat `which npm` #!/usr/bin/env node ;(function () { // wrapper in case we're in module_context mode var log = require("../lib/utils/log") log.waitForConfig() log.info("ok", "it worked if it ends with") var fs = require("../lib/utils/graceful-fs") , path = require("path") , sys = require("../lib/utils/sys") , npm = require("../npm") , ini = require("../lib/utils/ini") , rm = require("../lib/utils/rm-rf")
app.use(express.bodyParser()); app.use(express.cookieParser()); app.post('/', function(req, res){ // Perhaps we posted several items with a form // (use the bodyParser() middleware for this) var items = req.body.items; console.log(items); res.send('logging'); });
Templating
var express = require("express"); app.configure(function () { var public = __dirname + "/../public/"; public = require("path").normalize(public);
If ? is not after a variable then only the previous character is affected * Can be used as a wildcard in routes Includes when end of URL is optional e.g. '/app/e?'
•
Regex can be used any place in a route string e.g. '/app/(\\d)r?'
Exercises •
Create an express app with routes that capture '/' '/products' and '/services'
•
Create a route that captures the product ID after '/product/' e.g. '/product/abc12' and returns it in the response
•
Use a regular expression to restrict the ID parameter to 3 letter followed by 3-5 numbers
•
Create a route using a regex that matches the entire route
Passing Control • Routes are actually 'stacked middleware' • You can pass control between routes • The next() function calls the next matching route
app.get('/users/:id', function(req, res, next){ var id = req.params.id; if (checkPermission(id)) { // show private page } else { next(); } }); app.get('/users/:id', function(req, res){ // show public user page });
Passing Control •
next() is a function of router (and defined in the closure containing the route)
•
router will grab routes in the order they were declared
•
e.g. since'/*' will match everything so it should be the last route!
•
router doesn't care about verbs so you can use all () to operate on all verbs/routes and then use next () to pass to get(), put(), etc
Exercises • Create a simple check for correct product
IDs if not pass control to a route showing a custom error page
• Use app.all() to check user permission
before showing (mock-up) edit controls on a web site
Middleware
It's a pattern
req, res
next()
next()
next()
req, res
next()
next()
Dispatcher next()
req res
req, res, next
var express = require('express'), app = express.createServer(); var middleware = function (req, res, next) { req.foo = 'bar'; next(); }; app.use(middleware); app.get('/', function(req, res) { res.send(req.foo);
var express = require('express'), app = express.createServer(); var middleware = function (req, res, next) { var send = res.send; res.send = function(d) { res.send = send; res.send('hijacked! ' + d); } next(); }; app.use(middleware); app.get('/', function(req, res) { res.send('hi'); });
Connect middleware (Renamed express.* for convenience)
var express = require('express'), app = express.createServer(); var middleware = function (req, res, next) { req.foo = 'bar'; next(); }; app.get('/', middleware, function(req, res) { res.send(req.foo); });
var a, b, c, d; a = b = c = d = function(req,res,next) { next(); } var set1 = [a,b]; var set2 = [c,d]; var all = [set1, set2]; app.get('/set1', set1, function(req,res) { res.send('output'); }); app.get('/set2', [c,d], function(req,res) { res.send('output'); }); app.get('/all', all, function(req,res) { res.send('output'); });
Middleware factories
Middleware are just functions
var a, b, c, d; a = b = c = d = function(req,res,next) { next(); } var set1 = [a,b]; var set2 = [c,d]; var all = [set1, set2]; app.get('/set1', set1, function(req,res) { res.send('output'); }); app.get('/set2', [c,d], function(req,res) { res.send('output'); }); app.get('/all', all, function(req,res) { res.send('output'); });
var mFactory = function(letter) { return function(req,res,next) { var send = res.send; res.send = function(d) { res.send = send; res.send(letter + ' ' + d); } next(); } }; var set1 = [mFactory('a'),mFactory('b')]; var set2 = [mFactory('c'),mFactory('d')]; var all = [set1, set2]; app.get('/set1', set1, function(req,res) { res.send('output'); }); app.get('/set2', set2, function(req,res) { res.send('output'); }); app.get('/all', all, function(req,res) { res.send('output'); });
Exercise • Create a middleware to detect mobile
phone browsers and attach a boolean to req
• Create an express app that serves up links to an image using staticProvider
• Modify Profiler to profile your app and write each profile to a log file
• Create a middleware factory that sets the HTTP Expires header based on roles
Error handling
function NotFound(msg){ this.name = 'NotFound'; Error.call(this, msg); Error.captureStackTrace(this, arguments.callee); } NotFound.prototype.__proto__ = Error.prototype; app.get('/404', function(req, res){ throw new NotFound; }); app.get('/500', function(req, res){ throw new Error('keyboard cat!'); });
Create an express server that use jade, haml, ejs to render an index page
•
Create a public folder and include file from it (CSS, images, etc) in your layout
• •
Create a route for '/blog/id' to accept only digits
• •
Create a view for the '/blog/id' show the correct post
Make a 'fake database' (array) of blog posts and use a middleware to validate each id is valid Use a view partial to a preview of each blog post on the index page