Skip to content

Instantly share code, notes, and snippets.

@cowboy
cowboy / jquery.ba-each2.js
Created August 1, 2010 13:32 — forked from padolsey/gist:500145
Like .quickEach, but subtly different
// Plugin released:
// http://benalman.com/projects/jquery-misc-plugins/#each2
@cowboy
cowboy / very-small-ie-detect.js
Created August 21, 2010 13:26 — forked from padolsey/gist:527683
Very small IE detect (aka type coersion ftw)
// ----------------------------------------------------------
// A short snippet for detecting versions of IE in JavaScript
// without resorting to user-agent sniffing
// ----------------------------------------------------------
// If you're not in IE (or IE version is less than 6) then:
// ie === 0
// If you're in IE (>=6) then you can determine which version:
// ie === 7; // IE7
// Thus, to detect IE:
// if (ie) {}
@cowboy
cowboy / jQuery immediate ready.js
Created November 5, 2010 16:32 — forked from ralphholzmann/jQuery immediate ready.js
Bind DOM ready event handlers before jQuery is loaded
// Create a "fake" jQuery function that accepts function arguments to be
// queued as DOM ready callbacks.
(function(window){
var fake = window.jQuery = window.$ = function( fn ) {
if ( Object.prototype.toString.call( fn ) === '[object Function]' ) {
fake.queue.push( fn );
}
};
@cowboy
cowboy / pubsub-demo.js
Created December 16, 2010 20:04 — forked from rmurphey/pubsub-demo.js
Two approaches: "Traditional" vs Pub/Sub (via rmurphey)
// Note that this uses my Pub/Sub implementation, which is slightly different than
// phiggins' in that jQuery custom events are used, and as such the first event handler
// argument passed is the event object.
//
// jQuery Tiny Pub/Sub: A really, really, REALLY tiny pub/sub implementation for jQuery
// https://gist.github.com/661855
// The "traditional" way.
$ git clone github:lenary/guides.git
Cloning into guides...
remote: Counting objects: 255, done.
remote: Compressing objects: 100% (216/216), done.
remote: Total 255 (delta 111), reused 163 (delta 35)
Receiving objects: 100% (255/255), 1.49 MiB | 564 KiB/s, done.
Resolving deltas: 100% (111/111), done.
$ cd guides
$ git remote -v
@cowboy
cowboy / noteval.js
Created February 20, 2011 13:16 — forked from phiggins42/noteval.js
JavaScript noteval (from phiggins)
// Untested mod of phiggins' original gist. Maybe I'll actually try it someday.
function noteval( code, doc ) {
// add some javascript to a document, like an iframe
//
// var iframe = document.getElementById('theframe'),
// iframeDoc = iframe.contentDocument || iframe.contentWindow.document;
//
// noteval('alert("hi")', iframeDoc);
@cowboy
cowboy / utmstrip.user.js
Created May 20, 2011 20:37 — forked from paulirish/utmstrip.user.js
userscript: Drop the UTM params from a URL when the page loads
// ==UserScript==
// @name UTM param stripper
// @author Paul Irish
// @namespace http://github.com/paulirish
// @description Drop the UTM params from a URL when the page loads.
// @extra Cuz you know they're all ugly n shit.
// @include http://*
// ==/UserScript==
// save this as utmstrip.user.js and drag it into Chrome or Firebug (with greasemonkey)
@cowboy
cowboy / ago.js
Created June 2, 2011 20:21 — forked from gf3/ago.js
Super small relative dates
module.exports = (function(){
const MS =
{ seconds: 1000
, minutes: 60 * 1000
, hours: 60 * 60 * 1000
, days: 24 * 60 * 60 * 1000
, weeks: 7 * 24 * 60 * 60 * 1000
, months: 30 * 7 * 24 * 60 * 60 * 1000
, years: 365 * 24 * 60 * 60 * 1000 }
@cowboy
cowboy / Custom.css
Created August 17, 2011 15:20 — forked from bentruyman/Custom.css
IR_Black Theme for Chrome Developer Tools
/**********************************************/
/*
/* IR_Black Skin by Ben Truyman - 2011
/*
/* Based on Todd Werth's IR_Black:
/* http://blog.toddwerth.com/entries/2
/*
/* Inspired by Darcy Clarke's blog post:
/* http://darcyclarke.me/design/skin-your-chrome-inspector/
/*
@cowboy
cowboy / Folder Preferences
Created December 21, 2011 13:25 — forked from chrisyour/Folder Preferences
Show hidden files and hidden folders (except .git) in your TextMate project drawer
# Want to show hidden files and folders in your TextMate project drawer? Simple, just modify the file and folder patterns in TextMate's preferences.
# Instructions:
# Go to TextMate > Preferences...
# Click Advanced
# Select Folder References
# Replace the following:
# File Pattern