Skip to content

Instantly share code, notes, and snippets.

View spolu's full-sized avatar

Stanislas Polu spolu

View GitHub Profile
var fwk = require('fwk');
/**
* Object generic
*
* Implements simple methods to modifiy
* objects in database
* @inherits events.EventEmitter
*
* @param {mongo, cfg, collection, uid, [obj]}
@spolu
spolu / z3.js
Created November 19, 2012 15:29
Phl0ck z3
var util = require('util');
/**
* -------
* Helpers
* -------
*/
var dist = function(v1, v2) {
return Math.sqrt((v1.x - v2.x) * (v1.x - v2.x) +
(v1.y - v2.y) * (v1.y - v2.y));
@spolu
spolu / ReadMe.md
Created October 10, 2012 12:08
[Project] Fl0ck ReadMe

Fl0ck

Fl0ck is a programming game in which two or more programs control one or more spaceships in a SpaceWar-like environment with the goal of eliminating every other enemy ships and survive as long as possible.

Since it is a SpaceWar-like environment, there is a physical simulation going on. Physics are simulated by simple newtonian integration with a predefined step.

var fwk = require('fwk');
var child = require('child_process');
// cfg
var cfg = fwk.populateConfig(require("./config.js").config);
var dts = require('dattss').process({ name: 'estrack.' + cfg['ESTRACK_INSTANCE'],
auth: cfg['TELEPORTD_DATTSS_AUTH'] });
var dstat_first = true;
@spolu
spolu / BUGFIXING.txt
Created August 9, 2012 08:10
Bug Fixing & Reviewing process
// this process suppose all devs have push&pull access to all repositories
When you decide to start working on a bugfix:
---------------------------------------------
- create a branch:
> git checkout master // to make sure you branch from `master`
> git checkout -b fixXXX
- Think, Code, Test, Be Awesome
- Commit(s)
@spolu
spolu / teleportd.js
Created August 9, 2012 06:40
Teleportd PubSubHook
/* NodeJS / Express */
app.post('/pubsub/:seed', function(req, res) {
console.log('PUBSUB: ' + req.param('seed'));
res.json({ok: true});
igapi.queue(req.body);
});
<?
$test = '1';
?>
@spolu
spolu / tl_node_get.js
Created July 24, 2012 13:02
Teleportd Examples
var tl = require('teleportd').teleportd({ user_key: '_YOUR_USER_KEY_' });
/**
* Performs a get request to retrieve the full content of a pic
* @param sha of the pic to retrieve the details
* @param cb(err, pic) the result/error callback
* err: set if an error was raised
* pic: contain the pic data otherwise
*/
tl.get(sha, function(error, pic) {
@spolu
spolu / dattss.js
Created July 15, 2012 21:47
DaTtSs Node.js client library
// Copyright Teleportd Ltd.
//
// Authors: Stanislas Polu
//
// Permission is hereby granted, free of charge, to any person obtaining a
// copy of this software and associated documentation files (the
// "Software"), to deal in the Software without restriction, including
// without limitation the rights to use, copy, modify, merge, publish,
// distribute, sublicense, and/or sell copies of the Software, and to permit
// persons to whom the Software is furnished to do so, subject to the
@spolu
spolu / dattss.js
Created July 10, 2012 23:00
DaTtSs client library
var foo = require('dattss').process({ name: 'foo',
auth: '__YOUR_AUTH_KEY__' });
/* DaTtSs lets you aggregate 3 types of statistics */
foo.agg('new', '1c'); // counters (evolves incrementally)
foo.agg('query', '153ms'); // timers (time it takes to do smthg)
foo.agg('users', '23g'); // gauges (snapshot of a value)
/* It's also possible to emphasize a statistic */
foo.agg('signup', '1c!'); // emphasized counter