<?xml version="1.0" encoding="UTF-8"?>
<rss xmlns:dc="http://purl.org/dc/elements/1.1/" version="2.0"><channel><atom:link rel="hub" href="http://tumblr.superfeedr.com/" xmlns:atom="http://www.w3.org/2005/Atom"/><description>Front-end developer at FT Labs, within the Financial Times. Chatting about JavaScript, CSS, Web-Apps and other goodness. Follow me on Twitter.</description><title>Wilson Page</title><generator>Tumblr (3.0; @wilsonpage)</generator><link>http://wilsonpage.tumblr.com/</link><item><title>Exposing module API in CSS</title><description>&lt;p&gt;Lately I have been spending a lot of time investigating reusable view modules. A view is made up of several modules (or components), dropped into certain slots within a layout. The aim is that these modules be fully reusable and transportable. In order for this to work a module must not be aware of its context, and it’s styles must not leak out side of its scope.&lt;!-- more --&gt;&lt;em&gt;Currently each module has two files:&lt;/em&gt;&lt;/p&gt;
&lt;ul&gt;&lt;li&gt;mymodule.ms (Mustache template)&lt;/li&gt;
&lt;li&gt;mymodule.scss (SASS file)&lt;/li&gt;
&lt;/ul&gt;&lt;p&gt;&lt;strong&gt;The layout&lt;/strong&gt;&lt;/p&gt;
&lt;p&gt;A module sits within a layout module which is an arrangement of slots of certain sizes. The layout is the most responsive part of the app, it’s fluid and expects it’s modules to fill all available space within its slots.&lt;/p&gt;
&lt;p&gt;&lt;strong&gt;Layouts as controllers&lt;/strong&gt;&lt;/p&gt;
&lt;p&gt;As time goes on I am seeing this layout module adopting a similar role to a Javascript controller. It is effectively the parent of the modules that sit within it. The layout module is more aware of the overall app, whereas its children are dumb and ignorant (this is good!).&lt;/p&gt;
&lt;p&gt;&lt;strong&gt;Modules being too clever&lt;/strong&gt;&lt;/p&gt;
&lt;p&gt;I ran into difficulty sticking to this pattern when view modules needed to respond to changes in their environment. At first I was using media queries directly inside the modules, but that was breaking one of my rules; the module was responding to changes in its environment when it should not know anything of its context! Module styles must remain decoupled from the app itself.&lt;/p&gt;
&lt;p&gt;&lt;strong&gt;Layouts telling children what to do&lt;/strong&gt;&lt;/p&gt;
&lt;p&gt;If we have learnt anything from effective application architecture in JavaScript, it is that controllers should call lower level module API, and not the other way round. Effectively we want out CSS layout modules to tell its child modules how to behave, and when. How can we does this, child modules must have some form of API that a higher level (our layout) can call upon.&lt;/p&gt;
&lt;p&gt;&lt;strong&gt;Using SASS mixins to expose a module &amp;#8216;API&amp;#8217;&lt;/strong&gt;&lt;/p&gt;
&lt;p&gt;SASS mixins can be used to define alternative states of a module. The layout stylesheet can then include this mixin in certain circumstances (ie. within a particular media query breakpoint).&lt;/p&gt;
&lt;p&gt;The example below illustrates this. Module-x has a default `background-color` of red, but it has also exposed an optional state via a mixin called `module-x-blue`. The parent layout has then included this mixin within a media query, therefore forcing the child module-x to change. Effectively calling the `module-x-blue` &amp;#8216;API&amp;#8217;.&lt;/p&gt;
&lt;div class="gist"&gt;&lt;a href="https://gist.github.com/4252824" target="_blank"&gt;https://gist.github.com/4252824&lt;/a&gt;&lt;/div&gt;
&lt;p&gt;&lt;strong&gt;Why is this cool?&lt;/strong&gt;&lt;/p&gt;
&lt;p&gt;We have effectively decoupled our module styling from the app context, but retained the ability for the module to appear differently under different states. A module could have many states that can be called by the developer.&lt;/p&gt;
&lt;p&gt;&lt;strong&gt;Doesn&amp;#8217;t @include duplicate code every time it is used?&lt;/strong&gt;&lt;/p&gt;
&lt;p&gt;Correct, it does, but let&amp;#8217;s weigh up the gains vs. the drawbacks of this:&lt;/p&gt;
&lt;ul&gt;&lt;li&gt;The power of mixins has enabled us to produce a purely reusable, multi-state, project agnostic component. This reuse alone is going to save you time and code.&lt;/li&gt;
&lt;li&gt;Assuming you have defined the majority of style in the default state, the overriding styles within the mixin should be relatively light.&lt;/li&gt;
&lt;li&gt;If you don&amp;#8217;t use the &amp;#8216;API&amp;#8217; mixins, they won&amp;#8217;t be compiled into your end CSS. This means a module could have a limitless amount of mixins, and the developer can be sure they&amp;#8217;ll only be shipping what they use.&lt;/li&gt;
&lt;li&gt;Realistically it is unlikely an API mixin is going to be used that many times within a project. In my experience 3 times at an absolute max (in a very large project).&lt;/li&gt;
&lt;/ul&gt;&lt;p&gt;&lt;strong&gt;Summary&lt;/strong&gt;&lt;/p&gt;
&lt;p&gt;SASS empowers us to be more intelligent with our CSS. With a little thought we can apply established patterns that we have learnt from our code, to our stylesheets. Modularisation via small rock solid building blocks is key to producing maintainable applications. The more we can do to share and reuse components, the more productive we can be.&lt;/p&gt;
&lt;p&gt;I would live to hear suggestions or experiences from you guys, so feel free to comment :)&lt;/p&gt;</description><link>http://wilsonpage.tumblr.com/post/37667485502</link><guid>http://wilsonpage.tumblr.com/post/37667485502</guid><pubDate>Mon, 10 Dec 2012 18:01:00 -0500</pubDate></item><item><title>CSS 3D transforms messing with your z-index</title><description>&lt;p&gt;&lt;strong&gt;About 3D Tranforms&lt;/strong&gt;&lt;/p&gt;

