<?xml version="1.0" encoding="utf-8"?>
<rss version="2.0">
<channel>
    <title>Brian Cray&rsquo;s Blog</title>
    <link>http://icanhaza.com/</link>
    <description>Web Development, Design, and Optimization</description>
    <lastBuildDate>Wed, 9 May 2012 13:53:09 -0400</lastBuildDate>
    <language>en-us</language>
    
        <item>
            <title>An analogy to sell design iteration</title>
            <link>/posts/an-analogy-to-sell-design-iteration</link>
            <guid>/posts/an-analogy-to-sell-design-iteration</guid>
            <pubDate>Mon, 9 Apr 2012 08:54:00 -0400</pubDate>
            <description>&lt;p&gt;The beautiful thing about a car is that it&#39;s an amazingly complex system that can be controlled with just a steering wheel and two peddles. Sure, race car drivers have many more controls at their disposal, but they&#39;re advanced users. Let&#39;s help our users learn to drive before we teach them to be race care drivers.&lt;/p&gt;</description>
        </item>
    
        <item>
            <title>Javascript module pattern: When to use it and why</title>
            <link>/posts/javascript-module-pattern</link>
            <guid>/posts/javascript-module-pattern</guid>
            <pubDate>Thu, 23 Feb 2012 07:14:00 -0500</pubDate>
            <description>&lt;p&gt;There have been a few criticisms of the javascript module pattern, despite its many advantages. Take for example &lt;a href=&quot;http://snook.ca/archives/javascript/no-love-for-module-pattern&quot;&gt;Jonathon Snook&#39;s &amp;ldquo;Why I don&#39;t like javascript&#39;s module pattern&amp;rdquo;&lt;/a&gt;. While everyone has their own style, my fear is that people, given Snook&#39;s demanding presence, will take his word for gospel without understanding it.&lt;/p&gt;

&lt;p&gt;This article isn&#39;t about teaching you the pattern, but more about when to use it and why&amp;mdash;though I&#39;ll start with a brief example of the pattern to get us all on the same page.&lt;/p&gt;

&lt;h3&gt;A brief example in my favored flavor&lt;/h3&gt;

&lt;pre class=&quot;javascript&quot;&gt;
var module = (function () {
    // private variables and functions
    var foo = &#39;bar&#39;;

    // constructor
    var module = function () {
    };

    // prototype
    module.prototype = {
        constructor: module,
        something: function () {
        }
    };

    // return module
    return module;
})();

var my_module = new module();
&lt;/pre&gt;

&lt;p&gt;This appears to be a lot of unnecessary code at first glance, but each line is plays a key role in making the module pattern advantageous.&lt;/p&gt;

&lt;h3&gt;The when &amp;amp; why&lt;/h3&gt;

&lt;ul&gt;
&lt;li&gt;&lt;p&gt;&lt;strong&gt;Scalable.&lt;/strong&gt; Modules are isolated pieces of code that when well designed, work independently of other modules and therefore can be removed and added as necessary.&lt;/p&gt;&lt;/li&gt;
&lt;li&gt;&lt;p&gt;&lt;strong&gt;Team-ready.&lt;/strong&gt; Building a large-scale javascript application is simpler with the module pattern. Each developer on a team can be assigned a set of modules to develop and can work in parallel with minimal conflicts. Additionally, everyone can write in their own preferred style within the context of the pattern without preferences getting in the way of progress.&lt;/p&gt;&lt;/li&gt;

&lt;li&gt;&lt;p&gt;&lt;strong&gt;Localized.&lt;/strong&gt; Anonymous wrappers automatically create a new &quot;namespace&quot; for the whole module. This has performance advantages in garbage collection and scope chain walking. Furthermore, variables can be passed into the anonymous wrapper to localize commonly accessed global variables, such as &lt;code&gt;window&lt;/code&gt;, &lt;code&gt;document&lt;/code&gt;, and &lt;code&gt;jQuery&lt;/code&gt;, like so:&lt;/p&gt;

&lt;pre class=&quot;javascript&quot;&gt;
var module = (function (window, document, $) {
    // module stuff
})(window, document, jQuery);
&lt;/pre&gt;&lt;/li&gt;

&lt;li&gt;&lt;p&gt;&lt;strong&gt;Cross-instantiation private variables.&lt;/strong&gt; Normally when you instantiate an object with something like &lt;code&gt;new module()&lt;/code&gt;, a whole new clean object is created&amp;ndash;and that&#39;s still the case. But the private variables will retain their values across instantiations.&lt;/p&gt;&lt;/li&gt;
&lt;li&gt;&lt;p&gt;&lt;strong&gt;Extensible.&lt;/strong&gt; Want to dynamically add additional methods to a module? No problem.&lt;/p&gt;

&lt;pre class=&quot;javascript&quot;&gt;
// extend it with something_else();
var module = (function (module) {
    module.prototype.something_else = function () {
    };
    return module;
})(module);
&lt;/pre&gt;

&lt;p&gt;With a few changes this same pattern can be used to &quot;subclass&quot; an existing module.&lt;/p&gt;&lt;/li&gt;

&lt;li&gt;&lt;p&gt;&lt;strong&gt;Deferrable.&lt;/strong&gt; Another advantage of its isolation and containment is that you can inject it on demand without worrying about its impact on other modules. Using the following code, for example:

