Skip to content

Instantly share code, notes, and snippets.

View shripadk's full-sized avatar
🎯
Working

Shripad Krishna shripadk

🎯
Working
View GitHub Profile
➜ test sudo npm install test-sigar-gyp --verbose
npm info it worked if it ends with ok
npm verb cli [ '/Users/shripadk/node/bin/node',
npm verb cli '/Users/shripadk/node/bin/npm',
npm verb cli 'install',
npm verb cli 'test-sigar-gyp',
npm verb cli '--verbose' ]
npm info using npm@1.1.65
npm info using node@v0.8.14
npm verb read json /Users/shripadk/Test/package.json
@shripadk
shripadk / binding.gyp
Created November 9, 2012 17:04
binding file
{
'targets': [
{
'target_name': 'sigar',
'conditions': [
['OS=="win"', {
'build': '<!(echo windows))'
}, {
'build': '<!(sudo cp -rp <(module_root_dir)/deps/sigar <(module_root_dir)/build/sigar && cd <(module_root_dir)/build/sigar && sudo ./autogen.sh && sudo ./configure --prefix=<(module_root_dir)/build/Release --with-pic && sudo make && sudo make install))',
'sources': ['src/node_sigar.cc'],
{
'targets': [
{
'target_name': 'sigar',
'conditions': [
['OS=="win"', {
'build': '<!(echo windows))'
}, {
'build': '<!(sudo cp -rp <(module_root_dir)/deps/sigar <(module_root_dir)/build/sigar && cd <(module_root_dir)/build/sigar && ./autogen.sh && ./configure --prefix=<(module_root_dir)/build/Release --with-pic && make && make install))',
'sources': ['src/node_sigar.cc'],
@shripadk
shripadk / gist:3966915
Created October 27, 2012 23:52
manager.js
Manager.prototype.initStore = function () {
this.handshaken = {};
this.connected = {};
this.open = {};
this.closed = {};
this.rooms = {};
this.roomClients = {};
var self = this;
@shripadk
shripadk / gist:3966914
Created October 27, 2012 23:52
transport.js changes
Transport.prototype.end = function (reason) {
if (!this.disconnected) {
this.log.info('transport end (' + reason + ')');
var local = this.manager.transports[this.id];
this.close();
this.clearTimeouts();
this.disconnected = true;
var Route = function(pattern, callback) {
this.pattern = pattern;
this.callback = callback;
};
Route.prototype.matches = function(url) {
var params = {};
if(!url.length) return false;
if(url[url.length-1] === "/") {
url = url.slice(0, url.length-1);
@shripadk
shripadk / gist:1482647
Created December 15, 2011 20:10
queue
ZQueue = function() {
this.queue = [];
this.queued = false;
};
ZQueue.prototype.dequeue = function() {
this.queued = false;
this.shiftQueue();
};
#!/usr/bin/env node
var os = require('os');
var WebSocketClient = require('websocket').client;
var count = 0;
function recursion() {
var client = new WebSocketClient();
client.on('connectFailed', function(error) {
var http = require('http');
var sockjs = require('sockjs');
var node_static = require('node-static');
var sockjs_opts = {sockjs_url: "http://127.0.0.1:8888/sockjs.js"};
var sockjs_echo = sockjs.createServer(sockjs_opts);
sockjs_echo.on('connection', function(conn) {
console.log(conn.id + ' connected');
conn.on('data', function(message) {
// run sockjs server on port 9999
// use an old browser (ex: FF 3.5) which connects via polling transport
// frontend on 8888
bouncy(function (req, bounce) {
if(headers.hasOwnProperty('upgrade')) {
// check if the request for upgrade is for websocket
// else just destroy the socket