Skip to content

Instantly share code, notes, and snippets.

View ralt's full-sized avatar

Florian Margaine ralt

View GitHub Profile
module.exports = {
io: null,
socket: null,
createReactiveMethod: function() {},
initialize: function(server) {
console.log("initialized!");
this.io = require('socket.io').listen(server);
var that = this;
@ralt
ralt / x.js
Created May 29, 2012 17:22 — forked from Raynos/x.js
var UserCollection = require("../dataSources/user")
var User = {
find: function( name, skypeName, callback ) {
if ( skypeName ) {
findBySkypeName( name, callback );
}
// The rest of your logic there
}
}
// Assume errorPage, jsonBody, formBody exist within scope.
function methods(routes, handleHttpForms) {
if (handleHttpForms) {
return createHttpFormsRequestHandler(routes)
}
return requestHandler.bind(this)
}
function requestHandler(req, res) {
@ralt
ralt / shitanal.js
Created June 28, 2012 14:40
A little script that will screw up people using campaigns on Google Analytics
/**
* A little script that will screw up people using campaigns on Google
* Analytics.
*
* Do. Not. Use.
*
* I am not responsible for any action that people may employ using this
* little script. It was done purely out of curiosity.
*
* Usage:
@ralt
ralt / app.js
Created July 13, 2012 14:12
Trying to understand ncore...
var ncore = require( 'ncore' );
ncore.constructor( {
"./other.js": {
"test": "./test.js"
}
});
console.log( ncore );
@ralt
ralt / jquery-second-click.js
Created September 28, 2012 19:13 — forked from ryankinal/jquery-second-click.js
jQuery "second click" plugin
// Untested, off-the-cuff
$.fn.secondClick = function(handler)
{
if ( !$( this ).data( 'click' ) ) {
$( this ).data( 'click', 1 );
}
else if ( $( this ).data( 'click' ) === 1 ) {
handler();
$( this ).data( 'click', '' );
}
@ralt
ralt / other.js
Created October 25, 2012 17:48
json in node
var test = require('test.json');
test.some; // "property"
@ralt
ralt / gist:4030481
Created November 7, 2012 09:51
Closest() rewritten
if (!Node.prototype.matchesSelector) {
Node.prototype.matchesSelector = function(selector) {
return this === document.querySelector(selector);
};
}
function closest(selector, el) {
if (el.parentNode.matchesSelector(selector)) {
return el.parentNode;
}
@ralt
ralt / init
Created November 9, 2012 12:22
My fluxbox confi files
session.screen0.clientMenu.usePixmap: true
session.screen0.tab.placement: TopLeft
session.screen0.tab.width: 64
session.screen0.menu.alpha: 255
session.screen0.tabs.usePixmap: true
session.screen0.tabs.maxOver: false
session.screen0.tabs.intitlebar: true
session.screen0.iconbar.iconTextPadding: 10
session.screen0.iconbar.usePixmap: true
session.screen0.iconbar.iconWidth: 128
@ralt
ralt / gist:4051304
Created November 10, 2012 14:48
HTMLCollection vs NodeList
var divs = document.getElementsByTagName('div');
({}).toString.apply(divs);
// Firefox: "[object HTMLCollection]"
// Chrome/Safari: "[object NodeList]"