mo.notono.us

Thursday, March 24, 2011

IE9 the new king of the Underscore performance tests

See http://documentcloud.github.com/underscore/test/test.html and past tests: http://mo.notono.us/search?q=underscore

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).

http://net.tutsplus.com/tutorials/javascript-ajax/fun-with-jquery-templating-and-ajax/

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

http://net.tutsplus.com/tutorials/javascript-ajax/fun-with-jquery-templating-and-ajax/comment-page-1/#comment-357637

$.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: http://jsfiddle.net/austegard/ZaFVg/ - 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: , , , ,