<?xml version="1.0" encoding="utf-8"?>
<feed xmlns="http://www.w3.org/2005/Atom">
    <title>Irakli Gozalishvili</title>
    <subtitle>?.</subtitle>
    <link href="http://www.jeditoolkit.com/atom.xml" rel="self" type="application/atom+xml" />
    <link href="http://www.jeditoolkit.com" rel="alternate" type="text/html" />
    <id>http://www.jeditoolkit.com</id>
    <updated>2011-07-03T06:18:15-07:00</updated>
    <author>
        <name>Irakli Gozalishvili</name>
    </author>
    
        <entry>
            <title>JS Guards</title>
            <link href="http://www.jeditoolkit.com/2011/07/03/guards.html" rel="alternate" type="text/html" />
            <updated>2011-07-03T00:00:00-07:00</updated>
            <id>http://www.jeditoolkit.com/2011/07/03/guards</id>
            <content type="html">&lt;p&gt;I’ve written micro library, to solve a very common problem in JS code today. Most likely following example looks familiar:&lt;/p&gt;
&lt;pre&gt;
&lt;span class='Function'&gt;function&lt;/span&gt; Constructor&lt;span class='Parens'&gt;(&lt;/span&gt;options&lt;span class='Parens'&gt;)&lt;/span&gt; &lt;span class='Braces'&gt;{&lt;/span&gt;
  options &lt;span class='Operators'&gt;=&lt;/span&gt; options &lt;span class='Operators'&gt;||&lt;/span&gt; &lt;span class='Braces'&gt;{}&lt;/span&gt;
  &lt;span class='Statement'&gt;if&lt;/span&gt; &lt;span class='Parens'&gt;(&lt;/span&gt;&lt;span class='Operator'&gt;typeof&lt;/span&gt; options&lt;span class='Operators'&gt;.&lt;/span&gt;url &lt;span class='Operators'&gt;!==&lt;/span&gt; &lt;span class='String'&gt;'string'&lt;/span&gt;&lt;span class='Parens'&gt;)&lt;/span&gt;
    &lt;span class='Exception'&gt;throw&lt;/span&gt; &lt;span class='Operator'&gt;new&lt;/span&gt; &lt;span class='Error'&gt;TypeError&lt;/span&gt;&lt;span class='Parens'&gt;(&lt;/span&gt;&lt;span class='String'&gt;'url is required!'&lt;/span&gt;&lt;span class='Parens'&gt;)&lt;/span&gt;

  &lt;span class='Comment'&gt;// Finally, your logic here!&lt;/span&gt;
&lt;span class='Braces'&gt;}&lt;/span&gt;
&lt;/pre&gt;
&lt;p&gt;First of all, code is wrong. If falsy value is passed to a function it will misbehave. Secondly, boilerplate code makes it less readable. It takes three lines to validate just one property (very likely to have more) of the given data structure. Finally, validation code does not even belongs there, as it has nothing to do with an actual logic of a function.&lt;/p&gt;

&lt;p&gt;What we actually need is an annotation enforcing certain constraints. We don&amp;#8217;t have annotations in JS, but we have functions that are omnipotent! Just about everything can be solved everything using functions.&lt;/p&gt;
&lt;pre&gt;
&lt;span class='Function'&gt;function&lt;/span&gt; ConstructorOptions&lt;span class='Parens'&gt;(&lt;/span&gt;options&lt;span class='Parens'&gt;)&lt;/span&gt; &lt;span class='Braces'&gt;{&lt;/span&gt;
  &lt;span class='Statement'&gt;if&lt;/span&gt; &lt;span class='Parens'&gt;(&lt;/span&gt;options &lt;span class='Operators'&gt;===&lt;/span&gt; &lt;span class='Keyword'&gt;null&lt;/span&gt; &lt;span class='Operators'&gt;||&lt;/span&gt; options &lt;span class='Operators'&gt;===&lt;/span&gt; &lt;span class='Keyword'&gt;undefined&lt;/span&gt;&lt;span class='Parens'&gt;)&lt;/span&gt;
    options &lt;span class='Operators'&gt;=&lt;/span&gt; &lt;span class='Braces'&gt;{}&lt;/span&gt;
  &lt;span class='Statement'&gt;if&lt;/span&gt; &lt;span class='Parens'&gt;(&lt;/span&gt;&lt;span class='Operator'&gt;typeof&lt;/span&gt; options &lt;span class='Operators'&gt;!==&lt;/span&gt; &lt;span class='String'&gt;'object'&lt;/span&gt;&lt;span class='Parens'&gt;)&lt;/span&gt;
    &lt;span class='Exception'&gt;throw&lt;/span&gt; &lt;span class='Operator'&gt;new&lt;/span&gt; &lt;span class='Error'&gt;TypeError&lt;/span&gt;&lt;span class='Parens'&gt;(&lt;/span&gt;&lt;span class='String'&gt;'Options must an object!'&lt;/span&gt;&lt;span class='Parens'&gt;)&lt;/span&gt;

  &lt;span class='Statement'&gt;if&lt;/span&gt; &lt;span class='Parens'&gt;(&lt;/span&gt;&lt;span class='Operator'&gt;typeof&lt;/span&gt; options&lt;span class='Operators'&gt;.&lt;/span&gt;url &lt;span class='Operators'&gt;!==&lt;/span&gt; &lt;span class='String'&gt;'string'&lt;/span&gt;&lt;span class='Parens'&gt;)&lt;/span&gt;
    &lt;span class='Exception'&gt;throw&lt;/span&gt; &lt;span class='Operator'&gt;new&lt;/span&gt; &lt;span class='Error'&gt;TypeError&lt;/span&gt;&lt;span class='Parens'&gt;(&lt;/span&gt;&lt;span class='String'&gt;'url is required!'&lt;/span&gt;&lt;span class='Parens'&gt;)&lt;/span&gt;
&lt;span class='Braces'&gt;}&lt;/span&gt;

&lt;span class='Function'&gt;function&lt;/span&gt; Constructor&lt;span class='Parens'&gt;(&lt;/span&gt;options&lt;span class='Parens'&gt;)&lt;/span&gt; &lt;span class='Braces'&gt;{&lt;/span&gt;
  options &lt;span class='Operators'&gt;=&lt;/span&gt; ConstructorOptions&lt;span class='Parens'&gt;(&lt;/span&gt;options&lt;span class='Parens'&gt;)&lt;/span&gt;

  &lt;span class='Comment'&gt;// Your logic here!&lt;/span&gt;
&lt;span class='Braces'&gt;}&lt;/span&gt;
&lt;/pre&gt;
&lt;p&gt;This example is much better, because reader of &lt;code&gt;Constructor&lt;/code&gt; function can concentrate on function logic, without being distracted by a validation boilerplate. In addition, &lt;code&gt;options&lt;/code&gt;&amp;#8217; validation code can be independently unit tested and in some cases reused.&lt;/p&gt;

