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
sys = require "sys"; | |
http = require "http"; | |
url = require "url"; | |
connect = require "connect"; | |
redis = require "redis"; | |
hashRing = require "hash_ring"; | |
Sharding = { | |
servers = { "127.0.0.1 10000 6378": 1 }; | |
ring = new hashRing.HashRing servers; |
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
require 'rubygems' | |
require 'sinatra' | |
get '/' do | |
"hello world" | |
end |
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 = express.createServer(), | |
Post = require('./models/post'); | |
app.configure(function () { | |
app.use(express.methodOverride()); | |
app.use(express.bodyDecoder()); | |
app.use(express.staticProvider(__dirname + '/public')); | |
app.use(express.compiler({src: __dirname + '/public', enable: ['sass']})); | |
app.use(express.logger()); |
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 util = require('util'), | |
http = require('http'), | |
events = require('events'); | |
var Twitter = function(opts) { | |
this.username = opts.username; | |
this.password = opts.password; | |
this.track = opts.track; | |
this.data = ''; | |
}; |
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 exec = require('child_process').exec; | |
var fs = require('fs'); | |
var util = require('util'); | |
var http = require('http'); | |
var url = require('url'); | |
var PDFDocument = require('pdfkit'); // http://pdfkit.org/ | |
http.createServer(function (req, res) { |
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 sqlite3 = require('sqlite3').verbose(); | |
var db = new sqlite3.Database('guy.sqlite'); //':memory:' | |
db.serialize(function() { | |
db.get("SELECT name FROM sqlite_master WHERE type='table' AND name='lorem'", function(error, row) { | |
if (row !== undefined) { | |
console.log("table exists. cleaning existing records"); | |
db.run("DELETE FROM lorem", function(error) { | |
if (error) | |
console.log(error); |
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
linus@Newton:~$ redis-cli | |
redis 127.0.0.1:6379> publish /updates.foo "hello there!" | |
(integer) 1 | |
redis 127.0.0.1:6379> |
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
http = require('http'); | |
url = require('url'); | |
http.createServer(function(req, res){ | |
var requestURL = url.parse(req.url, true)['pathname']; | |
if (requestURL == '/log.gif') { | |
var imgHex = '47494638396101000100800000dbdfef00000021f90401000000002c00000000010001000002024401003b'; | |
var imgBinary = new Buffer(imgHex, 'hex'); | |
res.writeHead(200, {'Content-Type': 'image/gif' }); |
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
twitter.json |
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
/** | |
* Module dependencies. | |
*/ | |
var express = require('express') | |
, routes = require('./routes') | |
, cluster = require('cluster'); | |
var app = module.exports = express.createServer() | |
, io = require('./socket')(app); |
NewerOlder