Thursday, March 24, 2011

IE9 the new king of the Underscore performance tests

See and past tests:

Labels: , , , ,

Wednesday, March 23, 2011

Welcome to TicketMaster. How may we fleece you today?

  • Two mid-priced tickets to the Circus: $52.
  • Facility charge: $4.00
  • “Convenience” Charge to use our lousy website: $11.90
  • Order Processing Fee: $4.95
  • TicketFast® delivery – cause it takes us TWO WEEKS to print and mail two tickets, so you may not get them in time: $4.95
  • Total: $77.40
  • Are you sure you don’t want to add another $7 per ticket to insure against not being able to make the event due to illness, airline delay or traffic accidents?  (Cause 50% isn’t enough of a markup; we’d love to make it 75%.)

How, in an economy as market driven and litigious as the US has TicketMaster managed to become such an effective monopoly and not be priced – or sued – out of existence?

Labels: , ,

Tuesday, March 01, 2011

Practical example of jQuery 1.5’s deferred.when() and .then()

"“Fun with jQuery Templating and AJAX” by Dan Wellman is a generally interesting article, but I found the code in the “Getting the Data” block especially interesting – see how each get function RETURNS the $.ajax function call, which can then be called inside a when() function, vastly simplifying the workflow (there’s an error in the listed code – getTweets() is supposed to return the ajax function, not simply execute it).

Even more interesting is this pattern, suggested by commenter Eric Hynds (whose blog has now been added to my Google Reader list):

$.when( $.get('./tmpl/person.tmpl'), $.getJSON('path/to/data') )
   .then(function( template, data ){
      $.tmpl( template, data ).appendTo( "#people" );

The deferred.done() and then() methods will take as arguments the results from each function called in the when() function – in order – i.e. the output of the get will map to template, and the output from the getJson will be mapped to data.  This is pretty sweet!

Perhaps a simpler to observe example of the behavior is shown here: - no prize for correct guesses as to the result of this…

/* Hello and World are both treated as resolved deferreds - they 
can be replaced with any function, like a $.get, etc */
$.when( "Hello", "World" ).then(
   function(x, y){ alert(x + " " + y); }

Labels: , , , ,