Skip to content

Instantly share code, notes, and snippets.


Przemek Matylla matylla

View GitHub Profile
View post-receive.rb
#!/usr/bin/env ruby
# Aside from removing Ruby on Rails specific code this is taken verbatim from
# mislav's git-deploy ( and it's awesome
# - Ryan Florence (
# Install this hook to a remote repository with a working tree, when you push
# to it, this hook will reset the head so the files are updated
if ENV['GIT_DIR'] == '.'
matylla / cron-test.js
Created Jun 7, 2011 — forked from onewland/cron-test.js
simple cron API for node.js
View cron-test.js
var cron = require('./cron'), sys = require('sys');
cron.Every((2).seconds(), function() { sys.puts('Working!'); });
matylla / gist:987455
Created May 23, 2011
node js get client ip
View gist:987455
function getClientAddress(req) {
return req.headers['x-forwarded-for'] || req.connection.remoteAddress;
View connect-session-in-socket-io.js
// 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 / server.js
Created May 17, 2011 — forked from meddulla/server.js
using node to display realtime heatmap of user's clicks
View server.js
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 / nginx + node
Created May 9, 2011 — forked from joemccann/nginx + node
Set up nginx as a reverse proxy to node.js.
View nginx + node

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, 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 /
Created May 8, 2011 — forked from guybrush/
a list of slides from nodeconf 2011
You can’t perform that action at this time.