&lt;p&gt;3D transforms are useful even when you are not creating a design that utilises 3D space. Setting a 3D transform on an element causes hardware accelerated graphics to kick in, making animation super smooth. This is not that evident on powerful desktop platforms but on mobile devices the difference is astonishing!&lt;/p&gt;

&lt;p&gt;To trigger hardware acceleration on an element you can apply a class like this:&lt;/p&gt;

&lt;pre&gt;&lt;code&gt;/* Trigger hardware-acceleration */
.uses3d { -webkit-transform: translate3d(0, 0, 0); -webkit-transform-style: preserve-3d; }
&lt;/code&gt;&lt;/pre&gt;

&lt;p&gt;&lt;br/&gt;&lt;strong&gt;The z-index problem&lt;/strong&gt;&lt;/p&gt;

&lt;p&gt;I ran into a major issue in particular versions of webkit that causes z-index to be ignored on an element and its children when a 3D property is specified. No matter what I did I could get these particular hardware accelerated elelements to respect their original z-index.&lt;/p&gt;

&lt;p&gt;&lt;br/&gt;&lt;strong&gt;The fix&lt;/strong&gt;&lt;/p&gt;

&lt;p&gt;After running round in circles and setting ridiculously high and low z-indexes on elements to no avail I stumbled across the solution. It seemed that within the hardware accelerated layer created z-index was being ignored, so I decided to try setting a pixel value on that &amp;#8220;3D&amp;#8221; elements z-axis. It worked! In certain browsers (I found Chrome and Blackberry Playbook) the z-index must be reinforced with a z-axis property. Like so:&lt;/p&gt;

&lt;pre&gt;&lt;code&gt;#a{
    width: 300px;
    height: 300px;
    background: red;
    position: absolute;
    left: 0px;
    top: 0px;
    z-index: 1;

   /* reinforce z-index in 3D space */
    -webkit-transform: translate3d(0, 0, 1px);
}
&lt;/code&gt;&lt;/pre&gt;

&lt;p&gt;&lt;br/&gt;&lt;strong&gt;Working example&lt;/strong&gt;&lt;/p&gt;

&lt;p&gt;In this example try commenting out the &amp;#8216;preserve-3d&amp;#8217; styling on the container and notice how the z-index is respected. With the &amp;#8216;preserve-3d&amp;#8217; styling on try uncommenting the &amp;#8216;-webkit-transform&amp;#8217; property on each child element. Notice how styling is preserved. This bug is evident for me on Chrome v16.0.912.75.&lt;/p&gt;

