Skip to content

Instantly share code, notes, and snippets.


Paul Irish paulirish

View GitHub Profile

Keybase proof

I hereby claim:

  • I am paulirish on github.
  • I am 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:

View gist:216655
// 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')
var css = $.fn.css, methods = {'padding':1,'margin':1}, dirs = 'Top Right Bottom Left'.split(' ');
View Ode to Paul Irish
"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.
View gist:221905
// easy refresh-css keybinding to alt-w
// alt-r was taken in IE, so consider this a CSS Weefresh
// original code from
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())}}
View gist:221589
// 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
View 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)
View gist:270445
// A bookmarklet to add search ability to any repo.
// Note: Disable Chrome Frame in IE to use this bookmarklet as supports Chrome Frame
// @author John-David Dalton (
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
View provide_html5.html
<!DOCTYPE html>
<html class="no-js">
<script src=""></script>
<link rel="stylesheet" href="" type="text/css" />
<link rel="stylesheet" href="" type="text/css" />
<script src=""></script>
View jquery.activate.js
// Replicates .activate() from the Prototype JS library.
jQuery.fn.activate = function() {
if ('focus' in this) this.focus();
if ('select' in this && (this.tagName != 'INPUT' || !(/^(?:button|reset|submit)$/i.test(this.type)))) {;
View gist:274913
// 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:
// usage: $(elem).css('backgroundPosition');
// ticket:
var _css = $.fn.css;