Skip to content

Instantly share code, notes, and snippets.

@cowboy
cowboy / HEY-YOU.md
Last active February 27, 2025 12:24
jQuery Tiny Pub/Sub: A really, really, REALLY tiny pub/sub implementation for jQuery.
@shripadk
shripadk / gist:652819
Created October 29, 2010 03:10
Express authentication using Redis for session store and Couchdb for database (in coffeescript!)
###
Module dependencies
###
require.paths.unshift "#{__dirname}/lib/support/express-csrf/"
require.paths.unshift "#{__dirname}/lib/support/node_hash/lib/"
express = require 'express'
app = module.exports = express.createServer()
RedisStore = require 'connect-redis'
@remy
remy / gist:378764
Created April 25, 2010 22:04
konami as a special event
/**
* konami cheat code as a jQuery special event - *not* a demo of how small
* I could take the code, since this is tons smaller:
* http://www.newmediacampaigns.com/page/konami-code-jquery-plugin-pointlessly-easy
* !!! :-)
*
* I should add, I'm almost certain someone else has done this already!
*/
(function ($) {
@remy
remy / gist:370248
Created April 18, 2010 14:36
Capture mousewheel event (jQuery)
// taken from http://html5readiness.com/script.js - cheers paul!
$(document).bind('DOMMouseScroll mousewheel', function(e, delta) {
delta = delta || e.detail || e.wheelDelta;
});
@remy
remy / gist:360113
Created April 8, 2010 14:24
setInterval run once, then keep running
setInterval((function () {
console.log(new Date()); // run some arbitrary code
return arguments.callee; // here be the magic
})(), 1000);
// ^---- and that runs the function, and the return val is assign to the interval
@remy
remy / gist:360018
Created April 8, 2010 12:07 — forked from padolsey/gist:360015
Get element from mouse position
var x,y;
document.onmousemove = function(e){
e = e || window.event;
x = e.clientX;
y = e.clientY;
};
function elementAtMousePosition() {
return document.elementFromPoint(x,y);
var performance = (function () {
var my = {};
// Wrap a function body in this to return a copy that instruments itself
// If you want this to be useful, you should give your profiled function a name,
// otherwise it will be identified as "", which is less than useful.
my.profile = function (func) {
return function () {
var start = new Date().getTime(),
time,