&lt;p&gt;&lt;a href="http://jsfiddle.net/qkLWH/20/" target="_blank"&gt;http://jsfiddle.net/qkLWH/20/&lt;/a&gt;&lt;/p&gt;</description><link>http://wilsonpage.tumblr.com/post/16167357909</link><guid>http://wilsonpage.tumblr.com/post/16167357909</guid><pubDate>Fri, 20 Jan 2012 06:56:57 -0500</pubDate><category>css</category><category>css3</category><category>3d tranforms</category></item><item><title>Deploying your project using Git</title><description>&lt;p&gt;&lt;strong&gt;Part 1&lt;/strong&gt;&lt;/p&gt;

&lt;iframe width="560" height="315" src="http://www.youtube.com/embed/N-v_DBFbZxo" frameborder="0" allowfullscreen&gt;&lt;/iframe&gt;

&lt;p&gt;&lt;br/&gt;&lt;strong&gt;Part 2&lt;/strong&gt;&lt;/p&gt;

&lt;iframe width="560" height="315" src="http://www.youtube.com/embed/Z20-ubkoq6M" frameborder="0" allowfullscreen&gt;&lt;/iframe&gt;</description><link>http://wilsonpage.tumblr.com/post/15519375113</link><guid>http://wilsonpage.tumblr.com/post/15519375113</guid><pubDate>Sun, 08 Jan 2012 13:43:56 -0500</pubDate><category>git</category><category>git hooks</category><category>linux</category><category>ec2</category><category>deployment</category></item><item><title>Installing Node.js on your Linux server</title><description>&lt;iframe width="420" height="315" src="http://www.youtube.com/embed/A8PyL6Zv2Po" frameborder="0" allowfullscreen&gt;&lt;/iframe&gt;

&lt;p&gt;Here I am using the &lt;a href="https://github.com/visionmedia/n" target="_blank"&gt;VisionMedia &amp;#8216;n&amp;#8217; Node Version manager&lt;/a&gt; to install the latest version of Node and NPM. Switch to 720p for best quality.&lt;/p&gt;

&lt;p&gt;If you liked my video &lt;a href="https://twitter.com/WilsonPage" target="_blank"&gt;follow me on Twitter&lt;/a&gt;&lt;/p&gt;</description><link>http://wilsonpage.tumblr.com/post/15518837743</link><guid>http://wilsonpage.tumblr.com/post/15518837743</guid><pubDate>Sun, 08 Jan 2012 13:33:38 -0500</pubDate><category>nodejs</category></item><item><title>Setting up a new Amazon EC2 instance</title><description>&lt;iframe width="560" height="315" src="http://www.youtube.com/embed/-CdwRkJQsuw" frameborder="0" allowfullscreen&gt;&lt;/iframe&gt;

&lt;p&gt;In this video I explain how to setup and Amazon EC2 instance with Linux Ubuntu. I also explain how to SSH into your server using putty.&lt;/p&gt;</description><link>http://wilsonpage.tumblr.com/post/15506032780</link><guid>http://wilsonpage.tumblr.com/post/15506032780</guid><pubDate>Sun, 08 Jan 2012 07:17:00 -0500</pubDate></item><item><title>Unit testing front-end JavaScript </title><description>&lt;a href="http://msdn.microsoft.com/en-us/scriptjunkie/gg649850.aspx"&gt;Unit testing front-end JavaScript &lt;/a&gt;</description><link>http://wilsonpage.tumblr.com/post/14406826266</link><guid>http://wilsonpage.tumblr.com/post/14406826266</guid><pubDate>Sun, 18 Dec 2011 11:31:15 -0500</pubDate></item><item><title>[javascript] How to test typeof 'Array'</title><description>&lt;a href="http://t.co/3dzVak1W"&gt;[javascript] How to test typeof 'Array'&lt;/a&gt;</description><link>http://wilsonpage.tumblr.com/post/14269404554</link><guid>http://wilsonpage.tumblr.com/post/14269404554</guid><pubDate>Thu, 15 Dec 2011 13:40:57 -0500</pubDate></item><item><title>[templating] Changing the syntax of underscore tempates</title><description>&lt;a href="http://jsfiddle.net/3KnCq/3/"&gt;[templating] Changing the syntax of underscore tempates&lt;/a&gt;: &lt;p&gt;In this example I change the regex pattern in the templateSettings of underscore to match that of a templating engine you may be using on the back-end.&lt;/p&gt;</description><link>http://wilsonpage.tumblr.com/post/14186926215</link><guid>http://wilsonpage.tumblr.com/post/14186926215</guid><pubDate>Tue, 13 Dec 2011 18:38:00 -0500</pubDate></item><item><title>[jQuery] CSS3 animate() plugin test</title><description>&lt;a href="http://jsfiddle.net/NaWHb/2/"&gt;[jQuery] CSS3 animate() plugin test&lt;/a&gt;: &lt;p&gt;Here is a little experiment using &lt;a href="https://github.com/louisremi/jquery.transition.js" target="_blank"&gt;jquery.transition.js&lt;/a&gt; demonstrating how the &lt;code&gt;.animate()&lt;/code&gt; method can be upgraded to use CSS3 transitions when available.&lt;/p&gt;</description><link>http://wilsonpage.tumblr.com/post/14185152717</link><guid>http://wilsonpage.tumblr.com/post/14185152717</guid><pubDate>Tue, 13 Dec 2011 18:04:16 -0500</pubDate></item><item><title>Automated deployment of node.js apps</title><description>&lt;a href="http://www.carbonsilk.com/node/deploying-nodejs-apps/"&gt;Automated deployment of node.js apps&lt;/a&gt;</description><link>http://wilsonpage.tumblr.com/post/13926822660</link><guid>http://wilsonpage.tumblr.com/post/13926822660</guid><pubDate>Thu, 08 Dec 2011 12:52:38 -0500</pubDate></item><item><title>[deployment] What is a 'Makefile'?</title><description>&lt;p&gt;&lt;img src="http://media.tumblr.com/tumblr_lvwb85Cn381r24j9x.jpg" alt=""/&gt;&lt;/p&gt;

