Skip to content

Instantly share code, notes, and snippets.

View spolu's full-sized avatar

Stanislas Polu spolu

View GitHub Profile
app.configure(function(){
//[...]
app.use(express.static(__dirname + '/public'));
});
@spolu
spolu / parser.js
Created November 24, 2011 12:37
Dynamic Parser for \r\n separated JSON objects
var buf = require('buffer');
/**
* Dynamic Parser Object borrowed to twitter-node
*/
var Parser = function Parser() {
events.EventEmitter.call(this);
this.buffer = '';
return this;
};
var tl = require('teleportd-api').teleportd({ apikey: 'XXX' });
tl.stream({ meta: true,
full: true }, function(pic) {
console.log(JSON.stringify(pic) + '\r\n');
});
var util = require('util');
var exp = /lat=(\-{0,1}[0-9]+\.[0-9]+).long=(\-{0,1}[0-9]+\.[0-9]+)/;
var r = exp.exec(' <iframe width="270" height="165" frameborder="0"\nscrolling="no" marginheight="0" marginwidth="0"\nsrc="/google_map?lat=37.349001&long=-121.962850&show_controls=true"></iframe>');
console.log(util.debug(r));
@spolu
spolu / gist:1551451
Created January 2, 2012 17:29
functional inheritance
/**
* method(that, name, method, _super)
* Adds a method to the current object denoted by that and preserves
* _super implementation (see Crockford)
*/
method = function(that, name, method, _super) {
if(_super) {
var m = that[name];
_super[name] = function() {
return m.apply(that, arguments);
#!/usr/local/bin/node
var http = require('http');
var fwk = require('fwk');
var infra = require('../lib/infra.js');
/*
* bouncer.js
*
* Bouncer is a simple http proxy protected by api key access
@spolu
spolu / gist:1760688
Created February 7, 2012 16:48
resume calls
var http = require('http');
var buf1,buf2;
var pos1, pos2;
var dc = 0;
var done = function() {
if(dc === 0) {
dc++;
<html>
<body style="width: 100%; height: 100%; margin: 0">
<div style="position:absolute; width: 100%; background-color:grey;">
<div style="position:absolute; top: 0px; left: 0px; width: 100px; background-color: black; height: 100px;">
</div>
<div style="position:absolute; top: 0px; right: 0px; width: 100px; background-color: black; height: 20px;">
</div>
<div style="position:absolute; top: 0px; right: 100px; left: 100px; background-color: red;">
tata
TEST
@spolu
spolu / zombie.txt
Created March 26, 2012 17:24
zombie instances
user: teleportd
app: teleportd-api
I don't see any error, but my app broadcast on redis status udpates and teleportd-api has two instances running one that is accessible and one I can't reach. Restarting the app has no effect on the zombie process. According to the status updates I receive from it, the zombie process was never exposed to any traffic.
Cheers
Stanislas-Polus-MacBook-Pro:sets spolu$ jitsu deploy
info: Welcome to Nodejitsu
info: It worked if it ends with Nodejitsu ok
info: Executing command deploy
info: skipping require-analyzer because noanalyze option is set
info: skipping require-analyzer because noanalyze option is set
warn: Local version appears to be old.
warn: Your package.json version will be incremented for you automatically.
warn: About to write /Users/spolu/teleportd/src/sets/package.json
data: