Monthly Archives: May 2008

Bookmarklet to de-cache CSS and images

Update: This code has been replaced.

Save the following as a bookmarklet to dynamically get the latest versions of CSS and images, regardless of caching. This version doesn’t do CSS background images, though.

javascript:(function(){var i,j,x;x=document.getElementsByTagName('link');for(i=0,j=x.length;i<j;i++){x[i].href=x[i].href+'?'+new Date().getTime();}x=document.getElementsByTagName('img');for(i=0,j=x.length;i<j;i++){x[i].href=x[i].href+'?'+new Date().getTime();}})();

jQuery plugin to emulate “shake” on login failure in OSX login box

Ridiculous, but still:

jQuery.fn.shake = function(intShakes /*Amount of shakes*/, intDistance /*Shake distance*/, intDuration /*Time duration*/) {
  this.each(function() {
    for (var x=1; x<=intShakes; x++) {
      $(this).animate({left:(intDistance*-1)}, (((intDuration/intShakes)/4)))
      .animate({left:intDistance}, ((intDuration/intShakes)/2))
      .animate({left:0}, (((intDuration/intShakes)/4)));
  return this;
$(function() {
  $('#btn').click(function() {
    $(this).shake(3, 6, 180);