&lt;pre class=&quot;javascript&quot;&gt;
function inject_module (module_file) {
    var h = document.getElementsByTagName(&#39;head&#39;)[0];
    var s = document.createElement(&#39;script&#39;);
    s.type = &#39;text/javascript&#39;;
    s.src = module_file;
    h.appendChild(s);
};
&lt;/pre&gt;
&lt;/li&gt;

&lt;h3&gt;Bonus: Tips for well-designed modules&lt;/h3&gt;

&lt;ul&gt;
&lt;li&gt;Don&#39;t make modules explicitly depend on each other. Everything each module needs to work should be confined into either the module or plugins that are shared among modules.&lt;/li&gt;
&lt;li&gt;Have modules communicate to each other through event subscriptions, not through direct calls to each other. They call this a pubsub. If you&amp;rsquo;re using jQuery, check out &lt;a href=&quot;https://gist.github.com/661855&quot;&gt;jQuery Tiny Pub/Sub&lt;/a&gt;. If not, &lt;a href=&quot;http://addyosmani.com/resources/essentialjsdesignpatterns/book/#observerpatternjavascript&quot;&gt;here&amp;rsquo;s a good vanilla pubsub.&lt;/a&gt;&lt;/li&gt;
&lt;li&gt;Create a light integration layer that handles module injection and interaction.&lt;/lI&gt;
&lt;/ul&gt;

&lt;h3&gt;Conclusion&lt;/h3&gt;

&lt;p&gt;The javascript module pattern has many benefits through isolation and localization. They shouldn&#39;t be written off until you&#39;ve given due thought into the design of your application and your team. I&#39;m currently in the process of writing a large-scale javascript application based on this pattern, and I have to say, it&amp;rsquo;s a delight.&lt;/p&gt;</description>
        </item>
    
        <item>
            <title>Finding success as a web developer</title>
            <link>/posts/finding-success-as-a-web-developer</link>
            <guid>/posts/finding-success-as-a-web-developer</guid>
            <pubDate>Thu, 19 May 2011 10:42:00 -0400</pubDate>
            <description>&lt;p&gt;Let me start by setting the record straight. &lt;strong&gt;I&#39;m not going to tell you how to build a huge successful startup&lt;/strong&gt; because I haven&#39;t done it myself. But I &lt;em&gt;have&lt;/em&gt; made a small name for myself, &lt;a href=&quot;/portfolio/&quot;&gt;created a few minor successes&lt;/a&gt;, and hacked away a good path to follow (pun intended).&lt;/p&gt;

&lt;p&gt;Finding success as a web developer means finding happiness and fulfillment&amp;mdash;holistically just as much as monetarily. I&#39;ll do my best to help you find your way. And hopefully, your next successful interview. So how should you start?&lt;/p&gt;

&lt;h3&gt;Build &lt;em&gt;something&lt;/em&gt;, then do it again&lt;/h3&gt;

&lt;p&gt;I&#39;ve been interviewing a lot of developers for &lt;a href=&quot;http://topsy.com/&quot;&gt;Topsy&lt;/a&gt;. It&#39;s amazing how many candidates don&#39;t have a portfolio. After all, making something that people can publicly use is often their primary job description. I can tell you right now, the developer who has a portfolio is more likely to get a call than the one who doesn&#39;t. Simple as that.&lt;/p&gt;

&lt;p&gt;If you&#39;re lacking ideas, pay attention to your daily work routine. When you find yourself thinking &quot;This could be better&quot; or &quot;I wish I had ______,&quot; you have your idea. An idea derived from this insight is likely a good one. Necessity is the mother of invention.&lt;/p&gt;

&lt;p&gt;Do you have a good idea but you&#39;re holding back for the right moment? &lt;strong&gt;Don&#39;t wait for the right idea at the right time.&lt;/strong&gt; Nobody is smart enough to solve that equation. Hell, who&#39;d have thought that a photo taking app, Color, &lt;a href=&quot;http://www.zdnet.com/blog/foremski/color-a-fascinating-41m-startup-with-an-app-that-tests-social-mores/1713&quot;&gt;would raise $41 mil&lt;/a&gt;? WTF. Stop thinking and start executing. &lt;a href=&quot;http://www.paulgraham.com/startupmistakes.html&quot;&gt;One of the biggest mistakes you can make is waiting too long&lt;/a&gt;.&lt;/p&gt;

&lt;p&gt;&lt;strong&gt;And keep making stuff.&lt;/strong&gt; Before you know it, you&#39;ll have a few tasty examples of your prowess. Proven experience? Check. Broad understanding of web development and implementation? Check.&lt;/p&gt;

&lt;p&gt;So why the &lt;em&gt;hell&lt;/em&gt; aren&#39;t you building something? Right this second? Shut up and build.&lt;/p&gt;

&lt;h3&gt;Become a social developer&lt;/h3&gt;

&lt;p&gt;No, I don&#39;t mean you should go to more parties. I mean you should share your work, share your inspiration, and be involved in helping others make better stuff. Being a social developer builds your reputation and sharpens your skills &lt;em&gt;at the same time&lt;/em&gt;.&lt;/p&gt;

&lt;p&gt;&lt;strong&gt;Absolutely the best medium for this is blogging.&lt;/strong&gt; I hear a lot of people hesitant to start a blog because they don&#39;t have stuff to write about. But here&#39;s a simple place to start: if you&#39;ve come up with a solution to a problem you&#39;re working on, blog it. Chances are others are having a similar problem. &lt;a href=&quot;http://briancray.com/2009/04/16/target-ie6-and-ie7-with-only-1-extra-character-in-your-css/&quot;&gt;Even the simplest of solutions&lt;/a&gt; may result in &lt;a href=&quot;http://www.reddit.com/r/web_design/comments/8nlb2/target_ie6_and_ie7_with_only_1_extra_character_in&quot;&gt;a lot of exposure&lt;/a&gt;.&lt;/p&gt;

&lt;p&gt;Another great social development opportunity is &lt;a href=&quot;http://github.com/&quot;&gt;GitHub&lt;/a&gt;. Other than the &lt;em&gt;huge&lt;/em&gt; benefit of having hosted version control, GitHub gives developers the opportunity to build solutions &lt;em&gt;together&lt;/em&gt;. Others can follow your repositories and even fork them into new versions.&lt;/p&gt;

&lt;p&gt;Combine your efforts by hosting the source code you blog on GitHub, providing exposure for your GitHub repositories and nurturing a deeper relationship with your readers. At the end of the day, discuss it on &lt;a href=&quot;http://twitter.com/briancray&quot;&gt;Twitter&lt;/a&gt;.&lt;/p&gt;

&lt;h3&gt;Keep learning&lt;/h3&gt;
&lt;p&gt;I have the privilege to work with people who make me feel like I know nothing. Why? Because it inspires me to keep learning. The world we call our profession is constantly in a state of change. Hell, as a front-end engineer I don&#39;t know half of what I should.&lt;/p&gt;

&lt;p&gt;If you only have a hammer, everything looks like a nail. Learning not only makes us more resourceful and valuable, but it helps us approach problems with a much broader knowledge base for making informed, sustainable solutions.  A &lt;a href=&quot;http://lwn.net/Articles/441790/&quot;&gt;great article about scaling from the perspective of a database architect&lt;/a&gt; starts with &lt;strong&gt;&quot;Let me tell you a secret. I don&#39;t fix databases. I fix applications.&quot;&lt;/strong&gt; To me this means designing the best solution to a problem requires more than applying your field of study. It requires the ability to look at a problem from a number of angles. &lt;em&gt;Expand your toolbox.&lt;/em&gt;&lt;/p&gt;

&lt;p&gt;And if you&#39;ve managed to conquer all the languages of the programming world, pick up a few books on psychology, marketing, and social behavior. Learn, learn, learn.&lt;/p&gt;

&lt;h3&gt;Befriend failure&lt;/h3&gt;
&lt;p&gt;Failure is inevitable, and likely to happen more often than you&#39;d like. Don&#39;t quit if you fail at first. &lt;strong&gt;The only chance you have of winning is by fighting.&lt;/strong&gt; Failures are hidden morsels of life&#39;s greatest opportunities to learn. They give us the arsenal to fight the better fight. In the business world that translates to more success however you define it. But don&#39;t take it from me.&lt;/p&gt;
&lt;ul&gt;
&lt;li&gt;&lt;a href=&quot;http://www.entrepreneur.com/magazine/entrepreneur/2008/december/198516.html&quot;&gt;Entrepreneur.com says&lt;/a&gt; &quot;You&#39;re fortunate to have failed. You now have the opportunity to learn how to turn bad luck into good luck. If you can do that, you&#39;ll have a life of more and more good luck.&quot;&lt;/li&gt;
&lt;li&gt;&lt;a href=&quot;http://onstartups.com/tabid/3339/bid/47646/Insight-From-Dropbox-Failure-Is-Not-The-Worst-Outcome-Mediocrity-Is.aspx&quot;&gt;Dropbox says&lt;/a&gt; &quot;Failure is not the worst outcome, mediocrity is.&quot;&lt;/li&gt;
&lt;li&gt;&lt;a href=&quot;http://steveblank.com/2009/11/12/%E2%80%9Clessons-learned%E2%80%9D-%E2%80%93-a-new-type-of-vc-pitch/&quot;&gt;CafePress says&lt;/a&gt; &quot;Fail fast and cheap. And learn from it.&quot;&lt;/li&gt;
&lt;/ul&gt;

&lt;h3&gt;Love what you do&lt;/h3&gt;
&lt;p&gt;The last but most important aspect of finding success as a web developer is to love what you do. Ask yourself this simple question: If you weren&#39;t being paid for web development, would you still be doing it? If the answer is yes, you&#39;re almost certainly bound for success.&lt;/p&gt;</description>
        </item>
    
        <item>
            <title>Automatic translator built in javascript</title>
            <link>/posts/automatic-translator-javascript</link>
            <guid>/posts/automatic-translator-javascript</guid>
            <pubDate>Wed, 11 May 2011 08:39:00 -0400</pubDate>
            <description>&lt;p&gt;When it comes to my blog, I&#39;m always asking myself the same question: How can I make my content more engaging? I try to avoid so called &quot;enhancements&quot; like arbitrary visual embellishments or every-which-way navigation that distracts users from what they came for: a good read. I do my best to focus solely on making the content great.&lt;/p&gt;

&lt;p&gt;I&#39;ve done some playing in this area in the past, including &lt;a href=&quot;http://briancray.com/2010/04/09/estimated-reading-time-web-design/&quot;&gt;estimated reading time&lt;/a&gt; and &lt;a href=&quot;http://briancray.com/2010/02/03/measuring-simplicity-in-web-design/&quot;&gt;measuring simplicity&lt;/a&gt;. The other day, I thought I&#39;d try something new. This is what I ended up with.&lt;/p&gt;

&lt;h3&gt;Javascript translation: How does it work?&lt;/h3&gt;

&lt;ol&gt;
&lt;li&gt;Detect the user&#39;s Country Code using google.loader.ClientLocation (I&#39;ve written about this &lt;a href=&quot;http://briancray.com/2009/05/29/find-web-visitors-location-javascript-google-api/&quot;&gt;here&lt;/a&gt;)&lt;/li&gt;
&lt;li&gt;Translates the Country Code into a two digit language code&lt;/li&gt;
&lt;li&gt;If the user has a different native language, redirect the browser to a translated version of the page&lt;/li&gt;
&lt;/ol&gt;

&lt;h3&gt;A look at the source&lt;/h3&gt;

&lt;pre class=&quot;javascript&quot;&gt;
(function () {
    var loaded = false;

    test_cc = window.test_cc ? test_cc : false;
    test_url = window.test_url ? test_url : false;

    var inject_jsapi = function () {
        var h = document.getElementsByTagName(&#39;head&#39;)[0];
        var s = document.createElement(&#39;script&#39;);
        s.type = &#39;text/javascript&#39;;
        s.onreadystatechange = function () {
            if (this.readyState === &#39;loaded&#39; || this.readyState === &#39;complete&#39;) {
                translate(test_cc || (google.loader.ClientLocation &amp;&amp; google.loader.ClientLocation.address.country_code), &#39;en&#39;);
            }
        };
        s.onload = function () {
            translate(test_cc || (google.loader.ClientLocation &amp;&amp; google.loader.ClientLocation.address.country_code), &#39;en&#39;);
        };
        s.src = &#39;http://www.google.com/jsapi&#39;;
        h.appendChild(s);
    };

    var translate = function (cc, lang) {
        if (!cc || loaded) {
            return;
        }
        loaded = true;

        cc = cc.toLowerCase();

        // http://www.mobilefish.com/tutorials/country_language_codes/countrylanguagecodes.html
        var cc2lang = {
            af: &#39;fa&#39;, ax: &#39;sv&#39;, al: &#39;sq&#39;, dz: &#39;ar&#39;, as: &#39;sm&#39;, ad: &#39;ca&#39;,
            ao: &#39;pt&#39;, ai: &#39;en&#39;, aq: &#39;en&#39;, ag: &#39;en&#39;, ar: &#39;es&#39;, am: &#39;hy&#39;,
            aw: &#39;nl&#39;, ac: &#39;en&#39;, au: &#39;en&#39;, at: &#39;de&#39;, az: &#39;az&#39;, bs: &#39;en&#39;,
            bh: &#39;ar&#39;, bd: &#39;bn&#39;, bb: &#39;en&#39;, by: &#39;be&#39;, be: &#39;de&#39;, bz: &#39;en&#39;,
            bj: &#39;fr&#39;, bm: &#39;en&#39;, bt: &#39;dz&#39;, bo: &#39;es&#39;, ba: &#39;bs&#39;, bw: &#39;en&#39;,
            br: &#39;pt&#39;, io: &#39;en&#39;, bn: &#39;ms&#39;, bg: &#39;bg&#39;, bf: &#39;fr&#39;, bi: &#39;fr&#39;,
            kh: &#39;km&#39;, cm: &#39;en&#39;, ca: &#39;en&#39;, cv: &#39;pt&#39;, ky: &#39;en&#39;, cf: &#39;fr&#39;,
            td: &#39;fr&#39;, cl: &#39;es&#39;, cn: &#39;zh&#39;, cx: &#39;en&#39;, cc: &#39;ms&#39;, co: &#39;es&#39;,
            km: &#39;ar&#39;, cg: &#39;fr&#39;, cd: &#39;fr&#39;, ck: &#39;en&#39;, cr: &#39;es&#39;, ci: &#39;fr&#39;,
            hr: &#39;hr&#39;, cu: &#39;es&#39;, cy: &#39;el&#39;, cz: &#39;cs&#39;, dk: &#39;da&#39;, dj: &#39;fr&#39;,
            dm: &#39;en&#39;, do: &#39;es&#39;, ec: &#39;es&#39;, eg: &#39;ar&#39;, sv: &#39;es&#39;, gq: &#39;es&#39;,
            er: &#39;ti&#39;, ee: &#39;et&#39;, et: &#39;am&#39;, eu: &#39;en&#39;, fk: &#39;en&#39;, fo: &#39;fo&#39;,
            fj: &#39;en&#39;, fi: &#39;fi&#39;, fr: &#39;fr&#39;, gf: &#39;fr&#39;, pf: &#39;fr&#39;, tf: &#39;fr&#39;,
            ga: &#39;fr&#39;, gm: &#39;en&#39;, ge: &#39;ka&#39;, de: &#39;de&#39;, gh: &#39;en&#39;, gi: &#39;en&#39;,
            gr: &#39;el&#39;, gl: &#39;kl&#39;, gd: &#39;en&#39;, gp: &#39;fr&#39;, gu: &#39;en&#39;, gt: &#39;es&#39;,
            gg: &#39;en&#39;, gn: &#39;fr&#39;, gw: &#39;pt&#39;, gy: &#39;en&#39;, ht: &#39;fr&#39;, va: &#39;lt&#39;,
            hn: &#39;es&#39;, hk: &#39;zh&#39;, hu: &#39;hu&#39;, is: &#39;is&#39;, in: &#39;hi&#39;, id: &#39;id&#39;,
            ir: &#39;fa&#39;, iq: &#39;ar&#39;, ie: &#39;en&#39;, im: &#39;en&#39;, il: &#39;he&#39;, it: &#39;it&#39;,
            jm: &#39;en&#39;, jp: &#39;ja&#39;, je: &#39;en&#39;, jo: &#39;ar&#39;, kz: &#39;kk&#39;, ke: &#39;en&#39;,
            ki: &#39;en&#39;, kp: &#39;ko&#39;, kr: &#39;ko&#39;, kw: &#39;ar&#39;, kg: &#39;ky&#39;, la: &#39;lo&#39;,
            lv: &#39;lv&#39;, lb: &#39;ar&#39;, ls: &#39;en&#39;, lr: &#39;en&#39;, ly: &#39;ar&#39;, li: &#39;de&#39;,
            lt: &#39;lt&#39;, lu: &#39;de&#39;, mo: &#39;zh&#39;, mk: &#39;mk&#39;, mg: &#39;mg&#39;, mw: &#39;ny&#39;,
            my: &#39;ms&#39;, mv: &#39;dv&#39;, ml: &#39;fr&#39;, mt: &#39;mt&#39;, mh: &#39;mh&#39;, mq: &#39;fr&#39;,
            mr: &#39;ar&#39;, mu: &#39;en&#39;, yt: &#39;fr&#39;, mx: &#39;es&#39;, fm: &#39;en&#39;, md: &#39;mo&#39;,
            mc: &#39;fr&#39;, mn: &#39;mn&#39;, me: &#39;sr&#39;, ms: &#39;en&#39;, ma: &#39;ar&#39;, mz: &#39;pt&#39;,
            mm: &#39;my&#39;, na: &#39;en&#39;, nr: &#39;na&#39;, np: &#39;ne&#39;, nl: &#39;nl&#39;, an: &#39;nl&#39;,
            nc: &#39;fr&#39;, nz: &#39;en&#39;, ni: &#39;es&#39;, ne: &#39;fr&#39;, ng: &#39;en&#39;, nu: &#39;en&#39;,
            nf: &#39;en&#39;, mp: &#39;en&#39;, no: &#39;no&#39;, om: &#39;ar&#39;, pk: &#39;ur&#39;, pw: &#39;en&#39;,
            ps: &#39;ar&#39;, pa: &#39;es&#39;, pg: &#39;en&#39;, py: &#39;es&#39;, pe: &#39;es&#39;, ph: &#39;tl&#39;,
            pn: &#39;en&#39;, pl: &#39;pl&#39;, pt: &#39;pt&#39;, pr: &#39;es&#39;, qa: &#39;ar&#39;, re: &#39;fr&#39;,
            ro: &#39;ro&#39;, ru: &#39;ru&#39;, rw: &#39;rw&#39;, bl: &#39;fr&#39;, sh: &#39;en&#39;, kn: &#39;en&#39;,
            lc: &#39;en&#39;, pm: &#39;fr&#39;, vc: &#39;en&#39;, ws: &#39;sm&#39;, sm: &#39;it&#39;, st: &#39;pt&#39;,
            sa: &#39;ar&#39;, sn: &#39;fr&#39;, rs: &#39;sr&#39;, sc: &#39;en&#39;, sl: &#39;en&#39;, sg: &#39;en&#39;,
            sk: &#39;sk&#39;, si: &#39;sl&#39;, sb: &#39;en&#39;, so: &#39;so&#39;, za: &#39;en&#39;, gs: &#39;en&#39;,
            es: &#39;es&#39;, lk: &#39;si&#39;, sd: &#39;ar&#39;, sr: &#39;nl&#39;, sj: &#39;no&#39;, sz: &#39;en&#39;,
            se: &#39;sv&#39;, ch: &#39;de&#39;, sy: &#39;ar&#39;, tw: &#39;zh&#39;, tj: &#39;tg&#39;, tz: &#39;sw&#39;,
            th: &#39;th&#39;, tl: &#39;pt&#39;, tg: &#39;fr&#39;, tk: &#39;en&#39;, to: &#39;to&#39;, tt: &#39;en&#39;,
            tn: &#39;ar&#39;, tr: &#39;tr&#39;, tm: &#39;tk&#39;, tc: &#39;en&#39;, tv: &#39;tv&#39;, ug: &#39;en&#39;,
            ua: &#39;uk&#39;, ae: &#39;ar&#39;, gb: &#39;en&#39;, us: &#39;en&#39;, um: &#39;en&#39;, uy: &#39;es&#39;,
            vn: &#39;vi&#39;, vg: &#39;en&#39;, vi: &#39;en&#39;, wf: &#39;fr&#39;, eh: &#39;ar&#39;, ye: &#39;ar&#39;,
            yu: &#39;hr&#39;, zm: &#39;en&#39;, zw: &#39;en&#39;
        };

        if (cc &amp;&amp; cc2lang[cc] &amp;&amp; cc2lang[cc] != lang) {
            (function (uri) {
                document.location.href = &#39;http://translate.google.com/translate?langpair=&#39; + lang + &#39;|&#39; + cc2lang[cc] + &#39;&amp;u=&#39; + uri;
            })(test_url || document.location.href);
        }
    };

    inject_jsapi();
})();
&lt;/pre&gt;

&lt;h3&gt;More on GitHub&lt;/h3&gt;

&lt;p&gt;If you&#39;re a &lt;a href=&quot;http://www.github.com/&quot;&gt;GitHub&lt;/a&gt; fan, feel free to &lt;a href=&quot;https://github.com/briancray/Automatic-translator&quot;&gt;follow, fork, or play with the source on GitHub&lt;/a&gt;.&lt;/p&gt;</description>
        </item>
    
        <item>
            <title>Detect retina displays with javascript</title>
            <link>/posts/detect-retina-displays-with-javascript</link>
            <guid>/posts/detect-retina-displays-with-javascript</guid>
            <pubDate>Thu, 5 May 2011 10:08:00 -0400</pubDate>
            <description>&lt;p&gt;I&#39;ve been trying a way to detect a device&#39;s DPI for mobile design. While I haven&#39;t yet, I did at least find a way to detect whether the user is using a retina display. So without ado, here&#39;s how:&lt;/p&gt;

&lt;pre class=&quot;javascript&quot;&gt;
var retina = window.devicePixelRatio &gt; 1 ? true : false;
&lt;/pre&gt;

&lt;p&gt;Now the variable &lt;code&gt;retina&lt;/code&gt; will be set to &lt;code&gt;true&lt;/code&gt; if the user has a retina display. A simple &lt;code&gt;if&lt;/code&gt; statement can be used anywhere to execute code based on the user&#39;s display.&lt;/p&gt;

&lt;pre class=&quot;javascript&quot;&gt;
if (retina) {
    // the user has a retina display
}
else {
    // the user has a non-retina display
}
&lt;/pre&gt;

&lt;h3&gt;Why?&lt;/h3&gt;
&lt;p&gt;A good is exam
ple is if I have a 100x100 image (or video), the above code will tell me to upscale the image to 200x200 for it to look crisp on an iPhone 4 without forcing all users to unnecessarily download a 200x200 image. Especially given bandwidth is a major concern for mobile users.&lt;/p&gt;

&lt;pre class=&quot;javascript&quot;&gt;
if (retina) {
    var html = &#39;&lt;img src=&quot;my-high-res-image.jpg&quot;&gt;&#39;;
}
else {
    var html = &#39;&lt;img src=&quot;my-low-res-image.jpg&quot;&gt;&#39;;
}
&lt;/pre&gt;</description>
        </item>
    
        <item>
            <title>Diving deep into javascript logical operators</title>
            <link>/posts/javascript-logical-operators</link>
            <guid>/posts/javascript-logical-operators</guid>
            <pubDate>Mon, 18 Apr 2011 08:49:00 -0400</pubDate>
            <description>&lt;p&gt;I have lots of fun finding shortcuts in javascript, and logical operators can make for some interesting ways to act on a condition. In this article we&#39;ll look at the logical operators &lt;code&gt;&amp;&amp;&lt;/code&gt; (read: AND) and &lt;code&gt;||&lt;/code&gt; (read: OR).&lt;/p&gt;

&lt;p&gt;A few things to keep in mind:&lt;/p&gt;

&lt;ul&gt;
	&lt;li&gt;Although some of these examples can also be accomplished with a conditional operator (&lt;code&gt;condition ? expr1 : expr2&lt;/code&gt;), the point of this article is to explore the potential of logical operators.&lt;/li&gt;
	&lt;li&gt;Javascript evaluates logical operators from left-to-right, which means it evaluates what&#39;s on the left of a logical operator before evaluating what&#39;s on the right. So in &lt;code&gt;a &amp;&amp; b&lt;/code&gt;, &lt;code&gt;a&lt;/code&gt; is evaluated before &lt;code&gt;b&lt;/code&gt;.&lt;/li&gt;
	&lt;li&gt;In the examples below, &lt;code&gt;true&lt;/code&gt; and &lt;code&gt;false&lt;/code&gt; simply represent anything (variable, function, etc) that evaluates to &lt;code&gt;true&lt;/code&gt; or &lt;code&gt;false&lt;/code&gt; respectively.&lt;/li&gt;
	&lt;li&gt;Don&#39;t let shortcuts break code readability and maintainability. If your use of logical operators as a shortcut becomes to cryptic/complex, you may find yourself losing your mind.&lt;/p&gt;
&lt;/ul&gt;

&lt;h3&gt;If else, without the if else&lt;/h3&gt;

&lt;pre class=&quot;javascript&quot;&gt;
// traditional
if (true) {
	do_this();
}
// alternative method with &amp;&amp;
true &amp;&amp; do_this();

// traditional
if (false) {
	do_this();
}
// alternative method with ||
false || dont_do_this();

// do multiple things via anonymous wrapper
true &amp;&amp; (function () {
	do_this();
	and_this();
	...
})();

// real example - test if DOM object exists before acting on it
jQuery(&#39;#alert&#39;).length &amp;&amp; (function () {
	var el = jQuery(&#39;#alert&#39;);
	el.show();
	window.setTimeout(function () {
		el.hide();
	}, 5000);
})();
&lt;/pre&gt;

&lt;h3&gt;Conditional assignment&lt;/h3&gt;

&lt;pre class=&quot;javascript&quot;&gt;
// setting defaults with ||
var my_setting = optional_setting || default;

// real example - if input#email is blank, defaults to none@none.com with ||
var email = jQuery(&#39;#email&#39;).val() || &#39;none@none.com&#39;;

// setting value only if something else is true with &amp;&amp;
var my_setting = test_me &amp;&amp; setting;

// real example - setting email if valid with &amp;&amp;
var email = jQuery(&#39;#email&#39;).val().search(&#39;/[\d\w\.\-\_]+@[\d\w\.]/&#39;) &gt; -1 &amp;&amp; jQuery(&#39;#email&#39;).val();

// complex usage (mimic conditional operators)
var my_setting = (test_me &amp;&amp; optional_setting) || default;

// real example - setting email if valid, with default
var email = (jQuery(&#39;#email&#39;).val().search(&#39;/[\d\w\.\-\_]+@[\d\w\.]/&#39;) &gt; -1 &amp;&amp; jQuery(&#39;#email&#39;).val()) || &#39;none@none.com;
&lt;/pre&gt;

&lt;h3&gt;Method calls on conditional variables&lt;/h3&gt;

&lt;pre class=&quot;javascript&quot;&gt;
// use parenthesis to act on a condition
(check_if_true &amp;&amp; use_this_if_true).method();
(use_if_true || else_use_this).method();

// real example - Add form field error above itself if it&#39;s not wrapped in a &lt;form&gt; with ||
(jQuery(this).closest(&#39;form&#39;) || jQuery(this)).insertBefore(&#39;&lt;p&gt;Error!&lt;/p&gt;&#39;);

// real example - Add form field error only if it&#39;s a &lt;form&gt; with &amp;&amp;
// note: this will error if not in a form and not in a try...catch
(jQuery(this).closest(&#39;form&#39;) &amp;&amp; jQuery(this)).insertBefore(&#39;&lt;p&gt;Error!&lt;/p&gt;&#39;);
&lt;/pre&gt;

&lt;h3&gt;Conclusion&lt;/h3&gt;

&lt;p&gt;Javascript&#39;s conditional operators allow us to do some neat tricks. We looked at how to use them to bypass &lt;code&gt;if...else&lt;/code&gt;, make variable assignments based on conditions, and call methods depending on conditions. But with all shortcuts, use caution. Knowing how javascript works will help you use conditional operators to their full potential while keeping you safe from unexpected results.&lt;/p&gt;
</description>
        </item>
    
        <item>
            <title>Time On Site &amp; Bounce Rate: Get the real numbers in Google Analytics</title>
            <link>/posts/time-on-site-bounce-rate-get-the-real-numbers-in-google-analytics</link>
            <guid>/posts/time-on-site-bounce-rate-get-the-real-numbers-in-google-analytics</guid>
            <pubDate>Tue, 12 Apr 2011 14:21:00 -0400</pubDate>
            <description>&lt;p&gt;Google Analytics has a major problem with the way it calculates its Time On Site metric: its based on the length of time between a user entering your site and &lt;strong&gt;their last page view&lt;/strong&gt;. Can&#39;t see the holes yet? Here are 2 scenarios where this becomes a major problem (Bob will be our user):&lt;/p&gt;

&lt;h3&gt;Worst case scenario&lt;/h3&gt;

&lt;p&gt;&lt;img src=&quot;/static/media/images/2012/05/06/bounce.png &quot; width=&quot;554&quot; height=&quot;134&quot;&gt;&lt;/p&gt;

&lt;p&gt;In the above scenario Bob enters your site, loyally reads an article for 2 minutes and 13 seconds, saves it to his browser boomarks, then leaves. Can you see the problem? Bob never &lt;em&gt;interacted&lt;/em&gt; with the webpage. &lt;strong&gt;To Google, this is a bounce.&lt;/strong&gt; And bounced visits get marked with 0:00 Time On Site. In other words, your Bounce Rate just got inflated and your Avg. Time On Site just got its ass kicked.&lt;/p&gt;
&lt;h3&gt;Another bad scenario&lt;/h3&gt;

&lt;p&gt;&lt;img src=&quot;/static/media/images/2012/05/06/1page.png &quot; width=&quot;554&quot; height=&quot;134&quot;&gt;&lt;/p&gt;

&lt;p&gt;Let&#39;s say Bob enters your site and even visits a second page, spending a total of 2 minutes and 13 seconds on your site before leaving. But Google messes this up too: since Bob never interacted with the 2nd page, Google doesn&#39;t know how long he spent on the second page. Therefore, Time On Site = Visit to second page - Entrance time = 1 minute and 11 seconds, &lt;strong&gt;not 2 minutes and 13 seconds&lt;/strong&gt;.&lt;/p&gt;

&lt;p&gt;Google&#39;s calculation of Time On Site and Bounce Rate is limited by its unit of measure: &lt;strong&gt;the Pageview&lt;/strong&gt;. But Time On Site has very little to do with pageviews and Bounce Rates&amp;mdash;defined as &quot;the percentage of people who come to your website and leave instantly&quot; by &lt;a href=&quot;http://www.kaushik.net/avinash/2007/08/standard-metrics-revisited-3-bounce-rate.html&quot;&gt;Avinash Kaushik&lt;/a&gt;&amp;mdash;has nothing to do with pageviews.&lt;/p&gt;

&lt;h3&gt;Solution&lt;/h3&gt;

&lt;p&gt;With Google&#39;s &lt;a href=&quot;http://code.google.com/apis/analytics/docs/gaJS/gaJSApiEventTracking.html&quot;&gt;Event Tracking API&lt;/a&gt;, we&#39;ll tell Google Analytics that Bob is still on our site every 10 seconds. To make things &lt;strong&gt;even better&lt;/strong&gt;, an event is an engagement equivalent to a pageview, so it too increases Time On Site &lt;em&gt;and&lt;/em&gt; unbounces the visit. &lt;strong&gt;The result? A more accurate picture of user engagement.&lt;/strong&gt;&lt;/p&gt;

&lt;h4&gt;Javascript magic&lt;/h4&gt;
&lt;p&gt;Paste this javascript snippet right before &lt;code&gt;&amp;lt;/body&amp;gt;&lt;/code&gt; in your HTML pages. It won&#39;t matter if you&#39;re using the &lt;a href=&quot;http://code.google.com/apis/analytics/docs/tracking/asyncUsageGuide.html&quot;&gt;new&lt;/a&gt; or &lt;a href=&quot;http://code.google.com/apis/analytics/docs/tracking/gaTrackingOverview.html&quot;&gt;old&lt;/a&gt; tracking code.&lt;/p&gt;

&lt;pre class=&quot;javascript&quot;&gt;
(function (tos) {
  window.setInterval(function () {
    tos = (function (t) {
      return t[0] == 50 ? (parseInt(t[1]) + 1) + &#39;:00&#39; : (t[1] || &#39;0&#39;) + &#39;:&#39; + (parseInt(t[0]) + 10);
    })(tos.split(&#39;:&#39;).reverse());
    window.pageTracker ? pageTracker._trackEvent(&#39;Time&#39;, &#39;Log&#39;, tos) : _gaq.push([&#39;_trackEvent&#39;, &#39;Time&#39;, &#39;Log&#39;, tos]);
  }, 10000);
})(&#39;00&#39;);
&lt;/pre&gt;

&lt;p&gt;Once this code is installed, your site will update Google Analytics every 10 seconds under the Event Category &quot;Time&quot;, the Event Action &quot;Log&quot;, and &lt;strong&gt;the Event Value will be based on the pattern of 0:10, 0:20, 0:30, 0:40, 0:50, 1:00, 1:10, etc&lt;/strong&gt;.&lt;/p&gt;

&lt;h3&gt;Conclusion&lt;/h3&gt;

&lt;p&gt;Although Google Analytics has its flaws, it compensates in part with a powerful tracking API that keeps getting better. The snippet I&#39;ve written above can more than solve its Time On Site and Bounce Rate reporting issues. Furthermore, if you&#39;re a Google Analytics ninja (or ninja in training), break out the event values into a histogram that shows the distribution of site visit duration. Cheers!&lt;/p&gt;</description>
        </item>
    
        <item>
            <title>Surviving Silicon Valley</title>
            <link>/posts/surviving-silicon-valley</link>
            <guid>/posts/surviving-silicon-valley</guid>
            <pubDate>Wed, 10 Nov 2010 09:13:00 -0500</pubDate>
            <description>&lt;p&gt;The past 2 months have been more crazy than any other time in my professional web life. Why? I&#39;m surviving Silicon Valley.&lt;/p&gt;

&lt;p&gt;Two months ago I joined &lt;a href=&quot;http://topsy.com/&quot;&gt;Topsy&lt;/a&gt;, a &lt;a href=&quot;http://corp.topsy.com/&quot;&gt;real-time search engine powered by the social web&lt;/a&gt;. We have the largest index of tweets in the world, and turning all of that data into something useful for people is complex. Moreover, real-time and social are synonymous with fast-paced. Put the two together and we&#39;re talking &lt;em&gt;really&lt;/em&gt; fast-paced.&lt;/p&gt;

&lt;p&gt;But that&#39;s just how Silicon Valley rolls. The stakes are high as are the demands from the people expected to make things happen. So what does &quot;making things happen&quot; in Silicon Valley mean? Without further ado, here&#39;s a high-level view of what&#39;s happened during my first two months there.&lt;/p&gt;

&lt;h3&gt;Two months in Silicon Valley&lt;/h3&gt;

&lt;ul&gt;
&lt;li&gt;Thrown into a highly complex search environment trying to keep up with some of the smartest search engineers in the world&lt;/li&gt;
&lt;li&gt;Released a completely redesigned corporate blog&lt;/li&gt;
&lt;li&gt;Designed a complete product using Django/Python, both of which I&#39;ve never had past experience&lt;/li&gt;
&lt;li&gt;Built an powerful copy &amp; paste widget (coming soon to publishers near you)&lt;/li&gt;
&lt;li&gt;All while moving from GUI editors with FTP access to VIM over SSH with Git version control&lt;/li&gt;
&lt;/ul&gt;

&lt;p&gt;Wow. That&#39;s a lot. And I&#39;m just getting warmed up.&lt;/p&gt;

&lt;p&gt;I reflect on all of this often. Although I&#39;ve seen myself as a strong developer having developed many popular web apps, I appreciate the developer I&#39;m becoming … &lt;em&gt;in just two months&lt;/em&gt; mind you.&lt;/p&gt;

&lt;p&gt;But the real goal of this article is to prepare other smart developers around the world that are considering Silicon Valley for their next employment opportunity.&lt;/p&gt;

&lt;h3&gt;Tips for preparing to work in Silicon Valley&lt;/h3&gt;

&lt;h4&gt;Treat everyone like they&#39;re your boss&lt;/h4&gt;

&lt;p&gt;Silicon Valley hires people because they&#39;re the cream of the crop&amp;mdash;the best at what they do. The culture is very egalitarian in that a co-worker&#39;s advice is just as valuable as your boss&#39; or their boss&#39; advice when given in the context of their expertise. Unless obviously untrue, never should you doubt or underestimate their knowledge. It may be the best advice you&#39;ve ever received.&lt;/p&gt;

&lt;p&gt;When you&#39;re working with someone, think of your role in terms of how to make their jobs easier. If you do that, you&#39;ll likely to receive the same treatment back, because everybody respects co-workers who get shit done.&lt;/p&gt;

&lt;h4&gt;Get shit done&lt;/h4&gt;

&lt;p&gt;Silicon Valley startups represent a high performance culture. Shareholders, the nature of Silicon Valley, and the economics of technology all make things move fast. The &lt;em&gt;only&lt;/em&gt; way to keep up is to simply get &#39;er done.&lt;/p&gt;

&lt;p&gt;Additionally, the level of expertise required to work there means you&#39;re highly accountable to your output for two primary reasons. First, everyone is solving their own problems that help the business grow. Your problems are your own to the extent that you&#39;re ultimately accountable for solving them. Second, because everyone is a strong performer and the unforgiving nature of startups means the company is running lean. Your role is yours. Do it or say screw it and bounce out of Silicon Valley.&lt;/p&gt;

&lt;h4&gt;Burst your bubble&lt;/h4&gt;

&lt;p&gt;Over 50% of the tools I use to get my job done are new to me. I wasn&#39;t hired only because I knew the primary tools that were required for the role. I was hired because I had the capacity and the desire to learn and grow professionally and personally.&lt;/p&gt;

&lt;p&gt;If you&#39;re working in a bubble (mine was LAMP) and thinking about working in Silicon Valley, make sure that you&#39;re comfortable with learning new tools even as you&#39;re expected to perform with them. Silicon Valley is no place for people unwilling to break their barriers, even drastically.&lt;/p&gt;

&lt;h3&gt;Conclusion&lt;/h3&gt;

&lt;p&gt;Surviving Silicon Valley is about capacity to perform. Do you have the capacity to perform?&lt;/p&gt;

&lt;p&gt;On a related note, Topsy is a great place to work, and &lt;a href=&quot;http://corp.topsy.com/about/jobs/&quot;&gt;Topsy is always hiring&lt;/a&gt;. (And no, Topsy did &lt;strong&gt;not&lt;/strong&gt; ask me write that)&lt;/p&gt;</description>
        </item>
    
        <item>
            <title>Metadata design pattern for the web</title>
            <link>/posts/metadata-design-pattern-for-the-web</link>
            <guid>/posts/metadata-design-pattern-for-the-web</guid>
            <pubDate>Fri, 1 Oct 2010 08:01:00 -0400</pubDate>
            <description>&lt;p&gt;The Web is shifting. Web pages are no longer silos of information. &lt;a href=&quot;http://twitter.com/&quot;&gt;Twitter&lt;/a&gt;, &lt;a href=&quot;http://facebook.com&quot;&gt;Facebook&lt;/a&gt;, and blogs are adding conversations to the web, and those conversations are context for web content that can potentially provide an amazing amount of value to users.&lt;/p&gt;

&lt;p&gt;The major shift began when people could begin commenting on diaries with &lt;a href=&quot;http://en.wikipedia.org/wiki/Open_Diary&quot;&gt;Open Diary&lt;/a&gt; in 1998 and growing quickly in popularity when Google bought &lt;a href=&quot;http://www.blogger.com/&quot;&gt;Blogger&lt;/a&gt; in 2003. Today, conversations are happening everywhere, and more people are joining in every day.&lt;/p&gt;

&lt;h3&gt;New problem: Conversations are silos&lt;/h3&gt;

&lt;p&gt;But now conversations are falling into silos. Commenting on a blog about an linked-to-article isn&#39;t the same as commenting directly on that article. If I&#39;m looking at web content, I should be able to see what people everywhere are saying about that article. Instead, I have to become my own search engine robot&amp;mdash;crawling the web to see what others are saying.&lt;/p&gt;

&lt;p&gt;But why do I care what others are saying? Because it&#39;s &lt;a href=&quot;http://en.wikipedia.org/wiki/Social_proof&quot;&gt;social proof&lt;/a&gt;. Because it provides context. Information in context is infinitely more valuable.&lt;/p&gt;

&lt;h3&gt;Twitter redesign is tearing down the silos&lt;/h3&gt;

&lt;p&gt;&lt;a href=&quot;http://twitter.com/newtwitter&quot;&gt;Twitter&#39;s redesign&lt;/a&gt; is beginning to unlock this potential. Before the redesign, tweets were silos. I only knew that this person made such and such comment, and possibly that they tweeted such and such. But what exactly were they responding to? Who? Why?&lt;/p&gt;

&lt;p&gt;After the redesign I instantly see what others are saying, who said it first, and even a peak at what&#39;s being discussed when I click on a tweet. Suddenly, a wealth of information is at my fingertips with each new tweet coming in.&lt;/p&gt;

&lt;h3&gt;Others want to demolish the walls, too&lt;/h3&gt;

&lt;p&gt;Recently InformationArchitects.com (&lt;a href=&quot;http://twitter.com/ia&quot;&gt;@iA&lt;/a&gt;) posted &lt;a href=&quot;http://www.informationarchitects.jp/en/ias-2006-facebook-designs-redesigned/&quot;&gt;their own redesign of Facebook&lt;/a&gt;, which shares many similarities with Twitter&#39;s redesign. Click on something posted on your wall, and a panel opens revealing context for the post.&lt;/p&gt;

&lt;h3&gt;Building a design pattern for metadata&lt;/h3&gt;

&lt;p&gt;In Twitter and iA&#39;s Facebook designs you&#39;ll see that on the left is the main content, and on the right is metadata, unlocked by clicking on the main content. I believe this should become more commonplace for content on the web.&lt;/p&gt;

&lt;p&gt;&lt;img src=&quot;/static/media/images/2012/05/08/metadata-pattern.png&quot;&gt;&lt;/p&gt;

&lt;h3&gt;Applications&lt;/h3&gt;

&lt;h4&gt;Search engines&lt;/h4&gt;
&lt;p&gt;Imagine clicking on a result in Google and viewing discussions about a link, other pages that link to the page, and other popular pages on the site.&lt;/p&gt;

&lt;h4&gt;Content feeds&lt;/h4&gt;
&lt;p&gt;Twitter is already doing it. iA&#39;s Facebook redesign shows it. What about &lt;a href=&quot;http://www.google.com/reader/&quot;&gt;Google Reader&lt;/a&gt; or other aggregators? Aggregating content is not as powerful as aggregating content with context.&lt;/p&gt;

&lt;h4&gt;Websites&lt;/h4&gt;
&lt;p&gt;I&#39;m thinking about this for my own blog: Imagine clicking on a link and getting context about it without leaving the article? Or when I visit a page it automatically pulls in conversations and metadata from the web to supplement my own content.&lt;/p&gt;

&lt;h4&gt;Web browser plugins&lt;/h4&gt;
&lt;p&gt;Same as above, but the UI is built into the navigator. Some of Safari&#39;s extensions are already doing this, including &lt;a href=&quot;https://extensions.apple.com/#twitter&quot;&gt;Twitter for Safari&lt;/a&gt; and &lt;a href=&quot;http://www.macosxtips.co.uk/extensions/redditcomments.safariextz&quot;&gt;Reddit Comments&lt;/a&gt;.&lt;/p&gt;</description>
        </item>
    
        <item>
            <title>HTML5 Microdata: Why isn&#39;t anyone talking about it?</title>
            <link>/posts/html5-microdata</link>
            <guid>/posts/html5-microdata</guid>
            <pubDate>Wed, 8 Sep 2010 11:49:00 -0400</pubDate>
            <description>&lt;p&gt;Many big web design blogs are raving about HTML5, as they should be. But if you read many of them, [&lt;a href=&quot;http://www.smashingmagazine.com/2009/07/16/html5-and-the-future-of-the-web/&quot;&gt;1&lt;/a&gt;, &lt;a href=&quot;http://www.alistapart.com/articles/previewofhtml5&quot;&gt;2&lt;/a&gt;, &lt;a href=&quot;http://net.tutsplus.com/tutorials/html-css-techniques/html-5-and-css-3-the-techniques-youll-soon-be-using/&quot;&gt;3&lt;/a&gt;], you&#39;ll be bombarded with an over-publicizing of &lt;a href=&quot;http://www.w3schools.com/html5/tag_header.asp&quot;&gt;&lt;code&gt;header&lt;/code&gt;&lt;/a&gt;, &lt;a href=&quot;http://www.w3schools.com/html5/tag_article.asp&quot;&gt;&lt;code&gt;article&lt;/code&gt;&lt;/a&gt;, &lt;a href=&quot;http://www.w3schools.com/html5/tag_footer.asp&quot;&gt;&lt;code&gt;footer&lt;/code&gt;&lt;/a&gt;, et. al tags, which reminds me of &lt;a href=&quot;http://www.alistapart.com/articles/betterliving/&quot;&gt;circa 2002&lt;/a&gt; when we were all jumping onto the XHTML bandwagon.&lt;/p&gt;

&lt;p&gt;But 8 years later where&#39;d XHTML get us? Suddenly we&#39;re moving back to HTML. Why? &lt;strong&gt;XHTML provided no &lt;em&gt;actual&lt;/em&gt; benefits&lt;/strong&gt;. It just meant we had to add meaningless bytes to our user&#39;s downloads.&lt;/p&gt;

&lt;p&gt;HTML5 on the other hand is bringing with it a ton of actually &lt;em&gt;useful&lt;/em&gt; technologies, including &lt;a href=&quot;http://diveintohtml5.org/forms.html&quot;&gt;much needed advances in HTML forms&lt;/a&gt;, &lt;a href=&quot;http://diveintohtml5.org/video.html&quot;&gt;native video support&lt;/a&gt;, and &lt;a href=&quot;http://diveintohtml5.org/canvas.html&quot;&gt;a vector API/&lt;code&gt;canvas&lt;/code&gt;&lt;/a&gt;.&lt;/p&gt;

&lt;p&gt;But back to circa 2010/2002-wannabe. Here we are again bandwagoning (is that a word?) some futile tags of HTML5. Why get so excited about those tags? Look how flexible this is: &lt;code&gt;div id=&quot;&lt;em&gt;ANYTHING&lt;/em&gt;&quot;&lt;/code&gt;. Wow.&lt;/p&gt;

&lt;p&gt;So my fellow web design bloggers: let&#39;s shift our focus to something that&#39;s a part of the HTML5 definition, changes the way we write tags, &lt;em&gt;and&lt;/em&gt; has actual benefits: &lt;strong&gt;&lt;a href=&quot;http://www.w3.org/TR/html5/microdata.html&quot;&gt;Microdata&lt;/a&gt;&lt;/strong&gt;.&lt;/p&gt;

&lt;p&gt;A few web design blogs, including one of my favorites, &lt;a href=&quot;http://net.tutsplus.com/&quot;&gt;NETTUTS&lt;/a&gt;, has &lt;a href=&quot;http://net.tutsplus.com/tutorials/html-css-techniques/html5-microdata-welcome-to-the-machine/&quot;&gt;covered Microdata briefly&lt;/a&gt;, and I want to add some more fuel to the conversation.&lt;/p&gt;

&lt;h3&gt;What is HTML5 Microdata?&lt;/h3&gt;

&lt;p&gt;Old schoolies may remember this little thing called the &lt;a href=&quot;http://en.wikipedia.org/wiki/Semantic_Web&quot;&gt;Semantic Web&lt;/a&gt;. No I&#39;m not talking about &lt;a href=&quot;http://en.wikipedia.org/wiki/Semantic_HTML&quot;&gt;Semantic HTML&lt;/a&gt;, a fancy bit of jargon that by its mere mentioning can give web design newbies a glint of crazed evangelism in their eyes. No. I&#39;m talking about &lt;em&gt;actual&lt;/em&gt; ways to make the web more useful to users.&lt;/p&gt;

&lt;p&gt;The Semantic Web would ideally help users find and use information because computers would know, for example, that an event is an event rather than a bunch of text. If a computer knows an event is an event, it could potentially add a mechanism to allow the user to add the event to his or her calendar. Otherwise, in what has been the norm, the computer arbitrarily displays the information putting the burden in the hands of the user.&lt;/p&gt;

&lt;p&gt;While there have been many approaches to a semantic web, including &lt;a href=&quot;http://en.wikipedia.org/wiki/XML&quot;&gt;XML&lt;/a&gt;, none of them have really taken off beyond APIs because Internet users don&#39;t read XML code. Users look at web pages. Additionally writing &lt;a href=&quot;http://www.w3schools.com/schema/default.asp&quot;&gt;XML schemas&lt;/a&gt; was impractical and ill-adopted by web designers and search engines alike.&lt;/p&gt;

&lt;p&gt;But &quot;the times they are a-changin&#39;.&quot; HTML5 is introducing Microdata, which is an API for adding semantic data to plain ol&#39; HTML tags. This means that using plain ol&#39; HTML tags, you can tell the a web browser or search engine that an event is an event, a person is a person, and so on.&lt;/p&gt;

&lt;h3&gt;How does Microdata markup look?&lt;/h3&gt;

&lt;p&gt;Using Microdata is simple, because unlike XML, you do the same thing you&#39;ve been doing since you built your first website. The only difference is you add an extra attribute to your HTML tags, like so:&lt;/p&gt;

&lt;h4&gt;Before adding Microdata&lt;/h4&gt;
&lt;pre class=&quot;html&quot;&gt;
&lt;div&gt;
&lt;h1&gt;My big event&lt;/h1&gt;
&lt;p&gt;My big event is going to be fun. You should come.&lt;/p&gt;
&lt;p&gt;When: July 4th, 2022 at 6:00pm to July 4th, 2022 at 10:00pm.&lt;/p&gt;
&lt;p&gt;Where: Fun Times Bar&lt;/p&gt;
&lt;/div&gt;
&lt;/pre&gt;

&lt;h4&gt;After adding Microdata&lt;/h4&gt;
&lt;pre class=&quot;html&quot;&gt;
&lt;div itemscope itemtype=&quot;http://data-vocabulary.org/Event&quot;&gt;
&lt;h1 itemprop=&quot;summary&quot;&gt;My big event&lt;/h1&gt;
&lt;p itemprop=&quot;description&quot;&gt;My big event is going to be fun. You should come.&lt;/p&gt;
&lt;p&gt;When: &lt;span itemprop=&quot;startDate&quot; datetime=&quot;2022-07-04T18:00&quot;&gt;July 4th, 2022 at 6:00pm&lt;/span&gt; to &lt;span itemprop=&quot;endDate&quot; datetime=&quot;2022-07-04T22:00&quot;&gt;July 4th, 2022 at 10:00pm&lt;/span&gt;.&lt;/p&gt;
&lt;p itemprop=&quot;location&quot; itemscope
           itemtype=&quot;http://data-vocabulary.org/Organization&quot;&gt;Where: &lt;span itemprop=&quot;name&quot;&gt;Fun Times Bar&lt;/span&gt;&lt;/p&gt;
&lt;/div&gt;
&lt;/pre&gt;

&lt;p&gt;As you&#39;ll see from the example above, we&#39;re still using plain old HTML tags, just adding some additional attributes.&lt;/p&gt;

&lt;p&gt;Although completely going over all Microdata attributes is being the scope of this article, you can check out a &lt;a href=&quot;http://diveintohtml5.org/extensibility.html&quot;&gt;a fantastic documentation on using Microdata at Dive into HTML5&lt;/a&gt;&lt;/p&gt;

&lt;h3&gt;Use Microdata for immediate benefits&lt;/h3&gt;

&lt;p&gt;Unlike all the ideology surrounding XML that never came to fruition, &lt;strong&gt;&lt;a href=&quot;http://googlewebmastercentral.blogspot.com/2010/03/microdata-support-for-rich-snippets.html&quot;&gt;Microdata is already being adopted by Google&lt;/a&gt;&lt;/strong&gt; as part of their &lt;a href=&quot;http://googlewebmastercentral.blogspot.com/2009/05/introducing-rich-snippets.html&quot;&gt;rich snippets&lt;/a&gt; to aid in providing richer search results.&lt;/p&gt;

&lt;h4&gt;Google using Microdata events&lt;/h4&gt;
&lt;p&gt;&lt;img src=&quot;//www.google.com/help/hc/images/webmasters_164506_rsevents.png&quot; alt=&quot;image of a Google rich snippet for an events listing page&quot;&gt;&lt;/p&gt;

&lt;h4&gt;Google using Microdata people&lt;/h4&gt;
&lt;p&gt;&lt;img src=&quot;//www.googel.com//help/hc/images/webmasters_146676_rspeople.png&quot; alt=&quot;image of a Google search rich snippet representing a person&quot;&gt;&lt;/p&gt;

&lt;h4&gt;Google using Microdata reviews&lt;/h4&gt;
&lt;p&gt;&lt;img alt=&quot;image of a Google rich snippet for an aggregate review of a restaurant&quot; src=&quot;//www.google.com/help/hc/images/webmasters_99170_rsreview.png&quot;&gt;&lt;/p&gt;

&lt;p&gt;Google has a &lt;a href=&quot;http://www.google.com/support/webmasters/bin/topic.py?topic=21997&quot;&gt;list of rich snippets&lt;/a&gt; for more examples of how you can use Microdata to product richer search results for your own web pages.&lt;/p&gt;

&lt;h3&gt;Taking Microdata even further tomorrow&lt;/h3&gt;

&lt;p&gt;Google&#39;s adoption of Microdata is taking us a step closer to a semantic web, and there are still big steps to make. However, I believe Microdata may be practical enough to get us really rolling on the semantic web train. Here are a few things I believe would help:&lt;/p&gt;

&lt;h4&gt;Microdata adoption by browsers&lt;/h4&gt;

&lt;p&gt;What if a user rolled over a person&#39;s name and could add them as a contact, or roll over an event and add it to your calendar, all within the native web browser UI? That&#39;d be something, and it doesn&#39;t seem like it would be that hard to accomplish. How about it &lt;a href=&quot;http://www.mozilla.org/&quot;&gt;Mozilla&lt;/a&gt;, &lt;a href=&quot;http://www.apple.com/safari/&quot;&gt;Safari&lt;/a&gt;?&lt;/p&gt;

&lt;h4&gt;Microdata adoption by web developers&lt;/h4&gt;

&lt;p&gt;Web browsers and Google have little reason to support Microdata if us web developers aren&#39;t marking up our webpages with it. Plain and simple. Take a few moments to learn the Microdata API a little, and the semantic web will be right at our doorstep.&lt;/p&gt;

&lt;h3&gt;What are your thoughts about Microdata?&lt;/h3&gt;

&lt;p&gt;Finally, I want to hear your thoughts on Microdata. Have you had any experience with it? What are some potential uses for Microdata that I haven&#39;t discussed?&lt;/p&gt;</description>
        </item>
    
</channel>
</rss>