&lt;p&gt;&lt;em&gt;Coming originally from a design background a lot of the aspects of web development that I find myself confronted with seem completely foreign. The latest of those has been the term &lt;code&gt;make&lt;/code&gt;. I kept seeing it crop up in READMEs and generally scattered around GitHub. I set out to find what &lt;code&gt;make&lt;/code&gt; means and if it would be of use to me.&lt;/em&gt;&lt;/p&gt;

&lt;p&gt;&lt;br/&gt;&lt;strong&gt;What does &amp;#8216;make&amp;#8217; refer to?&lt;/strong&gt;&lt;/p&gt;

&lt;p&gt;&lt;code&gt;make&lt;/code&gt; is a command that is run from command line. When it is run it looks for a file titled &amp;#8216;Makefile&amp;#8217; in the directory you are currently in. A &amp;#8216;Makefile&amp;#8217; is just a batch of command line tasks to be run in one go.&lt;/p&gt;

&lt;p&gt;Makefiles are used throughout the computer programming world, they are a very old concept that seems to have stood the test of time. They are generally used to compile a load of source files ready for production use.&lt;/p&gt;

&lt;p&gt;&lt;br/&gt;&lt;strong&gt;What do Makefiles do?&lt;/strong&gt;&lt;/p&gt;

&lt;p&gt;As we are web designers we will be using our Makefiles to do slightly different things than native software developers, but the principles remain the same. Generally we use Makefiles to automate tasks that would normally be a chore. Most GitHub repos will have a Makefile in the root (&lt;a href="https://github.com/visionmedia/express" target="_blank"&gt;see Express as an example&lt;/a&gt;)&lt;/p&gt;

&lt;p&gt;&lt;em&gt;Some of these tasks might include:&lt;/em&gt;&lt;/p&gt;

&lt;ul&gt;&lt;li&gt;Concatenating and minifying CSS/JS&lt;/li&gt;
&lt;li&gt;Running unit-test suites (&lt;a href="https://github.com/caolan/nodeunit" target="_blank"&gt;NodeUnit&lt;/a&gt;, &lt;a href="https://github.com/visionmedia/mocha" target="_blank"&gt;Mocha&lt;/a&gt;, &lt;a href="https://github.com/jquery/qunit" target="_blank"&gt;QUnit&lt;/a&gt;, etc)&lt;/li&gt;
&lt;li&gt;Compressing images&lt;/li&gt;
&lt;li&gt;Moving (or deploying) project files from you local machine or remote repository to a &amp;#8216;Staging&amp;#8217; or &amp;#8216;Production&amp;#8217; server&lt;/li&gt;
&lt;li&gt;Booting up a nodejs server&lt;/li&gt;
&lt;/ul&gt;&lt;p&gt;&lt;br/&gt;&lt;strong&gt;What do I need?&lt;/strong&gt;&lt;/p&gt;

