2015-01-28 at

Immediately Invoked Functional Expressions (IIFEs) in JavaScript

References:
  • Wikipedia
  • http://gregfranko.com/blog/i-love-my-iife/
  • http://nicoespeon.com/en/2013/05/properly-isolate-variables-in-javascript
  • http://benalman.com/news/2010/11/immediately-invoked-function-expression/

A example for general use:

TL;DR
(function(ourcode){ourcode($,window,document)}(function($,window,document){/*do protected stuff*/}))

 /*
  * i.    There are two function expressions.
  *
  * ii.   The purpose of this outer IIFE is cosmetic, to display the global
  *       variables passed into the inner IIFE, at the TOP of your script.
  *       Otherwise they would be displayed at the bottom, e.g.
  *
  *         function(){
  *           // our spiffy code
  *         }(window.jQuery, window, document);
  *
  * iii.  In the inner IIFE, '$,' 'window,' and 'document,' are parameter names, 
  *       and therefore locally scoped. WE'RE NOT REFERRING TO GLOBALS.
  * 
  */



( function(ourcode) 
  {   
    console.log('Outer IFFE: I did not wait - I was simply invoked before the Inner IFFE.')
    ourcode(window.jQuery, window, document);
    console.log('Outer IFFE: I did not wait - I was simply invoked after the Inner IFFE.')
  }(  function($, window, document) 
      {   

        // Here, finally, lies the code we wanted to execute.

        $(function() {

          // Code that MUST wait for the DOM to be ready goes here. 
          console.log('Inner IFFE: I waited - I was invoked within $(like_this) ')

        });

        // Code that does NOT need to wait for the DOM to be ready goes here. 
        console.log('Inner IFFE: I did not wait - I was simply invoked.')

      }   
    )   
);

2015-01-19 at

Clobbered Punctuation

Seven years ago - that email. It was a good bellweather. It affirmed my speculations that working for illiterate government pansies makes one a bit of a beta. But one makes good money, very good money doing that, hand over fist really. We need them. We need all types. Who am I to judge - on average I spend more time losing money than making it. #youthinasia

2015-01-18 at

Being Nice to People

One thing I learnt from growing up with pastors... care giving is an activity. You move your face, and hands, and body, speak in certain ways, smile, and people feel better. It lets you work with others. Even if you take no personal interest in them. Trust is a job. On we go.