Complex manual cache-busting with RequireJS

July 24, 2015 | No comments

RequireJS gives you the urlArgs property in require.config to add cache-busting. You can use a version, so the browser grabs updated files only when you change the version number:

    urlArgs: 'v=1.00'

You can generate a time-based number so that the browser will grab updated files every single time:

    urlArgs: 'v=' + (new Date()).getTime()

» Read the rest of this entry «

Easy jQuery Quiz is now a real plugin!

June 10, 2013 | No comments

Hi folks, many thanks for your feedback and questions about my Easy jQuery Quiz tutorial. For those of you who would rather just download a plugin, you’re in luck, because I just made it into one!

See the demo or download the files.


Create an unordered list <ol> within a div. The <li>s that are quiz questions should all have on them and should contain a nested <ol> of multiple choice answers. The correct answer <li> within this nested <ol> should have on them. Like so: » Read the rest of this entry «

A great little JavaScript function for generating random Gaussian/Normal/Bell-Curve numbers

May 30, 2012 | No comments

Have you ever needed to generate random numbers that clustered around the center value? I have, and I found this little gem from Colin Godsey. Here’s the function:

Math.nrand = function() {
	var x1, x2, rad, y1;
	do {
		x1 = 2 * this.random() - 1;
		x2 = 2 * this.random() - 1;
		rad = x1 * x1 + x2 * x2;
	} while(rad >= 1 || rad == 0);
	var c = this.sqrt(-2 * Math.log(rad) / rad);
	return x1 * c;

I won’t pretend to understand how the math works, but I will show you a demo so you can get a picture of how you might use this: Generating a Random Gaussian Number with Javascript.

Tutorial: Easy jQuery-Based Quiz

March 16, 2012 | 7 comments

In this tutorial I’ll show you how to create your own interactive quiz using jQuery/JSON and CSS. View the demo or download the source files.

Part One: the HTML

A nested <ol>, input.submit, and inside a div#quiz. The rel attribute of div#quiz is important, more on that later. The question <li>s have unique ids (q1, q2 etc) while the answer <li>s within each question have classes (a1, a2, etc) that are repeated per question. » Read the rest of this entry «

@font-face problem with Facebook in IE8

December 16, 2011 | No comments

While working on a Facebook app that uses web fonts through an @font-face declaration created with Font Squirrel, I noticed a bizarre bug in IE8 in which all the text in the parent frame (ie Facebook) takes on one of the custom fonts supported with an EOT file. Despite the fact that it’s rather amusing to see all of Facebook rendered in a fancy display font, it would be very wrong and shocking for a user to see this.

Searching for a workaround, I came across a few different posts that helped me understand the issue better, but didn’t quite work in the context of a Facebook app. » Read the rest of this entry «

Scrollbars on Facebook Canvas iframe

October 3, 2011 | No comments

Just a quick heads up for anyone out there who is confounded by the existence of disabled scrollbars on their Facebook app canvas page. In your application’s advanced settings, checking Canvas Height: Fluid will add scrolling=”yes” to the iframe code, so select Settable to get rid of the scrollbars.

Converting my Flash game into an Android app

July 14, 2011 | 3 comments

We all know the story about Flash and the iPhone, but with Android phones there is no such obstacle. So with the help of Paul Trani’s tutorial on, I was able to convert my Cupcake Invaders Flash game into an Adobe AIR application for Android.

The key steps in the conversion:

  1. Instead of walking the character on an arrow button hover or arrow keydown, I used the accelerometer’s horizontal acceleration. Thus when the player tilts the device to the left or right, the character walks in that direction.
  2. I converted most of the graphics from Flash vector drawings into PNGs. While a PC has the processor power to scale and move vector graphics quickly, phone processors are less beefy and have an easier time with bitmap graphics.
  3. I downloaded the Adobe AIR SDK to compile the APK file and then downloaded the Android SDK to push the file to my DroidX for testing.

I haven’t published to the Android Market yet, but you can download and install the Cupcake Invaders app here.

Multiple jQuery UI dialogs in a dynamic page

June 21, 2011 | 2 comments

Recently I was doing the front-end dev for a dynamically generated page that needed to have a large number of popups. I found the following script to help me enable the dialogs in a way that would be easy to integrate with dynamically generated code.

The original script

My version:

$(function() {
    var options = {
		autoOpen: false,
		resizable: false,
		width: 462,
		height: 373,
		open: function() {
    var n = 1;
    $(".popup").each(function(i) {
        var dlg = $('#popup-' + n).dialog(options);
        $('.opener-' + n).click(function() {
            return false;
        $('#closer-' + n).click(function() {
            return false;


What I changed:

  • In the options I added a function on open to remove the title bar.
  • I used the a class on the dialog div instead of the opener link to run the each loop, because there would be multiple opener links for each dialog.
  • I added a close function on a closer button.

Review of Roots WordPress Theme

May 18, 2011 | No comments

I recently had the pleasure of using the blank WordPress theme Roots for the first time. I was pleased with the experience, but I do have a few suggestions for how the theme could be improved:

Adjusting the nav bar width: Roots supports, the grid-based CSS layout framework. For the most part this works quite well, with all elements adjusting to any width of box that you choose to put them in… except the main nav. The nav UL is set at 100% wide, so it renders at 960px. However, if you have left the right and left gutters out of your design, you’ll want a nav of 940px wide, which is achieved with the class .grid_12. However, since the nav UL is set to 100% and its parent nav#nav-main is not, you won’t get the nav bar down to 940px until you put a width of 100% on nav#nav-main as well.

Utility nav alignment: The utility nav (nav#nav-utility) has absolute positioning (top:0;right:0), but when its parent has a right margin, this does not affect the position of nav#nav-utility. Therefore you have to add the same width of the margin to the right value in the #nav-utility declaration (e.g. right:10px).

Height and width on logo image: The logo img tag has height and width values, which is generally not best practices. Very few logos will actually be those dimensions — 300×75, so if a developer forgets to delete the values in the HTML, the image will be distorted.

Google Instant misses letters

January 19, 2011 | 1 comment

After a couple of Google-praising posts, it’s only fair to point out one Google Product that doesn’t work well. When typing in the new “Google Instant” search field, I kept feeling like I was mistyping words or that my keyboard was getting sticky. But on closer inspection I realized that the fault lies with Google, not my keyboard or fat fingers.

As a member of the Instant-Messaging Generation, I do indeed type at lightning speed, which means that Google is returning it’s instant results at thunder speed. Or something like that. Now I just use my Firefox search bar. It was a nice thought to try to provide me with search results before I hit enter, but it’s not worth making me feel like I can’t type. #1 rule of usability: don’t make the user feel stupid.