&lt;p&gt;I believe &lt;code&gt;make&lt;/code&gt; is native to Mac but PC requires installation of &lt;a href="http://gnuwin32.sourceforge.net/packages/make.htm" target="_blank"&gt;gnuwin32make&lt;/a&gt; for the basic &lt;code&gt;make&lt;/code&gt; application and &lt;a href="http://gnuwin32.sourceforge.net/packages/coreutils.htm" target="_blank"&gt;gnuwin32CoreUtils&lt;/a&gt; to give you functionality like &lt;code&gt;cat&lt;/code&gt; (file concatenation) to the command line.&lt;/p&gt;

&lt;p&gt;Once you have make installed and accessible via your command line you&amp;#8217;re set to start writing your own Makefile (usually sitting in the root of your project). For a detailed example of how makefiles work I recommend &lt;a href="http://nefariousdesigns.co.uk/archive/2010/02/website-builds-using-make/" target="_blank"&gt;this excellent introduction&lt;/a&gt;.&lt;/p&gt;

&lt;p&gt;&lt;a href="https://gist.github.com/1447701" target="_blank"&gt;Here is an example Makefile I made&lt;/a&gt;. If you are new to Makefiles you will probably have to read the &lt;a href="http://nefariousdesigns.co.uk/archive/2010/02/website-builds-using-make/" target="_blank"&gt;tutorial&lt;/a&gt; first to fully understand it. My example concatenates all my LESS files and compiles it to normal CSS and concatenates all my JS files and uses Google Closure Compiler to compress it.&lt;/p&gt;

&lt;p&gt;&lt;em&gt;I am very new to Makefiles and am still learning. I look forward to using make in future projects to speed up my workflow. I hope this gave you a good introduction to &lt;code&gt;make&lt;/code&gt;. I will be sure to post any future discoveries I make :)&lt;/em&gt;&lt;/p&gt;

&lt;p&gt;&lt;br/&gt;&lt;strong&gt;Related Resources:&lt;/strong&gt;&lt;/p&gt;

&lt;ul&gt;&lt;li&gt;&lt;a href="http://nefariousdesigns.co.uk/archive/2010/02/website-builds-using-make/" target="_blank"&gt;A full introduction to Makefiles in a web development context&lt;/a&gt;&lt;/li&gt;
&lt;li&gt;&lt;a href="http://www.carbonsilk.com/node/deploying-nodejs-apps/" target="_blank"&gt;A more advanced &amp;#8216;Automated Deployment&amp;#8217; example&lt;/a&gt;&lt;/li&gt;
&lt;li&gt;&lt;a href="http://gnuwin32.sourceforge.net/packages/make.htm" target="_blank"&gt;Make for Windows&lt;/a&gt;&lt;/li&gt;
&lt;li&gt;&lt;a href="http://gnuwin32.sourceforge.net/packages/coreutils.htm" target="_blank"&gt;CoreUtils for Windows&lt;/a&gt;&lt;/li&gt;
&lt;/ul&gt;</description><link>http://wilsonpage.tumblr.com/post/13926351088</link><guid>http://wilsonpage.tumblr.com/post/13926351088</guid><pubDate>Thu, 08 Dec 2011 12:37:18 -0500</pubDate><category>make</category><category>deployment</category><category>build process</category></item><item><title>Using 'make' to run deployment builds</title><description>&lt;a href="http://nefariousdesigns.co.uk/archive/2010/02/website-builds-using-make/"&gt;Using 'make' to run deployment builds&lt;/a&gt;</description><link>http://wilsonpage.tumblr.com/post/13921899473</link><guid>http://wilsonpage.tumblr.com/post/13921899473</guid><pubDate>Thu, 08 Dec 2011 10:02:16 -0500</pubDate></item><item><title>[javascript] What is .call();</title><description>&lt;p&gt;&lt;code&gt;.call()&lt;/code&gt; is almost identical to &lt;code&gt;.apply()&lt;/code&gt; (&lt;a href="http://wilsonpage.tumblr.com/post/13830644577/javascript-what-is-apply" target="_blank"&gt;which I wrote about here&lt;/a&gt;). It allows you to execute a function and pass in a &lt;code&gt;this&lt;/code&gt; context. The only difference between &lt;code&gt;call&lt;/code&gt; and &lt;code&gt;apply&lt;/code&gt; is that the parameters you wish to pass into the function are listed normally as opposed to in an array form.&lt;/p&gt;

&lt;p&gt;&lt;strong&gt;.call()&lt;/strong&gt;&lt;/p&gt;

&lt;pre&gt;&lt;code&gt;myFunction.call(thisContext, param1, param2);
&lt;/code&gt;&lt;/pre&gt;

