Skip to content

Instantly share code, notes, and snippets.

function relativeDate(str) {
var s = ( +new Date() - Date.parse(str) ) / 1e3,
m = s / 60,
h = m / 60,
d = h / 24,
w = d / 7,
y = d / 365.242199,
M = y * 12;
function approx(num) {
@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 / 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 );
}
};
$ 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
@cowboy
cowboy / pre-commit
Created January 5, 2012 19:08 — forked from miketaylr/pre-commit
#!/bin/bash
# pre-commit hook to prevent html5 video or audio files from being checked
# into the repo. because large binary files in a git repo sucks. bad.
media_files=$(git diff --cached --name-only --diff-filter=ACR | \
egrep -i '\.(webm|mp4|ogg|mp3|ogv|m4v|avi|vp8|mov|oga|mp1|mp2|mpeg|3gp|wav)$')
if [[ "$media_files" ]]; then
echo 'Commit failed. Are you trying to check in media files into the repo?'
exit 1