Skip to content

Instantly share code, notes, and snippets.

Keybase proof

I hereby claim:

  • I am paulirish on github.
  • I am paulirish (https://keybase.io/paulirish) on keybase.
  • I have a public key whose fingerprint is 41BE F531 2AD3 FC63 D87B 9598 49E4 5F08 1ABE E562

To claim this, I am signing this object:

// css() upgrade for a few shorthand values
// paul irish. MIT license.
// by default you can't do $(elem).css('margin'), but instead $(elem).css('marginTop') and so on.
// this monkeypatch allows lets you retrieve all four values in shorthand style:
// e.g. $(this).css('padding')
(function($){
var css = $.fn.css, methods = {'padding':1,'margin':1}, dirs = 'Top Right Bottom Left'.split(' ');
"Ode to Paul Irish"
There once was a jQuery master from Boston,
whose soul-piercing eyes you could get lost in.
He gave some cool talks,
which knocked off my socks,
and now he's the daddy of my children.
// easy refresh-css keybinding to alt-w
// alt-r was taken in IE, so consider this a CSS Weefresh
// original code from http://paulirish.com/2008/how-to-iterate-quickly-when-debugging-css/
$(document).keyup(function(e){
if ( e.which == 87 && e.altKey){
var h,a,f;a=document.getElementsByTagName('link');for(h=0;h<a.length;h++){f=a[h];if(f.rel.toLowerCase().match(/stylesheet/)&&f.href){var g=f.href.replace(/(&|\?)forceReload=\d+/,'');f.href=g+(g.match(/\?/)?'&':'?')+'forceReload='+(new Date().valueOf())}}
}
// sharethis plugin by paul irish
// usage:
// $('a.sharethistrigger').shareThis();
// for ShareThis
$.fn.shareThis = function(){
if (!$(this).length) return this; // quit if theres nothing.
// this path should come out of the configurator
@paulirish
paulirish / to12hr.js
Created December 6, 2009 03:38 — forked from redoPop/to12hr.js
var to12Hr = function(n, r /* round to nearest r minutes */) {
if (!n || n >= 24) return '12:00 AM';
var m = (Math.round(n%1*(r = (r ? 60/r : 60)))/r)*60;
return ((n = (m>59 ? n+1 : n))>=13 ? (n|0)-12 : n|0) + ':' + (m>9 ? (m>59 ? '00' : m) : '0'+m) + (n>=12 && m<60 ? ' PM' : ' AM');
}
// to12Hr(6.5) => "6:30 AM"
// to12Hr(13.19) => "1:11 PM"
// to12Hr(13.19, 15) => "1:15 PM" (rounds to 15 mins)
// A bookmarklet to add search ability to any github.com repo.
// Note: Disable Chrome Frame in IE to use this bookmarklet as github.com supports Chrome Frame
// @author John-David Dalton (http://www.twitter.com/jdalton)
javascript:void(function(){var a='';if(!$('.subnav-bar').length){a=$('form#search-form input[name=q]').val();$('.big-search').remove();$('.tabs').after('<div class="subnav-bar"></div>')}else{$('#repo-search-form').remove()}$('.subnav-bar').append('<ul style="float:right;margin-left:10px;"><li><a class="dropdown" href="#">Search by&hellip;</a><ul><li><a href="#" onclick="$(\'#choice\').val(\'code\');return false;">Code</a></li><li><a href="#" onclick="$(\'#choice\').val(\'grep\');return false;">Commit Messages</a></li><li><a href="#" onclick="$(\'#choice\').val(\'author\');return false;">Author</a></li><li><a href="#" onclick="$(\'#choice\').val(\'committer\');return false;">Committer</a></li></ul></li></ul><form id="repo-search-form" action="'+$('.pagehead.repohead h1 a')[1].href+'/search"><i
<!DOCTYPE html>
<html class="no-js">
<head>
<script src="http://ajax.googleapis.com/ajax/libs/jquery/1.3.2/jquery.min.js"></script>
<link rel="stylesheet" href="http://ajax.googleapis.com/ajax/libs/jqueryui/1.7.2/themes/base/jquery-ui.css" type="text/css" />
<link rel="stylesheet" href="http://www.eyecon.ro/colorpicker/css/colorpicker.css" type="text/css" />
<script src="http://ajax.googleapis.com/ajax/libs/jqueryui/1.7.2/jquery-ui.min.js"></script>
//
// Replicates .activate() from the Prototype JS library.
// http://www.prototypejs.org/api/form/element/activate
//
jQuery.fn.activate = function() {
if ('focus' in this) this.focus();
if ('select' in this && (this.tagName != 'INPUT' || !(/^(?:button|reset|submit)$/i.test(this.type)))) {
this.select();
// 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;