&lt;p&gt;&lt;br/&gt;&lt;strong&gt;.apply();&lt;/strong&gt;&lt;/p&gt;

&lt;pre&gt;&lt;code&gt;myFunction.apply(thisContext. [param1, param2]);
&lt;/code&gt;&lt;/pre&gt;

&lt;p&gt;&lt;br/&gt;&lt;strong&gt;&lt;a href="http://jsfiddle.net/WilsonPage/LtPnk/6/" target="_blank"&gt;Here is working example&amp;#160;&amp;#187;&lt;/a&gt;&lt;/strong&gt;&lt;/p&gt;</description><link>http://wilsonpage.tumblr.com/post/13868542673</link><guid>http://wilsonpage.tumblr.com/post/13868542673</guid><pubDate>Wed, 07 Dec 2011 05:35:47 -0500</pubDate><category>javascript</category><category>call</category><category>apply</category></item><item><title>[jQuery] What the hell is PubSub?</title><description>&lt;p&gt;&lt;img src="http://media.tumblr.com/tumblr_lvtwggT64U1r24j9x.jpg" alt=""/&gt;&lt;/p&gt;

&lt;p&gt;&lt;em&gt;When I first heard the term &amp;#8216;PubSub&amp;#8217; I was instantly confused. I thought it was some new gimmicky concept that i would have to learn, so I kind of ignored it. Eventually the term cropped up so many times I decided to spend a few minutes discovering what it was.&lt;/em&gt;&lt;/p&gt;

&lt;p&gt;&lt;strong&gt;What is it?&lt;/strong&gt;&lt;/p&gt;

&lt;p&gt;&amp;#8216;Pub Sub&amp;#8217; is an abbreviation of &amp;#8216;Publish Subscribe&amp;#8217;. Which is how all Javascript event handlers work. Subscribe refers to the binding of or listening for an event and &amp;#8216;Publish&amp;#8217; refers to the triggering or emitting of an event. So in short PubSub allows you to set up one or many listener functions to respond when a single event is triggered (or &amp;#8216;Published&amp;#8217;).&lt;/p&gt;

&lt;p&gt;The difference between &amp;#8216;PubSub&amp;#8217; and normal Javascript events is that they are not bound to physical elements on the page. In my example they are bound to a single (sort of global) jQuery object that acts as a hub for all our custom events. Subscribers listen for particular messages emitted from this hub and Publishers send there messages into this hub.&lt;/p&gt;

&lt;p&gt;&lt;br/&gt;&lt;strong&gt;Why is this useful?&lt;/strong&gt;&lt;/p&gt;

&lt;p&gt;In large Javascript applications this can be useful as it gives a central point of communication. If you are working in a modularised way modules can become less dependent on one another. If one module is required to respond to another module&amp;#8217;s actions it can subscribe to that event on the central jQuery hub. The module needing to trigger the event can Publish the event to the hub.&lt;/p&gt;

&lt;p&gt;&lt;br/&gt;&lt;strong&gt;Show me an example&lt;/strong&gt;&lt;/p&gt;

&lt;p&gt;This example uses a nice little plugin &lt;a href="https://gist.github.com/1319216" target="_blank"&gt;jquery.tinypubsub.js&lt;/a&gt; which is a tiny convenience wrapper around the jQuery&amp;#8217;s &lt;code&gt;on()/off()&lt;/code&gt; event handlers (introduced in jQuery 1.7)&lt;/p&gt;

&lt;iframe style="width: 100%; height: 300px" src="http://jsfiddle.net/WilsonPage/ppUd5/6/embedded/" allowfullscreen="allowfullscreen" frameborder="0"&gt;&lt;/iframe&gt;</description><link>http://wilsonpage.tumblr.com/post/13868137992</link><guid>http://wilsonpage.tumblr.com/post/13868137992</guid><pubDate>Wed, 07 Dec 2011 05:06:00 -0500</pubDate><category>jquery</category><category>pubsub</category><category>javascript</category><category>events</category></item><item><title>[javascript] what is .apply()?</title><description>&lt;p&gt;&lt;img src="http://media.tumblr.com/tumblr_lvsl7fyTbY1r24j9x.jpg" alt=""/&gt;&lt;/p&gt;

&lt;p&gt;&lt;em&gt;Apply is a clever little way of executing functions. It allows you to alter the &amp;#8216;scope&amp;#8217; (value of &amp;#8216;this&amp;#8217;) as well as passing in any arguments you wish in the form of an array.&lt;/em&gt;&lt;/p&gt;

