This file contains hidden or 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
| // module dependencies | |
| var http = require('http'), | |
| url = require('url'); | |
| /** | |
| * UrlReq - Wraps the http.request function making it nice for unit testing APIs. | |
| * | |
| * @param {string} reqUrl The required url in any form | |
| * @param {object} options An options object (this is optional) |
This file contains hidden or 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
| <script src="//ajax.googleapis.com/ajax/libs/jquery/1.3.2/jquery.min.js"></script> | |
| <script src="//ajax.googleapis.com/ajax/libs/jqueryui/1.7.1/jquery-ui.min.js"></script><link rel='stylesheet' href='styles.css' type='text/css' media='all' /> |
This file contains hidden or 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
| /** | |
| * Module dependencies. | |
| */ | |
| var express = require('express') | |
| , routes = require('./routes') | |
| , http = require('http') | |
| , mongoose = require('mongoose') | |
| , path = require('path'); |
This file contains hidden or 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'); | |
| var app = module.exports = express.createServer(); | |
| var io = require('socket.io').listen(app); | |
| io.configure('development', function(){ | |
| io.set('log level', 1); | |
| io.set('transports', ['xhr-polling', 'websocket']); | |
| }); | |
| io.configure('production', function(){ |
This file contains hidden or 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 = express(), | |
| server = require('http').createServer(app), | |
| io = require('socket.io').listen(server) | |
| ; | |
| io.set('log level', 1); | |
| io.set('transports', ['websocket', 'flashsocket', 'htmlfile', 'xhr-polling', 'jsonp-polling']); | |
| global.io = io; |
This file contains hidden or 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
| /** | |
| * Module dependencies. | |
| */ | |
| var express = require('express') | |
| , routes = require('./routes') | |
| , http = require('http'); | |
| var app = express(); | |
| var server = app.listen(3000); |
This file contains hidden or 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
| require('crontab').load(cronLoaded); | |
| function cronLoaded(err, tab) { | |
| if (err) { console.log(err); process.exit(1); } | |
| var command = '/usr/bin/env echo "starting some service..."'; | |
| tab.remove(tab.findCommand(command)); | |
| var item = tab.create(command); | |
| item.everyReboot(); |
This file contains hidden or 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
| // middleware | |
| app.use(express.bodyParser({ keepExtensions: true, uploadDir: __dirname + "/public/uploads" })) | |
| // later | |
| app.get('/photos', uploadFile, addPhoto) | |
| // file is automatically saved to /public/uploads, let's just set | |
| function uploadFile(req, res, next) { | |
| if (req.files) { | |
| req.body.url = "http://myawesomesite.com/" + req.files.file.path.split("/").slice(-2).join("/") |
This file contains hidden or 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
| /** | |
| * Module dependencies | |
| */ | |
| var express = require('express'); | |
| var fs = require('fs'); | |
| var mongoose = require('mongoose'); | |
| var Schema = mongoose.Schema; | |
| // img path |
This file contains hidden or 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
| // embed an img element in an HTML page, point it at this. | |
| var sys = require("sys"), http = require("http"), crypto = require("crypto"); | |
| var db = require("redis-client").createClient(); | |
| http.createServer(function(request, response) { | |
| var date = new Date; | |
| var day = date.getUTCFullYear() + "-" + (date.getUTCMonth() + 1) + "-" + date.getUTCDate(); |