Shuffle Array

Technique #1
function Shuffle(o) {
	for(var j, x, i = o.length; i; j = parseInt(Math.random() * i), x = o[--i], o[i] = o[j], o[j] = x);
	return o;
};

Usage

var testArray = [1,2,3,4,5];
Shuffle(testArray);

// jQuery to dump out 
Avatar of Chris Coyier
Chris Coyier on (Updated on )

Validate HTML Bookmarklet

javascript:(function(){%20function%20fixFileUrl(u)%20{%20var%20windows,u;%20windows%20=%20(navigator.platform.indexOf("Win")%20!=%20-1);%20%20/*%20chop%20off%20file:///,%20unescape%20each%20%hh,%20convert%20/%20to%20\%20and%20|%20to%20:%20*/%20%20u%20=%20u.substr(windows%20?%208%20:%207);%20u%20=%20unescape(u);%20if(windows)%20{%20u%20=%20u.replace(/\//g,"\");%20u%20=%20u.replace(/\|/g,":");%20}%20return%20u;%20}%20/*%20bookmarklet%20body%20*/%20var%20loc,fileloc;%20loc%20=%20document.location.href;%20if%20(loc.length%20>%209%20&&%20loc.substr(0,8)=="file:///")%20{%20fileloc%20=%20fixFileUrl(loc);%20if%20(prompt("Copy%20filename%20to%20clipboard,%20press%20enter,%20paste%20into%20validator%20form",%20fileloc)%20!=%20null)%20{%20document.location.href%20=%20"http://validator.w3.org/file-upload.html"%20}%20}%20else%20document.location.href%20=%20"http://validator.w3.org/check?uri="%20+%20escape(document.location.href);%20void(0);%20})();

Make a bookmark with the above code, or just drag the following button link to your bookmarklets bar.

validate html

Avatar of Chris Coyier
Chris Coyier on (Updated on )

Ajax Image Uploading (With Less Suck)

This technology demo is courtesy of ZURB and the post was co-authored by ZURB and Chris.

How do you upload images now?

You select a file and click upload. Simple right? Except once you select your image you can no …

Avatar of Zurb
Zurb on (Updated on )

Instant Productivity

All jobs are a series of tasks needing to be completed. Let’s look at a construction worker. Today she needs to bust up a bunch of cement. Here is one path of action:

Put hardhat on
Start jackhammer
Bust up

Avatar of Chris Coyier
Chris Coyier on

Transparency in Web Design

How is it done? Let’s take a gander at four different ways. Each of them handling the illusion in a different way, and each completely appropriate depending on the situation at hand.…

Avatar of Chris Coyier
Chris Coyier on (Updated on )

Glyphs

Special Characters
" " quotation mark u+0022 ISOnum p:before { content:”\0022″; } alert(“\42”)
& & & ampersand u+0026 ISOnum p:before { content:”\0026″; } alert(“\46”)
&lt; &#60; < less-than sign u+003C ISOnum p:before { content:”\003c”; } alert(“\74”);
&gt; &#62; >
Avatar of Chris Coyier
Chris Coyier on (Updated on )

Video Screencasts

#80: Regarding Wheel Invention
Running time: 19:09
Sometimes “reinventing the wheel” is the right way to go. You get control and all the learning that goes into it. Sometimes it is a waste of time and an existing solution will
Avatar of Chris Coyier
Chris Coyier on (Updated on )

#86: First Moments with MAMP

I’m way behind the times on this one, but until recently, I have never really developed locally. Everything I did was “going commando” and working directly on servers. The situation arose where I really needed to, so now I have …

Avatar of Chris Coyier
Chris Coyier on (Updated on )