This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
// use like this: | |
// process.emit( 'app:log', module, arg1, arg2, ..., argN ); | |
var Module = require('module'); | |
function logConsole(method, module) { | |
var args = [(new Date()).toJSON(), method]; | |
var index = 1; | |
if (module instanceof Module) { |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
// What name can I refer to ? | |
app.get('/hello-world', function () { console.log(3); }); | |
// OK, suppose I can build the path from params | |
app.get('/:id/:name', function hello1 () { console.log(1); }); | |
// OK, suppose the "callback" is the last one | |
app.get('/hello/:name', requiresAuthentication, function hello2 () { console.log(2); }); | |
// How do I build the path ? |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
var http = require('http'); | |
var fs = require('fs'); | |
var path = require('path'); | |
var constants = require('constants'); | |
var timers = require('timers'); | |
var port = 8080; | |
http.createServer(function(req, res) { | |
if(req.url == '/') { | |
res.writeHead(200, { 'Content-Type': 'text/plain' }); |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
# Main entry point | |
SOURCE = src/app.js | |
# The dependencies (other than node_modules/**) | |
LIBS = $(shell ls src/lib/*.js src/components/*.js) | |
# The target | |
TARGET = build/app.js | |
# Compilation flags |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
<!-- Live demo : http://bl.ocks.org/1213727 --> | |
<html> | |
<head> | |
<title>Un affichage de numéro vert avec Microformat et mise en forme en CSS</title> | |
<link rel="stylesheet" media="all" href="numero_vert.css" type="text/css" /> | |
</head> | |
<body> | |
<span class="vcard numerovert"> | |
<span class="fn">Nom de la société</span> |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
var app = require('../app'); | |
console.log(); | |
app.routes.all().forEach(function(route){ | |
console.log(' \033[90m%s \033[36m%s\033[0m', route.method.toUpperCase(), route.path); | |
}); | |
console.log(); | |
process.exit(); |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
var assert = require('assert') | |
, db = require('../db')({namespace:'bookmarks-test-db'}) | |
, the_bookmark = {} | |
require('vows') | |
.describe('bookmarks-db') | |
.addBatch({ | |
"Initialize": { | |
topic: function () { | |
db.deleteAll(this.callback); |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
var express = require('express') | |
, app = module.exports = express.createServer() | |
app.configure(function () { | |
app.set('views', __dirname + '/views'); | |
app.set('view engine', 'jade'); | |
app.use(app.router); | |
app.use(express.static(__dirname + '/public')); | |
}); | |
app.configure('development', function () { |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
app.get('/help', function(req, res){ | |
res.send('some help'); | |
}); | |
app.get('/search/:query/p:page', function(req, res){ | |
var query = req.params.query | |
, page = req.params.page; | |
res.send('search "' + query + '", page ' + (page || 1)); | |
}); |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
var casper = require("casper").create() | |
, url = casper.cli.get(0) | |
, metas = []; | |
if (!url) { | |
casper.echo('Usage: casperjs [url]').exit(); | |
} | |
casper.on('remote.message', function(msg) { | |
console.log(msg); |