Skip to content

Instantly share code, notes, and snippets.

Avatar

Florian Margaine ralt

View GitHub Profile
View gist:2769373
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 — forked from Raynos/x.js
View 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
}
}
View methods.js
// 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 Jun 28, 2012
A little script that will screw up people using campaigns on Google Analytics
View shitanal.js
/**
* 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 Jul 13, 2012
Trying to understand ncore...
View app.js
var ncore = require( 'ncore' );
ncore.constructor( {
"./other.js": {
"test": "./test.js"
}
});
console.log( ncore );
@ralt
ralt / jquery-second-click.js
Created Sep 28, 2012 — forked from ryankinal/jquery-second-click.js
jQuery "second click" plugin
View jquery-second-click.js
// 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 Oct 25, 2012
json in node
View other.js
var test = require('test.json');
test.some; // "property"
@ralt
ralt / gist:4030481
Created Nov 7, 2012
Closest() rewritten
View gist:4030481
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 Nov 9, 2012
My fluxbox confi files
View init
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 Nov 10, 2012
HTMLCollection vs NodeList
View gist:4051304
var divs = document.getElementsByTagName('div');
({}).toString.apply(divs);
// Firefox: "[object HTMLCollection]"
// Chrome/Safari: "[object NodeList]"