<?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>A blog about server side technologies, nodejs, language design and more.</description><title>TJ Holowaychuk</title><generator>Tumblr (3.0; @tjholowaychuk)</generator><link>http://tjholowaychuk.com/</link><item><title>Modular CSS preprocessing with rework</title><description>&lt;p&gt;Several months ago I started a project named &lt;a href="https://github.com/visionmedia/rework" target="_blank"&gt;Rework&lt;/a&gt;, a very fast, simple, flexible, and modular CSS preprocessor. The biggest and most obvious question I get is how this tool compares to something like &lt;a href="https://github.com/learnboost/stylus" target="_blank"&gt;Stylus&lt;/a&gt;, &lt;a href="http://lesscss.org/" target="_blank"&gt;LESS&lt;/a&gt;, or &lt;a href="http://sass-lang.com/" target="_blank"&gt;Sass&lt;/a&gt;, and why would you want to use it.&lt;/p&gt;

&lt;p&gt;The simple answer is that Rework caters to a different audience, and provide you the flexibility to craft the preprocessor &lt;em&gt;you&lt;/em&gt; want, not the choices the author(s) have force on you.&lt;/p&gt;

&lt;p&gt;Our goal with Rework contrasts the others, as it does not provide a higher level language within the CSS documents, Rework&amp;#8217;s goal is to make those constructs unnecessary, being the most transparent CSS pre-processor out there.&lt;/p&gt;

&lt;h2&gt;Speed&lt;/h2&gt;

&lt;p&gt;Rework was designed to be simple and fast out of the box, without implementing complex caching models allowing everyone to hack on Rework itself or associate plugins easily.&lt;/p&gt;

&lt;p&gt;Powering rework is a &lt;a href="https://github.com/visionmedia/css-parse" target="_blank"&gt;css parser&lt;/a&gt; written in JavaScript that may be used with &lt;a href="http://nodejs.org" target="_blank"&gt;node.js&lt;/a&gt; or in the browser. On the other end there is the &lt;a href="https://github.com/visionmedia/css-stringify" target="_blank"&gt;css compiler&lt;/a&gt; which accepts the &lt;strong&gt;AST&lt;/strong&gt; from css-parse, outputting CSS.&lt;/p&gt;

&lt;p&gt;So where does Rework come in? Rework is the plugin and transformation engine that sits in-between these two tools. The AST is manipulated by Rework and its plugins (or user-defined plugins), which is then passed to the compiler.&lt;/p&gt;

&lt;p&gt;Because these transformations are performed in JavaScript and not in a specialized preprocessor language they are simple to implement and efficient.&lt;/p&gt;

&lt;p&gt;Let&amp;#8217;s check out what it can do!&lt;/p&gt;

&lt;h2&gt;Modularity &amp;amp; Flexibility&lt;/h2&gt;

&lt;p&gt;Before diving into the plugins bundled with Rework, let&amp;#8217;s take a look at how they can be applied. Rework&amp;#8217;s API is very simple, you can specify vendor prefixes with &lt;code&gt;.vendors()&lt;/code&gt;, which all plugins have access to, or you may pass specific vendor prefixes to most plugins themselves. Plugins are passed to a &lt;code&gt;.use()&lt;/code&gt; method, and then finally the CSS output is returned with &lt;code&gt;.toString()&lt;/code&gt;. In practice this looks something like:&lt;/p&gt;

&lt;pre&gt;&lt;code&gt;var rework = require('rework');

var css = rework('string of css here')
  .vendors(['-webkit-', '-moz-'])
  .use(rework.prefixValue('linear-gradient'))
  .use(rework.prefixValue('radial-gradient'))
  .use(rework.prefixValue('transform'))
  .use(rework.vars())
  .use(rework.colors())
  .toString()
&lt;/code&gt;&lt;/pre&gt;

&lt;p&gt;Out of the box rework provides plugins for the following, which may be mixed and matched as you wish:&lt;/p&gt;

&lt;ul&gt;&lt;li&gt;&lt;a href="https://github.com/visionmedia/rework#mediaobj" target="_blank"&gt;media macros&lt;/a&gt; — define your own &lt;strong&gt;@media&lt;/strong&gt; queries&lt;/li&gt;
&lt;li&gt;&lt;a href="https://github.com/visionmedia/rework#ease" target="_blank"&gt;ease&lt;/a&gt; — several additional easing functions&lt;/li&gt;
&lt;li&gt;&lt;a href="https://github.com/visionmedia/rework#at2xvendors" target="_blank"&gt;at2x&lt;/a&gt; — serve high resolution images&lt;/li&gt;
&lt;li&gt;&lt;a href="https://github.com/visionmedia/rework#prefixpropertyproperties-vendors" target="_blank"&gt;prefix&lt;/a&gt; — add vendor prefixes to properties&lt;/li&gt;
&lt;li&gt;&lt;a href="https://github.com/visionmedia/rework#prefixvaluevalue-vendors" target="_blank"&gt;prefixValue&lt;/a&gt; — add vendor prefixes to values&lt;/li&gt;
&lt;li&gt;&lt;a href="https://github.com/visionmedia/rework#prefixselectorsstring" target="_blank"&gt;prefixSelectors&lt;/a&gt; — add prefixes to selectors&lt;/li&gt;
&lt;li&gt;&lt;a href="https://github.com/visionmedia/rework#opacity" target="_blank"&gt;opacity&lt;/a&gt; — add IE opacity support&lt;/li&gt;
&lt;li&gt;&lt;a href="https://github.com/visionmedia/rework#urlcallback" target="_blank"&gt;url&lt;/a&gt; — rewrite &lt;code&gt;url()&lt;/code&gt;s with a callback function&lt;/li&gt;
&lt;li&gt;&lt;a href="https://github.com/visionmedia/rework#vars" target="_blank"&gt;vars&lt;/a&gt; — add css variable support&lt;/li&gt;
&lt;li&gt;&lt;a href="https://github.com/visionmedia/rework#keyframesvendors" target="_blank"&gt;keyframes&lt;/a&gt; — add &lt;strong&gt;@keyframe&lt;/strong&gt; vendor prefixing&lt;/li&gt;
&lt;li&gt;&lt;a href="https://github.com/visionmedia/rework#colors" target="_blank"&gt;colors&lt;/a&gt; — add colour helpers like &lt;code&gt;rgba(#fc0, .5)&lt;/code&gt;&lt;/li&gt;
&lt;li&gt;&lt;a href="https://github.com/visionmedia/rework#references" target="_blank"&gt;references&lt;/a&gt; — add property references support &lt;code&gt;height: @width&lt;/code&gt; etc&lt;/li&gt;
&lt;li&gt;&lt;a href="https://github.com/visionmedia/rework#mixinobjects" target="_blank"&gt;mixin&lt;/a&gt; — add custom property logic with mixing&lt;/li&gt;
&lt;li&gt;&lt;a href="https://github.com/visionmedia/rework#extend" target="_blank"&gt;extend&lt;/a&gt; — add &lt;code&gt;extend: selector&lt;/code&gt; support&lt;/li&gt;
&lt;/ul&gt;&lt;p&gt;Let&amp;#8217;s look at some examples!&lt;/p&gt;

&lt;h3&gt;Vendor prefixes&lt;/h3&gt;

&lt;p&gt;The &lt;code&gt;prefix&lt;/code&gt;, &lt;code&gt;prefixValue&lt;/code&gt;, and &lt;code&gt;keyframes&lt;/code&gt; plugins make vendor prefixing extremely simple. Here the prefix plugin is applied to only two properties for illustration:&lt;/p&gt;

&lt;pre&gt;&lt;code&gt;var rework = require('..')
var read = require('fs').readFileSync

var css = rework(read('examples/prefix.css', 'utf8'))
  .vendors(['-webkit-', '-moz-'])
  .use(rework.prefix('border-radius'))
  .use(rework.prefix('box-shadow'))
  .toString()

console.log(css)
&lt;/code&gt;&lt;/pre&gt;

&lt;p&gt;With the &lt;em&gt;prefix.css&lt;/em&gt; file containing the following CSS:&lt;/p&gt;

&lt;pre&gt;&lt;code&gt;.button {
  border-radius: 5px;
  box-shadow: inset 0 0 1px white;
}
&lt;/code&gt;&lt;/pre&gt;

&lt;p&gt;Rework yields the following prefixed output:&lt;/p&gt;

&lt;pre&gt;&lt;code&gt;.button {
  -webkit-border-radius: 5px;
  -moz-border-radius: 5px;
  border-radius: 5px;
  -webkit-box-shadow: inset 0 0 1px white;
  -moz-box-shadow: inset 0 0 1px white;
  box-shadow: inset 0 0 1px white
}
&lt;/code&gt;&lt;/pre&gt;

&lt;h3&gt;Extending&lt;/h3&gt;

&lt;p&gt;The &lt;code&gt;extend&lt;/code&gt; plugin adds support for a special property named &lt;code&gt;extend&lt;/code&gt;, which propagates the selector back up the AST so that the styles are applied without duplication. For example here&amp;#8217;s a contrived green join button implementation:&lt;/p&gt;

&lt;pre&gt;&lt;code&gt;button {
  padding: 5px 10px;
  border: 1px solid #eee;
  border-bottom-color: #ddd;
}

.green {
  background: green;
  padding: 10px 15px
}

a.join {
  extend: button;
  extend: .green;
  padding: 20px;
}
&lt;/code&gt;&lt;/pre&gt;

&lt;p&gt;With this plugin enabled both of the &lt;code&gt;extend&lt;/code&gt; properties are gone, and you&amp;#8217;re left with the CSS you might expect:&lt;/p&gt;

&lt;pre&gt;&lt;code&gt;button,
a.join {
  padding: 5px 10px;
  border: 1px solid #eee;
  border-bottom-color: #ddd
}

.green,
a.join {
  background: green;
  padding: 10px 15px
}

a.join {
  padding: 20px
}
&lt;/code&gt;&lt;/pre&gt;

&lt;h3&gt;Better rgba()&lt;/h3&gt;

&lt;p&gt;Ever had a color hex and then wanted to alter the alpha channel? Then you probably know how annoying this is with CSS. The &lt;code&gt;colors&lt;/code&gt; plugin allows you to pass hex values to &lt;code&gt;rgba()&lt;/code&gt;, for example &lt;code&gt;rgba(#c00, .5)&lt;/code&gt; which is then compiled to &lt;code&gt;rgba(204,0,0,0.5)&lt;/code&gt;.&lt;/p&gt;

&lt;h2&gt;Writing your own plugins&lt;/h2&gt;

&lt;p&gt;Writing plugins for Rework is simple, suppose for example you want the ability to create your own properties, here expanding single-line position properties:&lt;/p&gt;

&lt;pre&gt;&lt;code&gt;#logo {
  absolute: top left;
}

#logo {
  relative: top 5px left;
}

#logo {
  fixed: top 5px left 10px;
}
&lt;/code&gt;&lt;/pre&gt;

&lt;p&gt;Into the valid CSS shown below:&lt;/p&gt;

&lt;pre&gt;&lt;code&gt;#logo {
  position: absolute;
  top: 0;
  left: 0
}

#logo {
  position: relative;
  top: 5px;
  left: 0
}

#logo {
  position: fixed;
  top: 5px;
  left: 10px
}
&lt;/code&gt;&lt;/pre&gt;

&lt;p&gt;The AST css-parse provides you is made up of simple objects and arrays, making it extremely easy to manipulate without extra knowledge of how the nodes are constructed or strange internal APIs. In the following plugin function we walk the declarations, check if the property is one of the positions, parse the value by splitting on whitespace and then inject the new css properties.&lt;/p&gt;

&lt;pre&gt;&lt;code&gt;function positions() {
  var positions = ['absolute', 'relative', 'fixed'];

  return function(style){
    rework.visit.declarations(style, function(declarations){
      declarations.forEach(function(decl, i){
        if (!~positions.indexOf(decl.property)) return;
        var args = decl.value.split(/\s+/);
        var arg, n;

        // remove original
        declarations.splice(i, 1);

        // position prop
        declarations.push({
          property: 'position',
          value: decl.property
        });

        // position
        while (args.length) {
          arg = args.shift();
          n = parseFloat(args[0]) ? args.shift() : 0;
          declarations.push({
            property: arg,
            value: n
          });
        }
      });
    });
  }
}
&lt;/code&gt;&lt;/pre&gt;