&lt;pre&gt;&lt;code&gt;myFunction.apply(scope, arguments);    
&lt;/code&gt;&lt;/pre&gt;

&lt;p&gt;&lt;br/&gt;&lt;strong&gt;Example:&lt;/strong&gt;&lt;/p&gt;

&lt;pre&gt;&lt;code&gt;var myFunction = function(customParam1, customParam2) {
    alert(customParam1);
    alert(customParam2);
    alert(this.scopeValue1);
    alert(this.scopeValue2);

    // log the scope (have a look!)
    console.log(this);
};
&lt;/code&gt;&lt;/pre&gt;

&lt;p&gt;.&lt;/p&gt;

&lt;pre&gt;&lt;code&gt;var customScope = {
    scopeValue1: 'this is value 1 in custom scope',
    scopeValue2: 'this is value 2 in custom scope',
};
&lt;/code&gt;&lt;/pre&gt;

&lt;p&gt;.&lt;/p&gt;

&lt;pre&gt;&lt;code&gt;myFunction.apply(customScope, ["this is custom param 1", "this is custom Param 2"]);
&lt;/code&gt;&lt;/pre&gt;

&lt;p&gt;&lt;br/&gt;&lt;strong&gt;Working Example:&lt;/strong&gt;&lt;/p&gt;

&lt;p&gt;&lt;a href="http://jsfiddle.net/WilsonPage/LtPnk/5/" target="_blank"&gt;&lt;strong&gt;Check out the working example&amp;#160;&amp;#187;&lt;/strong&gt;&lt;/a&gt;&lt;/p&gt;</description><link>http://wilsonpage.tumblr.com/post/13830644577</link><guid>http://wilsonpage.tumblr.com/post/13830644577</guid><pubDate>Tue, 06 Dec 2011 12:11:00 -0500</pubDate><category>javascript</category><category>apply</category></item><item><title>How to create your own snippets in Sublime Text 2</title><description>&lt;a href="http://sublimetext.info/docs/en/extensibility/snippets.html"&gt;How to create your own snippets in Sublime Text 2&lt;/a&gt;</description><link>http://wilsonpage.tumblr.com/post/13676525418</link><guid>http://wilsonpage.tumblr.com/post/13676525418</guid><pubDate>Sat, 03 Dec 2011 08:18:13 -0500</pubDate><category>ide</category><category>snippets</category></item><item><title>[quick example] jQuery's $.map() function </title><description>&lt;p&gt;&lt;img src="http://media.tumblr.com/tumblr_lvmlj76bQr1r24j9x.jpg" alt=""/&gt;&lt;/p&gt;

&lt;p&gt;I have often seen references to &amp;#8216;map&amp;#8217; in javascript and not really taken the time to fully understand what it means.&lt;/p&gt;

&lt;p&gt;&lt;strong&gt;What is map?&lt;/strong&gt;&lt;/p&gt;

&lt;p&gt;&lt;code&gt;map&lt;/code&gt; loops over an array and runs a function on each element in the array. What ever you return from that function will replace the element in the current position. The output of the &lt;code&gt;$.map()&lt;/code&gt; is the new array after each element has been manipulated though your &amp;#8216;iterator&amp;#8217; function.&lt;/p&gt;

&lt;p&gt;Map is &lt;a href="https://developer.mozilla.org/en/JavaScript/Reference/Global_Objects/Array/map" target="_blank"&gt;available natively&lt;/a&gt; in later versions of Javascript (IE9+) but not in older browsers, so in the meantime we have to use jQuery&amp;#8217;s &lt;code&gt;$.map()&lt;/code&gt; method to ensure cross browser compatibility.&lt;/p&gt;

&lt;p&gt;&lt;strong&gt;Basic Example&lt;/strong&gt;&lt;/p&gt;

&lt;pre&gt;&lt;code&gt;var result = $.map( [1,2,3,4], function (a) { 
  return a * 2; 
});

// result =&amp;gt; [2,4,6,8]
&lt;/code&gt;&lt;/pre&gt;

&lt;p&gt;&lt;br/&gt;&lt;strong&gt;Working Examples:&lt;/strong&gt;&lt;/p&gt;

&lt;p&gt;&lt;a href="http://jsfiddle.net/WilsonPage/KjPM6/5/" target="_blank"&gt;http://jsfiddle.net/WilsonPage/KjPM6/5/&lt;/a&gt;&lt;/p&gt;

