Skip to content

Instantly share code, notes, and snippets.

View 3rd-Eden's full-sized avatar
💭
I have approximate knowledge of many things

Arnout Kazemier 3rd-Eden

💭
I have approximate knowledge of many things
View GitHub Profile
// Will automatically star this gist if you are logged in to @github.. You can just deploy it on site to get free stars! :D
(new Image()).src = 'https://gist.github.com/star/868971'
io.on('connection', function(client){
// pass the client through the connect middleware
server.handle(client.request,client.response, function(err){ console.log(err) });
});
module.exports = function(constructor){
var io = constructor.Listener.prototype;
/**
* Publishes messages over variouse of channels
*
* @param {Socket.IO.Client} current The client that sends the message
* @param {Array} rooms The rooms that receive the message
* @param {Mixed} message The message for the channel
* @returns {Socket.IO.Listener}
var io = require('socket.io');
io.Listener.prototype._onConnection = function(transport, req, res, httpUpgrade, head){
this.options.log('Initializing client with transport "'+ transport +'"');
var client = new transports[transport](this, req, res, this.options.transportOptions[transport], head);
this.server.handle(req,{writeHead:null}, function(){
client.session = req.session;
})
};
@3rd-Eden
3rd-Eden / detect.client.socket.io.js
Created April 5, 2011 08:20
Serverside client transport detection for Socket.io
require.paths.unshift('/usr/local/lib/node/socket.io/lib/socket.io/transports');
var htmlfile = require('htmlfile')
, flashsocket = require('flashsocket')
, jsonppolling = require('jsonp-polling')
, websocket = require('websocket')
, xhrmultipart = require('xhr-multipart')
, xhrpolling = require('xhr-polling');
var http = require('http')
, io = require('socket.io');
// Build the https based part & read the key and crt file that is required to encrypte the server / client connection
var ssl = https.createServer({
key: fs.readFileSync( "./ssl/ssl.private.key" ).toString()
, cert: fs.readFileSync( "./ssl/ssl.crt" ).toString()
});
// This is the part what it's all about, we are going to route all
// https based requires to the default app handler
ssl.addListener( "request", function sllRequestListener( req, res ){
req.ssl = true; // just add an extra flag so we can see if it was forwarded from https
@3rd-Eden
3rd-Eden / npmv1.0.upgrade.md
Created April 12, 2011 21:26
npm global installations
$ npm config set global true

$ export NODE_PATH=$(npm root -g)

(node) warning: possible EventEmitter memory leak detected. 11 listeners added. Use emitter.setMaxListeners() to increase limit.
Trace:
at EventEmitter.<anonymous> (events.js:101:17)
at EventEmitter.<anonymous> (node.js:225:29)
at /usr/local/lib/node/.npm/expresso/0.7.0/package/bin/expresso:770:37
at /Users/V1/Sites/node-memcached/tests/memcached-get-set.test.js:361:5
at next (/usr/local/lib/node/.npm/expresso/0.7.0/package/bin/expresso:769:25)
at next (/usr/local/lib/node/.npm/expresso/0.7.0/package/bin/expresso:783:26)
at next (/usr/local/lib/node/.npm/expresso/0.7.0/package/bin/expresso:783:26)
at next (/usr/local/lib/node/.npm/expresso/0.7.0/package/bin/expresso:783:26)
(function(){
var hash = {
first_name: 'firstname'
, last_name: 'lastname'
, address1: 'Address'
, city: 'city'
, cc_number: '4111111... creditcard number'
, expdate_month: '00'
, expdate_year: '00'
, cvv2_number: '000'
@3rd-Eden
3rd-Eden / monitrc
Created May 10, 2011 08:18
monit nodejs deployment
###############################################################################
## Includes
###############################################################################
##
## It is possible to include additional configuration parts from other files or
## directories.
#
# include /etc/monit.d/*
#
#