This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
// Dump all document.styleSheets[*].cssRules[*].cssText to console: | |
(function(s,c,r,i,j){ for(i=0;i<s.length;i++){c=s[i].cssRules;for(j=0;j<c.length;j++){r=c[j].cssText;console.log('document.styleSheets['+i+'].cssRules['+j+'].cssText = "'+r+'";')}} })(document.styleSheets); |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
(function($){ | |
// Store fetched long URLs here. | |
var cache = {}; | |
$.longUrl = function( url, callback, options ) { | |
// Override defaults with specified options. | |
options = $.extend( {}, $.longUrl.options, options ); | |
var params = {}; |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
/*! | |
* jQuery.preloadImg | |
* description: cache images via $.preloadImg(['src','src']) or $('img').preloadImg() | |
* author: Cody Lindley | |
*/ | |
(function($) { | |
// Internal cache of image src values. | |
var cache = {}; |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
// I need to explain this. Soon. | |
// BAD | |
function a(){ | |
console.log(1); | |
b(); | |
}; | |
function b(){ |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
/*! | |
* $imple cache - v0.3pre - 07/16/2010 | |
* http://benalman.com/ | |
* | |
* Copyright (c) 2010 "Cowboy" Ben Alman | |
* Dual licensed under the MIT and GPL licenses. | |
* http://benalman.com/about/license/ | |
*/ | |
(function($,window){ |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
/* | |
Usages: | |
$(selector).classList() //returns an array of classnames | |
$(selector).classList('newclass') //replaces the current element's classes | |
$(selector).classList(['new', 'class', 'names']) //replaces the current element's classes | |
*/ | |
jQuery.fn.classList = function( classNames ) { | |
if ( jQuery.isArray( classNames ) ) { | |
// An array was passed, join it into a string. |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
// If you want jQuery replaceText to be able to replace modified content | |
// inside a textarea, you might need to do this kind of thing, since | |
// changing the textarea .value doesn't change the textarea's child text | |
// node! | |
$('textarea') | |
.each(function(){ | |
$(this).html( this.value ).val( this.value ); | |
}) | |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
function filter( e ){ | |
var term = $.trim( this.value.toLowerCase() ); | |
if( !term ){ | |
rows.show(); | |
} else { | |
rows.hide(); | |
self._trigger( "filter", e, $.map( cache, function(v,i){ | |
if ( v.indexOf(term) !== -1 ) { |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
// plugin "foo plus stuff" contains standalone plugin "foo" | |
// additional code | |
(function($){ | |
$.foo = {}; | |
$.foo.bar = prop; | |
})(jQuery); |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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) { |