a list of slides from nodeconf
you may want to take a look at the jsconf-gist too!
/** Testing sax push parsing | |
* | |
* The output file should have almost identical | |
* to the input file | |
* | |
* Known issues with this example output | |
* | |
* - Doesn't escape entities. You can do it | |
* manually on the character content. | |
* - Doesn't replicate self-closing tags. |
function createPool (port, host, https, credentials) { | |
var pool = new events.EventEmitter(); | |
pool.clients = []; | |
var getClient = function () { | |
for (var i=0;i<pool.clients.length;i+=1) { | |
if (!pool.clients[i].busy) { | |
return pool.clients[i]; | |
} | |
} |
var Person = function( name ){ this.name = name }; | |
Person.create = function(name) { return new Person(name) }; | |
Brian = new Person('brianleroux'); | |
Tim = Person.create('tim'); | |
// Lame, I would do this one of three ways depending on how it will be used | |
// If the example really was this simple and there was nothing else involved, | |
// I would use object literals. No need to overcomplicate things |
var fs = require('fs'); | |
OAuth = require('oauth').OAuth; | |
var config = JSON.parse( fs.readFileSync(__dirname + '/default_config.json') ); | |
var oauth = config.oauth; | |
console.warn(oauth); | |
var oa = new OAuth(oauth.requestTokenURL | |
, oauth.accessTokenURL |
a list of slides from nodeconf
you may want to take a look at the jsconf-gist too!
#include "Vector.h" | |
Persistent<FunctionTemplate> Vector::ctor; | |
void | |
Vector::Initialize(Handle<Object> target) { | |
HandleScope scope; | |
ctor = Persistent<FunctionTemplate>::New(FunctionTemplate::New(New)); | |
ctor->InstanceTemplate()->SetInternalFieldCount(1); |
Creationix.route("GET", "/", function (req, res, params, next) { | |
render("frontindex", { | |
title: query("index", "title"), | |
links: query("index", "links"), | |
articles: loadArticles | |
}, function (err, html) { | |
if (err) return next(err); | |
res.writeHead(200, { | |
"Content-Length": Buffer.byteLength(html), | |
"Content-Type": "text/html; charset=utf-8" |
diff --git a/node/handler/APIHandler.js b/node/handler/APIHandler.js | |
index a057bfc..7476818 100644 | |
--- a/node/handler/APIHandler.js | |
+++ b/node/handler/APIHandler.js | |
@@ -75,8 +75,8 @@ exports.handle = function(functionName, fields, req, res) | |
//check the api key! | |
if(fields["apikey"] != apikey) | |
{ | |
- res.send({code: 4, message: "no or wrong API Key", data: null}); | |
- return; |
var express = require('express'); | |
var app = express.createServer(); | |
app.set('view engine', 'jade'); | |
app.set('port', parseInt(process.env.PORT || 5000, 10)); | |
app.get('/', function(req, res) { | |
res.render('index'); |