&lt;p&gt;To use this plugin you would simply pass it to &lt;code&gt;.use()&lt;/code&gt;:&lt;/p&gt;

&lt;pre&gt;&lt;code&gt;var css = rework('#logo { absolute: top left; }')
  .use(positions())
  .toString()
&lt;/code&gt;&lt;/pre&gt;

&lt;h2&gt;Significant whitespace&lt;/h2&gt;

&lt;p&gt;Since CSS has a relatively simple grammar significant whitespace can help improve your productivity without turning the whole thing into an unreadable mess, this is especially true since Rework does not provide the higher level language constructs, which can get lost in the indentation. This is where &lt;a href="http://" target="_blank"&gt;css-whitespace&lt;/a&gt; comes in! It lets you write things like:&lt;/p&gt;

&lt;pre&gt;&lt;code&gt;ul
  li
    background: #eee
    &amp;amp;:hover
      background: white
    &amp;amp;:active
      background: #ddd
&lt;/code&gt;&lt;/pre&gt;

&lt;p&gt;Which yields:&lt;/p&gt;

&lt;pre&gt;&lt;code&gt;ul li:hover {
  background: white;
}

ul li:active {
  background: #ddd;
}

ul li {
  background: #eee;
}
&lt;/code&gt;&lt;/pre&gt;

&lt;h2&gt;Future&lt;/h2&gt;

&lt;p&gt;In the near future we&amp;#8217;ll be providing a more intuitive way to apply &lt;em&gt;all&lt;/em&gt; or large chunks of the functionality Rework provides without manually adding all of the plugins, as well as improving the &lt;a href="https://github.com/visionmedia/rework/blob/master/bin/rework" target="_blank"&gt;rework(1)&lt;/a&gt; executable.&lt;/p&gt;</description><link>http://tjholowaychuk.com/post/44267035203</link><guid>http://tjholowaychuk.com/post/44267035203</guid><pubDate>Thu, 28 Feb 2013 19:04:00 -0800</pubDate><category>rework</category><category>css</category><category>design</category><category>designer</category><category>developer</category><category>web</category><category>node</category><category>nodejs</category><category>js</category><category>javascript</category><category>less</category><category>stylus</category><category>sass</category></item><item><title>Mocha JavaScript test framework matrix reporter:...</title><description>&lt;img src="http://25.media.tumblr.com/539d72f592314895e507cb7f6e3351c5/tumblr_mir3kxjVgW1qbcdnco1_500.png"/&gt;&lt;br/&gt;&lt;br/&gt;&lt;p&gt;Mocha JavaScript test framework matrix reporter: &lt;a href="https://github.com/visionmedia/mocha-matrix" target="_blank"&gt;https://github.com/visionmedia/mocha-matrix&lt;/a&gt;&lt;/p&gt;</description><link>http://tjholowaychuk.com/post/43941034060</link><guid>http://tjholowaychuk.com/post/43941034060</guid><pubDate>Sun, 24 Feb 2013 16:48:32 -0800</pubDate><category>js</category><category>mocha</category><category>browser</category><category>web</category><category>developer</category><category>testing</category></item><item><title>Ark - a work in progress digital painting with Pixelmator</title><description>&lt;img src="http://25.media.tumblr.com/7154d632bf7e80ab4b4eb80ce3a8c7b3/tumblr_mhv3l5zuEP1qbcdnco5_500.png"/&gt;&lt;br/&gt; &lt;br/&gt;&lt;img src="http://24.media.tumblr.com/8aab32934a0df52c84e928dabe07c6f2/tumblr_mhv3l5zuEP1qbcdnco1_500.png"/&gt;&lt;br/&gt; &lt;br/&gt;&lt;img src="http://24.media.tumblr.com/3d4c3fed0dbcffd8566bed37347ae9c7/tumblr_mhv3l5zuEP1qbcdnco2_500.png"/&gt;&lt;br/&gt; &lt;br/&gt;&lt;img src="http://24.media.tumblr.com/f51f94c876a62b87f102130bfec196ff/tumblr_mhv3l5zuEP1qbcdnco3_500.png"/&gt;&lt;br/&gt; &lt;br/&gt;&lt;img src="http://25.media.tumblr.com/5f9eed802b9ef17935c64282178a8e85/tumblr_mhv3l5zuEP1qbcdnco4_500.png"/&gt;&lt;br/&gt; &lt;br/&gt;&lt;img src="http://24.media.tumblr.com/8a6dec95cd1877cc3d8bc06696e0c85a/tumblr_mhv3l5zuEP1qbcdnco6_500.png"/&gt;&lt;br/&gt; &lt;br/&gt;&lt;p&gt;Ark - a work in progress digital painting with Pixelmator&lt;/p&gt;</description><link>http://tjholowaychuk.com/post/42513917491</link><guid>http://tjholowaychuk.com/post/42513917491</guid><pubDate>Thu, 07 Feb 2013 10:05:29 -0800</pubDate></item><item><title>First 30 minute digital painting with Corel Painter</title><description>&lt;img src="http://24.media.tumblr.com/64cb2ac50251231cc52426af1686e9ec/tumblr_mfhywesMVN1qbcdnco1_500.png"/&gt;&lt;br/&gt;&lt;br/&gt;&lt;p&gt;First 30 minute digital painting with Corel Painter&lt;/p&gt;</description><link>http://tjholowaychuk.com/post/38642551687</link><guid>http://tjholowaychuk.com/post/38642551687</guid><pubDate>Sun, 23 Dec 2012 10:48:13 -0800</pubDate><category>corel</category><category>painting</category></item><item><title>Modular web applications with Node.js and Express</title><description>&lt;a href="https://vimeo.com/56166857"&gt;Modular web applications with Node.js and Express&lt;/a&gt;: &lt;p&gt;This short screencast describes how you can use Express’ app mounting feature to create modular self-contained applications to construct your product.&lt;/p&gt;</description><link>http://tjholowaychuk.com/post/38571504626</link><guid>http://tjholowaychuk.com/post/38571504626</guid><pubDate>Sat, 22 Dec 2012 13:37:16 -0800</pubDate><category>nodejs</category><category>express</category><category>components</category></item><item><title>Creating components screencast</title><description>&lt;a href="https://vimeo.com/53730178"&gt;Creating components screencast&lt;/a&gt;: &lt;p&gt;This screencast walks through creation of web components and some fundamentals driving the movement. Improve your client-side workflow and help us build a strong foundation for the web!&lt;/p&gt;</description><link>http://tjholowaychuk.com/post/38310533170</link><guid>http://tjholowaychuk.com/post/38310533170</guid><pubDate>Wed, 19 Dec 2012 08:53:59 -0800</pubDate><category>component</category><category>screencast</category><category>js</category><category>css</category></item><item><title>Web components introduction screencast</title><description>&lt;a href="https://vimeo.com/48054442"&gt;Web components introduction screencast&lt;/a&gt;: &lt;p&gt;An introduction into using the javascript implementation of components, walking through a quick example of how you might integrate them into your application. Note that this is the node implementation only, in the future hopefully we’ll have python, ruby, java, etcetera tools as well, all consuming the same things.&lt;/p&gt;</description><link>http://tjholowaychuk.com/post/38310503237</link><guid>http://tjholowaychuk.com/post/38310503237</guid><pubDate>Wed, 19 Dec 2012 08:53:25 -0800</pubDate><category>component</category><category>screencast</category><category>js</category><category>css</category></item><item><title>Building a date picker component</title><description>&lt;p&gt;First install &lt;code&gt;component(1)&lt;/code&gt; with &lt;code&gt;npm&lt;/code&gt;:&lt;/p&gt;

&lt;pre&gt;&lt;code&gt;$ npm install -g component
&lt;/code&gt;&lt;/pre&gt;

&lt;p&gt;Or if you don&amp;#8217;t have &lt;code&gt;node&lt;/code&gt; installed at all, on OSX execute:&lt;/p&gt;

&lt;pre&gt;&lt;code&gt;$ (cd /usr/local &amp;amp;&amp;amp; \
   curl -L# &lt;a href="http://nodejs.org/dist/v0.8.15/node-v0.8.15-darwin-x86.tar.gz" target="_blank"&gt;http://nodejs.org/dist/v0.8.15/node-v0.8.15-darwin-x86.tar.gz&lt;/a&gt; \
   | tar -zx --strip 1) \
  &amp;amp;&amp;amp; npm install -g component \
  &amp;amp;&amp;amp; printf "installed component(1) %s\n" $(component --version)
&lt;/code&gt;&lt;/pre&gt;

&lt;p&gt;Next you&amp;#8217;ll need to bootstrap a new component, you can do this manually or use the quick &lt;code&gt;component-create(1)&lt;/code&gt; command:&lt;/p&gt;

&lt;pre&gt;&lt;code&gt;$ component create datepicker
repo (username/project): component/datepicker
description: Datepicker ui component built on component/calendar
does this component have js? y  
does this component have css? y
does this component have html? 

      create : datepicker
      create : datepicker/index.js
      create : datepicker/datepicker.css
      create : datepicker/Makefile
      create : datepicker/Readme.md
      create : datepicker/History.md
      create : datepicker/.gitignore
      create : datepicker/component.json
&lt;/code&gt;&lt;/pre&gt;

&lt;h2&gt;Adding dependencies&lt;/h2&gt;

&lt;p&gt;Next &lt;code&gt;cd&lt;/code&gt; into the new directory and install the &lt;a href="https://github.com/component/calendar" target="_blank"&gt;component/calendar&lt;/a&gt; component as a dependency:&lt;/p&gt;

&lt;p&gt;$ component install component/calendar&lt;/p&gt;

&lt;pre&gt;&lt;code&gt;    install : component/calendar@master
        dep : component/range@master
    install : component/range@master
        dep : component/jquery@master
    install : component/jquery@master
        dep : component/emitter@master
    install : component/emitter@master
        sep : component/in-groups-of@master
    install : component/in-groups-of@master
      fetch : component/calendar:index.js
      fetch : component/calendar:lib/utils.js
      fetch : component/calendar:lib/template.js
      fetch : component/calendar:lib/calendar.js
      fetch : component/calendar:lib/days.js
      fetch : component/calendar:lib/calendar.css
      fetch : component/range:index.js
      fetch : component/jquery:index.js
      fetch : component/in-groups-of:index.js
      fetch : component/emitter:index.js
   complete : component/range
   complete : component/in-groups-of
   complete : component/emitter
   complete : component/jquery
   complete : component/calendar
&lt;/code&gt;&lt;/pre&gt;

&lt;p&gt;If you &lt;code&gt;cat&lt;/code&gt; the &lt;em&gt;component.json&lt;/em&gt; file you&amp;#8217;ll see that &lt;code&gt;component-install(1)&lt;/code&gt; has added the dependency for us:&lt;/p&gt;