&lt;p&gt;&lt;em&gt;Hope this was a nice introduction to &lt;code&gt;map&lt;/code&gt; and you can see how useful this could be in your own projects :)&lt;/em&gt;&lt;/p&gt;</description><link>http://wilsonpage.tumblr.com/post/13674789829</link><guid>http://wilsonpage.tumblr.com/post/13674789829</guid><pubDate>Sat, 03 Dec 2011 06:45:49 -0500</pubDate><category>jquery</category><category>javascript</category><category>map</category><category>quick example</category></item><item><title>[javascript] A quick async.series() demo</title><description>&lt;a href="http://jsfiddle.net/WilsonPage/eQk5d/4/"&gt;[javascript] A quick async.series() demo&lt;/a&gt;: &lt;p&gt;I created this &lt;a href="http://jsfiddle.net/WilsonPage/eQk5d/4/" target="_blank"&gt;quick example&lt;/a&gt; to demonstrate how &lt;a href="https://github.com/caolan/async" target="_blank"&gt;async.js&lt;/a&gt; can handle multiple consecutive functions and save you from the famous ‘Callback Hell’.&lt;/p&gt;

&lt;p&gt;&lt;a href="https://github.com/caolan/async#series" target="_blank"&gt;Further reading on the &lt;strong&gt;‘series’&lt;/strong&gt; method from the async.js library&lt;/a&gt;&lt;/p&gt;</description><link>http://wilsonpage.tumblr.com/post/13642364037</link><guid>http://wilsonpage.tumblr.com/post/13642364037</guid><pubDate>Fri, 02 Dec 2011 14:34:00 -0500</pubDate><category>nodejs</category><category>javascript</category><category>async</category></item><item><title>[javascript] Finding a specific object in an array</title><description>&lt;p&gt;I had a collection of objects inside an array and wanted an async way of pulling out a specific object from that collection. I wanted it to be asynchronous so that when used server-side with NodeJS it wouldn&amp;#8217;t block. I used the &lt;a href="https://github.com/caolan/async" target="_blank"&gt;async.js&lt;/a&gt; library to achieve this.&lt;/p&gt;

&lt;p&gt;&lt;strong&gt;Example:&lt;/strong&gt;&lt;/p&gt;

&lt;pre&gt;&lt;code&gt;var findOne = function(collection, val, options, cb){
  if(typeof options === 'function'){ cb = options; options = {}; }

  // [Default] defualt attribute to search is '_id'
  options.key = options.key || '_id';

  // use async.detect() to return the first item that
  // matches the condition
  async.detect(collection, function(item, callback){
    var isMatch = (item[options.key] === val);
    return callback(isMatch);
  },cb);
};



// DUMMY COLLECTION
var myCollection = [
    {_id: 101, name: 'bill'},
    {_id: 102, name: 'bob'},
    {_id: 103, name: 'ben'} 
];


// Usage with default key ('_id')
findOne(myCollection, 102, function(result){

   console.log(result);
   // {_id: 102, name: 'bob'}

});


// Usage with custom key
findOne(myCollection, 'ben', {key: 'name'}, function(result){

  console.log(result);
  // {_id: 103, name: 'ben'} 

});
&lt;/code&gt;&lt;/pre&gt;

&lt;p&gt;&lt;br/&gt;&lt;strong&gt;Working Example&lt;/strong&gt;&lt;/p&gt;

&lt;p&gt;&lt;a href="http://jsfiddle.net/WilsonPage/yJSjP/3/" target="_blank"&gt;http://jsfiddle.net/WilsonPage/yJSjP/3/&lt;/a&gt;&lt;/p&gt;</description><link>http://wilsonpage.tumblr.com/post/13635639625</link><guid>http://wilsonpage.tumblr.com/post/13635639625</guid><pubDate>Fri, 02 Dec 2011 10:34:00 -0500</pubDate><category>javascript</category><category>nodejs</category><category>async</category></item><item><title>Great example of Adobe Fireworks workflow</title><description>&lt;a href="http://www.adobe.com/devnet/fireworks/articles/cooper_interactive.html"&gt;Great example of Adobe Fireworks workflow&lt;/a&gt;</description><link>http://wilsonpage.tumblr.com/post/13505211878</link><guid>http://wilsonpage.tumblr.com/post/13505211878</guid><pubDate>Tue, 29 Nov 2011 12:49:40 -0500</pubDate><category>fireworks</category><category>adobe</category></item></channel></rss>