&lt;p&gt;JS &lt;a href='https://github.com/Gozala/guards' title='JS library for data type &amp;amp; data structure validations'&gt;guards&lt;/a&gt;, is a small library that takes this idea to the next level. It provides declarative and recomposable way to define data type &amp;amp; data structure validations.&lt;/p&gt;
&lt;pre&gt;
&lt;span class='Identifier'&gt;var&lt;/span&gt; guards &lt;span class='Operators'&gt;=&lt;/span&gt; &lt;span class='Keyword'&gt;require&lt;/span&gt;&lt;span class='Parens'&gt;(&lt;/span&gt;&lt;span class='String'&gt;'&lt;a href='https://raw.github.com/Gozala/guards/v0.3.0/guards.js'&gt;https://raw.github.com/Gozala/guards/v0.3.0/guards.js&lt;/a&gt;'&lt;/span&gt;&lt;span class='Parens'&gt;)&lt;/span&gt;

&lt;span class='Comment'&gt;// Define a { x, y } data structure, where x and y fallback to 0.&lt;/span&gt;
&lt;span class='Identifier'&gt;var&lt;/span&gt; Point &lt;span class='Operators'&gt;=&lt;/span&gt; guards&lt;span class='Operators'&gt;.&lt;/span&gt;Schema&lt;span class='Parens'&gt;(&lt;/span&gt;&lt;span class='Braces'&gt;{&lt;/span&gt;
  x&lt;span class='Operators'&gt;:&lt;/span&gt; guards&lt;span class='Operators'&gt;.&lt;/span&gt;&lt;span class='Type'&gt;Number&lt;/span&gt;&lt;span class='Parens'&gt;(&lt;/span&gt;0&lt;span class='Parens'&gt;)&lt;/span&gt;&lt;span class='Operators'&gt;,&lt;/span&gt;
  y&lt;span class='Operators'&gt;:&lt;/span&gt; guards&lt;span class='Operators'&gt;.&lt;/span&gt;&lt;span class='Type'&gt;Number&lt;/span&gt;&lt;span class='Parens'&gt;(&lt;/span&gt;0&lt;span class='Parens'&gt;)&lt;/span&gt;
&lt;span class='Braces'&gt;}&lt;/span&gt;&lt;span class='Parens'&gt;)&lt;/span&gt;

&lt;span class='Comment'&gt;// Define any type of guard as a function&lt;/span&gt;
&lt;span class='Function'&gt;function&lt;/span&gt; color&lt;span class='Parens'&gt;(&lt;/span&gt;value&lt;span class='Parens'&gt;)&lt;/span&gt; &lt;span class='Braces'&gt;{&lt;/span&gt;
  &lt;span class='Comment'&gt;// If validates just return value&lt;/span&gt;
  &lt;span class='Statement'&gt;if&lt;/span&gt; &lt;span class='Parens'&gt;(&lt;/span&gt;&lt;span class='Operator'&gt;typeof&lt;/span&gt; value &lt;span class='Operators'&gt;===&lt;/span&gt; &lt;span class='String'&gt;&amp;quot;number&amp;quot;&lt;/span&gt; &lt;span class='Operators'&gt;&amp;amp;&amp;amp;&lt;/span&gt; value &lt;span class='Operators'&gt;&amp;lt;=&lt;/span&gt; 255 &lt;span class='Operators'&gt;&amp;amp;&amp;amp;&lt;/span&gt; value &lt;span class='Operators'&gt;&amp;gt;=&lt;/span&gt; 0&lt;span class='Parens'&gt;)&lt;/span&gt; &lt;span class='Statement'&gt;return&lt;/span&gt; value
  &lt;span class='Comment'&gt;// If not throw TypeError&lt;/span&gt;
  &lt;span class='Exception'&gt;throw&lt;/span&gt; &lt;span class='Operator'&gt;new&lt;/span&gt; &lt;span class='Error'&gt;TypeError&lt;/span&gt;&lt;span class='Parens'&gt;(&lt;/span&gt;&lt;span class='String'&gt;&amp;quot;Color is a number between 0 and 255&amp;quot;&lt;/span&gt;&lt;span class='Parens'&gt;)&lt;/span&gt;
&lt;span class='Braces'&gt;}&lt;/span&gt;

&lt;span class='Comment'&gt;// Define a [0-255, 0-255, 0-255] data structure guard.&lt;/span&gt;
&lt;span class='Identifier'&gt;var&lt;/span&gt; RGB &lt;span class='Operators'&gt;=&lt;/span&gt; guards&lt;span class='Operators'&gt;.&lt;/span&gt;Tuple&lt;span class='Parens'&gt;(&lt;/span&gt;&lt;span class='Braces'&gt;[&lt;/span&gt; color&lt;span class='Operators'&gt;,&lt;/span&gt; color&lt;span class='Operators'&gt;,&lt;/span&gt; color &lt;span class='Braces'&gt;]&lt;/span&gt;&lt;span class='Parens'&gt;)&lt;/span&gt;

&lt;span class='Comment'&gt;// Compose data structure out of existing guards.&lt;/span&gt;
&lt;span class='Identifier'&gt;var&lt;/span&gt; Segment &lt;span class='Operators'&gt;=&lt;/span&gt; guards&lt;span class='Operators'&gt;.&lt;/span&gt;Schema&lt;span class='Parens'&gt;(&lt;/span&gt;&lt;span class='Braces'&gt;{&lt;/span&gt;
  start&lt;span class='Operators'&gt;:&lt;/span&gt; Point&lt;span class='Operators'&gt;,&lt;/span&gt;
  end&lt;span class='Operators'&gt;:&lt;/span&gt; Point&lt;span class='Operators'&gt;,&lt;/span&gt;
  color&lt;span class='Operators'&gt;:&lt;/span&gt; RGB&lt;span class='Operators'&gt;,&lt;/span&gt;
&lt;span class='Braces'&gt;}&lt;/span&gt;&lt;span class='Parens'&gt;)&lt;/span&gt;

Segment&lt;span class='Parens'&gt;(&lt;/span&gt;&lt;span class='Braces'&gt;{&lt;/span&gt; end&lt;span class='Operators'&gt;:&lt;/span&gt; &lt;span class='Braces'&gt;{&lt;/span&gt; y&lt;span class='Operators'&gt;:&lt;/span&gt; 23 &lt;span class='Braces'&gt;}&lt;/span&gt;&lt;span class='Operators'&gt;,&lt;/span&gt; color&lt;span class='Operators'&gt;:&lt;/span&gt; &lt;span class='Braces'&gt;[&lt;/span&gt;17&lt;span class='Operators'&gt;,&lt;/span&gt; 255&lt;span class='Operators'&gt;,&lt;/span&gt; 0&lt;span class='Braces'&gt;]&lt;/span&gt; &lt;span class='Braces'&gt;}&lt;/span&gt;&lt;span class='Parens'&gt;)&lt;/span&gt;
&lt;span class='Comment'&gt;// { start: { x: 0, y: 0 }, end: { x: 0, y: 23 }, color: [ 17, 255, 0 ] }&lt;/span&gt;
Segment&lt;span class='Parens'&gt;(&lt;/span&gt;&lt;span class='Braces'&gt;{&lt;/span&gt; start&lt;span class='Operators'&gt;:&lt;/span&gt; 0&lt;span class='Operators'&gt;,&lt;/span&gt; end&lt;span class='Operators'&gt;:&lt;/span&gt; &lt;span class='Braces'&gt;{&lt;/span&gt; y&lt;span class='Operators'&gt;:&lt;/span&gt; 23 &lt;span class='Braces'&gt;}&lt;/span&gt;&lt;span class='Operators'&gt;,&lt;/span&gt; color&lt;span class='Operators'&gt;:&lt;/span&gt; &lt;span class='Braces'&gt;[&lt;/span&gt;17&lt;span class='Operators'&gt;,&lt;/span&gt; 255&lt;span class='Operators'&gt;,&lt;/span&gt; 0&lt;span class='Braces'&gt;]&lt;/span&gt; &lt;span class='Braces'&gt;}&lt;/span&gt;&lt;span class='Parens'&gt;)&lt;/span&gt;
&lt;span class='Comment'&gt;// TypeError: Object expected instead of number `0`&lt;/span&gt;
Segment&lt;span class='Parens'&gt;(&lt;/span&gt;&lt;span class='Braces'&gt;{&lt;/span&gt; color&lt;span class='Operators'&gt;:&lt;/span&gt; &lt;span class='Braces'&gt;[&lt;/span&gt; 10&lt;span class='Operators'&gt;,&lt;/span&gt; 40&lt;span class='Operators'&gt;,&lt;/span&gt; &lt;span class='String'&gt;'30'&lt;/span&gt; &lt;span class='Braces'&gt;]}&lt;/span&gt;&lt;span class='Parens'&gt;)&lt;/span&gt;
&lt;span class='Comment'&gt;// TypeError: Color is a number between 0 and 255&lt;/span&gt;
&lt;/pre&gt;
&lt;p&gt;You can use this library in browsers, jetpack and nodejs. Also, you can try it out right now via &lt;a href='http://jsfiddle.net/gozala/pfnAM/' title='JSFiddle interactive example'&gt;interactive example&lt;/a&gt; on JSFiddle. For more details and examples check out library &lt;a href='http://jeditoolkit.com/guards/docs/' title='Documentation'&gt;documentation&lt;/a&gt;. Finally, there is a &lt;a href='http://wiki.ecmascript.org/doku.php?id=strawman:guards' title='EcmaScript proposal'&gt;guards proposal&lt;/a&gt; for EcmaScript and chances are we&amp;#8217;ll get a syntax sugar some day (It will take a while though as it&amp;#8217;s not even in &lt;a href='http://wiki.ecmascript.org/doku.php?id=harmony:proposals'&gt;Harmony&lt;/a&gt;).&lt;/p&gt;

&lt;p&gt;As always I&amp;#8217;m more than happy to hear your feedback!&lt;/p&gt;</content>
        </entry>
    
        <entry>
            <title>Packageless modules</title>
            <link href="http://www.jeditoolkit.com/2011/06/16/packageless-modules.html" rel="alternate" type="text/html" />
            <updated>2011-06-16T00:00:00-07:00</updated>
            <id>http://www.jeditoolkit.com/2011/06/16/packageless-modules</id>
            <content type="html">&lt;h1 id='packages'&gt;Packages&lt;/h1&gt;

&lt;p&gt;Every time I write code in javasciprt for jetpack or &lt;a href='http://nodejs.org/' title='Evented I/O for V8 JavaScript'&gt;nodejs&lt;/a&gt; I question myself: &amp;#8220;Do we really need packages ?&amp;#8221;. Even with amazing package manager like &lt;a href='http://npmjs.org/' title='NodeJS package manager'&gt;npm&lt;/a&gt; it still feels wrong to me for a few reasons:&lt;/p&gt;

&lt;h3 id='1_size_and_scope'&gt;1. Size and scope&lt;/h3&gt;

&lt;p&gt;Writing code for the web taught us keeping line numbers tight, to a bare minimum. It could be a platform limitation, but more importantly it&amp;#8217;s a &lt;a href='http://en.wikipedia.org/wiki/Best_practice' title='Methods or processes that have proven themselves over time'&gt;best practice&lt;/a&gt; that has multiple advantages:&lt;/p&gt;

&lt;ul&gt;
&lt;li&gt;You never overgeneralize by trying to solve each and every problem.&lt;/li&gt;

&lt;li&gt;You reduce a surface for bugs, less lines =&amp;gt; less bugs.&lt;/li&gt;

&lt;li&gt;You build reusable building blocks, with a focus on one thing only. Also, such blocks are easy to mix and match.&lt;/li&gt;

&lt;li&gt;Faster to download, parse, execute.&lt;/li&gt;
&lt;/ul&gt;

&lt;p&gt;Most of the modern js libraries / frameworks consist of one file, solve one problem and do it well. &lt;a href='http://microjs.com/' title='Fantastic Micro-Frameworks and Micro-Libraries for Fun and Profit'&gt;MicroJS&lt;/a&gt; started a great job of promoting this trend by building a nice spot for discovering fantastic micro frameworks and libraries!&lt;/p&gt;

&lt;p&gt;Package definition, on the other hand, implies wrapping collection of things into a single form. So no matter how great package manager is, packages will tend to grow in size attempting to solve bigger set of tasks.&lt;/p&gt;

&lt;h3 id='2_explicitness'&gt;2. Explicitness&lt;/h3&gt;

&lt;p&gt;Looking at source should be enough to understand what program does, what it depends on, etc.. Unfortunately this is not the case with packages as it requires looking at the package descriptors and understanding non trivial module search logic. To put it other way &lt;pre&gt;bar &lt;span class='Operators'&gt;=&lt;/span&gt; &lt;span class='Keyword'&gt;require&lt;/span&gt;&lt;span class='Parens'&gt;(&lt;/span&gt;&lt;span class='String'&gt;'foo/bar'&lt;/span&gt;&lt;span class='Parens'&gt;)&lt;/span&gt;&lt;/pre&gt; expression depends on too many things: requirer module, package descriptor, existence of various files in various places. In jetpack &lt;a href='https://github.com/mozilla/addon-sdk/blob/master/static-files/md/dev-guide/addon-development/module-search.md'&gt;module search&lt;/a&gt; logic ended up being very complex. NodeJS has a better story, but still there more than two axis involved. It should be simple &amp;amp; straight forward.&lt;/p&gt;

&lt;h3 id='3_simplicity'&gt;3. Simplicity&lt;/h3&gt;

&lt;p&gt;When I find some useful &amp;amp; well maintained module on the web, I just want to be able to use it straight away, without downloading and bundling with my code, or even worth creating a package out of it publishing into some centralized registry in order to finally be able to require it! And when I want to alter some functionality in third party module I don&amp;#8217;t want to go through change / rename / publish routine, I just want to fork on github and require!&lt;/p&gt;

&lt;h3 id='4_interoperability'&gt;4. Interoperability&lt;/h3&gt;

&lt;p&gt;Packages are not for browsers, because they have dependencies that have their own dependencies etc.. All this dependencies are expressed in a separate &lt;code&gt;package.json&lt;/code&gt; files and it&amp;#8217;s impossible to interpret &lt;code&gt;require&lt;/code&gt; without reading package descriptor or knowledge of a requirer and I won&amp;#8217;t even go into details of search paths and dependency duplications. Only visible solution for using packages in browsers requires build step on each file change or a server that does this at runtime. It&amp;#8217;s a big compromise to make even though we do builds before deployments.&lt;/p&gt;

&lt;h3 id='5_far_from_harmony'&gt;5. Far from harmony&lt;/h3&gt;

&lt;p&gt;No packages are in harmony, just a &lt;a href='http://wiki.ecmascript.org/doku.php?id=harmony:modules' title='Modules proposal for ES.next'&gt;simple modules&lt;/a&gt; with compile-time resolution and linking. Hopefully very soon, I heard that by end of this year, we will have a first class modules in JavaScript and that will be the ultimate way to distribute building blocks with built-in support from js engines, so closer we stick to the model cheaper will be migration.&lt;/p&gt;

&lt;h1 id='alternative'&gt;Alternative&lt;/h1&gt;

&lt;p&gt;Web is awesome, it&amp;#8217;s cross platform, fully distributed, yet connected via links / URLs.&lt;/p&gt;

&lt;p&gt;I think we should be building ecosystem for building web, with a same spirit: cross-platform interoperable modules, that are fully distributed across the web, still connected via URLs. Each doing one thing only, but doing it well. No need for complicated module search logic or central authority for distribution! I&amp;#8217;m very happy that, &lt;a href='http://wiki.ecmascript.org/doku.php?id=harmony:modules_examples#remote_modules_on_the_web_1' title='Remote module loading examples'&gt;that&amp;#8217;s exactly how modules&lt;/a&gt; are thought to work in Harmony.&lt;/p&gt;

&lt;h1 id='solution'&gt;Solution&lt;/h1&gt;

&lt;p&gt;In my spare time I have prototyped a tool called &lt;a href='https://github.com/Gozala/graphquire/'&gt;graphquire&lt;/a&gt; that makes it possible to write and use such modules, that will work across different platforms including: jetpack, nodejs and browsers. Unfortunately different platforms limitations made it impossible to require modules with an actual URLs, but it very close:&lt;/p&gt;
&lt;pre&gt;
&lt;span class='Comment'&gt;// Relative&lt;/span&gt;
&lt;span class='Keyword'&gt;require&lt;/span&gt;&lt;span class='Parens'&gt;(&lt;/span&gt;&lt;span class='String'&gt;'./foo/bar'&lt;/span&gt;&lt;span class='Parens'&gt;)&lt;/span&gt;
&lt;span class='Keyword'&gt;require&lt;/span&gt;&lt;span class='Parens'&gt;(&lt;/span&gt;&lt;span class='String'&gt;'./bla.js'&lt;/span&gt;&lt;span class='Parens'&gt;)&lt;/span&gt;
&lt;span class='Keyword'&gt;require&lt;/span&gt;&lt;span class='Parens'&gt;(&lt;/span&gt;&lt;span class='String'&gt;'../baz'&lt;/span&gt;&lt;span class='Parens'&gt;)&lt;/span&gt;

&lt;span class='Comment'&gt;// Absolute&lt;/span&gt;
&lt;span class='Keyword'&gt;require&lt;/span&gt;&lt;span class='Parens'&gt;(&lt;/span&gt;&lt;span class='String'&gt;'http!foo.org/bar'&lt;/span&gt;&lt;span class='Parens'&gt;)&lt;/span&gt;
&lt;span class='Keyword'&gt;require&lt;/span&gt;&lt;span class='Parens'&gt;(&lt;/span&gt;&lt;span class='String'&gt;'https!bla.org/baz.js)&lt;/span&gt;

&lt;/pre&gt;
&lt;p&gt;You might have some constraints:&lt;/p&gt;

&lt;ol&gt;
&lt;li&gt;
&lt;p&gt;Long require statements:&lt;/p&gt;

&lt;p&gt;Can be solved in many ways, starting from URL shortening services, finished with a private module registries, similar to &lt;a href='http://microjs.com/' title='Fantastic Micro-Frameworks and Micro-Libraries for Fun and Profit'&gt;MicroJS&lt;/a&gt;.&lt;/p&gt;
&lt;/li&gt;

&lt;li&gt;
&lt;p&gt;Updating require statements more than 1 place:&lt;/p&gt;

&lt;p&gt;Not really an issue with right set of tools like &lt;a href='https://github.com/harthur/replace'&gt;replace&lt;/a&gt; for example, also editors and even &lt;a href='https://github.com/Gozala/graphquire/'&gt;graphquire&lt;/a&gt; might get build-in support for this. In any case that&amp;#8217;s something we will have to face in harmony.&lt;/p&gt;
&lt;/li&gt;

&lt;li&gt;
&lt;p&gt;Content under URL can change:&lt;/p&gt;

&lt;p&gt;This is true, but same can happen in package registries. We just need to make sure to require modules from URLs that are guaranteed to have the same content: modules under version tags, registries, own servers.&lt;/p&gt;
&lt;/li&gt;
&lt;/ol&gt;

&lt;p&gt;Please let me know what you think!&lt;/p&gt;</content>
        </entry>
    
        <entry>
            <title>Addons in multi process future</title>
            <link href="http://www.jeditoolkit.com/2011/06/04/Addons-in-multi-process-future.html" rel="alternate" type="text/html" />
            <updated>2011-06-04T00:00:00-07:00</updated>
            <id>http://www.jeditoolkit.com/2011/06/04/Addons-in-multi-process-future</id>
            <content type="html">&lt;p&gt;The most frequently asked questions on jetpack mailing list concern content scripts. It&amp;#8217;s not obvious for users why these scripts are powerless, why modules don&amp;#8217;t have access to the content&amp;#8217;s dom and why they need to communicate between them by message passing. The short answer is: Mozilla platform is moving towards a model were separate processes are used for chrome, content and add-ons. Therefore SDK modules were designed with &lt;a href='https://wiki.mozilla.org/Electrolysis' title='The Mozilla platform that uses separate processes to display browser UI, web content, and plugins.'&gt;Electrolysis&lt;/a&gt; in mind, to guarantee painless transition to a new model. Much more details about this may be found in the &lt;a href='https://jetpack.mozillalabs.com/sdk/latest/docs/dev-guide/addon-development/web-content.html'&gt;documentation of content scripts&lt;/a&gt;.&lt;/p&gt;

&lt;p&gt;Even though we won&amp;#8217;t ship 1.0 with support for &lt;a href='https://wiki.mozilla.org/Electrolysis' title='The Mozilla platform that uses separate processes to display browser UI, web content, and plugins.'&gt;Electrolysis&lt;/a&gt;, some of us (&lt;a href='https://github.com/toolness/jetpack-e10s' title='Jetpack + Electrolysis Integration Package'&gt;Atul&lt;/a&gt;, &lt;a href='https://github.com/ochameau/jetpack-oop' title='Experimental use of Out-Of-Process capabilities in firefox 4'&gt;Alex&lt;/a&gt; and &lt;a href='https://github.com/Gozala/vats' title='Prototype implementation of vats for Jetpack'&gt;me&lt;/a&gt;) have explored some ideas, but until few month ago I was still unsure we were heading a right path.&lt;/p&gt;

&lt;p&gt;Several month ago I was reading Peter Michaux&amp;#8217;s blog post about &lt;a href='http://peter.michaux.ca/articles/mvc-architecture-for-javascript-applications' title='I really reccomnd to read this'&gt;MVC Architecture for JavaScript Applications&lt;/a&gt; from which I&amp;#8217;d like to quote following description of &amp;#8220;Real MVC&amp;#8221;:&lt;/p&gt;

&lt;blockquote&gt;
&lt;p&gt;&amp;#8220;In a nutshell the classic MVC architecture works like this. There is a model that is at the heart of the whole thing. If the model changes, it notifies its observers that a change occurred. The view is the stuff you can see and the view observes the model. When the view is notified that the model has changed, the view changes its appearance. The user can interact with the view (e.g. clicking stuff) but the view doesn’t know what to do. So the view tells the controller what the user did and assumes the controller knows what to do. The controller appropriately changes the model. And around and around it goes.&amp;#8221;&lt;/p&gt;
&lt;/blockquote&gt;

&lt;p&gt;Even though I&amp;#8217;ve been writing apps with &lt;a href='http://en.wikipedia.org/wiki/Model-view-controller' title='Model View Controller'&gt;MVC&lt;/a&gt; architecture for a while, it never occurred to me to look at jetpack in MVC.&lt;/p&gt;

&lt;h3 id='light_side'&gt;Light side&lt;/h3&gt;

&lt;p&gt;Ironically, most of Add-on SDK APIs provide access to the things that are basically models, associated with a different views of the browser UI (like &lt;a href='https://jetpack.mozillalabs.com/sdk/latest/docs/packages/addon-kit/docs/windows.html' title='Windows module documentation'&gt;windows&lt;/a&gt;, &lt;a href='https://jetpack.mozillalabs.com/sdk/latest/docs/packages/addon-kit/docs/tabs.html' title='Tabs module documentation'&gt;tabs&lt;/a&gt;, &lt;a href='https://jetpack.mozillalabs.com/sdk/latest/docs/packages/addon-kit/docs/widget.html' title='Widget module documentation'&gt;widgets&lt;/a&gt;). Also, low level modules can be seen as controllers of two types:&lt;/p&gt;

&lt;ol&gt;
&lt;li&gt;Model observers that propagate changes to the associated views.&lt;/li&gt;

&lt;li&gt;View observers that update associated models.&lt;/li&gt;
&lt;/ol&gt;

&lt;p&gt;Such perspective also makes whole multi-process architecture switch way more simple. All we need to do is to move models to the other process and make sure that changes on views and models are synchronized via controllers.&lt;/p&gt;

&lt;h3 id='dark_side'&gt;Dark side&lt;/h3&gt;

&lt;p&gt;Unfortunately big part of the code base was not written with such MVC perspective, or in other words we don&amp;#8217;t have a strict separation between models and outlined controller types.&lt;/p&gt;

&lt;h3 id='technical_side'&gt;Technical side&lt;/h3&gt;

&lt;p&gt;This part of the blog is probably too technical to enjoy, unless you plan to hack jetpack itself, so feel free to skip :)&lt;/p&gt;

&lt;p&gt;Overall, everything boils down to few key components:&lt;/p&gt;

&lt;ol&gt;
&lt;li&gt;Pipe for delivering messages across processes, something like &lt;code&gt;port&lt;/code&gt; on our worker objects.&lt;/li&gt;

&lt;li&gt;Models that are serializeable and fully reconstructible via JSON. This is important as models are going to live in add-on processes. Model synchronization logic can be encapsulated in one function that just emits events on the port.&lt;/li&gt;

&lt;li&gt;Controllers observing views, or in other words, event listeners that extract and serialize interesting data from events and emits to the pipe so that models can react.&lt;/li&gt;

&lt;li&gt;Controllers observing model changes, via listeners on the pipe and updating views.&lt;/li&gt;
&lt;/ol&gt;

&lt;p&gt;Outlined strong separation of roles is a good practice anyway, so I tried to stick to it to make transition to E10S easier.&lt;/p&gt;

&lt;ol&gt;
&lt;li&gt;
&lt;p&gt;Models that can be serialized / recreated: &lt;a href='https://github.com/mozilla/addon-sdk/blob/master/packages/addon-kit/lib/hotkeys.js'&gt;hotkey&lt;/a&gt;&lt;/p&gt;
&lt;/li&gt;

&lt;li&gt;
&lt;p&gt;Controllers that emit events on view (Browser UI) changes: &lt;a href='https://github.com/mozilla/addon-sdk/blob/master/packages/api-utils/lib/tabs/observer.js'&gt;tabs/observer&lt;/a&gt;, &lt;a href='https://github.com/mozilla/addon-sdk/blob/master/packages/api-utils/lib/keyboard/observer.js'&gt;keyboard/observer&lt;/a&gt;, &lt;a href='https://github.com/mozilla/addon-sdk/blob/master/packages/api-utils/lib/windows/observer.js'&gt;windows/observer&lt;/a&gt;&lt;/p&gt;
&lt;/li&gt;

&lt;li&gt;
&lt;p&gt;I don&amp;#8217;t have examples of controllers that update views on model changes.&lt;/p&gt;
&lt;/li&gt;
&lt;/ol&gt;

&lt;p&gt;Finally here is a link to &amp;#8220;in progress&amp;#8221; &lt;a href='https://github.com/Gozala/models/blob/master/lib/models.js' title='M form MVC '&gt;implementation of models&lt;/a&gt; that I hope to get into jetpack in a future.&lt;/p&gt;</content>
        </entry>
    
        <entry>
            <title>Yet another take on inheritance</title>
            <link href="http://www.jeditoolkit.com/2011/04/23/Yet-another-take-on-inheritance.html" rel="alternate" type="text/html" />
            <updated>2011-04-23T00:00:00-07:00</updated>
            <id>http://www.jeditoolkit.com/2011/04/23/Yet-another-take-on-inheritance</id>
            <content type="html">&lt;p&gt;Every now and then you need to use inheritance in JavaScript. When you do, you suffer, because there&amp;#8217;s just too many ways to do that and regardless of your choice, syntax noise will make your eyes bleed! Well you may consider saving your eyes by using a library, but this is not going to save you as you&amp;#8217;ll be drown in an ocean of endless choices!&lt;/p&gt;

&lt;p&gt;Choice is good, but when it&amp;#8217;s in manageable quantities. Anyway only reasonable solution is: Yet another new library that does exact same thing in a slightly different fashion.&lt;/p&gt;

&lt;p&gt;That&amp;#8217;s a short story of how &lt;a href='https://github.com/Gozala/extendables'&gt;extendables&lt;/a&gt; micro-library started. It is super minimalistic. Function &lt;code&gt;Extendable&lt;/code&gt; is only thing it exports, which is just like built-in &lt;code&gt;Object&lt;/code&gt;. Only difference is &lt;code&gt;extend&lt;/code&gt; own property that behaves similar to &lt;a href='http://documentcloud.github.com/backbone/'&gt;backbone&lt;/a&gt;&amp;#8217;s &lt;code&gt;Model.extend&lt;/code&gt;.&lt;/p&gt;

&lt;p&gt;&lt;code&gt;Extendable.extend&lt;/code&gt; may be called with an object containing properties that will be defined on the resulting constructor&amp;#8217;s &lt;code&gt;prototype&lt;/code&gt;. Which by the way, will inherit from the target function&amp;#8217;s (function who&amp;#8217;s &lt;code&gt;extend&lt;/code&gt; was called) &lt;code&gt;prototype&lt;/code&gt;. In addition all own properties of a target will be copied to the resulting constructor.&lt;/p&gt;

&lt;p&gt;That&amp;#8217;s actually all of what this library does! In contrast to backbone, library is built with ES5 in mind, which makes it aware of new goodies: non-enumerable, non-writable and non-configurable properties. This also means that it requires ES5 engine to run. But don&amp;#8217;t get broken hearted yet, as you still can use it on IE6 (Please note that you&amp;#8217;ll burn in hell if you do!) and friends, with a help of another micro-lib &lt;a href='https://github.com/kriskowal/es5-shim'&gt;es5-shim&lt;/a&gt;.&lt;/p&gt;

&lt;p&gt;Library is known to work in browsers via AMD loaders, in &lt;a href='https://jetpack.mozillalabs.com/'&gt;jetpack&lt;/a&gt; and in &lt;a href='http://nodejs.org/'&gt;nodejs&lt;/a&gt;. Likely it&amp;#8217;s going to work on any other CommonJS compliant platform as well. Finally here is a &lt;a href='http://jsfiddle.net/gh/gist/jquery/edge/937354/'&gt;jsfiddle&lt;/a&gt; and source &lt;a href='https://gist.github.com/937354'&gt;gist&lt;/a&gt; showing it off with a few examples:&lt;/p&gt;
&lt;pre&gt;
&lt;span class='Comment'&gt;/* vim:set ts=2 sw=2 sts=2 expandtab */&lt;/span&gt;
&lt;span class='Comment'&gt;/*jshint asi: true undef: true es5: true node: true devel: true&lt;/span&gt;
&lt;span class='Comment'&gt;         forin: true latedef: false supernew: true */&lt;/span&gt;
&lt;span class='Comment'&gt;/*global define: true */&lt;/span&gt;


define&lt;span class='Parens'&gt;(&lt;/span&gt;&lt;span class='String'&gt;'demo'&lt;/span&gt;&lt;span class='Operators'&gt;,&lt;/span&gt; &lt;span class='Function'&gt;function&lt;/span&gt;&lt;span class='Parens'&gt;(&lt;/span&gt;&lt;span class='Keyword'&gt;require&lt;/span&gt;&lt;span class='Operators'&gt;,&lt;/span&gt; &lt;span class='Keyword'&gt;exports&lt;/span&gt;&lt;span class='Operators'&gt;,&lt;/span&gt; module&lt;span class='Operators'&gt;,&lt;/span&gt; &lt;span class='Keyword'&gt;undefined&lt;/span&gt;&lt;span class='Parens'&gt;)&lt;/span&gt; &lt;span class='Braces'&gt;{&lt;/span&gt;

&lt;span class='String'&gt;'use strict'&lt;/span&gt;&lt;span class='Operators'&gt;;&lt;/span&gt;

&lt;span class='Identifier'&gt;var&lt;/span&gt; Extendable &lt;span class='Operators'&gt;=&lt;/span&gt; &lt;span class='Keyword'&gt;require&lt;/span&gt;&lt;span class='Parens'&gt;(&lt;/span&gt;&lt;span class='String'&gt;&amp;quot;&lt;a href='https://github.com/Gozala/extendables/raw/v0.1.2/lib/extendables.js'&gt;https://github.com/Gozala/extendables/raw/v0.1.2/lib/extendables.js&lt;/a&gt;&amp;quot;&lt;/span&gt;&lt;span class='Parens'&gt;)&lt;/span&gt;&lt;span class='Operators'&gt;.&lt;/span&gt;Extendable

&lt;span class='Identifier'&gt;var&lt;/span&gt; Base &lt;span class='Operators'&gt;=&lt;/span&gt; Extendable&lt;span class='Operators'&gt;.&lt;/span&gt;extend&lt;span class='Parens'&gt;(&lt;/span&gt;&lt;span class='Braces'&gt;{&lt;/span&gt;
  inherited&lt;span class='Operators'&gt;:&lt;/span&gt; &lt;span class='Function'&gt;function&lt;/span&gt; inherited&lt;span class='Parens'&gt;()&lt;/span&gt; &lt;span class='Braces'&gt;{&lt;/span&gt;
    &lt;span class='Statement'&gt;return&lt;/span&gt; &lt;span class='String'&gt;&amp;quot;inherited property&amp;quot;&lt;/span&gt;
  &lt;span class='Braces'&gt;}&lt;/span&gt;&lt;span class='Operators'&gt;,&lt;/span&gt;
  overridden&lt;span class='Operators'&gt;:&lt;/span&gt; &lt;span class='Function'&gt;function&lt;/span&gt; overridden&lt;span class='Parens'&gt;()&lt;/span&gt; &lt;span class='Braces'&gt;{&lt;/span&gt;
    &lt;span class='Statement'&gt;return&lt;/span&gt; &lt;span class='String'&gt;&amp;quot;property to override&amp;quot;&lt;/span&gt;
  &lt;span class='Braces'&gt;}&lt;/span&gt;&lt;span class='Operators'&gt;,&lt;/span&gt;
  &lt;span class='Comment'&gt;// No supers by default, use prototype and be proud, but if you really want&lt;/span&gt;
  &lt;span class='Comment'&gt;// super get one!&lt;/span&gt;
  _super&lt;span class='Operators'&gt;:&lt;/span&gt; &lt;span class='Function'&gt;function&lt;/span&gt; _super&lt;span class='Parens'&gt;()&lt;/span&gt; &lt;span class='Braces'&gt;{&lt;/span&gt;
    &lt;span class='Statement'&gt;return&lt;/span&gt; &lt;span class='Type'&gt;Object&lt;/span&gt;&lt;span class='Operators'&gt;.&lt;/span&gt;getPrototypeOf&lt;span class='Parens'&gt;(&lt;/span&gt;&lt;span class='Type'&gt;Object&lt;/span&gt;&lt;span class='Operators'&gt;.&lt;/span&gt;getPrototypeOf&lt;span class='Parens'&gt;(&lt;/span&gt;&lt;span class='Keyword'&gt;this&lt;/span&gt;&lt;span class='Parens'&gt;))&lt;/span&gt;
  &lt;span class='Braces'&gt;}&lt;/span&gt;
&lt;span class='Braces'&gt;}&lt;/span&gt;&lt;span class='Parens'&gt;)&lt;/span&gt;
&lt;span class='Comment'&gt;// Adding static method.&lt;/span&gt;
Base&lt;span class='Operators'&gt;.&lt;/span&gt;implement &lt;span class='Operators'&gt;=&lt;/span&gt; &lt;span class='Function'&gt;function&lt;/span&gt; implement&lt;span class='Parens'&gt;(&lt;/span&gt;source&lt;span class='Parens'&gt;)&lt;/span&gt; &lt;span class='Braces'&gt;{&lt;/span&gt;
  &lt;span class='Comment'&gt;// Going through each argument to copy properties from each source.&lt;/span&gt;
  &lt;span class='Type'&gt;Array&lt;/span&gt;&lt;span class='Operators'&gt;.&lt;/span&gt;&lt;span class='Keyword'&gt;prototype&lt;/span&gt;&lt;span class='Operators'&gt;.&lt;/span&gt;forEach&lt;span class='Operators'&gt;.&lt;/span&gt;call&lt;span class='Parens'&gt;(&lt;/span&gt;&lt;span class='Keyword'&gt;arguments&lt;/span&gt;&lt;span class='Operators'&gt;,&lt;/span&gt; &lt;span class='Function'&gt;function&lt;/span&gt;&lt;span class='Parens'&gt;(&lt;/span&gt;source&lt;span class='Parens'&gt;)&lt;/span&gt; &lt;span class='Braces'&gt;{&lt;/span&gt;
    &lt;span class='Comment'&gt;// Going through each own property of the source to copy it.&lt;/span&gt;
    &lt;span class='Type'&gt;Object&lt;/span&gt;&lt;span class='Operators'&gt;.&lt;/span&gt;getOwnPropertyNames&lt;span class='Parens'&gt;(&lt;/span&gt;source&lt;span class='Parens'&gt;)&lt;/span&gt;&lt;span class='Operators'&gt;.&lt;/span&gt;forEach&lt;span class='Parens'&gt;(&lt;/span&gt;&lt;span class='Function'&gt;function&lt;/span&gt;&lt;span class='Parens'&gt;(&lt;/span&gt;key&lt;span class='Parens'&gt;)&lt;/span&gt; &lt;span class='Braces'&gt;{&lt;/span&gt;
      &lt;span class='Comment'&gt;// If property is already owned then skip it.&lt;/span&gt;
      &lt;span class='Statement'&gt;if&lt;/span&gt; &lt;span class='Parens'&gt;(&lt;/span&gt;&lt;span class='Type'&gt;Object&lt;/span&gt;&lt;span class='Operators'&gt;.&lt;/span&gt;&lt;span class='Keyword'&gt;prototype&lt;/span&gt;&lt;span class='Operators'&gt;.&lt;/span&gt;hasOwnProperty&lt;span class='Operators'&gt;.&lt;/span&gt;call&lt;span class='Parens'&gt;(&lt;/span&gt;&lt;span class='Keyword'&gt;this&lt;/span&gt;&lt;span class='Operators'&gt;.&lt;/span&gt;&lt;span class='Keyword'&gt;prototype&lt;/span&gt;&lt;span class='Operators'&gt;,&lt;/span&gt; key&lt;span class='Parens'&gt;))&lt;/span&gt; &lt;span class='Statement'&gt;return&lt;/span&gt; &lt;span class='Keyword'&gt;null&lt;/span&gt;
      &lt;span class='Comment'&gt;// Otherwise define property.&lt;/span&gt;
      &lt;span class='Type'&gt;Object&lt;/span&gt;&lt;span class='Operators'&gt;.&lt;/span&gt;defineProperty&lt;span class='Parens'&gt;(&lt;/span&gt;&lt;span class='Keyword'&gt;this&lt;/span&gt;&lt;span class='Operators'&gt;.&lt;/span&gt;&lt;span class='Keyword'&gt;prototype&lt;/span&gt;&lt;span class='Operators'&gt;,&lt;/span&gt; key&lt;span class='Operators'&gt;,&lt;/span&gt;
                            &lt;span class='Type'&gt;Object&lt;/span&gt;&lt;span class='Operators'&gt;.&lt;/span&gt;getOwnPropertyDescriptor&lt;span class='Parens'&gt;(&lt;/span&gt;source&lt;span class='Operators'&gt;,&lt;/span&gt; key&lt;span class='Parens'&gt;))&lt;/span&gt;
    &lt;span class='Braces'&gt;}&lt;/span&gt;&lt;span class='Operators'&gt;,&lt;/span&gt; &lt;span class='Keyword'&gt;this&lt;/span&gt;&lt;span class='Parens'&gt;)&lt;/span&gt;
  &lt;span class='Braces'&gt;}&lt;/span&gt;&lt;span class='Operators'&gt;,&lt;/span&gt; &lt;span class='Keyword'&gt;this&lt;/span&gt;&lt;span class='Parens'&gt;)&lt;/span&gt;
&lt;span class='Braces'&gt;}&lt;/span&gt;

&lt;span class='Identifier'&gt;var&lt;/span&gt; b1 &lt;span class='Operators'&gt;=&lt;/span&gt; &lt;span class='Operator'&gt;new&lt;/span&gt; Base
&lt;span class='Keyword'&gt;console&lt;/span&gt;&lt;span class='Operators'&gt;.&lt;/span&gt;log&lt;span class='Parens'&gt;(&lt;/span&gt;b1 &lt;span class='Operator'&gt;instanceof&lt;/span&gt; Base&lt;span class='Parens'&gt;)&lt;/span&gt;              &lt;span class='Comment'&gt;// -&amp;gt; true&lt;/span&gt;
&lt;span class='Keyword'&gt;console&lt;/span&gt;&lt;span class='Operators'&gt;.&lt;/span&gt;log&lt;span class='Parens'&gt;(&lt;/span&gt;b1 &lt;span class='Operator'&gt;instanceof&lt;/span&gt; Extendable&lt;span class='Parens'&gt;)&lt;/span&gt;        &lt;span class='Comment'&gt;// -&amp;gt; true&lt;/span&gt;
&lt;span class='Keyword'&gt;console&lt;/span&gt;&lt;span class='Operators'&gt;.&lt;/span&gt;log&lt;span class='Parens'&gt;(&lt;/span&gt;b1&lt;span class='Operators'&gt;.&lt;/span&gt;inherited&lt;span class='Parens'&gt;())&lt;/span&gt;                  &lt;span class='Comment'&gt;// -&amp;gt; &amp;quot;inherited property&amp;quot;&lt;/span&gt;

&lt;span class='Identifier'&gt;var&lt;/span&gt; b2 &lt;span class='Operators'&gt;=&lt;/span&gt; Base&lt;span class='Parens'&gt;()&lt;/span&gt;                             &lt;span class='Comment'&gt;// -&amp;gt; Works same as without `new`&lt;/span&gt;
&lt;span class='Keyword'&gt;console&lt;/span&gt;&lt;span class='Operators'&gt;.&lt;/span&gt;log&lt;span class='Parens'&gt;(&lt;/span&gt;b2 &lt;span class='Operator'&gt;instanceof&lt;/span&gt; Base&lt;span class='Parens'&gt;)&lt;/span&gt;             &lt;span class='Comment'&gt;// -&amp;gt; true&lt;/span&gt;
&lt;span class='Keyword'&gt;console&lt;/span&gt;&lt;span class='Operators'&gt;.&lt;/span&gt;log&lt;span class='Parens'&gt;(&lt;/span&gt;b2 &lt;span class='Operator'&gt;instanceof&lt;/span&gt; Extendable&lt;span class='Parens'&gt;)&lt;/span&gt;       &lt;span class='Comment'&gt;// -&amp;gt; true&lt;/span&gt;
&lt;span class='Keyword'&gt;console&lt;/span&gt;&lt;span class='Operators'&gt;.&lt;/span&gt;log&lt;span class='Parens'&gt;(&lt;/span&gt;b2&lt;span class='Operators'&gt;.&lt;/span&gt;inherited&lt;span class='Parens'&gt;())&lt;/span&gt;                 &lt;span class='Comment'&gt;// -&amp;gt; &amp;quot;inherited property&amp;quot;&lt;/span&gt;


&lt;span class='Identifier'&gt;var&lt;/span&gt; Decedent &lt;span class='Operators'&gt;=&lt;/span&gt; Base&lt;span class='Operators'&gt;.&lt;/span&gt;extend&lt;span class='Parens'&gt;(&lt;/span&gt;&lt;span class='Braces'&gt;{&lt;/span&gt;
  &lt;span class='Keyword'&gt;constructor&lt;/span&gt;&lt;span class='Operators'&gt;:&lt;/span&gt; &lt;span class='Function'&gt;function&lt;/span&gt; Decedent&lt;span class='Parens'&gt;(&lt;/span&gt;options&lt;span class='Parens'&gt;)&lt;/span&gt; &lt;span class='Braces'&gt;{&lt;/span&gt;
    &lt;span class='Keyword'&gt;this&lt;/span&gt;&lt;span class='Operators'&gt;.&lt;/span&gt;name &lt;span class='Operators'&gt;=&lt;/span&gt; options&lt;span class='Operators'&gt;.&lt;/span&gt;name&lt;span class='Operators'&gt;;&lt;/span&gt;
  &lt;span class='Braces'&gt;}&lt;/span&gt;&lt;span class='Operators'&gt;,&lt;/span&gt;
  overridden&lt;span class='Operators'&gt;:&lt;/span&gt; &lt;span class='Function'&gt;function&lt;/span&gt; override&lt;span class='Parens'&gt;()&lt;/span&gt; &lt;span class='Braces'&gt;{&lt;/span&gt;
    &lt;span class='Comment'&gt;// I'd rather copied `overridden` with a diff name overriddenBase for&lt;/span&gt;
    &lt;span class='Comment'&gt;// example or used `Base.prototype.overridden.call(this)`&lt;/span&gt;
    &lt;span class='Comment'&gt;// But this works as well :)&lt;/span&gt;
    &lt;span class='Statement'&gt;return&lt;/span&gt; &lt;span class='String'&gt;&amp;quot;No longer &amp;quot;&lt;/span&gt; &lt;span class='Operators'&gt;+&lt;/span&gt; &lt;span class='Keyword'&gt;this&lt;/span&gt;&lt;span class='Operators'&gt;.&lt;/span&gt;_super&lt;span class='Parens'&gt;()&lt;/span&gt;&lt;span class='Operators'&gt;.&lt;/span&gt;overridden&lt;span class='Operators'&gt;.&lt;/span&gt;call&lt;span class='Parens'&gt;(&lt;/span&gt;&lt;span class='Keyword'&gt;this&lt;/span&gt;&lt;span class='Parens'&gt;)&lt;/span&gt;
  &lt;span class='Braces'&gt;}&lt;/span&gt;&lt;span class='Operators'&gt;,&lt;/span&gt;
  &lt;span class='Comment'&gt;// overriddenBase: Base.prototype.overridden&lt;/span&gt;
&lt;span class='Braces'&gt;}&lt;/span&gt;&lt;span class='Parens'&gt;)&lt;/span&gt;
Decedent&lt;span class='Operators'&gt;.&lt;/span&gt;implement&lt;span class='Parens'&gt;(&lt;/span&gt;&lt;span class='Braces'&gt;{&lt;/span&gt;
  bye&lt;span class='Operators'&gt;:&lt;/span&gt; &lt;span class='Function'&gt;function&lt;/span&gt; bye&lt;span class='Parens'&gt;()&lt;/span&gt; &lt;span class='Braces'&gt;{&lt;/span&gt;
    &lt;span class='Statement'&gt;return&lt;/span&gt; &lt;span class='String'&gt;&amp;quot;Buy my dear &amp;quot;&lt;/span&gt; &lt;span class='Operators'&gt;+&lt;/span&gt; &lt;span class='Keyword'&gt;this&lt;/span&gt;&lt;span class='Operators'&gt;.&lt;/span&gt;name
  &lt;span class='Braces'&gt;}&lt;/span&gt;
&lt;span class='Braces'&gt;}&lt;/span&gt;&lt;span class='Parens'&gt;)&lt;/span&gt;

&lt;span class='Identifier'&gt;var&lt;/span&gt; d1 &lt;span class='Operators'&gt;=&lt;/span&gt; &lt;span class='Operator'&gt;new&lt;/span&gt; Decedent&lt;span class='Parens'&gt;(&lt;/span&gt;&lt;span class='Braces'&gt;{&lt;/span&gt; name&lt;span class='Operators'&gt;:&lt;/span&gt; &lt;span class='String'&gt;&amp;quot;friend&amp;quot;&lt;/span&gt; &lt;span class='Braces'&gt;}&lt;/span&gt;&lt;span class='Parens'&gt;)&lt;/span&gt;
&lt;span class='Keyword'&gt;console&lt;/span&gt;&lt;span class='Operators'&gt;.&lt;/span&gt;log&lt;span class='Parens'&gt;(&lt;/span&gt;d1 &lt;span class='Operator'&gt;instanceof&lt;/span&gt; Decedent&lt;span class='Parens'&gt;)&lt;/span&gt;       &lt;span class='Comment'&gt;// -&amp;gt; true&lt;/span&gt;
&lt;span class='Keyword'&gt;console&lt;/span&gt;&lt;span class='Operators'&gt;.&lt;/span&gt;log&lt;span class='Parens'&gt;(&lt;/span&gt;d1 &lt;span class='Operator'&gt;instanceof&lt;/span&gt; Base&lt;span class='Parens'&gt;)&lt;/span&gt;           &lt;span class='Comment'&gt;// -&amp;gt; true&lt;/span&gt;
&lt;span class='Keyword'&gt;console&lt;/span&gt;&lt;span class='Operators'&gt;.&lt;/span&gt;log&lt;span class='Parens'&gt;(&lt;/span&gt;d1 &lt;span class='Operator'&gt;instanceof&lt;/span&gt; Extendable&lt;span class='Parens'&gt;)&lt;/span&gt;     &lt;span class='Comment'&gt;// -&amp;gt; true&lt;/span&gt;
&lt;span class='Keyword'&gt;console&lt;/span&gt;&lt;span class='Operators'&gt;.&lt;/span&gt;log&lt;span class='Parens'&gt;(&lt;/span&gt;d1&lt;span class='Operators'&gt;.&lt;/span&gt;inherited&lt;span class='Parens'&gt;())&lt;/span&gt;               &lt;span class='Comment'&gt;// -&amp;gt; &amp;quot;inherited property&amp;quot;&lt;/span&gt;
&lt;span class='Keyword'&gt;console&lt;/span&gt;&lt;span class='Operators'&gt;.&lt;/span&gt;log&lt;span class='Parens'&gt;(&lt;/span&gt;d1&lt;span class='Operators'&gt;.&lt;/span&gt;overridden&lt;span class='Parens'&gt;())&lt;/span&gt;              &lt;span class='Comment'&gt;// -&amp;gt; No longer a property to override&lt;/span&gt;
&lt;span class='Keyword'&gt;console&lt;/span&gt;&lt;span class='Operators'&gt;.&lt;/span&gt;log&lt;span class='Parens'&gt;(&lt;/span&gt;d1&lt;span class='Operators'&gt;.&lt;/span&gt;bye&lt;span class='Parens'&gt;())&lt;/span&gt;                     &lt;span class='Comment'&gt;// -&amp;gt; &amp;quot;Bye my dear friend&amp;quot;&lt;/span&gt;

&lt;span class='Braces'&gt;}&lt;/span&gt;&lt;span class='Parens'&gt;)&lt;/span&gt;
&lt;span class='Keyword'&gt;require&lt;/span&gt;&lt;span class='Operators'&gt;.&lt;/span&gt;main&lt;span class='Parens'&gt;(&lt;/span&gt;&lt;span class='String'&gt;&amp;quot;demo&amp;quot;&lt;/span&gt;&lt;span class='Parens'&gt;)&lt;/span&gt;
&lt;/pre&gt;
&lt;p&gt;Finally, if you are a &lt;a href='http://jashkenas.github.com/coffee-script/'&gt;coffee&lt;/a&gt; fan like me, you&amp;#8217;ll love the fact that regular coffee class syntax may be used to extend &lt;code&gt;Extendable&lt;/code&gt; and it&amp;#8217;s decedents. Also all coffee classes that extend &lt;code&gt;Extendable&lt;/code&gt; can be extended further from javascript.&lt;/p&gt;</content>
        </entry>
    
        <entry>
            <title>Shareable private properties</title>
            <link href="http://www.jeditoolkit.com/2011/04/11/shareable-private-properties.html" rel="alternate" type="text/html" />
            <updated>2011-04-11T00:00:00-07:00</updated>
            <id>http://www.jeditoolkit.com/2011/04/11/shareable-private-properties</id>
            <content type="html">&lt;p&gt;In JavaScript it is not possible to create properties that have limited or controlled accessibility. It is possible to create non-enumerable and non-writable properties, but still they can be discovered and accessed. Usually so called &amp;#8220;closure capturing&amp;#8221; pattern is used to encapsulate such properties in lexical scope:&lt;/p&gt;
&lt;script src='https://gist.github.com/915169.js?file=closure-capturing.js'&gt;
function Base(options) {
  var _secret = options.secret
  this.hello = function hello() {
    return 'Hello ' + _secret
  }
}

function Decedent(options) {
  var _secret = options.secret
  Base.call(this, options)
  this.bye = function bye() {
    return 'Bye ' + _secret
  }
  this.boom = function boom() {
    _secret = 'boom !'
  }
}
Decedent.prototype = Object.create(Base.prototype)
&lt;/script&gt;
&lt;p&gt;Unfortunately given approach does not works very well with OO inheritance:&lt;/p&gt;

&lt;ol&gt;
&lt;li&gt;Code readability degrades and some code duplication becomes necessary.&lt;br /&gt;&lt;em&gt;(See firs lines of &lt;code&gt;Base&lt;/code&gt; and &lt;code&gt;Decedent&lt;/code&gt; constructors)&lt;/em&gt;.&lt;/li&gt;

&lt;li&gt;Prototypes do not contain any properties and there for each instance gets it&amp;#8217;s own fresh copy of them.&lt;br /&gt;&lt;em&gt;(Not very good for performance)&lt;/em&gt;.&lt;/li&gt;

&lt;li&gt;Own and inherited methods access different copies of private properties and there for changes do not propagate.&lt;br /&gt;&lt;em&gt;(&lt;code&gt;boom&lt;/code&gt; method of &lt;code&gt;Decedent&lt;/code&gt; illustrates the issue).&lt;/em&gt;&lt;/li&gt;

&lt;li&gt;Access to a private properties can not be shared with a limited group.&lt;/li&gt;
&lt;/ol&gt;

&lt;p&gt;I believe because of these reasons &amp;#8221;&lt;code&gt;-&lt;/code&gt;&amp;#8221; prefix was established as a &amp;#8220;de facto&amp;#8221; standard for private property names. Unfortunately it&amp;#8217;s just a coding style that does not implies any property access restrictions.&lt;/p&gt;

&lt;p&gt;In Jetpack we&amp;#8217;ve explored &lt;a href='https://jetpack.mozillalabs.com/sdk/1.0b4/docs/packages/api-utils/docs/cortex.html'&gt;different techniques&lt;/a&gt; to overcome issues mentioned above, but property access sharing to the limited groups of consumers remained painful and unobvious.&lt;/p&gt;

&lt;p&gt;Recently I got an &lt;a href='https://github.com/mozilla/addon-sdk/blob/fe8f35933c5f71b3fdc698e6768d9e51e6b5ad4e/packages/addon-kit/lib/context-menu.js#L342-348'&gt;interesting idea&lt;/a&gt; inspired by &lt;a href='http://wiki.ecmascript.org/doku.php?id=strawman:private_names'&gt;private names proposal&lt;/a&gt; for ECMAScript &lt;em&gt;(I recommend to reading &lt;a href='http://www.wirfs-brock.com/allen/posts/32'&gt;Allen Wirfs blog post&lt;/a&gt; explaining details of the proposal)&lt;/em&gt;. Here is an illustration of the idea with a same example:&lt;/p&gt;
&lt;script src='https://gist.github.com/915169.js?file=idea.js'&gt;
var KEY = {};   // key for accessing private properties.

function Base(options) {
  // Defining all the private properties on the local object.
  var privates = { secret: options.secret }
  // Override `Object.prototype.valueOf` to share access to the private
  // properties with a limited group of consumers who has an access to the
  // `KEY`.
  this.valueOf = function valueOf(key) {
    // If consumer has a right `key` we give access to our private properties,
    // otherwise we fall back to a default behaviour.
    return key === KEY ? privates : Object.prototype.valueOf.call(this)
  }
}
Base.prototype.hello = function hello() {
  return 'Hello ' + this.valueOf(KEY).secret
}

function Decedent(options) {
  Base.call(this, options)
}
Decedent.prototype = Object.create(Base.prototype)
Decedent.prototype.bye = function bye() {
  return 'Bye ' + this.valueOf(KEY).secret
}
Decedent.prototype.boom = function boom() {
  this.valueOf(KEY).secret = 'boom !'
}
&lt;/script&gt;
&lt;p&gt;Please note that this solves all the issues outlined. Also access to the privates can be shared with any group, just by giving them a &lt;code&gt;KEY&lt;/code&gt;. After tinkering with this idea for some time, I&amp;#8217;m happy to announce birth of &lt;a href='https://github.com/Gozala/namespace'&gt;namespace&lt;/a&gt; micro-library. Below you can see same example, but this time coded as a commonjs module and using mentioned library:&lt;/p&gt;
&lt;script src='https://gist.github.com/915169.js?file=fiddle.js'&gt;
define('demo', function(require, exports, module, undefined) {

'use strict'

// importing library.
var Namespace = require('http://jeditoolkit.com/namespace/lib/namespace.js').Namespace
// Creating namespace for private properties.
var _ = new Namespace

function Base(options) {
  _(this).secret = options.secret
}
Base.prototype.hello = function hello() {
  return 'Hello ' + _(this).secret
}

function Decedent(options) {
  Base.call(this, options)
}
Decedent.prototype = Object.create(Base.prototype)
Decedent.prototype.bye = function bye() {
  return 'Bye ' + _(this).secret
}
Decedent.prototype.boom = function boom() {
  _(this).secret = 'boom !'
}

var base = new Base({ secret: 'Father' })

alert(base.secret)      // -&gt; undefined
alert(base.hello())     // -&gt; 'Hello Father'

var decedent = new Decedent({ secret: 'Yoda' })

alert(decedent.hello())   // -&gt; 'Hello Yoda'
alert(decedent.bye())     // -&gt; 'Bye Yoda'
decedent.boom();

alert(decedent.hello())   // -&gt; 'Hello boom !'
alert(decedent.bye())     // -&gt; 'Bye boom !'

})

// Loading module &quot;demo&quot;
require.main(&quot;demo&quot;)
&lt;/script&gt;
&lt;p&gt;Library not only wraps outlined idea into a nice API, but also allows provides a way to use multiple namespaces with the same object.&lt;/p&gt;

&lt;p&gt;Finally here is a &lt;a href='http://jsfiddle.net/gh/gist/jquery/edge/915169/'&gt;jsfiddle link&lt;/a&gt; containing this example if you wan to play with it. Of course comments / feedback / ideas is more then welcome!&lt;/p&gt;</content>
        </entry>
    
        <entry>
            <title>Evolving VS Adjusting</title>
            <link href="http://www.jeditoolkit.com/2010/10/20/evolving-VS-adjusting.html" rel="alternate" type="text/html" />
            <updated>2010-10-20T00:00:00-07:00</updated>
            <id>http://www.jeditoolkit.com/2010/10/20/evolving-VS-adjusting</id>
            <content type="html">&lt;p&gt;We often have to make the choice between adjusting to conditions or paying a price for improving them. Usually it is safer to adjust, but still we have to be very careful we don&amp;#8217;t miss an opportunity to improve. Probably the best way to do that is to compare the price and improvements.&lt;/p&gt;

&lt;p&gt;&lt;a href='http://wiki.commonjs.org/wiki/Modules/AsynchronousDefinition'&gt;Asynchronous Module Definition&lt;/a&gt; is one of the hottest topics on the &lt;a href='http://www.commonjs.org/'&gt;CommonJS&lt;/a&gt; &lt;a href='http://groups.google.com/group/commonjs' title='CommonJS mailing list'&gt;mailing list&lt;/a&gt; this days. Unfortunately my impression is that most of the participants of these debates forget to measure price VS improvement and this can be harmful.&lt;/p&gt;

&lt;p&gt;I believe there are two sides:&lt;/p&gt;

&lt;ol&gt;
&lt;li&gt;People that believe that &lt;a href='http://wiki.commonjs.org/wiki/Modules/1.0' title='Modules/1.0 - CommonJS Spec'&gt;CommonJS modules&lt;/a&gt; are not well suited for in-browser usage (suggesting an alternative, &amp;#8220;browser friendly&amp;#8221; syntax).&lt;/li&gt;

&lt;li&gt;People who believe that &lt;a href='http://wiki.commonjs.org/wiki/Modules/1.0' title='Modules/1.0 - CommonJS Spec'&gt;CommonJS modules&lt;/a&gt; are perfectly usable within browser without any changes.&lt;/li&gt;
&lt;/ol&gt;

&lt;p&gt;I&amp;#8217;m one among few others who uses CommonJS modules both on the server and in the browser already. With that in mind it&amp;#8217;s not easy to convince me, that change in well established standard is absolutely necessary.&lt;/p&gt;

&lt;h3 id='issues_with_current_modules'&gt;Issues with current modules&lt;/h3&gt;

&lt;p&gt;There were many arguments why current modules are not suited for in-browser usage, but unfortunately I did not manage to convince enough people to make a list of them, so I will summarise them as: &amp;#8220;Non of the existing module loading techniques provides perfect debugging experience across the different browsers without involvement of a server component or a building step.&amp;#8221;&lt;/p&gt;

&lt;h3 id='different_view_on_these_issues'&gt;Different view on these issues&lt;/h3&gt;

&lt;ul&gt;
&lt;li&gt;Debugging story is not that bad actually (much better than it used to be not a long time ago), but it&amp;#8217;s true, rarely, but still strange issues occur. In any case those are bugs in debuggers not with a modules. Only way to fix bugs is by report them. I&amp;#8217;m pretty confident that &lt;a href='http://getfirebug.com/'&gt;firebug&lt;/a&gt; team is going to make their best, to make debugging experience as good as possible. I also hope that it&amp;#8217;s true for a web inspector.&lt;/li&gt;

&lt;li&gt;Dismissing a server as a show stopper is also inadequate IMO, since there are few other things like &lt;a href='http://www.w3.org/TR/offline-webapps/#offline'&gt;Offline Application Caching&lt;/a&gt; that would still depend on it and won&amp;#8217;t work without. And in the end it just matter of running one simple command before starting development. For instance to hack on jetpack you need to run &lt;code&gt;source bin/activate&lt;/code&gt; and I believe it was show stopper for anyone.&lt;/li&gt;
&lt;/ul&gt;

&lt;h3 id='issues_with_proposed_changes'&gt;Issues with proposed changes&lt;/h3&gt;

&lt;p&gt;Proposed changes are not perfect either:&lt;/p&gt;

&lt;ul&gt;
&lt;li&gt;
&lt;p&gt;Some people will argue against this statement, but there is nothing in common between proposed &lt;a href='http://wiki.commonjs.org/wiki/Modules/AsynchronousDefinition'&gt;Asynchronous Module Definition&lt;/a&gt; and existing &lt;a href='http://wiki.commonjs.org/wiki/Modules/1.0' title='Modules/1.0 - CommonJS Spec'&gt;module&lt;/a&gt; specs other then the CommonJS label. This will be a source of confusion and community fragmentation.&lt;/p&gt;

&lt;p&gt;Below you can find a simple module being rewritten according to two different specs:&lt;/p&gt;

&lt;p&gt;Asynchronous definition:&lt;/p&gt;
&lt;script src='http://gist.github.com/636422.js?file=asincdefinition.js'&gt;
     define(&quot;foo&quot;, [&quot;bar&quot;], function (bar) {
         return {
           doAnotherThing: function() {
             return bar.doSomething() + 2;
           }
         };
     });
&lt;/script&gt;
&lt;p&gt;CommonJS module:&lt;/p&gt;
&lt;script src='http://gist.github.com/636422.js?file=commonjs-module.js'&gt;
     var bar = require(&quot;bar&quot;);
     exports.doAnotherThing = function() {
       return bar.doSomething() + 2;
     }
&lt;/script&gt;&lt;/li&gt;

&lt;li&gt;
&lt;p&gt;Asynchronous definition seem to encourage handwritten boilerplate but what is puzzling here is, why would any programmer prefer writing a boilerplate code by hand over writing a program that would do that for him. Yes it&amp;#8217;s nice to refresh browser and be ready to go without any build step, but nothing prevents us form writing programs that support this workflow.&lt;/p&gt;
&lt;/li&gt;

&lt;li&gt;
&lt;p&gt;A most important issue is that the new proposal suggests to adjust to the unpleasant situation browser are in now, and what is even worse, it brings this mess to the server. Adjustment to broken tooling is only going to delay innovation! I truly believe that if we had had such a big adoption of CommonJS modules a few years ago, we would have perfect debugging story today (well maybe not in all browsers :). I also think that wide adoption of CommonJS modules already triggered some innovation and partially that is the reason why we might get native modules in harmony. And you know what ? Once we&amp;#8217;ll get them, no magic will happen, as it did not happened when Web Workers arrived. It will take some time to get a decent tooling support. Again it should not stop innovation by trying to adjust new amazing platforms to the mess we are at with browsers.&lt;/p&gt;
&lt;/li&gt;
&lt;/ul&gt;

&lt;h3 id='evolving'&gt;Evolving&lt;/h3&gt;

&lt;p&gt;I think that the only sane thing to do now is to bring the innovation that happens in server side javascript back to the browser without compromising anything. With that in mind I&amp;#8217;m planning to put a lot of effort in &lt;span&gt;teleport&lt;/span&gt;, a tool that I wrote some time ago. It allowed few projects to share CommonJS modules across server and client. I don&amp;#8217;t believe there is any perfect solution to all problems, but each problem has a solution and I hope that &lt;span&gt;teleport&lt;/span&gt; will be a set of solutions addressing CommonJS module loading problems. The &lt;a href='http://github.com/Gozala/teleport/issues'&gt;list of tasks&lt;/a&gt; I&amp;#8217;ll be working on, is probably the best way to get a better idea what is it all about. Feel free to fork me, suggest new ideas or just comment here.&lt;/p&gt;</content>
        </entry>
    
        <entry>
            <title>oh my zsh</title>
            <link href="http://www.jeditoolkit.com/2010/10/09/oh-my-zsh.html" rel="alternate" type="text/html" />
            <updated>2010-10-09T00:00:00-07:00</updated>
            <id>http://www.jeditoolkit.com/2010/10/09/oh-my-zsh</id>
            <content type="html">&lt;p&gt;I have been thinking about switching to the &lt;a href='http://www.zsh.org/'&gt;zsh&lt;/a&gt; shell for some time, mainly because I was missing &lt;a href='http://www.vim.org/'&gt;vim&lt;/a&gt; environment in the console. About a month ago I&amp;#8217;ve decided to switch. Quickly enough I got tired of tweaking my &lt;code&gt;.zshrc&lt;/code&gt;, I was about to give up when I discovered very nice project called &lt;a href='http://github.com/robbyrussell/oh-my-zsh'&gt;oh my zsh&lt;/a&gt;.&lt;/p&gt;

&lt;p&gt;A community-driven framework for managing zsh configuration proved to be very nice. At the end of the day I ended up with a new theme and improved git plugin.&lt;/p&gt;

&lt;p&gt;&lt;img src='/resources/images/zsh-git-status.png' alt='status' /&gt;&lt;/p&gt;

&lt;p&gt;As you can see there is bunch of small icons on the right side that&amp;#8217;s a visualisation of the git working tree:&lt;/p&gt;

&lt;pre&gt;&lt;code&gt;✭  Displayed if there are modifications.  
✈  Displayed if there are staged changes.  
✗  Displayed if there are deleted files.  
➦  Displayed if there are moved files.  
⚑  Displayed if there are untracked files.  
⚡  Displayed if there is a merge conflict.  &lt;/code&gt;&lt;/pre&gt;

&lt;p&gt;Hope you&amp;#8217;re excited and considering to try out zsh. If that&amp;#8217;s a case I&amp;#8217;ll definitely recommend to try out &lt;a href='http://github.com/robbyrussell/oh-my-zsh'&gt;oh my zsh&lt;/a&gt;. There is already made &lt;a href='http://github.com/robbyrussell/oh-my-zsh/pull/100'&gt;pull request&lt;/a&gt; with my new theme &lt;strong&gt;gozilla&lt;/strong&gt; and get plugin improvements. If you cant wait you can pull changes directly form my &lt;a href='http://github.com/Gozala/oh-my-zsh/tree/gozilla'&gt;fork&lt;/a&gt;.&lt;/p&gt;</content>
        </entry>
    
        <entry>
            <title>Git status in bash prompt</title>
            <link href="http://www.jeditoolkit.com/2010/09/04/git-status-in-bash-prompt.html" rel="alternate" type="text/html" />
            <updated>2010-09-04T00:00:00-07:00</updated>
            <id>http://www.jeditoolkit.com/2010/09/04/git-status-in-bash-prompt</id>
            <content type="html">&lt;p&gt;There are a lot of blog posts describing techniques of putting your current git branch in your bash prompt. After reading one of those posts more then year ago I immediately edited my &lt;code&gt;~/.bash_profile&lt;/code&gt; and was very happy until very recent, when I have started using &lt;code&gt;--color&lt;/code&gt; argument with git commands. Surprisingly to me colors made me so much more effective that I quickly tweaked my git config: &lt;code&gt;git config --global color.ui auto&lt;/code&gt; This allowed my to have colors everywhere by default. Shortly after I got an idea that colors in prompt may be used for displaying a status of the working tree / index.&lt;/p&gt;

&lt;p&gt;&lt;strong&gt;Motivation&lt;/strong&gt;&lt;/p&gt;

&lt;p&gt;I really wanted to try that idea out, because I thought it was a chance to solve a problem that bugged me for years already. I was looking for a way to remind myself to commit more often, since I tempt to commit only after I&amp;#8217;m done with a task and it&amp;#8217;s hard to imagine how many times I regretted that!!&lt;/p&gt;

&lt;p&gt;&lt;strong&gt;Design&lt;/strong&gt;&lt;/p&gt;

&lt;p&gt;So my plan was to display &amp;#8220;current git branch&amp;#8221; in a bash prompt in a different color depending on a state of the working tree / index:&lt;/p&gt;
&lt;ul&gt;
  &lt;li style='color:#8998DD'&gt;No changes&lt;/li&gt;
  &lt;li style='color:#6EA4D0'&gt;Untracked files&lt;/li&gt;
  &lt;li style='color:#74A77C'&gt;Stashed changes&lt;/li&gt;
  &lt;li style='color:#53ADA0'&gt;Modified files&lt;/li&gt;
  &lt;li style='color:#DA7865'&gt;Deleted files&lt;/li&gt;
&lt;/ul&gt;
&lt;p&gt;&lt;strong&gt;Implementation&lt;/strong&gt;&lt;/p&gt;

&lt;p&gt;I wont bother you with a details on how to get a &amp;#8220;current git branch&amp;#8221; since there are lots of posts about it, instead I&amp;#8217;ll focus your attention on snippet that parses git status and adds colors:&lt;/p&gt;
&lt;script src='http://gist.github.com/564751.js'&gt;
&lt;pre&gt;&lt;div class='line' id='LC1'&gt;&lt;span class='nv'&gt;txtblk&lt;/span&gt;&lt;span class='o'&gt;=&lt;/span&gt;&lt;span class='s1'&gt;'\033[0;30m'&lt;/span&gt; &lt;span class='c'&gt;# Black - Regular&lt;/span&gt;&lt;/div&gt;&lt;div class='line' id='LC2'&gt;&lt;span class='nv'&gt;txtred&lt;/span&gt;&lt;span class='o'&gt;=&lt;/span&gt;&lt;span class='s1'&gt;'\033[0;31m'&lt;/span&gt; &lt;span class='c'&gt;# Red&lt;/span&gt;&lt;/div&gt;&lt;div class='line' id='LC3'&gt;&lt;span class='nv'&gt;txtgrn&lt;/span&gt;&lt;span class='o'&gt;=&lt;/span&gt;&lt;span class='s1'&gt;'\033[0;32m'&lt;/span&gt; &lt;span class='c'&gt;# Green&lt;/span&gt;&lt;/div&gt;&lt;div class='line' id='LC4'&gt;&lt;span class='nv'&gt;txtylw&lt;/span&gt;&lt;span class='o'&gt;=&lt;/span&gt;&lt;span class='s1'&gt;'\033[0;33m'&lt;/span&gt; &lt;span class='c'&gt;# Yellow&lt;/span&gt;&lt;/div&gt;&lt;div class='line' id='LC5'&gt;&lt;span class='nv'&gt;txtblu&lt;/span&gt;&lt;span class='o'&gt;=&lt;/span&gt;&lt;span class='s1'&gt;'\033[0;34m'&lt;/span&gt; &lt;span class='c'&gt;# Blue&lt;/span&gt;&lt;/div&gt;&lt;div class='line' id='LC6'&gt;&lt;span class='nv'&gt;txtpur&lt;/span&gt;&lt;span class='o'&gt;=&lt;/span&gt;&lt;span class='s1'&gt;'\033[0;35m'&lt;/span&gt; &lt;span class='c'&gt;# Purple&lt;/span&gt;&lt;/div&gt;&lt;div class='line' id='LC7'&gt;&lt;span class='nv'&gt;txtcyn&lt;/span&gt;&lt;span class='o'&gt;=&lt;/span&gt;&lt;span class='s1'&gt;'\033[0;36m'&lt;/span&gt; &lt;span class='c'&gt;# Cyan&lt;/span&gt;&lt;/div&gt;&lt;div class='line' id='LC8'&gt;&lt;span class='nv'&gt;txtwht&lt;/span&gt;&lt;span class='o'&gt;=&lt;/span&gt;&lt;span class='s1'&gt;'\033[0;37m'&lt;/span&gt; &lt;span class='c'&gt;# White&lt;/span&gt;&lt;/div&gt;&lt;div class='line' id='LC9'&gt;&lt;span class='nv'&gt;bldblk&lt;/span&gt;&lt;span class='o'&gt;=&lt;/span&gt;&lt;span class='s1'&gt;'\033[1;30m'&lt;/span&gt; &lt;span class='c'&gt;# Black - Bold&lt;/span&gt;&lt;/div&gt;&lt;div class='line' id='LC10'&gt;&lt;span class='nv'&gt;bldred&lt;/span&gt;&lt;span class='o'&gt;=&lt;/span&gt;&lt;span class='s1'&gt;'\033[1;31m'&lt;/span&gt; &lt;span class='c'&gt;# Red&lt;/span&gt;&lt;/div&gt;&lt;div class='line' id='LC11'&gt;&lt;span class='nv'&gt;bldgrn&lt;/span&gt;&lt;span class='o'&gt;=&lt;/span&gt;&lt;span class='s1'&gt;'\033[1;32m'&lt;/span&gt; &lt;span class='c'&gt;# Green&lt;/span&gt;&lt;/div&gt;&lt;div class='line' id='LC12'&gt;&lt;span class='nv'&gt;bldylw&lt;/span&gt;&lt;span class='o'&gt;=&lt;/span&gt;&lt;span class='s1'&gt;'\033[1;33m'&lt;/span&gt; &lt;span class='c'&gt;# Yellow&lt;/span&gt;&lt;/div&gt;&lt;div class='line' id='LC13'&gt;&lt;span class='nv'&gt;bldblu&lt;/span&gt;&lt;span class='o'&gt;=&lt;/span&gt;&lt;span class='s1'&gt;'\033[1;34m'&lt;/span&gt; &lt;span class='c'&gt;# Blue&lt;/span&gt;&lt;/div&gt;&lt;div class='line' id='LC14'&gt;&lt;span class='nv'&gt;bldpur&lt;/span&gt;&lt;span class='o'&gt;=&lt;/span&gt;&lt;span class='s1'&gt;'\033[1;35m'&lt;/span&gt; &lt;span class='c'&gt;# Purple&lt;/span&gt;&lt;/div&gt;&lt;div class='line' id='LC15'&gt;&lt;span class='nv'&gt;bldcyn&lt;/span&gt;&lt;span class='o'&gt;=&lt;/span&gt;&lt;span class='s1'&gt;'\033[1;36m'&lt;/span&gt; &lt;span class='c'&gt;# Cyan&lt;/span&gt;&lt;/div&gt;&lt;div class='line' id='LC16'&gt;&lt;span class='nv'&gt;bldwht&lt;/span&gt;&lt;span class='o'&gt;=&lt;/span&gt;&lt;span class='s1'&gt;'\033[1;37m'&lt;/span&gt; &lt;span class='c'&gt;# White&lt;/span&gt;&lt;/div&gt;&lt;div class='line' id='LC17'&gt;&lt;span class='nv'&gt;unkblk&lt;/span&gt;&lt;span class='o'&gt;=&lt;/span&gt;&lt;span class='s1'&gt;'\033[4;30m'&lt;/span&gt; &lt;span class='c'&gt;# Black - Underline&lt;/span&gt;&lt;/div&gt;&lt;div class='line' id='LC18'&gt;&lt;span class='nv'&gt;undred&lt;/span&gt;&lt;span class='o'&gt;=&lt;/span&gt;&lt;span class='s1'&gt;'\033[4;31m'&lt;/span&gt; &lt;span class='c'&gt;# Red&lt;/span&gt;&lt;/div&gt;&lt;div class='line' id='LC19'&gt;&lt;span class='nv'&gt;undgrn&lt;/span&gt;&lt;span class='o'&gt;=&lt;/span&gt;&lt;span class='s1'&gt;'\033[4;32m'&lt;/span&gt; &lt;span class='c'&gt;# Green&lt;/span&gt;&lt;/div&gt;&lt;div class='line' id='LC20'&gt;&lt;span class='nv'&gt;undylw&lt;/span&gt;&lt;span class='o'&gt;=&lt;/span&gt;&lt;span class='s1'&gt;'\033[4;33m'&lt;/span&gt; &lt;span class='c'&gt;# Yellow&lt;/span&gt;&lt;/div&gt;&lt;div class='line' id='LC21'&gt;&lt;span class='nv'&gt;undblu&lt;/span&gt;&lt;span class='o'&gt;=&lt;/span&gt;&lt;span class='s1'&gt;'\033[4;34m'&lt;/span&gt; &lt;span class='c'&gt;# Blue&lt;/span&gt;&lt;/div&gt;&lt;div class='line' id='LC22'&gt;&lt;span class='nv'&gt;undpur&lt;/span&gt;&lt;span class='o'&gt;=&lt;/span&gt;&lt;span class='s1'&gt;'\033[4;35m'&lt;/span&gt; &lt;span class='c'&gt;# Purple&lt;/span&gt;&lt;/div&gt;&lt;div class='line' id='LC23'&gt;&lt;span class='nv'&gt;undcyn&lt;/span&gt;&lt;span class='o'&gt;=&lt;/span&gt;&lt;span class='s1'&gt;'\033[4;36m'&lt;/span&gt; &lt;span class='c'&gt;# Cyan&lt;/span&gt;&lt;/div&gt;&lt;div class='line' id='LC24'&gt;&lt;span class='nv'&gt;undwht&lt;/span&gt;&lt;span class='o'&gt;=&lt;/span&gt;&lt;span class='s1'&gt;'\033[4;37m'&lt;/span&gt; &lt;span class='c'&gt;# White&lt;/span&gt;&lt;/div&gt;&lt;div class='line' id='LC25'&gt;&lt;span class='nv'&gt;bakblk&lt;/span&gt;&lt;span class='o'&gt;=&lt;/span&gt;&lt;span class='s1'&gt;'\033[40m'&lt;/span&gt;   &lt;span class='c'&gt;# Black - Background&lt;/span&gt;&lt;/div&gt;&lt;div class='line' id='LC26'&gt;&lt;span class='nv'&gt;bakred&lt;/span&gt;&lt;span class='o'&gt;=&lt;/span&gt;&lt;span class='s1'&gt;'\033[41m'&lt;/span&gt;   &lt;span class='c'&gt;# Red&lt;/span&gt;&lt;/div&gt;&lt;div class='line' id='LC27'&gt;&lt;span class='nv'&gt;badgrn&lt;/span&gt;&lt;span class='o'&gt;=&lt;/span&gt;&lt;span class='s1'&gt;'\033[42m'&lt;/span&gt;   &lt;span class='c'&gt;# Green&lt;/span&gt;&lt;/div&gt;&lt;div class='line' id='LC28'&gt;&lt;span class='nv'&gt;bakylw&lt;/span&gt;&lt;span class='o'&gt;=&lt;/span&gt;&lt;span class='s1'&gt;'\033[43m'&lt;/span&gt;   &lt;span class='c'&gt;# Yellow&lt;/span&gt;&lt;/div&gt;&lt;div class='line' id='LC29'&gt;&lt;span class='nv'&gt;bakblu&lt;/span&gt;&lt;span class='o'&gt;=&lt;/span&gt;&lt;span class='s1'&gt;'\033[44m'&lt;/span&gt;   &lt;span class='c'&gt;# Blue&lt;/span&gt;&lt;/div&gt;&lt;div class='line' id='LC30'&gt;&lt;span class='nv'&gt;bakpur&lt;/span&gt;&lt;span class='o'&gt;=&lt;/span&gt;&lt;span class='s1'&gt;'\033[45m'&lt;/span&gt;   &lt;span class='c'&gt;# Purple&lt;/span&gt;&lt;/div&gt;&lt;div class='line' id='LC31'&gt;&lt;span class='nv'&gt;bakcyn&lt;/span&gt;&lt;span class='o'&gt;=&lt;/span&gt;&lt;span class='s1'&gt;'\033[46m'&lt;/span&gt;   &lt;span class='c'&gt;# Cyan&lt;/span&gt;&lt;/div&gt;&lt;div class='line' id='LC32'&gt;&lt;span class='nv'&gt;bakwht&lt;/span&gt;&lt;span class='o'&gt;=&lt;/span&gt;&lt;span class='s1'&gt;'\033[47m'&lt;/span&gt;   &lt;span class='c'&gt;# White&lt;/span&gt;&lt;/div&gt;&lt;div class='line' id='LC33'&gt;&lt;span class='nv'&gt;txtrst&lt;/span&gt;&lt;span class='o'&gt;=&lt;/span&gt;&lt;span class='s1'&gt;'\033[m'&lt;/span&gt;   &lt;span class='c'&gt;# Text Reset&lt;/span&gt;&lt;/div&gt;&lt;div class='line' id='LC34'&gt;&lt;br /&gt;&lt;/div&gt;&lt;div class='line' id='LC35'&gt;__vcs_status&lt;span class='o'&gt;()&lt;/span&gt; &lt;span class='o'&gt;{&lt;/span&gt;&lt;/div&gt;&lt;div class='line' id='LC36'&gt;&amp;nbsp;&amp;nbsp;&lt;span class='k'&gt;if &lt;/span&gt;&lt;span class='nb'&gt;type&lt;/span&gt; -p __git_ps1; &lt;span class='k'&gt;then&lt;/span&gt;&lt;/div&gt;&lt;div class='line' id='LC37'&gt;&lt;span class='k'&gt;    &lt;/span&gt;&lt;span class='nv'&gt;branch&lt;/span&gt;&lt;span class='o'&gt;=&lt;/span&gt;&lt;span class='k'&gt;$(&lt;/span&gt;__git_ps1&lt;span class='k'&gt;)&lt;/span&gt;&lt;/div&gt;&lt;div class='line' id='LC38'&gt;&amp;nbsp;&amp;nbsp;&lt;span class='k'&gt;else&lt;/span&gt;&lt;/div&gt;&lt;div class='line' id='LC39'&gt;&lt;span class='k'&gt;    &lt;/span&gt;&lt;span class='nv'&gt;branch&lt;/span&gt;&lt;span class='o'&gt;=&lt;/span&gt;&lt;span class='k'&gt;$(&lt;/span&gt;git branch --no-color 2&amp;gt; /dev/null | sed -e &lt;span class='s1'&gt;'/^[^*]/d'&lt;/span&gt; -e &lt;span class='s1'&gt;'s/* \(.*\)/(\1)/'&lt;/span&gt;&lt;span class='k'&gt;)&lt;/span&gt;&lt;/div&gt;&lt;div class='line' id='LC40'&gt;&amp;nbsp;&amp;nbsp;&lt;span class='k'&gt;fi&lt;/span&gt;&lt;/div&gt;&lt;div class='line' id='LC41'&gt;&lt;span class='k'&gt;  if&lt;/span&gt; &lt;span class='o'&gt;[&lt;/span&gt; &lt;span class='nv'&gt;$branch&lt;/span&gt; &lt;span class='o'&gt;]&lt;/span&gt;; &lt;span class='k'&gt;then&lt;/span&gt;&lt;/div&gt;&lt;div class='line' id='LC42'&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&lt;span class='c'&gt;# not updated&lt;/span&gt;&lt;/div&gt;&lt;div class='line' id='LC43'&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&lt;span class='nv'&gt;color&lt;/span&gt;&lt;span class='o'&gt;=&lt;/span&gt;&lt;span class='s2'&gt;&quot;${txtpur}&quot;&lt;/span&gt;&lt;/div&gt;&lt;div class='line' id='LC44'&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&lt;span class='nv'&gt;status&lt;/span&gt;&lt;span class='o'&gt;=&lt;/span&gt;&lt;span class='k'&gt;$(&lt;/span&gt;git status --porcelain 2&amp;gt; /dev/null&lt;span class='k'&gt;)&lt;/span&gt;&lt;/div&gt;&lt;div class='line' id='LC45'&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&lt;span class='c'&gt;# if we have non untracked files (blue)&lt;/span&gt;&lt;/div&gt;&lt;div class='line' id='LC46'&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&lt;span class='k'&gt;if&lt;/span&gt; &lt;span class='k'&gt;$(&lt;/span&gt;&lt;span class='nb'&gt;echo&lt;/span&gt; &lt;span class='s2'&gt;&quot;$status&quot;&lt;/span&gt; | grep &lt;span class='s1'&gt;'?? '&lt;/span&gt; &amp;amp;&amp;gt; /dev/null&lt;span class='k'&gt;)&lt;/span&gt;; &lt;span class='k'&gt;then&lt;/span&gt;&lt;/div&gt;&lt;div class='line' id='LC47'&gt;&lt;span class='k'&gt;      &lt;/span&gt;&lt;span class='nv'&gt;color&lt;/span&gt;&lt;span class='o'&gt;=&lt;/span&gt;&lt;span class='s2'&gt;&quot;${txtblu}&quot;&lt;/span&gt;&lt;/div&gt;&lt;div class='line' id='LC48'&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&lt;span class='k'&gt;fi&lt;/span&gt;&lt;/div&gt;&lt;div class='line' id='LC49'&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&lt;span class='c'&gt;#  added to index (green)&lt;/span&gt;&lt;/div&gt;&lt;div class='line' id='LC50'&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&lt;span class='k'&gt;if&lt;/span&gt; &lt;span class='k'&gt;$(&lt;/span&gt;&lt;span class='nb'&gt;echo&lt;/span&gt; &lt;span class='s2'&gt;&quot;$status&quot;&lt;/span&gt; | grep &lt;span class='s1'&gt;'^A  '&lt;/span&gt; &amp;amp;&amp;gt; /dev/null&lt;span class='k'&gt;)&lt;/span&gt;; &lt;span class='k'&gt;then&lt;/span&gt;&lt;/div&gt;&lt;div class='line' id='LC51'&gt;&lt;span class='k'&gt;      &lt;/span&gt;&lt;span class='nv'&gt;color&lt;/span&gt;&lt;span class='o'&gt;=&lt;/span&gt;&lt;span class='s2'&gt;&quot;${txtgrn}&quot;&lt;/span&gt;&lt;/div&gt;&lt;div class='line' id='LC52'&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&lt;span class='k'&gt;fi&lt;/span&gt;&lt;/div&gt;&lt;div class='line' id='LC53'&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&lt;span class='c'&gt;# updated in index (Cyan)&lt;/span&gt;&lt;/div&gt;&lt;div class='line' id='LC54'&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&lt;span class='k'&gt;if&lt;/span&gt; &lt;span class='k'&gt;$(&lt;/span&gt;&lt;span class='nb'&gt;echo&lt;/span&gt; &lt;span class='s2'&gt;&quot;$status&quot;&lt;/span&gt; | grep &lt;span class='s1'&gt;'^ M '&lt;/span&gt; &amp;amp;&amp;gt; /dev/null&lt;span class='k'&gt;)&lt;/span&gt;; &lt;span class='k'&gt;then&lt;/span&gt;&lt;/div&gt;&lt;div class='line' id='LC55'&gt;&lt;span class='k'&gt;      &lt;/span&gt;&lt;span class='nv'&gt;color&lt;/span&gt;&lt;span class='o'&gt;=&lt;/span&gt;&lt;span class='s2'&gt;&quot;${txtcyn}&quot;&lt;/span&gt;&lt;/div&gt;&lt;div class='line' id='LC56'&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&lt;span class='k'&gt;fi&lt;/span&gt;&lt;/div&gt;&lt;div class='line' id='LC57'&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&lt;span class='c'&gt;#  deleted from index (red)&lt;/span&gt;&lt;/div&gt;&lt;div class='line' id='LC58'&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&lt;span class='k'&gt;if&lt;/span&gt; &lt;span class='k'&gt;$(&lt;/span&gt;&lt;span class='nb'&gt;echo&lt;/span&gt; &lt;span class='s2'&gt;&quot;$status&quot;&lt;/span&gt; | grep &lt;span class='s1'&gt;'^ D '&lt;/span&gt; &amp;amp;&amp;gt; /dev/null&lt;span class='k'&gt;)&lt;/span&gt;; &lt;span class='k'&gt;then&lt;/span&gt;&lt;/div&gt;&lt;div class='line' id='LC59'&gt;&lt;span class='k'&gt;      &lt;/span&gt;&lt;span class='nv'&gt;color&lt;/span&gt;&lt;span class='o'&gt;=&lt;/span&gt;&lt;span class='s2'&gt;&quot;${txtred}&quot;&lt;/span&gt;&lt;/div&gt;&lt;div class='line' id='LC60'&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&lt;span class='k'&gt;fi&lt;/span&gt;&lt;/div&gt;&lt;div class='line' id='LC61'&gt;&lt;span class='k'&gt;    &lt;/span&gt;&lt;span class='nb'&gt;echo&lt;/span&gt; -e &lt;span class='nv'&gt;$color&lt;/span&gt;&lt;/div&gt;&lt;div class='line' id='LC62'&gt;&amp;nbsp;&amp;nbsp;&lt;span class='k'&gt;fi&lt;/span&gt;&lt;/div&gt;&lt;div class='line' id='LC63'&gt;&lt;span class='o'&gt;}&lt;/span&gt;&lt;/div&gt;&lt;div class='line' id='LC64'&gt;&lt;br /&gt;&lt;/div&gt;&lt;/pre&gt;
&lt;/script&gt;
&lt;p&gt;I am not that good at bash and I would be more then happy to hear your your suggestions how to make implementation smaller or faster. Any other suggestions or comments are also very welcome.&lt;/p&gt;

&lt;p&gt;Finally if you want to see full implementation check out my &lt;a href='http://github.com/Gozala/.bash' title='git repo with my bash config'&gt;git repo&lt;/a&gt;.&lt;/p&gt;</content>
        </entry>
    
        <entry>
            <title>CommonJS based Github library</title>
            <link href="http://www.jeditoolkit.com/2010/05/28/CommonJS-github-library.html" rel="alternate" type="text/html" />
            <updated>2010-05-28T00:00:00-07:00</updated>
            <id>http://www.jeditoolkit.com/2010/05/28/CommonJS-github-library</id>
            <content type="html">&lt;p&gt;This post is about &lt;a href='http://wiki.commonjs.org/wiki/Packages/' title='Cohesive wrapping of a collection of modules, code and other assets into a single form'&gt;CommonJS Package&lt;/a&gt;, a library, allowing consumers to list, read, write, delete &amp;amp; comment private / public gists. Library employs v2 &amp;amp; v1 Github API&amp;#8217;s in combination with some dirty hacks to make this possible.&lt;/p&gt;

&lt;p&gt;Main target platform is a browser, but it can run on any other platform that will provide implementation of XMLHttpRequests. Since browsers have many limitations in comparison to other platforms this idea was a challenge form a beginning. The first thing and probably something you already have in mind is &lt;a href='http://en.wikipedia.org/wiki/Same_origin_policy'&gt;same origin policy&lt;/a&gt;. Luckily all modern browsers today implement &lt;a href='http://www.w3.org/' title='The World Wide Web Consortium'&gt;W3C&lt;/a&gt; standard for &lt;a href='http://www.w3.org/TR/cors/'&gt;cross-origin resource sharing&lt;/a&gt;. Unfortunately though, only a few websites employ this technique and reply client with &lt;code&gt;Access-Control-Allow-Origin&lt;/code&gt; headers. Believe me or not, &lt;a href='https://github.com/' title='Popular web-based hosting service for projects that use the Git revision control system'&gt;Github&lt;/a&gt; is not one of those!! Actually &lt;a href='http://support.github.com/discussions/gist/148-gist-api'&gt;convincing them&lt;/a&gt; to start useing this standard was not as easy either&amp;#8230;&lt;/p&gt;

&lt;p&gt;I did not want to give up, so I have decide to implement this library anyway with accompany of two proof of concept experiments demoed in previous posts. I really hope this way I&amp;#8217;ll get enough attention from Github folks and they will see a value of improved browser friendly Gist API&amp;#8217;s :)&lt;/p&gt;

&lt;p&gt;As you could&amp;#8217;ve guessed I found a workaround, actually not, I&amp;#8217;ll better call it an elegant solution :) Anyway solution to this problem was &lt;a href='http://developer.yahoo.com/yql/' title='Yahoo Query Language'&gt;YQL&lt;/a&gt;. If you don&amp;#8217;t know yet, it&amp;#8217;s a very cool service from &lt;a href='http://www.yahoo.com/'&gt;Yahoo&lt;/a&gt; and likely easiest way to make &lt;a href='http://en.wikipedia.org/wiki/Representational_State_Transfer' title='RESTful web services'&gt;rest&lt;/a&gt; services + all in JavaScript, you should definitely check it out!! After some hacking I&amp;#8217;ve managed to put together several &lt;a href='http://github.com/Gozala/github/tree/gh-pages/resources/'&gt;&amp;#8220;YQL Open Data Tables&amp;#8221;&lt;/a&gt; with an access to data that can&amp;#8217;t be retrieved with a current Github API&amp;#8217;s. Most importantly allowing users to select and insert &lt;strong&gt;private&lt;/strong&gt; gists. Since &lt;a href='http://developer.yahoo.com/yql/' title='Yahoo Query Language'&gt;YQL&lt;/a&gt; puts &lt;code&gt;Access-Control-Allow-Origin&lt;/code&gt; headers, same origin policy problem was solved, as a side effect it also allowed some optimizations by moving several operations from client to server.&lt;/p&gt;

&lt;p&gt;Unfortunately it&amp;#8217;s not the end of the story neither it was end of the issues I had to run into. After a while I discovered that firefox sends &lt;code&gt;HTTP OPTONS&lt;/code&gt; request, before sending desired &lt;code&gt;HTTP POST&lt;/code&gt; on which &lt;a href='http://developer.yahoo.com/yql/' title='Yahoo Query Language'&gt;YQL&lt;/a&gt; replies without necessary &lt;code&gt;Access-Control-Allow-Origin&lt;/code&gt; header. With &lt;code&gt;HTTP GET&lt;/code&gt; everything is fine since &lt;code&gt;HTTP OPTIONS&lt;/code&gt; are not send in that case. Other browsers don&amp;#8217;t have issues nor with &lt;code&gt;GET&lt;/code&gt; nor with &lt;code&gt;POST&lt;/code&gt; since they don&amp;#8217;t seem to send &lt;code&gt;HTTP OPTIONS&lt;/code&gt;. I have reported about this &lt;a href='http://developer.yahoo.net/forum/?showtopic=5199'&gt;issue&lt;/a&gt; to &lt;a href='http://developer.yahoo.com/yql/' title='Yahoo Query Language'&gt;YQL&lt;/a&gt; folks and they were super fast with picking it up, they plan to have a fix in for a next release, which I hope will be anytime soon.&lt;/p&gt;

&lt;p&gt;After all the efforts &lt;a href='http://github.com/Gozala/github/' title='CommonJS library for accessing GitHub API'&gt;github library&lt;/a&gt; is ready to be forked!! So please give it a try and lets make some amazing stuff to show Github folks that,&lt;/p&gt;

&lt;h3 id='we_need_a_better_gist_apis'&gt;we need a better Gist API&amp;#8217;s!!&lt;/h3&gt;</content>
        </entry>
    
        <entry>
            <title>Taskhub</title>
            <link href="http://www.jeditoolkit.com/2010/05/05/Taskhub.html" rel="alternate" type="text/html" />
            <updated>2010-05-05T00:00:00-07:00</updated>
            <id>http://www.jeditoolkit.com/2010/05/05/Taskhub</id>
            <content type="html">&lt;p&gt;Majority of web applications today are data owners. Yes, even if data is mine, it&amp;#8217;s still owned by application, since all the ways to interact with it go through application. In some cases application kindly allows to export and import data, sometimes even delete or access it with other applications, but the point is, that somehow it is always between me, my tooling and my data. For example I just can&amp;#8217;t simply move my social activity data access privileges from Facebook to MySpace or vise versa.&lt;/p&gt;

&lt;p&gt;Still not sure weather this is fundamentally wrong or just can be better. One way or another, &lt;a href='http://gozala.github.com/taskhub/' title='Prototype of a backend-less HTML5 based application, build on top of CommonJS packages'&gt;Taskhub&lt;/a&gt; is an experiment, trying to make it differently. With &lt;a href='http://gozala.github.com/taskhub/' title='Prototype of a backend-less HTML5 based application, build on top of CommonJS packages'&gt;Taskhub&lt;/a&gt; I am an owner of my data and application itself is just a tool of my choice to interact with my data. To achieve this, &lt;a href='http://gozala.github.com/taskhub/' title='Prototype of a backend-less HTML5 based application, build on top of CommonJS packages'&gt;Taskhub&lt;/a&gt; takes &lt;a href='http://github.com/mojombo/jekyll/' title='Blog-aware, static site generator in Ruby'&gt;Jekyll&lt;/a&gt; like approach and saves tasks as &lt;a href='http://daringfireball.net/projects/markdown/' title='A plain text formatting syntax'&gt;Markdown&lt;/a&gt; formatted, plain text &lt;span&gt;gist&lt;/span&gt;s. This way application respects my freedom of choice by allowing me to switch to any alternative task manager at any moment, making switch as painless as it can get, just stop using it. And if I&amp;#8217;ll decide to switch back, &lt;a href='http://gozala.github.com/taskhub/' title='Prototype of a backend-less HTML5 based application, build on top of CommonJS packages'&gt;Taskhub&lt;/a&gt; will just work. Think in summary, data is just mine and it should not bound me to any application. One can say here that it&amp;#8217;s bounded to &lt;a href='http://github.com/' title='Web-based hosting service for projects that use the Git revision control system'&gt;github&lt;/a&gt;, but it&amp;#8217;s not true, because &lt;a href='http://github.com/' title='Web-based hosting service for projects that use the Git revision control system'&gt;github&lt;/a&gt; in this case is just wire that connects my data to the cloud. In ideal world we will have &amp;#8220;Data Clouds&amp;#8221;, virtual hard drives with standard data access APIs. Users will buy them to store their data, just like they do with hard drives today.&lt;/p&gt;

&lt;p&gt;For the moment &lt;a href='http://gozala.github.com/taskhub/' title='Prototype of a backend-less HTML5 based application, build on top of CommonJS packages'&gt;Taskhub&lt;/a&gt; is just a geek toy, but I hope to see it&amp;#8217;s decedents, being more useful to a regular users, one way of doing this is through adding support of saving data in less geeky storage, for example saving data to files in &lt;span&gt;Dropbox&lt;/span&gt;, will make a trick, besides it&amp;#8217;s a step towards &amp;#8220;Data Clouds&amp;#8221;.&lt;/p&gt;

&lt;p&gt;I&amp;#8217;m not in illusions that, high performance will be easy to achieve with this model, but I do believe in smart people :).&lt;/p&gt;

&lt;h3 id='under_the_hood'&gt;Under the hood&lt;/h3&gt;

&lt;ul&gt;
&lt;li&gt;
&lt;p&gt;HTML5 &lt;a href='http://www.w3.org/TR/offline-webapps/' title='HTML 5 contains several features that address the challenge of building Web applications that work while offline'&gt;Offline web applications&lt;/a&gt;&lt;br /&gt;As I mentioned high performance with this model is not easy. To reach acceptable performance application uses HTML5 localStorage for a live data, that concurrently gets synchronized with a gist storage. HTML5 offline application caching APIs are used to make it possible to run application while being offline. All the data is synchronized once user goes back online. So far there is no conflict resolutions, because of limited gist APIs, so browser always gets priority, which leads to a funny results when used with multiple clients. Fixing this is on my taskhub list, so stay tuned.&lt;/p&gt;
&lt;/li&gt;

&lt;li&gt;
&lt;p&gt;&lt;a href='http://commonjs.org/' title='JavaScript ecosystem for web servers, desktop, command line, and browser'&gt;CommonJS&lt;/a&gt;&lt;br /&gt;Application is build on top of &lt;a href='http://commonjs.org/' title='JavaScript ecosystem for web servers, desktop, command line, and browser'&gt;CommonJS&lt;/a&gt;. It uses &lt;a href='#' title='Actually
one of the first browser based CommonJS module loaders'&gt;yet another&lt;/a&gt; CommonJS module loader &lt;a href='http://github.com/Gozala/teleport/' title='CommonJS module loader for browsers'&gt;Teleport&lt;/a&gt;, which asynchronously delivers modules from mapped &lt;a href='http://wiki.commonjs.org/wiki/Packages/' title='Cohesive wrapping of a collection of modules, code and other assets into a single form'&gt;CommonJS package&lt;/a&gt;s. One of the main components / packages is &lt;span&gt;github library&lt;/span&gt; allowing to list, read and write gists straight from a browser and I&amp;#8217;ll be posting details about it in the next post.&lt;/p&gt;
&lt;/li&gt;

&lt;li&gt;
&lt;p&gt;Backendless&lt;br /&gt;One of the interesting moments of architecture is in it&amp;#8217;s selfhostness. That makes it possible to run app from any server, it even can be dropped to &lt;span&gt;dropbox&lt;/span&gt; or can be used directly from local filesystem.&lt;/p&gt;
&lt;/li&gt;
&lt;/ul&gt;

&lt;h3 id='demo'&gt;Demo&lt;/h3&gt;
&lt;object height='345' classid='clsid:d27cdb6e-ae6d-11cf-96b8-444553540000' codebase='http://download.macromedia.com/pub/shockwave/cabs/flash/swflash.cab#version=9,0,115,0' width='560'&gt;
	&lt;param name='movie' value='http://screenr.com/Content/assets/screenr_1116090935.swf' /&gt;
	&lt;param name='flashvars' value='i=67685' /&gt;
	&lt;param name='allowFullScreen' value='true' /&gt;
	&lt;embed src='http://screenr.com/Content/assets/screenr_1116090935.swf' allowFullScreen='true' pluginspage='http://www.macromedia.com/go/getflashplayer' height='345' flashvars='i=67685' width='560'&gt;
	&lt;/embed&gt;
&lt;/object&gt;</content>
        </entry>
    
</feed>