&lt;pre&gt;&lt;code&gt;  cat component.json 
  {
    "name": "datepicker",
    "repo": "component/datepicker",
    "description": "Datepicker ui component built on component/calendar",
    "version": "0.0.1",
    "keywords": [],
    "dependencies": {
      "component/calendar": "*"
    },
    "development": {},
    "license": "MIT",
    "scripts": [
      "index.js"
    ],
    "styles": [
      "datepicker.css"
    ]
&lt;/code&gt;&lt;/pre&gt;

&lt;h2&gt;Creating the component&lt;/h2&gt;

&lt;p&gt;Like any other software it&amp;#8217;s good to have a suite of tests, or at very least a functioning demo for developers and end-users. In this case we&amp;#8217;ll just create &lt;em&gt;example.html&lt;/em&gt; to test drive the date picker, create the file and add the following HTML:&lt;/p&gt;

&lt;pre&gt;&lt;code&gt;&amp;lt;!DOCTYPE html&amp;gt;
&amp;lt;html&amp;gt;
  &amp;lt;head&amp;gt;
    &amp;lt;title&amp;gt;Datepicker&amp;lt;/title&amp;gt;
    &amp;lt;meta http-equiv="Content-Type" content="text/html; charset=utf-8"&amp;gt;
    &amp;lt;link rel="stylesheet" href="build/build.css"&amp;gt;
    &amp;lt;script src="build/build.js"&amp;gt;&amp;lt;/script&amp;gt;
  &amp;lt;/head&amp;gt;
  &amp;lt;body&amp;gt;
    &amp;lt;input type="text" name="date" placeholder="Choose a date"&amp;gt;

    &amp;lt;script&amp;gt;
       var picker = require('datepicker');
       var el = document.querySelector('[name=date]');
       picker(el);
    &amp;lt;/script&amp;gt;
  &amp;lt;/body&amp;gt;
&amp;lt;/html&amp;gt;
&lt;/code&gt;&lt;/pre&gt;

&lt;p&gt;Our date picker is going to be pretty simple, we&amp;#8217;re going to handle click events for the &lt;code&gt;element&lt;/code&gt; passed to &lt;code&gt;picker()&lt;/code&gt;, and then display the &lt;code&gt;Calendar&lt;/code&gt; in a &lt;code&gt;Popover&lt;/code&gt; instance, populating the input when a selection is made.&lt;/p&gt;

&lt;p&gt;Before getting started you&amp;#8217;ll want to install the popover component, event utility, and the optional &amp;#8220;aurora&amp;#8221; theme:&lt;/p&gt;

&lt;pre&gt;&lt;code&gt;$ component install component/popover component/aurora component/event
&lt;/code&gt;&lt;/pre&gt;

&lt;p&gt;Or with brace expansion:&lt;/p&gt;

&lt;pre&gt;&lt;code&gt;$ component install component/{popover,aurora,event}
&lt;/code&gt;&lt;/pre&gt;

&lt;p&gt;The following JavaScript snippet is what will go into &lt;code&gt;./index.js&lt;/code&gt;, the main entry-point script of the component. As you can see here the dependencies are explicitly required at the top of the file via the commonjs module system, making it very obvious what this module is interacting with. Next we export a single object, the &lt;code&gt;Datepicker&lt;/code&gt; constructor itself which sets up a bit of event handling boilerplate.&lt;/p&gt;

&lt;pre&gt;&lt;code&gt;var Calendar = require('calendar')
  , Popover = require('popover')
  , event = require('event')

module.exports = Datepicker;

function Datepicker(el) {
  if (!(this instanceof Datepicker)) return new Datepicker(el);
  this.el = el;
  event.bind(el, 'click', this.onclick.bind(this));
}

Datepicker.prototype.onclick = function(e){

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

&lt;p&gt;&lt;strong&gt;NOTE&lt;/strong&gt;: The use of &amp;#8220;event&amp;#8221; may seem low-level here, and that&amp;#8217;s because it is, the event module is nothing more than a cross-browser event binding utility. These APIs are not designed to be cute, they&amp;#8217;re designed to drastically reduce the dependency bloat, by only using what your component needs. &amp;#8220;Cute&amp;#8221; APIs are provided by higher level components such as the jQuery-like &lt;a href="http://github.com/component/dom" target="_blank"&gt;dom&lt;/a&gt; component, and are typically recommended for app-level use only&lt;/p&gt;

&lt;p&gt;To finish up the JavaScript portion of the &lt;code&gt;Datepicker&lt;/code&gt; instantiate a new &lt;code&gt;Calendar&lt;/code&gt; in the constructor, and add a classname for styling purposes. Next in the &lt;code&gt;.onclick&lt;/code&gt; handler a new &lt;code&gt;Popover&lt;/code&gt; is passed the &lt;code&gt;cal&lt;/code&gt; element for its content, and a &lt;code&gt;datepicker-popover&lt;/code&gt; classname is given here for styling purposes as well, then finally the call to &lt;code&gt;popover.show(this.el)&lt;/code&gt; shows the popover relative to the &lt;code&gt;&amp;lt;input&amp;gt;&lt;/code&gt; element.&lt;/p&gt;

&lt;pre&gt;&lt;code&gt;var Calendar = require('calendar')
  , Popover = require('popover')
  , event = require('event')

module.exports = Datepicker;

function Datepicker(el) {
  if (!(this instanceof Datepicker)) return new Datepicker(el);
  this.el = el;
  this.cal = new Calendar;
  this.cal.el.addClass('datepicker-calendar');
  event.bind(el, 'click', this.onclick.bind(this));
}

Datepicker.prototype.onclick = function(e){
  this.cal.on('change', this.onchange.bind(this));
  this.popover = new Popover(this.cal.el);
  this.popover.classname = 'datepicker-popover popover';
  this.popover.show(this.el);
};

Datepicker.prototype.onchange = function(date){
  el.value = date.getFullYear()
    + '/'
    + date.getMonth()
    + '/'
    + date.getDate();

  this.popover.hide();
};
&lt;/code&gt;&lt;/pre&gt;

&lt;h2&gt;Building the component&lt;/h2&gt;

&lt;p&gt;To build the component invoke the following &lt;code&gt;component-build(1)&lt;/code&gt; command:&lt;/p&gt;

&lt;pre&gt;&lt;code&gt;$ component build
&lt;/code&gt;&lt;/pre&gt;

&lt;p&gt;Or simply use &lt;code&gt;make&lt;/code&gt;, as the targets are already set up in the &lt;code&gt;Makefile&lt;/code&gt; for you:&lt;/p&gt;

&lt;pre&gt;&lt;code&gt;$ make
&lt;/code&gt;&lt;/pre&gt;

&lt;p&gt;A new directory named &lt;code&gt;./build&lt;/code&gt; will now have been created for you with the resulting &lt;code&gt;build.css&lt;/code&gt; and &lt;code&gt;build.js&lt;/code&gt; files.&lt;/p&gt;

&lt;p&gt;To make this process transparent in development I recommend using the &lt;code&gt;watch&lt;/code&gt; command that some environments already have, for those that do not have it there&amp;#8217;s &lt;a href="https://github.com/visionmedia/watch" target="_blank"&gt;watch(1)&lt;/a&gt;. Before working on a component you may now simply watch the &lt;code&gt;make&lt;/code&gt; command and chuck that process in the background to get out of your way:&lt;/p&gt;

&lt;pre&gt;&lt;code&gt;$ watch make &amp;amp;
&lt;/code&gt;&lt;/pre&gt;

&lt;p&gt;When you&amp;#8217;re done invoke &lt;code&gt;fg&lt;/code&gt; to foreground the job again, or kill it with:&lt;/p&gt;

&lt;pre&gt;&lt;code&gt;$ kill %1
&lt;/code&gt;&lt;/pre&gt;

&lt;h2&gt;Styling the component&lt;/h2&gt;

&lt;p&gt;Without custom styling the Aurora calendar / popover themes will look something like the following, not exactly great for a date picker since the calendar already looks self-contained.&lt;/p&gt;

&lt;p&gt;&lt;img src="http://f.cl.ly/items/3f3U243e1p0A2v3e2Q3u/picker.png" alt="datepicker component before styling"/&gt;&lt;/p&gt;

&lt;p&gt;Add the following CSS to &lt;code&gt;./datepicker.css&lt;/code&gt; to cancel out the popover border for the datepicker popover only:&lt;/p&gt;

&lt;pre&gt;&lt;code&gt;.datepicker-calendar {
  font: 10px "Helvetica Neue", Helvetica, Arial, sans-serif;
}

.datepicker-popover .tip-arrow {
  top: auto;
}

.datepicker-popover .tip-inner {
  border: none;
}
&lt;/code&gt;&lt;/pre&gt;

&lt;p&gt;Now re-build and you should have the following completed datepicker:&lt;/p&gt;

&lt;p&gt;&lt;img src="http://f.cl.ly/items/1D2R0L42361o2x3C1C27/picker2.png" alt="completed datepicker component"/&gt;&lt;/p&gt;

&lt;h2&gt;Publishing&lt;/h2&gt;

&lt;p&gt;To &amp;#8220;publish&amp;#8221; the component all you need to do is push it to GitHub and then install with &lt;code&gt;component install myname/datepicker&lt;/code&gt;! No fighting over names, you can call them whatever you like. To increase discoverability of your component you can then add it to the &lt;a href="https://github.com/component/component/wiki/Components" target="_blank"&gt;Wiki component listing&lt;/a&gt; and the &lt;code&gt;component-search(1)&lt;/code&gt; command will index it.&lt;/p&gt;

&lt;p&gt;Get the code for this component at &lt;a href="https://github.com/component/datepicker" target="_blank"&gt;component/datepicker&lt;/a&gt;.&lt;/p&gt;

&lt;p&gt;For more on components check out the &lt;a href="https://github.com/component/component" target="_blank"&gt;component repo&lt;/a&gt; and the &lt;a href="https://github.com/component/component/wiki" target="_blank"&gt;Wiki&lt;/a&gt;.&lt;/p&gt;</description><link>http://tjholowaychuk.com/post/37832588021</link><guid>http://tjholowaychuk.com/post/37832588021</guid><pubDate>Thu, 13 Dec 2012 06:34:56 -0800</pubDate><category>component</category><category>js</category><category>css</category></item><item><title>Monitoring processes with mon</title><description>&lt;p&gt;&lt;a href="https://github.com/visionmedia/mon" target="_blank"&gt;mon&lt;/a&gt; is an extremely small, simple, and light-weight
 alternative to &lt;a href="http://mmonit.com/monit/" target="_blank"&gt;monit&lt;/a&gt; for monitoring processes. Monit&amp;#8217;s approach
 of using a &lt;a href="http://en.wikipedia.org/wiki/Domain-specific_language" target="_blank"&gt;DSL&lt;/a&gt; is at times inflexible
 and often annoying. Mon&amp;#8217;s approach is to monitor only a &lt;em&gt;single&lt;/em&gt; process, monitoring of several
 require a mon instance per process, however reducing single points of failure.&lt;/p&gt;

&lt;p&gt;This may sound like it&amp;#8217;s a lot of work to manage, but I promise you it&amp;#8217;s not! There&amp;#8217;s another tool for this called &lt;code&gt;mongroup(1)&lt;/code&gt; to tie them together.&lt;/p&gt;

&lt;h2&gt;Monitoring a single process&lt;/h2&gt;

&lt;p&gt;Mon instances weigh in at about 400kb per process, so you don&amp;#8217;t have to worry
  about spawning a bunch of them. The simplest use of mon accepts a command to execute,
  and keep alive:&lt;/p&gt;

&lt;pre&gt;&lt;code&gt;$ mon "echo hello; sleep 5"
&lt;/code&gt;&lt;/pre&gt;

&lt;p&gt;Mon will execute the command with &lt;code&gt;/bin/sh -c&lt;/code&gt;, so brace expansion and other shell goodies
  are completely fine. Once the sub process exits, mon will bring it back to life. By default
  mon logs to stdout:&lt;/p&gt;

&lt;pre&gt;&lt;code&gt;mon : child 94136
mon : sh -c "echo hey; sleep 5"
hey
mon : last restart less than one second ago
mon : 10 attempts remaining
mon : child 94138
mon : sh -c "echo hey; sleep 5"
hey
mon : last restart 5 seconds ago
mon : 9 attempts remaining
mon : child 94140
mon : sh -c "echo hey; sleep 5"
hey
&lt;/code&gt;&lt;/pre&gt;

&lt;p&gt;Mon will continue to execute the command until mon itself is signalled with &lt;strong&gt;SIGQUIT&lt;/strong&gt; or
  &lt;strong&gt;SIGTERM&lt;/strong&gt; at which point it will signal the child using the same signal, and gracefully exit.&lt;/p&gt;

&lt;p&gt;When a process continues to fail upon restart, cyclic spawning will be detected by mon, it will
  then exit and log a warning. By default &lt;code&gt;10&lt;/code&gt; restart attempts within 60 seconds are allowed,
  however you may tweak this value with &lt;code&gt;--attempts &amp;lt;n&amp;gt;&lt;/code&gt;.&lt;/p&gt;

&lt;h2&gt;Failure alerts&lt;/h2&gt;

&lt;p&gt;Mon provides two facilities for notification. The first is the &lt;code&gt;--on-restart &amp;lt;cmd&amp;gt;&lt;/code&gt; flag,
  which mon will invoke upon &lt;em&gt;any&lt;/em&gt; restart. This is useful for emailing administrators 
  the tail of a log file, notifying your team via IRC, etcetera.&lt;/p&gt;

&lt;p&gt;The second, and more crucial facility is the &lt;code&gt;--on-error &amp;lt;cmd&amp;gt;&lt;/code&gt; flag, which is invoked
  only when a cyclic restart is detected, and mon has bailed out. Administrators should
  be notified immediately as the process is completely down.&lt;/p&gt;

&lt;h2&gt;Daemonization&lt;/h2&gt;

&lt;p&gt;Mon&amp;#8217;s &lt;code&gt;--daemonize&lt;/code&gt; flag may be used to background the process and disassociate with the terminal,
  at this point stdio will be redirected to the log file specified by &lt;code&gt;--log&lt;/code&gt;, otherwise
  defaulting as &amp;#8220;./mon.log&amp;#8221;, typically this looks something like:&lt;/p&gt;

&lt;pre&gt;&lt;code&gt;$ mon -d -l /var/log/app.log "node app.js"
&lt;/code&gt;&lt;/pre&gt;

&lt;h2&gt;Monitoring multiple processes with mongroup&lt;/h2&gt;

&lt;p&gt;Using mon with several flags is obviously not something you&amp;#8217;d want to be 
  typing all the time, but part of the benefit of using mon is that shell
  scripts become your DSL. If you&amp;#8217;re not interested in doing this yourself
  but have several processes to manage I recommend checking out a project
  by &lt;a href="https://github.com/jgallen23" target="_blank"&gt;jgallen23&lt;/a&gt; called &lt;a href="https://github.com/jgallen23/mongroup" target="_blank"&gt;mongroup(1)&lt;/a&gt;. I&amp;#8217;ve forked the project to add some goodies, until merged you can find them &lt;a href="https://github.com/visionmedia/mongroup" target="_blank"&gt;here&lt;/a&gt;.&lt;/p&gt;

&lt;p&gt;Mongroup uses a simple configuration file, defaulting to the name &lt;code&gt;./mongroup.conf&lt;/code&gt;,
  which simply lists out the &lt;code&gt;pids&lt;/code&gt; and &lt;code&gt;files&lt;/code&gt; directories, as well as
  one or more processes to spawn:&lt;/p&gt;

&lt;pre&gt;&lt;code&gt; pids = /var/run
 logs = /var/log
 web1 = node server 3000
 web2 = node server 3001
 web3 = node server 3002
 web4 = node server 3003
 redis = redis-server
&lt;/code&gt;&lt;/pre&gt;

&lt;p&gt;Mongroup ships with typical init-style commands &lt;code&gt;start&lt;/code&gt;, &lt;code&gt;stop&lt;/code&gt;, &lt;code&gt;restart&lt;/code&gt;, &lt;code&gt;status&lt;/code&gt; and so on,
  without a lot of the boilerplate associated with writing init scripts.&lt;/p&gt;

&lt;h3&gt;Launching processes&lt;/h3&gt;

&lt;p&gt;To check the status of your monitoring group, simply invoke &lt;code&gt;mongroup status&lt;/code&gt;, or &lt;code&gt;mongroup&lt;/code&gt;,
  as it&amp;#8217;s the default sub-command. You&amp;#8217;ll see a list of process names, pids, and the status itself:&lt;/p&gt;

&lt;p&gt;&lt;img src="http://f.cl.ly/items/3Y3P1I2Z1z3M3o211t0R/status-dead.png" alt=""/&gt;&lt;/p&gt;

&lt;p&gt;Firing up the entire suite of processes takes only a single command, &lt;code&gt;mongroup start&lt;/code&gt;:&lt;/p&gt;

&lt;p&gt;&lt;img src="http://f.cl.ly/items/3R3M35323Q1K1O022S0e/start.png" alt=""/&gt;&lt;/p&gt;

&lt;p&gt;Checking the status again will show the process uptime:&lt;/p&gt;

&lt;p&gt;&lt;img src="http://f.cl.ly/items/3Z1l1t3B0X333k3u192U/status-alive.png" alt=""/&gt;&lt;/p&gt;

&lt;p&gt;You may also start, stop, or restart single processes at a time via:&lt;/p&gt;

&lt;pre&gt;&lt;code&gt;$ mongroup stop [name]
$ mongroup start [name]
$ mongroup restart [name]
&lt;/code&gt;&lt;/pre&gt;

&lt;p&gt;&lt;img src="http://f.cl.ly/items/0W070U0b0E1a0n0z1Y2R/status-somedead.png" alt=""/&gt;&lt;/p&gt;

&lt;p&gt;Since mongroup is working-directory sensitive unless the &lt;code&gt;--config &amp;lt;file&amp;gt;&lt;/code&gt; flag
  is specified, I recommend adding a small snippet to your shell profile similar
  to the following:&lt;/p&gt;

&lt;pre&gt;&lt;code&gt;procs() {
  (cd ~ &amp;amp;&amp;amp; mongroup $@)
}
&lt;/code&gt;&lt;/pre&gt;

&lt;p&gt;If you&amp;#8217;re super paranoid you can monitor mon with mon:&lt;/p&gt;

&lt;pre&gt;&lt;code&gt;  $ mon "mon 'node app'"
&lt;/code&gt;&lt;/pre&gt;

&lt;p&gt;That&amp;#8217;s all for now!&lt;/p&gt;

&lt;p&gt;&lt;strong&gt;EDIT&lt;/strong&gt;: changes to mongroup(1) have been merged! &lt;a href="https://github.com/jgallen23/mongroup" target="_blank"&gt;https://github.com/jgallen23/mongroup&lt;/a&gt;&lt;/p&gt;</description><link>http://tjholowaychuk.com/post/35623012479</link><guid>http://tjholowaychuk.com/post/35623012479</guid><pubDate>Mon, 12 Nov 2012 22:14:00 -0800</pubDate><category>monitoring</category><category>mon</category><category>mongroup</category><category>monit</category></item><item><title>Express 3.0</title><description>&lt;p&gt;Express 3.0 is here (finally) and while it is mostly a refinement release,
  between it and Connect 2.x there are some helpful new features. Sorry
  for the massive delay! Been busy and wanted to get a reasonable amount
  of documentation up on &lt;a href="http://expressjs.com" target="_blank"&gt;expressjs.com&lt;/a&gt; before
  releasing, more docs will be coming soon.&lt;/p&gt;

&lt;p&gt;Keep in mind that the goal of Express is to aid you with HTTP, not
  to become a framework super-power like Rails, so this update may
  be underwhelming to some since it&amp;#8217;s merely a refinement.&lt;/p&gt;

&lt;h2&gt;Connect 2.x&lt;/h2&gt;

&lt;p&gt;Changes introduced by Connect 2.x:&lt;/p&gt;

&lt;ul&gt;&lt;li&gt;added &lt;code&gt;err.status&lt;/code&gt; support to Connect&amp;#8217;s default end-point&lt;/li&gt;
&lt;li&gt;added &lt;code&gt;session()&lt;/code&gt; &amp;#8220;proxy&amp;#8221; setting to trust &amp;#8220;X-Forwarded-Proto&amp;#8221;&lt;/li&gt;
&lt;li&gt;added &lt;code&gt;cookieSession()&lt;/code&gt; middleware&lt;/li&gt;
&lt;li&gt;added &lt;code&gt;compress()&lt;/code&gt; middleware for gzipped responses&lt;/li&gt;
&lt;li&gt;added &lt;code&gt;multipart()&lt;/code&gt; middleware&lt;/li&gt;
&lt;li&gt;added &lt;code&gt;json()&lt;/code&gt; middleware&lt;/li&gt;
&lt;li&gt;added &lt;code&gt;urlencoded()&lt;/code&gt; middleware&lt;/li&gt;
&lt;li&gt;added &lt;code&gt;limit&lt;/code&gt; option to the three above middleware&lt;/li&gt;
&lt;li&gt;added &lt;code&gt;defer&lt;/code&gt; option to &lt;code&gt;multipart()&lt;/code&gt; to listen on formidable&amp;#8217;s events&lt;/li&gt;
&lt;li&gt;added &lt;code&gt;debug()&lt;/code&gt; instrumentation to aid in debugging&lt;/li&gt;
&lt;li&gt;changed &lt;code&gt;basicAuth()&lt;/code&gt;&amp;#8217;s &lt;code&gt;req.remoteUser&lt;/code&gt; to &lt;code&gt;req.user&lt;/code&gt;&lt;/li&gt;
&lt;li&gt;changed &lt;code&gt;session()&lt;/code&gt; to only set-cookie on modification (hashed session json)&lt;/li&gt;
&lt;li&gt;changed &lt;code&gt;bodyParser()&lt;/code&gt; to be an aggregate of &lt;code&gt;json()&lt;/code&gt;, &lt;code&gt;multipart()&lt;/code&gt; and &lt;code&gt;urlencoded()&lt;/code&gt;&lt;/li&gt;
&lt;li&gt;moved many cookie-related utils into npm&lt;/li&gt;
&lt;li&gt;moved &lt;code&gt;static()&lt;/code&gt;&amp;#8217;s logic into a separate npm module named &amp;#8220;send&amp;#8221;&lt;/li&gt;
&lt;li&gt;increase perf ~%20 by memoizing url parsing&lt;/li&gt;
&lt;li&gt;removed &lt;code&gt;router()&lt;/code&gt; middleware&lt;/li&gt;
&lt;li&gt;fixed default encoding for &lt;code&gt;logger()&lt;/code&gt;, now &amp;#8220;utf8&amp;#8221; instead of &amp;#8220;ascii&amp;#8221;&lt;/li&gt;
&lt;li&gt;&lt;p&gt;fixed mount-path case-sensitivity&lt;/p&gt;

&lt;p&gt;Connect docs are available at &lt;a href="http://www.senchalabs.org/connect/" target="_blank"&gt;&lt;a href="http://www.senchalabs.org/connect/" target="_blank"&gt;http://www.senchalabs.org/connect/&lt;/a&gt;&lt;/a&gt;,
and will eventually be mirrored on expressjs.com as well for convenience,
along with usage guides.&lt;/p&gt;&lt;/li&gt;
&lt;/ul&gt;&lt;h2&gt;Express 3.x&lt;/h2&gt;

&lt;p&gt;Changes introduced by Express 3.x:&lt;/p&gt;

&lt;ul&gt;&lt;li&gt;added several new examples in &lt;code&gt;./examples&lt;/code&gt;&lt;/li&gt;
&lt;li&gt;added unit testing for the examples (most of them at least)&lt;/li&gt;
&lt;li&gt;added &lt;code&gt;res.jsonp()&lt;/code&gt; to explicitly opt-in to JSONP support&lt;/li&gt;
&lt;li&gt;added ETags and conditional-GET handling to &lt;code&gt;res.send()&lt;/code&gt; responses&lt;/li&gt;
&lt;li&gt;added &amp;#8220;jsonp callback name&amp;#8221; setting&lt;/li&gt;
&lt;li&gt;added support for status code as first or second arg to &lt;code&gt;res.send()&lt;/code&gt; and &lt;code&gt;res.redirect()&lt;/code&gt;&lt;/li&gt;
&lt;li&gt;added &lt;code&gt;req.range(size)&lt;/code&gt; to parse &lt;code&gt;Range&lt;/code&gt; header fields&lt;/li&gt;
&lt;li&gt;added &lt;code&gt;req.auth&lt;/code&gt; for basic auth&lt;/li&gt;
&lt;li&gt;added &lt;code&gt;res.links(obj)&lt;/code&gt; to set response the &lt;code&gt;Link&lt;/code&gt; header field for pagination&lt;/li&gt;
&lt;li&gt;added &lt;code&gt;res.format(obj)&lt;/code&gt; for content-negotiation&lt;/li&gt;
&lt;li&gt;added &lt;code&gt;req.fresh&lt;/code&gt; for conditional-GETs&lt;/li&gt;
&lt;li&gt;added &lt;code&gt;req.stale&lt;/code&gt; for conditional-GETs&lt;/li&gt;
&lt;li&gt;added mount-point relative redirection support to &lt;code&gt;res.redirect()&lt;/code&gt;&lt;/li&gt;
&lt;li&gt;added &lt;code&gt;req.ip&lt;/code&gt; for the remote address (supporting reverse proxies)&lt;/li&gt;
&lt;li&gt;added &lt;code&gt;req.ips&lt;/code&gt; for remote address(es) (supporting reverse proxies)&lt;/li&gt;
&lt;li&gt;added &lt;code&gt;[]&lt;/code&gt; support in jsonp callback&lt;/li&gt;
&lt;li&gt;added &lt;code&gt;app.get(name)&lt;/code&gt; to compliment &lt;code&gt;app.set(name, val)&lt;/code&gt;&lt;/li&gt;
&lt;li&gt;added &lt;code&gt;app.engine()&lt;/code&gt; to register template engines (replaces &lt;code&gt;app.register()&lt;/code&gt;)&lt;/li&gt;
&lt;li&gt;added &lt;code&gt;req.subdomains&lt;/code&gt; to return an array of subdomains&lt;/li&gt;
&lt;li&gt;added &lt;code&gt;req.protocol&lt;/code&gt; to return the request protocol string (&amp;#8220;http&amp;#8221; or &amp;#8220;https&amp;#8221;)&lt;/li&gt;
&lt;li&gt;added &lt;code&gt;req.secure&lt;/code&gt; to assert that &lt;code&gt;req.protocol&lt;/code&gt; is &amp;#8220;https&amp;#8221;&lt;/li&gt;
&lt;li&gt;added &lt;code&gt;req.path&lt;/code&gt; to return the parsed url&amp;#8217;s pathname&lt;/li&gt;
&lt;li&gt;added &lt;code&gt;req.host&lt;/code&gt; to return hostname (&lt;code&gt;Host&lt;/code&gt; void of port)&lt;/li&gt;
&lt;li&gt;added &lt;code&gt;debug()&lt;/code&gt; instrumentation to aid debugging&lt;/li&gt;
&lt;li&gt;added &lt;code&gt;req.accepts()&lt;/code&gt;&lt;/li&gt;
&lt;li&gt;added &lt;code&gt;req.acceptsLanguage()&lt;/code&gt;&lt;/li&gt;
&lt;li&gt;added &lt;code&gt;req.acceptsCharset()&lt;/code&gt;&lt;/li&gt;
&lt;li&gt;added &lt;code&gt;req.accepted&lt;/code&gt;&lt;/li&gt;
&lt;li&gt;added &lt;code&gt;req.acceptedLanguages&lt;/code&gt;&lt;/li&gt;
&lt;li&gt;added &lt;code&gt;req.acceptedCharsets&lt;/code&gt;&lt;/li&gt;
&lt;li&gt;added &amp;#8220;json replacer&amp;#8221; setting to manipulate json responses (remove private keys etc)&lt;/li&gt;
&lt;li&gt;added &amp;#8220;json spaces&amp;#8221; setting to compress or expand json as you like (defaults to &lt;code&gt;2&lt;/code&gt; in dev)&lt;/li&gt;
&lt;li&gt;added &lt;code&gt;express.application&lt;/code&gt; prototype&lt;/li&gt;
&lt;li&gt;added &lt;code&gt;express.request&lt;/code&gt; prototype&lt;/li&gt;
&lt;li&gt;added &lt;code&gt;express.response&lt;/code&gt; prototype&lt;/li&gt;
&lt;li&gt;added &lt;code&gt;app.render()&lt;/code&gt; for app-level templates&lt;/li&gt;
&lt;li&gt;added &lt;code&gt;res.type()&lt;/code&gt; to replace old &lt;code&gt;res.contentType()&lt;/code&gt;&lt;/li&gt;
&lt;li&gt;added &lt;code&gt;{ signed: true }&lt;/code&gt; option to &lt;code&gt;res.cookie()&lt;/code&gt;&lt;/li&gt;
&lt;li&gt;added async signature to &lt;code&gt;res.render()&lt;/code&gt;, engines in &lt;a href="http://github.com/visionmedia/consolidate.js" target="_blank"&gt;consolidate.js&lt;/a&gt; work OOTB&lt;/li&gt;
&lt;li&gt;removed &lt;code&gt;partial()&lt;/code&gt;&lt;/li&gt;
&lt;li&gt;removed express-level layout support (engines provide similar)&lt;/li&gt;
&lt;li&gt;renamed &amp;#8220;case sensitive routes&amp;#8221; to &amp;#8220;case sensitive routing&amp;#8221;&lt;/li&gt;
&lt;li&gt;removed &lt;code&gt;res.signedCookie()&lt;/code&gt;&lt;/li&gt;
&lt;li&gt;removed &amp;#8220;root&amp;#8221; setting&lt;/li&gt;
&lt;li&gt;removed &lt;code&gt;res.redirect('home')&lt;/code&gt; support&lt;/li&gt;
&lt;li&gt;removed &lt;code&gt;req.notify()&lt;/code&gt;&lt;/li&gt;
&lt;li&gt;removed &lt;code&gt;app.register()&lt;/code&gt;&lt;/li&gt;
&lt;li&gt;removed &lt;code&gt;app.redirect()&lt;/code&gt;&lt;/li&gt;
&lt;li&gt;removed &lt;code&gt;app.is()&lt;/code&gt;&lt;/li&gt;
&lt;li&gt;removed &lt;code&gt;app.helpers()&lt;/code&gt;&lt;/li&gt;
&lt;li&gt;&lt;p&gt;removed &lt;code&gt;app.dynamicHelpers()&lt;/code&gt;&lt;/p&gt;

&lt;p&gt;Head over to the &lt;a href="https://github.com/visionmedia/express/wiki/New-features-in-3.x" target="_blank"&gt;New Features in 3.x&lt;/a&gt;
wiki page for a more comprehensive list of additions, or to &lt;a href="https://github.com/visionmedia/express/wiki/Migrating-from-2.x-to-3.x" target="_blank"&gt;3.x migration&lt;/a&gt; to help you
upgrade if you wish to do so.&lt;/p&gt;&lt;/li&gt;
&lt;/ul&gt;</description><link>http://tjholowaychuk.com/post/34189797102</link><guid>http://tjholowaychuk.com/post/34189797102</guid><pubDate>Tue, 23 Oct 2012 15:28:00 -0700</pubDate><category>express</category><category>nodejs</category></item><item><title>“path” - 45 minute digial painting with pixelmator</title><description>&lt;img src="http://25.media.tumblr.com/tumblr_mc7ywgAuVg1qbcdnco1_500.png"/&gt;&lt;br/&gt;&lt;br/&gt;&lt;p&gt;“path” - 45 minute digial painting with pixelmator&lt;/p&gt;</description><link>http://tjholowaychuk.com/post/33997065362</link><guid>http://tjholowaychuk.com/post/33997065362</guid><pubDate>Sat, 20 Oct 2012 18:31:28 -0700</pubDate><category>concept</category><category>art</category><category>painting</category><category>pixelmator</category></item><item><title>more game WIP</title><description>&lt;img src="http://25.media.tumblr.com/tumblr_mamsusLpA31qbcdnco1_500.png"/&gt;&lt;br/&gt; &lt;br/&gt;&lt;img src="http://25.media.tumblr.com/tumblr_mamsusLpA31qbcdnco2_500.png"/&gt;&lt;br/&gt; &lt;br/&gt;&lt;p&gt;more game WIP&lt;/p&gt;</description><link>http://tjholowaychuk.com/post/31907777182</link><guid>http://tjholowaychuk.com/post/31907777182</guid><pubDate>Wed, 19 Sep 2012 21:37:39 -0700</pubDate></item><item><title>Mocha 1.4.0</title><description>&lt;p&gt;This is another relatively small release but still has some goodies!&lt;/p&gt;

&lt;h2&gt;.only()&lt;/h2&gt;

&lt;p&gt;By appending &lt;code&gt;.only()&lt;/code&gt; Mocha will generate an internal &lt;code&gt;.grep()&lt;/code&gt; call for you. This is very useful if you have a regression and a test-case fails. Instead of moving the test-case and associated code out in order to debug you can simply invoke &lt;code&gt;it.only(title, callback)&lt;/code&gt; (for the BDD UI) and Mocha will ignore all others. Here&amp;#8217;s an example that will execute &amp;#8220;bar&amp;#8221; and its test-cases only:&lt;/p&gt;

&lt;pre&gt;&lt;code&gt;describe('foo', function(){
  it('should foo', function(){

  })
})

describe.only('bar', function(){
  it('should bar', function(){

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

&lt;h2&gt;.skip()&lt;/h2&gt;

&lt;p&gt;By appending &lt;code&gt;.skip()&lt;/code&gt; you can tell Mocha to ignore these tests. This was previously called &lt;code&gt;xdescribe()&lt;/code&gt;, &lt;code&gt;xit()&lt;/code&gt; etc to match other frameworks (Jasmine I believe?) but we decided to go with &lt;code&gt;.skip()&lt;/code&gt; which is more readable. The jasmine-style functions will remain for now but they will be removed in the future. This is effectively the same as commenting out cases, however they remain in a pending state so that you do not forget to re-enable them.&lt;/p&gt;

&lt;pre&gt;&lt;code&gt;describe('foo', function(){
  it.skip('should foo', function(){

  })
})

describe('bar', function(){
  it('should bar', function(){

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

&lt;h2&gt;Filtering HTML passes and failures&lt;/h2&gt;

&lt;p&gt;The &amp;#8220;passes&amp;#8221; and &amp;#8220;failures&amp;#8221; labels are now clickable links that will filter respectively.&lt;/p&gt;

&lt;p&gt;&lt;img src="http://f.cl.ly/items/3i2t0Y3o443T0m1z3313/Screen%20Shot%202012-08-22%20at%204.37.12%20PM.png" alt=""/&gt;&lt;/p&gt;

&lt;h2&gt;Retina&lt;/h2&gt;

&lt;p&gt;The canvas progress reporter is now retina-enabled via the &lt;a href="https://github.com/component/autoscale-canvas" target="_blank"&gt;autoscale-canvas&lt;/a&gt; component. No more ugly pixelated progress!&lt;/p&gt;

&lt;h2&gt;Changelog&lt;/h2&gt;

&lt;p&gt;Here&amp;#8217;s the full changelog between 1.3 and 1.4:&lt;/p&gt;

&lt;ul&gt;&lt;li&gt;add mkdir -p to &lt;code&gt;mocha init&lt;/code&gt;. Closes #539&lt;/li&gt;
&lt;li&gt;add &lt;code&gt;.only()&lt;/code&gt;. Closes #524&lt;/li&gt;
&lt;li&gt;add &lt;code&gt;.skip()&lt;/code&gt;. Closes #524&lt;/li&gt;
&lt;li&gt;add passes/failures toggling to HTML reporter&lt;/li&gt;
&lt;li&gt;add pending state to &lt;code&gt;xit()&lt;/code&gt; and &lt;code&gt;xdescribe()&lt;/code&gt; [Brian Moore]&lt;/li&gt;
&lt;li&gt;add the @charset &amp;#8220;UTF-8&amp;#8221;; to fix #522 with FireFox. [Jonathan Creamer]&lt;/li&gt;
&lt;li&gt;add border-bottom to #stats links&lt;/li&gt;
&lt;li&gt;add check for runnable in &lt;code&gt;Runner#uncaught()&lt;/code&gt;. Closes #494&lt;/li&gt;
&lt;li&gt;add 0.4 and 0.6 back to travis.yml&lt;/li&gt;
&lt;li&gt;add &lt;code&gt;-E, --growl-errors&lt;/code&gt; to growl on failures only&lt;/li&gt;
&lt;li&gt;add prefixes to debug() names. Closes #497&lt;/li&gt;
&lt;li&gt;add &lt;code&gt;Mocha#invert()&lt;/code&gt; to js api&lt;/li&gt;
&lt;li&gt;change str.trim() to use utils.trim(). Closes #533&lt;/li&gt;
&lt;li&gt;change dot reporter to use sexy unicode dots&lt;/li&gt;
&lt;li&gt;fix HTML progress indicator retina display&lt;/li&gt;
&lt;li&gt;fix url-encoding of click-to-grep HTML functionality&lt;/li&gt;
&lt;li&gt;fix exports double-execution regression. Closes #531&lt;/li&gt;
&lt;li&gt;fix error when clicking pending test in HTML reporter&lt;/li&gt;
&lt;li&gt;fix &lt;code&gt;make tm&lt;/code&gt;&lt;/li&gt;
&lt;/ul&gt;</description><link>http://tjholowaychuk.com/post/29996505898</link><guid>http://tjholowaychuk.com/post/29996505898</guid><pubDate>Wed, 22 Aug 2012 16:39:47 -0700</pubDate><category>mocha</category><category>nodejs</category><category>testing</category></item><item><title>A ~2.5 hour work in progress digital painting</title><description>&lt;img src="http://24.media.tumblr.com/tumblr_m8w1c78wQj1qbcdnco8_500.jpg"/&gt;&lt;br/&gt; &lt;br/&gt;&lt;img src="http://25.media.tumblr.com/tumblr_m8w1c78wQj1qbcdnco1_500.jpg"/&gt;&lt;br/&gt; &lt;br/&gt;&lt;img src="http://25.media.tumblr.com/tumblr_m8w1c78wQj1qbcdnco2_500.jpg"/&gt;&lt;br/&gt; &lt;br/&gt;&lt;img src="http://25.media.tumblr.com/tumblr_m8w1c78wQj1qbcdnco3_500.jpg"/&gt;&lt;br/&gt; &lt;br/&gt;&lt;img src="http://24.media.tumblr.com/tumblr_m8w1c78wQj1qbcdnco5_500.jpg"/&gt;&lt;br/&gt; &lt;br/&gt;&lt;img src="http://24.media.tumblr.com/tumblr_m8w1c78wQj1qbcdnco6_500.jpg"/&gt;&lt;br/&gt; &lt;br/&gt;&lt;img src="http://24.media.tumblr.com/tumblr_m8w1c78wQj1qbcdnco7_500.jpg"/&gt;&lt;br/&gt; &lt;br/&gt;&lt;img src="http://25.media.tumblr.com/tumblr_m8w1c78wQj1qbcdnco10_r1_500.jpg"/&gt;&lt;br/&gt; &lt;br/&gt;&lt;p&gt;A ~2.5 hour work in progress digital painting&lt;/p&gt;</description><link>http://tjholowaychuk.com/post/29609660807</link><guid>http://tjholowaychuk.com/post/29609660807</guid><pubDate>Fri, 17 Aug 2012 00:12:00 -0700</pubDate><category>digital art</category><category>pixelmator</category><category>painting</category><category>concept</category></item><item><title>“Edge” - a ~3 hour digital painting</title><description>&lt;img src="http://24.media.tumblr.com/tumblr_m8iv2wDEKL1qbcdnco1_500.jpg"/&gt;&lt;br/&gt; &lt;br/&gt;&lt;img src="http://24.media.tumblr.com/tumblr_m8iv2wDEKL1qbcdnco3_500.jpg"/&gt;&lt;br/&gt; &lt;br/&gt;&lt;img src="http://25.media.tumblr.com/tumblr_m8iv2wDEKL1qbcdnco2_500.jpg"/&gt;&lt;br/&gt; &lt;br/&gt;&lt;img src="http://25.media.tumblr.com/tumblr_m8iv2wDEKL1qbcdnco4_500.jpg"/&gt;&lt;br/&gt; &lt;br/&gt;&lt;img src="http://25.media.tumblr.com/tumblr_m8iv2wDEKL1qbcdnco5_500.jpg"/&gt;&lt;br/&gt; &lt;br/&gt;&lt;img src="http://25.media.tumblr.com/tumblr_m8iv2wDEKL1qbcdnco6_500.jpg"/&gt;&lt;br/&gt; &lt;br/&gt;&lt;img src="http://25.media.tumblr.com/tumblr_m8iv2wDEKL1qbcdnco7_500.jpg"/&gt;&lt;br/&gt; &lt;br/&gt;&lt;p&gt;“Edge” - a ~3 hour digital painting&lt;/p&gt;</description><link>http://tjholowaychuk.com/post/29103987900</link><guid>http://tjholowaychuk.com/post/29103987900</guid><pubDate>Thu, 09 Aug 2012 21:28:07 -0700</pubDate><category>digital art</category><category>concept</category></item><item><title>Components</title><description>&lt;p&gt;With the advent of numerous client-side JavaScript package managers, I wanted to write up some of my thoughts about the fragmentation that we have today, and some ways that I think we could really improve delivering packages a community. Keep in mind that these are only &lt;em&gt;my&lt;/em&gt; opinions, everyone has done a great job and there&amp;#8217;s a lot of cool work going on out there.&lt;/p&gt;

&lt;p&gt;I think there are a few problems with the current environment, though some are subjective. The first of these and the most important in my opinion is the lack of unification around package consumption and definitions. The second issue is package delivery, what&amp;#8217;s going to transport them to your machine? The final issue is the use of the components, how are they exposed to the browser for your application.&lt;/p&gt;

&lt;p&gt;Once I&amp;#8217;m done rambling I&amp;#8217;ll show you how we&amp;#8217;ve been using components to build our application at &lt;a href="http://learnboost.com" target="_blank"&gt;LearnBoost&lt;/a&gt;, and how they really fare. Before getting into all that let&amp;#8217;s dig into what I mean by &amp;#8220;component&amp;#8221;.&lt;/p&gt;

&lt;h2&gt;Building components&lt;/h2&gt;

&lt;p&gt;There have been many attempts to come up with some sort of client-side package manager, and some of them do it very well, however I think they are missing the big picture, a &amp;#8220;component&amp;#8221; is much more than just JavaScript.&lt;/p&gt;

&lt;h3&gt;Create components, not JavaScript packages&lt;/h3&gt;

&lt;p&gt;A component can be not just JavaScript, but CSS, images, fonts or other resources, or a component may be any combination of these. This is the main idea that I want to sell, we need to broaden modularity beyond just JavaScript source. This is not a new concept at all, Drupal has been employing it for over 7 years but it seems like something that hasn&amp;#8217;t really caught on in most communities, at least not beyond the private application level.&lt;/p&gt;

&lt;p&gt;A great example of a component would be a popover from the &lt;a href="http://twitter.github.com/bootstrap/components.html" target="_blank"&gt;Twitter Bootstrap&lt;/a&gt; library (not picking on you guys, it&amp;#8217;s just a good example):&lt;/p&gt;

&lt;p&gt;&lt;img src="http://f.cl.ly/items/1C1t2t3H2Z1G1w0J2n3o/Screen%20Shot%202012-06-21%20at%206.14.13%20PM.png" alt=""/&gt;&lt;/p&gt;

&lt;p&gt;This thing looks so sexy that I just want to install it with my package manager, and have it automatically available to me in the client. For this to happen we need to admit that a component is much more than JavaScript,
  and should be packaged accordingly. Like the &amp;#8220;dialog&amp;#8221; in &lt;a href="https://github.com/visionmedia/uikit/tree/master/lib/components/dialog" target="_blank"&gt;UIKit&lt;/a&gt; for example:&lt;/p&gt;

&lt;p&gt;&lt;img src="http://f.cl.ly/items/1e1f1n1J1z0u2p2q0a3O/Screen%20Shot%202012-06-21%20at%206.24.15%20PM.png" alt=""/&gt;&lt;/p&gt;

&lt;p&gt;UIKit even at this state is not a good example of a solution for this problem, it uses its own custom build script to produce a single &lt;code&gt;ui.js&lt;/code&gt; and &lt;code&gt;ui.css&lt;/code&gt; file from the components in the &lt;a href="https://github.com/visionmedia/uikit/tree/master/lib/components" target="_blank"&gt;repo&lt;/a&gt;, so it&amp;#8217;s still not something the community can consume directly without the custom build step. I&amp;#8217;ve started moving UIKit components over to &lt;a href="http://github.com/component" target="_blank"&gt;github.com/component&lt;/a&gt;.&lt;/p&gt;

&lt;p&gt;Another problem in the community is the size and scope of projects.&lt;/p&gt;

&lt;h3&gt;Size and scope&lt;/h3&gt;

&lt;p&gt;The classic battle between DOM manipulation libraries such as jQuery and MooTools
  serve as an obvious example of fragmentation. Even if one is more popular than the other
  this doesn&amp;#8217;t mean we don&amp;#8217;t have a problem. Have you ever seen a great jQuery plugin and
  thought to yourself &amp;#8220;damn! I&amp;#8217;m using MooTools!&amp;#8221; or perhaps the other way around? That
  highlights the problem right there, we should have no &amp;#8220;jQuery plugins&amp;#8221;, no &amp;#8220;Dojo modules&amp;#8221;,
  just simply &amp;#8220;components&amp;#8221; that we can all consume.&lt;/p&gt;

&lt;p&gt;Components could then utilize these smaller, more modular dependencies to perform tasks. Instead
  of requiring jQuery as a dependency to convert a string of HTML into elements, one could simply
  add &lt;a href="https://github.com/component/domify/blob/master/lib/domify.js" target="_blank"&gt;domify&lt;/a&gt; as a dependency and invoke
  &lt;code&gt;domify(html)&lt;/code&gt;, similar components could facilitate event handling etcetera. My point here is that ubiquitous libraries like jQuery will eventually be a thing of the past and fragmentation will hopefully decrease.&lt;/p&gt;

&lt;p&gt;Another thing I think we really need to avoid, is the use of pre-processed assets within components, this includes things like Stylus, LESS, Sass, Jade, CoffeeScript among others. These are all great and can increase productivity in your application, my opinion is that they do not belong in public components, they fragment the community and reduce contributions, chances are if you&amp;#8217;re depending on these tools for UI packages your component&amp;#8217;s scope is too large.&lt;/p&gt;

&lt;p&gt;A package such as &amp;#8220;UIKit&amp;#8221; could then simply aggregate all its parts into one convenient component for those who wish to consume the entire thing, but there&amp;#8217;s no reason these need to live together, we&amp;#8217;re just lacking the tools to make this convenient.&lt;/p&gt;

&lt;p&gt;This leads to the next issue, modernization!&lt;/p&gt;

&lt;h3&gt;Modernization&lt;/h3&gt;

&lt;p&gt;There are a lot great tools being produced to deal with modernization,
  within reason we should not have to deal with these kinds of issues at
  the component level. Stylesheets are particularly bad for this, libraries
  are either faced with using CSS preprocessors to provide vendor prefixed
  versions of their styles, or of course need to manually declare them. This
  is a huge pain, and forever changing. What do we do? Nothing!&lt;/p&gt;

&lt;p&gt;I strongly suggest that we write our public component stylesheets using regular old CSS. Other tools can still be utilized at the application level if you really need them. With explicit vendor prefixing out of the way we can &lt;em&gt;enjoy&lt;/em&gt; building components since we&amp;#8217;re not focused on vendor details (when possible), they will remain light-weight, and customizable via consumer manipulation via a library such as &lt;a href="https://github.com/NV/CSSOM" target="_blank"&gt;CSSOM&lt;/a&gt; or &lt;a href="http://github.com/visionmedia/node-css" target="_blank"&gt;node-css&lt;/a&gt;.&lt;/p&gt;

&lt;p&gt;On to the next topic! Structural styling.&lt;/p&gt;

&lt;h3&gt;Structural styling&lt;/h3&gt;

&lt;p&gt;Structural styling is another thing I frequently have issues with. JavaScript
  libraries, jQuery plugins and others often ship with stylesheets, this is great
  but these libs should &lt;em&gt;only&lt;/em&gt; define structural styles.&lt;/p&gt;

&lt;p&gt;What do I mean by &amp;#8220;structural styling&amp;#8221;? Take for example the &lt;code&gt;Dialog&lt;/code&gt; from UIKit,
  it contains only styles necessary to make the component presentable, but does not
  force a ton of extra styling on you, and serves as a good base to build on. I even
  took this a little far, box-shadows etc should be omitted by default.&lt;/p&gt;

&lt;p&gt;&lt;img src="http://f.cl.ly/items/0m0a1Y0M071A3B2R3y1R/Screen%20Shot%202012-07-24%20at%205.59.38%20PM.png" alt=""/&gt;&lt;/p&gt;

&lt;p&gt;The basic idea here is let stylesheets be stylesheets, &lt;em&gt;application&lt;/em&gt; should define the look and feel of things, if you must provide &amp;#8220;themed&amp;#8221; versions simply have a component named &amp;#8220;dialog-dark-theme&amp;#8221; with only a stylesheet in it, and so on.&lt;/p&gt;

&lt;h3&gt;package.json&lt;/h3&gt;

&lt;p&gt;Components could have a &amp;#8220;component.json&amp;#8221; much like the &lt;a href="http://www.commonjs.org/" target="_blank"&gt;commonjs&lt;/a&gt; package.json, or we can simply extend package.json. This would of course act as the package manifest, letting the world know if it has stylesheets, templates, scripts, images and so on. I believe we should avoid the minimal gains of magical auto-globbing of files, we can just simply list these and avoid unnecessary
 complexity and I/O.&lt;/p&gt;

&lt;p&gt;A Dialog component would simply look like the following, nothing fancy here, just an explicit manifest.&lt;/p&gt;

&lt;pre&gt;&lt;code&gt;{
   "name": "dialog",
   "version": "1.0.0",
   "scripts": ["index.js"],
   "styles": ["dialog.css"],
   "templates": ["dialog.html"]
}
&lt;/code&gt;&lt;/pre&gt;

&lt;p&gt;The reason I would name these &lt;code&gt;styles&lt;/code&gt;, and &lt;code&gt;templates&lt;/code&gt; instead of &lt;code&gt;css&lt;/code&gt; and &lt;code&gt;html&lt;/code&gt; would be that when using private components within your application, the build tool could simply sniff out things like &lt;code&gt;["login.jade"]&lt;/code&gt;, realize it&amp;#8217;s a Jade template and compile it appropriately. Like I&amp;#8217;ve mentioned though I dont think these tools belong in public code.&lt;/p&gt;

&lt;p&gt;It may also be useful in the future to define optional dependencies for legacy browser support. Suppose I dont care anything below IE 9, I should be able to tell the build system that I&amp;#8217;m fine with omitting legacy functionality, and the packages that handle this sort of things for events, the DOM etcetera would simply not load those in, the APIs that those modules provide would remain identical.&lt;/p&gt;

&lt;h2&gt;Require fragmentation&lt;/h2&gt;

&lt;p&gt;Another huge issue in the community right now is fragmentation regarding
  javascript loader definitions, the most common probably being &lt;a href="http://wiki.commonjs.org/wiki/Modules/AsynchronousDefinition" target="_blank"&gt;AMD&lt;/a&gt;. Personally I&amp;#8217;m not a fan of AMD for one reason, it&amp;#8217;s ugly.&lt;/p&gt;

&lt;p&gt;Granted that&amp;#8217;s not a very good reason to dislike something. AMD provides the nice benefit of working without a build step, however when you need a library to test out a script anyway I feel like a quick build step to convert the more convenient commonjs &lt;code&gt;require()&lt;/code&gt; style wins here, at least for me.&lt;/p&gt;

&lt;p&gt;The real problem today is that if you want to share your public client-side code, you end up with something like the following:&lt;/p&gt;

&lt;pre&gt;&lt;code&gt;  // AMD support
  if (typeof define === 'function' &amp;amp;&amp;amp; define.amd) {
      define(function () { return Cookies; });
  // CommonJS and Node.js module support.
  } else if (typeof exports !== 'undefined') {
      // Support Node.js specific `module.exports` (which can be a function)
      if (typeof module != 'undefined' &amp;amp;&amp;amp; module.exports) {
          exports = module.exports = Cookies;
      }
      // But always support CommonJS module 1.1.1 spec (`exports` cannot be a function)
      exports.Cookies = Cookies;
  } else {
      window.Cookies = Cookies;
  }
&lt;/code&gt;&lt;/pre&gt;

&lt;p&gt;This &lt;em&gt;sucks&lt;/em&gt;. I hope to never look at this, nor support this sort of concept ever again! This is really painful. I completely understand that perhaps AMD nor sync-style requires are perfect, but if we pick &lt;em&gt;one&lt;/em&gt; we can easily translate scripts to an async style for production builds if necessary.&lt;/p&gt;

&lt;h2&gt;Delivering components&lt;/h2&gt;

&lt;p&gt;We&amp;#8217;ll obviously need a way to store and deliver components, existing tools are close but I think we can still do a little better and think a little larger.&lt;/p&gt;

&lt;h3&gt;Package managers&lt;/h3&gt;

&lt;p&gt;Tools like node&amp;#8217;s &lt;a href="http://npmjs.org" target="_blank"&gt;npm(1)&lt;/a&gt; package manager are again very great, but there are several reasons I think these packages should not live in the npm registry.&lt;/p&gt;

&lt;p&gt;The first reason being that not everyone uses node, only us as node developers can be convenienced by using it, other communities should be able to easily access and consume these components with whichever tools they prefer, or if they really want to use one written in another language then sure why not!&lt;/p&gt;

&lt;p&gt;Client-side packages in the npm registry are ambiguous, without tagging them as such it&amp;#8217;s unclear which are intended for which environment. Many packages also end up disambiguating with a suffix, for example &lt;a href="http://github.com/visionmedia/debug" target="_blank"&gt;debug&lt;/a&gt; works both on the client and in node, however without augmenting package.json one would need to publish &amp;#8220;debug&amp;#8221; and &amp;#8220;debug-component&amp;#8221; or similar to the registry.&lt;/p&gt;

&lt;p&gt;Another reason is that the package manager simply should not matter, and it usually does &lt;em&gt;not&lt;/em&gt; matter. You just want some packages on your local machine, these should absolutely be as decoupled as possible.&lt;/p&gt;

&lt;h3&gt;Component registries&lt;/h3&gt;

&lt;p&gt;Arguably the best registry would simply be &lt;a href="http://github.com" target="_blank"&gt;Github&lt;/a&gt;, or git repositories in general. There are a few downsides to this of course:&lt;/p&gt;

&lt;pre&gt;&lt;code&gt;- even shallow clones can be slow
- coupled with git both at the consumer and producer levels
- large dependency urls (unless we default github to "username/project" etc...)
&lt;/code&gt;&lt;/pre&gt;

&lt;p&gt;Some nice benefits as well:&lt;/p&gt;

&lt;pre&gt;&lt;code&gt;- clear &amp;amp; explicit dependency origins
- github is awesome
&lt;/code&gt;&lt;/pre&gt;

&lt;h2&gt;Utilizing components&lt;/h2&gt;

&lt;p&gt;Most &amp;#8220;real&amp;#8221; applications require build steps these days, however even with this being the case, build scripts are extremely implementation specific and may vary greatly for your private application(s) depending on the scope of the project.&lt;/p&gt;

&lt;p&gt;Here I would propose a free-for-all, use whatever you like from whichever community you&amp;#8217;re a part of. As long as the &amp;#8220;package manager&amp;#8221; can transfer these to your machine, you do whatever you need to integrate them into your application, the details here are largely irrelevant.&lt;/p&gt;

&lt;h2&gt;Components in practice&lt;/h2&gt;

&lt;p&gt;Traditionally most applications (that I&amp;#8217;ve experienced) are built in more of a &amp;#8220;vertical&amp;#8221; approach, spreading a single concept into multiple sections of an application. Making the application, and the components of a specific feature very difficult to reason with. This is akin to how unix libraries splatter themselves all over your system into various directories and files.&lt;/p&gt;

&lt;p&gt;At LearnBoost we&amp;#8217;ve been using components for a while now, but like I&amp;#8217;ve mentioned not only for abstract UI components, but for &lt;em&gt;everything&lt;/em&gt; in our application, even the build system and application bootstrap are implemented as components.&lt;/p&gt;

&lt;p&gt;What does look like? Nothing more than a simple list of directories as shown in the following screenshot. Each component here is comprised of any combination of server-side logic, styles, scripts, images, fonts and so on.&lt;/p&gt;

&lt;p&gt;&lt;img src="http://f.cl.ly/items/2m3c350u0Q3d2k0y0Z0h/Screen%20Shot%202012-07-24%20at%207.09.21%20PM.png" alt="web components in practice"/&gt;&lt;/p&gt;

&lt;p&gt;Beyond obvious organizational benefits this helps our team focus on specific tasks without stepping all over each other. Testing is also easier, as each component providing server functionality simply exports a fully self-contained &lt;a href="http://expressjs.com" target="_blank"&gt;express&lt;/a&gt; application, which has its own set of tests, then our root &lt;code&gt;make test&lt;/code&gt; iterates those.&lt;/p&gt;

&lt;p&gt;Our build system simply produces the output scripts and styles that we need into our root ./public directory, wrapping scripts with commonjs &lt;code&gt;require()&lt;/code&gt;s, images, fonts and other assets are served from the self-contained servers.&lt;/p&gt;

&lt;p&gt;My point here is that this concept goes beyond public components. Obviously it would be next to impossible, and ill-advised to start sharing components with server portions, but for your own application sticking to whatever language / platform you&amp;#8217;re using it works very well.&lt;/p&gt;

&lt;h2&gt;What next?!&lt;/h2&gt;

&lt;p&gt;Keep building! The JavaScript community has been moving in great directions lately, take what I&amp;#8217;ve said with a grain of salt but I hope to see some attempts at &amp;#8220;component&amp;#8221; management, not just JavaScript ;)&lt;/p&gt;

&lt;p&gt;Until then you may want to keep your eyes on &lt;a href="https://github.com/component" target="_blank"&gt;&lt;a href="https://github.com/component" target="_blank"&gt;https://github.com/component&lt;/a&gt;&lt;/a&gt; for future work from us at LearnBoost in regards to this topic. EDIT: I&amp;#8217;ve started a &lt;a href="https://github.com/component/component/wiki/Spec" target="_blank"&gt;component wiki&lt;/a&gt; where we can toss around ideas.&lt;/p&gt;

&lt;hr&gt;&lt;p&gt;&lt;img src="http://verybadfrog.com/wp-content/uploads/2010/05/Haters-gonna-hate-cat.jpg" alt=""/&gt;&lt;/p&gt;

&lt;p&gt;&lt;strong&gt;EDIT&lt;/strong&gt;: Work on the &lt;a href="https://github.com/component/component" target="_blank"&gt;component(1)&lt;/a&gt; executable have begun, as well as a JavaScript implementation of a builder for components, aptly named &lt;a href="https://github.com/component/builder.js" target="_blank"&gt;component/builder.js&lt;/a&gt;. For now &lt;code&gt;component-build(1)&lt;/code&gt; is shipped with &lt;code&gt;component(1)&lt;/code&gt; to ease use, otherwise the tools are not coupled. For example you could use `component(1) to perform installation and then use builder.js directly in code and customize your build, use the command, or use an entirely custom solution if you wish. I&amp;#8217;ve started documenting some &lt;a href="https://github.com/component/component/wiki/F.A.Q" target="_blank"&gt;frequently asked questions&lt;/a&gt;, and we&amp;#8217;re starting a &lt;a href="https://github.com/component/component/wiki/Components" target="_blank"&gt;Wiki page&lt;/a&gt; listing some of the components available so far, with well over 70 within the last month or so we&amp;#8217;re off to a good start!&lt;/p&gt;</description><link>http://tjholowaychuk.com/post/27984551477</link><guid>http://tjholowaychuk.com/post/27984551477</guid><pubDate>Wed, 25 Jul 2012 08:34:00 -0700</pubDate><category>components</category><category>js</category><category>css</category><category>nodejs</category><category>ideas</category></item><item><title>git-extras introduction screencast</title><description>&lt;p&gt;This &lt;a href="https://vimeo.com/45506445" target="_blank"&gt;screencast&lt;/a&gt; is an introduction to the &lt;a href="http://github.com/visionmedia/git-extras" target="_blank"&gt;git-extras&lt;/a&gt; project and covers the following commands:&lt;/p&gt;

&lt;ul&gt;&lt;li&gt;git setup&lt;/li&gt;
&lt;li&gt;git ignore&lt;/li&gt;
&lt;li&gt;git summary&lt;/li&gt;
&lt;li&gt;git effort&lt;/li&gt;
&lt;li&gt;git changelog&lt;/li&gt;
&lt;li&gt;git release&lt;/li&gt;
&lt;/ul&gt;&lt;h2&gt;Git aliases&lt;/h2&gt;

&lt;p&gt;My personal git aliases as promised:&lt;/p&gt;

&lt;pre&gt;&lt;code&gt;alias gd="git diff | mate"
alias ga="git add"
alias gbd="git branch -D"
alias gst="git status"
alias gca="git commit -a -m"
alias gm="git merge --no-ff"
alias gpt="git push --tags"
alias gp="git push"
alias grh="git reset --hard"
alias gb="git branch"
alias gcob="git checkout -b"
alias gco="git checkout"
alias gba="git branch -a"
alias gcp="git cherry-pick"
alias gl="git log --pretty='format:%Cgreen%h%Creset %an - %s' --graph"
alias gpom="git pull origin master"
alias gcd='cd "`git rev-parse --show-toplevel`"'
&lt;/code&gt;&lt;/pre&gt;

&lt;p&gt;Mostly I just wanted to play with my new snowball mic :D (no more loud keyboard noise!!). Also wtf vimeo compression?&amp;#8230; might use youtube next time.&lt;/p&gt;</description><link>http://tjholowaychuk.com/post/26904939933</link><guid>http://tjholowaychuk.com/post/26904939933</guid><pubDate>Tue, 10 Jul 2012 07:39:58 -0700</pubDate><category>screencast</category><category>git-extras</category><category>git</category></item><item><title>Page.js 1.2.0</title><description>&lt;p&gt;Along with better API docs the &lt;a href="http://visionmedia.github.com/page.js/" target="_blank"&gt;page.js&lt;/a&gt; 1.2.0 is released, the client-side micro router.&lt;/p&gt;

&lt;p&gt;&lt;img src="http://f.cl.ly/items/3i3n001d0s1Q031r2q1P/page.png" alt="page.js router logo"/&gt;&lt;/p&gt;

&lt;p&gt;The additions are subtle, the first is a &lt;code&gt;ctx.querystring&lt;/code&gt; property exposing the query string, followed by the complimenting &lt;code&gt;ctx.pathname&lt;/code&gt; to reference the &lt;code&gt;ctx.path&lt;/code&gt; void of query string. &lt;a href="https://twitter.com/#!/ovaillancourt" target="_blank"&gt;@ovaillancourt&lt;/a&gt; also added support for passing query strings in the first place, which was arguably a bug, and added &lt;code&gt;.defaultPrevented&lt;/code&gt; support to opt-out of page&amp;#8217;s handling (as well as browser defaults of course).&lt;/p&gt;</description><link>http://tjholowaychuk.com/post/26588657394</link><guid>http://tjholowaychuk.com/post/26588657394</guid><pubDate>Thu, 05 Jul 2012 16:17:00 -0700</pubDate><category>page.js</category><category>js</category></item><item><title>Mocha 1.3.0</title><description>&lt;p&gt;A relatively minor release this time but we&amp;#8217;ve still got some cool new features!&lt;/p&gt;

&lt;h2&gt;Scrolling HTML reporter&lt;/h2&gt;

&lt;p&gt;The window will now scroll to follow along with larger test suites, and the statistics are fixed to the upper right-hand corner, a small but nice touch.&lt;/p&gt;

&lt;h2&gt;Custom reporters&lt;/h2&gt;

&lt;p&gt;Mocha has quite a few bundled reporters now, so future reporters that are not deemed important enough to provide the convenience of being in core should be published to npm. Some  less important reporters &lt;em&gt;may&lt;/em&gt; be removed from core and published to npm in the future.&lt;/p&gt;

&lt;p&gt;This new feature also allows you to use localized private reporters. The &lt;code&gt;--reporter NAME&lt;/code&gt; flag now behaves like &lt;code&gt;require()&lt;/code&gt;, so for example you could do &lt;code&gt;--reporter ./myreporter&lt;/code&gt;, or a third-party npm module such as &lt;code&gt;--reporter lcov-reporter&lt;/code&gt;.&lt;/p&gt;

&lt;p&gt;For details on creating and finding third-party reporters visit the &lt;a href="https://github.com/visionmedia/mocha/wiki" target="_blank"&gt;wiki&lt;/a&gt;.&lt;/p&gt;

&lt;h2&gt;Grep inversion&lt;/h2&gt;

&lt;p&gt;The awesome &lt;code&gt;--grep&lt;/code&gt; feature can now be inverted with the aptly named &lt;code&gt;--invert&lt;/code&gt; flag. For example suppose you had tests tagged as &lt;strong&gt;@slow&lt;/strong&gt;, and you wanted to run only slow tests you might use &lt;code&gt;--grep @slow&lt;/code&gt;, however if you wanted to run only fast tests &lt;code&gt;--grep @slow --invert&lt;/code&gt; would do the trick.&lt;/p&gt;

&lt;p&gt;Along with this change &lt;code&gt;--grep PATTERN&lt;/code&gt; is now escaped, meaning chars that used to behave as regexp special chars are now escaped.&lt;/p&gt;

&lt;h2&gt;Changelog&lt;/h2&gt;

&lt;p&gt;Here&amp;#8217;s the full changelog:&lt;/p&gt;

&lt;h1&gt;1.3.0 / 2012-07-05&lt;/h1&gt;

&lt;ul&gt;&lt;li&gt;add window scrolling to &lt;code&gt;HTML&lt;/code&gt; reporter&lt;/li&gt;
&lt;li&gt;add v8&amp;#160;&lt;code&gt;--trace-*&lt;/code&gt; option support&lt;/li&gt;
&lt;li&gt;add support for custom reports via &lt;code&gt;--reporter MODULE&lt;/code&gt;&lt;/li&gt;
&lt;li&gt;add &lt;code&gt;--invert&lt;/code&gt; switch to invert &lt;code&gt;--grep&lt;/code&gt; matches&lt;/li&gt;
&lt;li&gt;fix export of &lt;code&gt;Nyan&lt;/code&gt; reporter. Closes #495&lt;/li&gt;
&lt;li&gt;fix escaping of &lt;code&gt;HTML&lt;/code&gt; suite titles. Closes #486&lt;/li&gt;
&lt;li&gt;fix &lt;code&gt;done()&lt;/code&gt; called multiple times with an error test&lt;/li&gt;
&lt;li&gt;change &lt;code&gt;--grep&lt;/code&gt; - regexp escape the input&lt;/li&gt;
&lt;/ul&gt;</description><link>http://tjholowaychuk.com/post/26576019855</link><guid>http://tjholowaychuk.com/post/26576019855</guid><pubDate>Thu, 05 Jul 2012 13:03:14 -0700</pubDate><category>mocha</category><category>js</category><category>node</category></item><item><title>commander.c - C option parser</title><description>&lt;p&gt;Every time I write a C program I end up rolling my own option parsing with a loop and &lt;code&gt;strcmp()&lt;/code&gt;, so I figured it was time to port over &lt;a href="https://github.com/visionmedia/commander.c" target="_blank"&gt;commander.c&lt;/a&gt; from the original &lt;a href="http://github.com/visionmedia/commander" target="_blank"&gt;ruby commander&lt;/a&gt;, and there&amp;#8217;s also a &lt;a href="http://github.com/visionmedia/commander.js" target="_blank"&gt;node.js port&lt;/a&gt;.&lt;/p&gt;

&lt;p&gt;Commander.c is a super simple script that makes defining options declarative and does the dirty work for you, its usage looks like this:&lt;/p&gt;

&lt;pre&gt;&lt;code&gt;#include &amp;lt;stdio.h&amp;gt;
#include "commander.h"

static void
verbose(command_t *self) {
  printf("verbose: enabled\n");
}

static void
required(command_t *self) {
  printf("required: %s\n", self-&amp;gt;arg);
}

static void
optional(command_t *self) {
  printf("optional: %s\n", self-&amp;gt;arg);
}

int
main(int argc, const char **argv){
  command_t cmd;
  command_init(&amp;amp;cmd, argv[0], "0.0.1");
  command_option(&amp;amp;cmd, "-v", "--verbose", "enable verbose stuff", verbose);
  command_option(&amp;amp;cmd, "-r", "--required &amp;lt;arg&amp;gt;", "required arg", required);
  command_option(&amp;amp;cmd, "-o", "--optional [arg]", "optional arg", optional);
  command_parse(&amp;amp;cmd, argc, argv);
  printf("additional args:\n");
  for (int i = 0; i &amp;lt; cmd.argc; ++i) {
    printf("  - '%s'\n", cmd.argv[i]);
  }
  return 0;
}
&lt;/code&gt;&lt;/pre&gt;

&lt;p&gt;As a bonus it generates the &lt;code&gt;--help&lt;/code&gt; from what it already knows about your program:&lt;/p&gt;

&lt;pre&gt;&lt;code&gt;Usage: example [options]

Options:

  -V, --version                 output program version
  -h, --help                    output help information
  -v, --verbose                 enable verbose stuff
  -r, --required &amp;lt;arg&amp;gt;          required arg
  -o, --optional [arg]          optional arg
&lt;/code&gt;&lt;/pre&gt;

&lt;p&gt;Commander handles optional and required args:&lt;/p&gt;

&lt;pre&gt;&lt;code&gt;$ mon --sleep
 --sleep requires an argument
&lt;/code&gt;&lt;/pre&gt;

&lt;p&gt;Warns about unrecognized flags:&lt;/p&gt;

&lt;pre&gt;&lt;code&gt;$ ./test --foo
unrecognized flag --foo
&lt;/code&gt;&lt;/pre&gt;

&lt;p&gt;Unparsed arguments are then provided as &lt;code&gt;cmd.argv&lt;/code&gt; and of course its companion &lt;code&gt;cmd.argc&lt;/code&gt;, which of course includes &lt;code&gt;--&lt;/code&gt; support to flag subsequent args as literals:&lt;/p&gt;

&lt;pre&gt;&lt;code&gt;$ ./test foo -- --foo
additional args:
  - 'foo'
  - '--bar'
&lt;/code&gt;&lt;/pre&gt;

&lt;p&gt;If you have a struct that you want to access within each callback just assign to &lt;code&gt;cmd.data&lt;/code&gt;, a &lt;code&gt;void *&lt;/code&gt;.&lt;/p&gt;

&lt;p&gt;That&amp;#8217;s it for now, I&amp;#8217;ll be adding a few more things in the near future so check it out on &lt;a href="https://github.com/visionmedia/commander.c" target="_blank"&gt;github&lt;/a&gt;.&lt;/p&gt;</description><link>http://tjholowaychuk.com/post/25509398730</link><guid>http://tjholowaychuk.com/post/25509398730</guid><pubDate>Wed, 20 Jun 2012 09:13:37 -0700</pubDate><category>c</category></item></channel></rss>
