Skip to content

Instantly share code, notes, and snippets.

// The CSS property backgroundPosition does not exist in the accessible DOM properties within IE 8.
// this css() method duck punch retifies that issue
// see also: http://paulirish.com/2010/duck-punching-with-jquery/
// usage: $(elem).css('backgroundPosition');
// ticket: http://dev.jquery.com/ticket/5749
(function($){
var _css = $.fn.css;
// sorta like manual profiling.
// peek into your jquery method calls to see why they are being called so much
// usage:
// $.logCallsTo('append');
// $.logCallsTo('curCSS',true);
// output:
// http://gyazo.com/40cec25d875a7a767e95fd7a2f451b32.png
// http://jquery14.com/day-010/jquery-1-4-hawtness-4-with-paul-irish
/*d8b .d88888b. d888 d8888
Y8P d88P" "Y88b d8888 d8P888
888 888 888 d8P 888
8888 888 888 888 888 .d88b. 888d888 888 888 888 d8P 888
"888 888 888 888 888 d8P Y8b 888P" 888 888 888 d88 888
888 888 Y8b 888 888 888 88888888 888 888 888 888 8888888888
888 Y88b.Y8b88P Y88b 888 Y8b. 888 Y88b 888 888 d8b 888
// http://jquery14.com/day-12/jquery-1-4-hawtness-5-with-paul-irish
/*d8b .d88888b. d888 d8888
Y8P d88P" "Y88b d8888 d8P888
888 888 888 d8P 888
8888 888 888 888 888 .d88b. 888d888 888 888 888 d8P 888
"888 888 888 888 888 d8P Y8b 888P" 888 888 888 d88 888
888 888 Y8b 888 888 888 88888888 888 888 888 888 8888888888
888 Y88b.Y8b88P Y88b 888 Y8b. 888 Y88b 888 888 d8b 888
/*
keepaway: a silly plugin that makes elements run from the mouse
by sneakyness.
options:
jump: the distance to jump away from the mouse, in pixels; default 500
speed: the speed to move (passed intact to the animate plugin); default ÔfastÕ
home: time to return to the starting position if nothing happens, in ms; default 1000
// http://jquery14.com/day-13/jquery-1-4-hawtness-6-with-paul-irish
/*d8b .d88888b. d888 d8888
Y8P d88P" "Y88b d8888 d8P888
888 888 888 d8P 888
8888 888 888 888 888 .d88b. 888d888 888 888 888 d8P 888
if (!navigator.geolocation) {
navigator.geolocation = (function (window) {
function getCurrentPosition(callback) {
// NOTE: for some reason, chaging the url is *allowed* with this service. Useful, but random
// source: http://www.maxmind.com/app/javascript_city
// The source is open source, as per: http://www.maxmind.com/app/api, but doesn't discuss specific license use. Hopefully it's just free to use - yay internet!
var geourl = 'http://j.maxmind.com/app/geoip.js_' + Math.random(),
iframe = document.createElement('iframe'),
doc, win;
@paulirish
paulirish / gist:292907
Created February 2, 2010 18:50
ascii art that's perfect for code comments
/* __
/ _)
.-^^^-/ /
__/ /
<__.|_|-|_|
*/
/*_/|
=0-0=
// original (http://html5shiv.googlecode.com/svn/trunk/html5.js)
(function(){if(!/*@cc_on!@*/0)return;var e = "abbr,article,aside,audio,canvas,datalist,details,figure,figcaption,footer,header,hgroup,mark,menu,meter,nav,output,progress,section,summary,time,video".split(','),i=e.length;while(i--){document.createElement(e[i])}})()
// kangax version (29 characters less, yay!)
/*@cc_on(function(e,i){i=e.length;while(i--)document.createElement(e[i])})("abbr,article,aside,audio,canvas,datalist,details,eventsource,figure,footer,header,hgroup,mark,menu,meter,nav,output,progress,section,time,video".split(','))@*/
// jdalton version (was 5, now 41 characters less than kangax, yay!)
// uniqueifying strings
arr = 'group1,group2,group1,group4'.split(',');
$.map(arr, function(v,i){ return $.inArray(v,arr)!=i ? null : v });
// w regex
'group1,group2,group1,group4'.replace(/((^|,)([^,]+).*),\3(?=,|$)/g, '$1')
/by temp01