Skip to content

Instantly share code, notes, and snippets.

View matylla's full-sized avatar

Przemek Matylla matylla

View GitHub Profile
// helper function that goes inside your socket connection
client.connectSession = function(fn) {
var cookie = client.request.headers.cookie;
var sid = unescape(cookie.match(/connect\.sid=([^;]+)/)[1]);
redis.get(sid, function(err, data) {
fn(err, JSON.parse(data));
});
};
// usage
@matylla
matylla / server.js
Created May 17, 2011 17:15 — forked from meddulla/server.js
using node to display realtime heatmap of user's clicks
var sys = require('sys'),
fs = require('fs'),
Url = require('url'),
http = require('http'),
querystring = require('querystring');
//create a Heatmap Obj that inherits
//from EventEmitter
var events = require('events');
@matylla
matylla / nginx + node setup.md
Created May 9, 2011 17:47 — forked from joemccann/nginx + node setup.md
Set up nginx as a reverse proxy to node.js.

The idea is to have nginx installed and node installed. I will extend this gist to include how to install those as well, but at the moment, the following assumes you have nginx 0.7.62 and node 0.2.3 installed on a Linux distro (I used Ubuntu).

In a nutshell,

  1. nginx is used to serve static files (css, js, images, etc.)
  2. node serves all the "dynamic" stuff.

So for example, www.foo.com request comes and your css, js, and images get served thru nginx while everything else (the request for say index.html or "/") gets served through node.

  1. nginx listens on port 80.
@matylla
matylla / nodeconf_2011.md
Created May 8, 2011 18:49 — forked from guybrush/nodeconf_2011.md
a list of slides from nodeconf 2011