<?xml version="1.0"?>
<feed xmlns="http://www.w3.org/2005/Atom">
 
  <title>dandean.com</title>
  <link href="http://dandean.com/"/>
  <link type="application/atom+xml" rel="self" href="http://dandean.com/atom.xml"/>
  <updated>2013-09-11T15:26:44-07:00</updated>
  <id>http://dandean.com/</id>
  <author>
    <name>Dan Dean</name>
    <email>me@dandean.com</email>
  </author>

  
  <entry>
    <id>http://dandean.com/what-should-this-thing-be</id>
    <link type="text/html" rel="alternate" href="http://dandean.com/what-should-this-thing-be"/>
    <title>What should this thing be?</title>
    <updated>2013-08-31T00:00:00-07:00</updated>
    <author>
      <name>Dan Dean</name>
      <uri>http://dandean.com/</uri>
    </author>
    <content type="html">&lt;h1 id=&quot;what-should-this-thing-be&quot;&gt;What should this thing be?&lt;/h1&gt;

&lt;p class=&quot;date&quot;&gt;Aug 31, 2013&lt;/p&gt;

&lt;p&gt;&lt;strong&gt;What‘s the point of this website? Why do I bother keeping and nominally maintaining it?&lt;/strong&gt;&lt;/p&gt;

&lt;p&gt;There are a few reason, all of which range from completely unrealistic to somewhat reasonable. The first and possibly most unreasonable is that I dislike the idea of my content – the web-facing record of my daily thoughts and life – existing soley within an array of proprietary walled gardens:&lt;/p&gt;

&lt;ul&gt;
  &lt;li&gt;&lt;a href=&quot;http://www.flickr.com/photos/dandean/&quot;&gt;flickr&lt;/a&gt;&lt;/li&gt;
  &lt;li&gt;&lt;a href=&quot;http://facebook.com/dandean&quot;&gt;Facebook&lt;/a&gt;&lt;/li&gt;
  &lt;li&gt;&lt;a href=&quot;https://twitter.com/dandean&quot;&gt;Twitter&lt;/a&gt;&lt;/li&gt;
  &lt;li&gt;&lt;a href=&quot;http://dandean.tumblr.com/&quot;&gt;Tumblr&lt;/a&gt;&lt;/li&gt;
  &lt;li&gt;&lt;a href=&quot;http://pinterest.com/dandean/&quot;&gt;Pinterest&lt;/a&gt;&lt;/li&gt;
  &lt;li&gt;&lt;a href=&quot;https://soundcloud.com/dandean&quot;&gt;Soundcloud&lt;/a&gt;&lt;/li&gt;
&lt;/ul&gt;

&lt;p&gt;I genuinely enjoy what these services do, and how they allow me to interact with my friends, family and acquaintances without much effort. The chances that these same people are going to come find “my content” here on my website is so close to zero that I might as well not even consider it an option.&lt;/p&gt;

&lt;p&gt;But STILL, jesus fucking christ, I &lt;em&gt;hate&lt;/em&gt; that these services essentially own my content, and have it within their means to control who gets to see it, and if it continues to exist into the future. The only reason they choose to maintain a record of my life on their servers is to figure out a way to squeeze a few pennies out of it. Sigh…&lt;/p&gt;

&lt;p&gt;So, keeping this in mind – that very few will ever see content posted here, but that it is at least within my full control – what exactly can I do with this space? The ideal format for what is posted here should be in the format of a tumblog:&lt;/p&gt;

&lt;ul&gt;
  &lt;li&gt;Images and videos with little or no text&lt;/li&gt;
  &lt;li&gt;Short thoughts and observations that capture a snapshot of a fleeting moment&lt;/li&gt;
  &lt;li&gt;Audio snippets captured with my phone’s microphone (with still image?)&lt;/li&gt;
  &lt;li&gt;Longer form posts, similar to this one, about my life or about specific projects that I’m working on&lt;/li&gt;
&lt;/ul&gt;

&lt;h2 id=&quot;is-low-friction-convesion-and-publishing-possible&quot;&gt;Is low-friction convesion and publishing possible?&lt;/h2&gt;

&lt;p&gt;How to update and post to this without while creating as few barriers as possible? I should be able to, for the most part, post to the other services I use and have them automatically get cross-posted to this website. How could that work? Probably the easiest way would be to mark posts on other services in a way that could tell an automated script to pull them down and generate the files necessary to push here.&lt;/p&gt;

&lt;p&gt;Content from specific services could be targeted, converted and posted:&lt;/p&gt;

&lt;ul&gt;
  &lt;li&gt;Post an image to &lt;strong&gt;Flickr&lt;/strong&gt; with, tagged with “keep”
    &lt;ul&gt;
      &lt;li&gt;Original-size images are pulled down and uploaded to a folder on my website&lt;/li&gt;
      &lt;li&gt;Posts are created with the image date and linked to the flickr post&lt;/li&gt;
      &lt;li&gt;Image is given any associated caption from the flickr post&lt;/li&gt;
    &lt;/ul&gt;
  &lt;/li&gt;
  &lt;li&gt;Post a &lt;strong&gt;tweet&lt;/strong&gt; that I want to keep
    &lt;ul&gt;
      &lt;li&gt;I DO NOT want to include a fucking hash tag the designates the need for re-posting…&lt;/li&gt;
      &lt;li&gt;Other options… a specific ASCII or Unicode character could be included as a marker. Something pretty but unobtrusive:
        &lt;ul&gt;
          &lt;li&gt;⥿&lt;/li&gt;
          &lt;li&gt;⥁&lt;/li&gt;
          &lt;li&gt;↯&lt;/li&gt;
          &lt;li&gt;°&lt;/li&gt;
          &lt;li&gt;★&lt;/li&gt;
          &lt;li&gt;⚐&lt;/li&gt;
          &lt;li&gt;☉&lt;/li&gt;
          &lt;li&gt;☇&lt;/li&gt;
          &lt;li&gt;⚀&lt;/li&gt;
          &lt;li&gt;◎&lt;/li&gt;
          &lt;li&gt;◉&lt;/li&gt;
          &lt;li&gt;⦿&lt;/li&gt;
          &lt;li&gt;◆&lt;/li&gt;
          &lt;li&gt;⊙&lt;/li&gt;
          &lt;li&gt;⨕&lt;/li&gt;
          &lt;li&gt;⋔&lt;/li&gt;
          &lt;li&gt;⫓&lt;/li&gt;
          &lt;li&gt;⩶&lt;/li&gt;
          &lt;li&gt;⩩&lt;/li&gt;
          &lt;li&gt;⩪&lt;/li&gt;
        &lt;/ul&gt;
      &lt;/li&gt;
      &lt;li&gt;The most practical option, though, would be something which is accessible from the phone’s keyboard, but rarely used.&lt;/li&gt;
    &lt;/ul&gt;
  &lt;/li&gt;
  &lt;li&gt;Post a &lt;strong&gt;Facebook image or video&lt;/strong&gt;: like flickr, pull down the file and upload it to this server. Tagging looks like it sucks, so would probably be limited to the above-mentioned ASCII/Unicode character marker in the photo description or title.&lt;/li&gt;
  &lt;li&gt;&lt;strong&gt;Facebook status update&lt;/strong&gt;: Turn it into a regular text post. Would need to mark it with a special character.&lt;/li&gt;
  &lt;li&gt;&lt;strong&gt;Soundcloud&lt;/strong&gt;: ???&lt;/li&gt;
  &lt;li&gt;&lt;strong&gt;Pinterest pins&lt;/strong&gt;… is there really a need here? One possible use case is for a recipe. Save a draft with a link to the original recipe. I could then create a fleshed out version consisting of how I ended up modifying the recipe, photos of the result, and thoughts about how it turned out.&lt;/li&gt;
&lt;/ul&gt;

&lt;p&gt;If any post contains geodata, a map should be embedded on the page.&lt;/p&gt;

&lt;h2 id=&quot;the-automatic-posting-processs&quot;&gt;The automatic posting processs&lt;/h2&gt;

&lt;ul&gt;
  &lt;li&gt;IFTTT periodically checks the various services for new posts&lt;/li&gt;
  &lt;li&gt;If not IFTTT, a web application could pull individual services, triggered by cron.&lt;/li&gt;
  &lt;li&gt;All new content is posted to service-specific endpoints on my domain:
    &lt;ul&gt;
      &lt;li&gt;http://asdfasdfadf.dandean.com/flickr&lt;/li&gt;
      &lt;li&gt;http://asdfasdfadf.dandean.com/twitter&lt;/li&gt;
      &lt;li&gt;etc…&lt;/li&gt;
    &lt;/ul&gt;
  &lt;/li&gt;
  &lt;li&gt;Specific endpoints process content and transform it into a format suitable for this website&lt;/li&gt;
  &lt;li&gt;New resources are saved and pages are built&lt;/li&gt;
  &lt;li&gt;Textual markers are removed from content&lt;/li&gt;
  &lt;li&gt;Where possible, original resources get a link back to this site’s version in the format of a comment or reply&lt;/li&gt;
  &lt;li&gt;A text message is sent to me with a link to the new post.&lt;/li&gt;
  &lt;li&gt;The endpoints create the new files, kick of the Jekyll build process, and upload the files (if on a different server) or move them in to place (if on the same server).&lt;/li&gt;
&lt;/ul&gt;

&lt;h2 id=&quot;building-it&quot;&gt;Building it&lt;/h2&gt;

&lt;p&gt;This is the shitty (but really FUN) part. It takes time to build these things. The most realistic thing to do would be to implement one service at a time, starting with the most used. The endpoints themselves could exist as a single application on my own server, or live on a single and tiny application on a cloud provider like EC2 or Nodejitsu.&lt;/p&gt;

&lt;p&gt;Separate projects:&lt;/p&gt;

&lt;ul&gt;
  &lt;li&gt;Triggered build and deployments of the website&lt;/li&gt;
  &lt;li&gt;Discovery: service-specific discovery modules&lt;/li&gt;
  &lt;li&gt;Conversion: service-specific content conversion modules&lt;/li&gt;
  &lt;li&gt;Transport: sends converted post data to service-specific endpoints&lt;/li&gt;
  &lt;li&gt;Jekyll Post Builder: builds jekyll posts using service-specific data&lt;/li&gt;
&lt;/ul&gt;

&lt;p&gt;Now, we get to see if I actually do this.&lt;/p&gt;
</content>
  </entry>
  
  <entry>
    <id>http://dandean.com/json-transformer</id>
    <link type="text/html" rel="alternate" href="http://dandean.com/json-transformer"/>
    <title>JSON Transformer</title>
    <updated>2013-04-18T00:00:00-07:00</updated>
    <author>
      <name>Dan Dean</name>
      <uri>http://dandean.com/</uri>
    </author>
    <content type="html">&lt;h1 id=&quot;json-transformer-is-rad&quot;&gt;JSON Transformer Is Rad&lt;/h1&gt;

&lt;p class=&quot;date&quot;&gt;Apr 18, 2013&lt;/p&gt;

&lt;h2 id=&quot;the-problem&quot;&gt;The Problem:&lt;/h2&gt;

&lt;p&gt;Servers and clients often speak in different JSON variants.
The two most frequent use either &lt;code&gt;snake_case&lt;/code&gt; or &lt;code&gt;camelCase&lt;/code&gt; keys.&lt;/p&gt;

&lt;p&gt;It can be frustrating to worked with a mixed bag JSON formats.
&lt;code&gt;json-transformer&lt;/code&gt; helps with this issue by applying a string transformation
to the raw JSON string to enforce either &lt;code&gt;snake_case&lt;/code&gt; or &lt;code&gt;camelCase&lt;/code&gt; formatting.&lt;/p&gt;

&lt;h2 id=&quot;a-solution&quot;&gt;A Solution:&lt;/h2&gt;

&lt;p&gt;With &lt;code&gt;json-transformer&lt;/code&gt;, &lt;strong&gt;JSON can be transformed before deserialization on the
way into your application, and after serialization on the way out.&lt;/strong&gt; This allows
you to work with a consistent JSON format within your application regardless of
the preferences of the services your application depends on.&lt;/p&gt;

&lt;h3 id=&quot;sample-data&quot;&gt;Sample Data&lt;/h3&gt;

&lt;div class=&quot;highlight&quot;&gt;&lt;pre&gt;&lt;code class=&quot;javascript&quot;&gt;&lt;span class=&quot;kd&quot;&gt;var&lt;/span&gt; &lt;span class=&quot;nx&quot;&gt;snake_case_data&lt;/span&gt; &lt;span class=&quot;o&quot;&gt;=&lt;/span&gt; &lt;span class=&quot;nx&quot;&gt;JSON&lt;/span&gt;&lt;span class=&quot;p&quot;&gt;.&lt;/span&gt;&lt;span class=&quot;nx&quot;&gt;stringify&lt;/span&gt;&lt;span class=&quot;p&quot;&gt;({&lt;/span&gt;
  &lt;span class=&quot;s2&quot;&gt;&amp;quot;property_one&amp;quot;&lt;/span&gt;&lt;span class=&quot;o&quot;&gt;:&lt;/span&gt; &lt;span class=&quot;s2&quot;&gt;&amp;quot;foo&amp;quot;&lt;/span&gt;&lt;span class=&quot;p&quot;&gt;,&lt;/span&gt;
  &lt;span class=&quot;s2&quot;&gt;&amp;quot;property_two&amp;quot;&lt;/span&gt;&lt;span class=&quot;o&quot;&gt;:&lt;/span&gt; &lt;span class=&quot;s2&quot;&gt;&amp;quot;bar&amp;quot;&lt;/span&gt;&lt;span class=&quot;p&quot;&gt;,&lt;/span&gt;
&lt;span class=&quot;p&quot;&gt;});&lt;/span&gt;
&lt;span class=&quot;c1&quot;&gt;// &amp;quot;{&amp;quot;property_one&amp;quot;:&amp;quot;foo&amp;quot;,&amp;quot;property_two&amp;quot;:&amp;quot;bar&amp;quot;}&amp;quot;&lt;/span&gt;

&lt;span class=&quot;kd&quot;&gt;var&lt;/span&gt; &lt;span class=&quot;nx&quot;&gt;camelCaseData&lt;/span&gt; &lt;span class=&quot;o&quot;&gt;=&lt;/span&gt; &lt;span class=&quot;nx&quot;&gt;JSON&lt;/span&gt;&lt;span class=&quot;p&quot;&gt;.&lt;/span&gt;&lt;span class=&quot;nx&quot;&gt;stringify&lt;/span&gt;&lt;span class=&quot;p&quot;&gt;({&lt;/span&gt;
  &lt;span class=&quot;s2&quot;&gt;&amp;quot;propertyOne&amp;quot;&lt;/span&gt;&lt;span class=&quot;o&quot;&gt;:&lt;/span&gt; &lt;span class=&quot;s2&quot;&gt;&amp;quot;biz&amp;quot;&lt;/span&gt;&lt;span class=&quot;p&quot;&gt;,&lt;/span&gt;
  &lt;span class=&quot;s2&quot;&gt;&amp;quot;propertyTwo&amp;quot;&lt;/span&gt;&lt;span class=&quot;o&quot;&gt;:&lt;/span&gt; &lt;span class=&quot;s2&quot;&gt;&amp;quot;baz&amp;quot;&lt;/span&gt;&lt;span class=&quot;p&quot;&gt;,&lt;/span&gt;
&lt;span class=&quot;p&quot;&gt;});&lt;/span&gt;
&lt;span class=&quot;c1&quot;&gt;// &amp;quot;{&amp;quot;propertyOne&amp;quot;:&amp;quot;biz&amp;quot;,&amp;quot;propertyTwo&amp;quot;:&amp;quot;baz&amp;quot;}&amp;quot;&lt;/span&gt;
&lt;/code&gt;&lt;/pre&gt;&lt;/div&gt;

&lt;h3 id=&quot;convert-snakecase-to-camelcase&quot;&gt;Convert &lt;code&gt;snake_case&lt;/code&gt; to &lt;code&gt;camelCase&lt;/code&gt;:&lt;/h3&gt;

&lt;div class=&quot;highlight&quot;&gt;&lt;pre&gt;&lt;code class=&quot;javascript&quot;&gt;&lt;span class=&quot;kd&quot;&gt;var&lt;/span&gt; &lt;span class=&quot;nx&quot;&gt;transformer&lt;/span&gt; &lt;span class=&quot;o&quot;&gt;=&lt;/span&gt; &lt;span class=&quot;nx&quot;&gt;require&lt;/span&gt;&lt;span class=&quot;p&quot;&gt;(&lt;/span&gt;&lt;span class=&quot;s1&quot;&gt;&amp;#39;json-transformer&amp;#39;&lt;/span&gt;&lt;span class=&quot;p&quot;&gt;);&lt;/span&gt;
&lt;span class=&quot;nx&quot;&gt;transformer&lt;/span&gt;&lt;span class=&quot;p&quot;&gt;.&lt;/span&gt;&lt;span class=&quot;nx&quot;&gt;underscoreToCamel&lt;/span&gt;&lt;span class=&quot;p&quot;&gt;(&lt;/span&gt;&lt;span class=&quot;nx&quot;&gt;snake_case_data&lt;/span&gt;&lt;span class=&quot;p&quot;&gt;);&lt;/span&gt;
&lt;span class=&quot;c1&quot;&gt;// {&amp;quot;propertyOne&amp;quot;:&amp;quot;foo&amp;quot;,&amp;quot;propertyTwo&amp;quot;:&amp;quot;bar&amp;quot;}&lt;/span&gt;
&lt;/code&gt;&lt;/pre&gt;&lt;/div&gt;

&lt;h3 id=&quot;convert-camelcase-to-snakecase&quot;&gt;Convert &lt;code&gt;camelCase&lt;/code&gt; to &lt;code&gt;snake_case&lt;/code&gt;:&lt;/h3&gt;

&lt;div class=&quot;highlight&quot;&gt;&lt;pre&gt;&lt;code class=&quot;javascript&quot;&gt;&lt;span class=&quot;nx&quot;&gt;transformer&lt;/span&gt;&lt;span class=&quot;p&quot;&gt;.&lt;/span&gt;&lt;span class=&quot;nx&quot;&gt;camelToUnderscore&lt;/span&gt;&lt;span class=&quot;p&quot;&gt;(&lt;/span&gt;&lt;span class=&quot;nx&quot;&gt;camelCaseData&lt;/span&gt;&lt;span class=&quot;p&quot;&gt;);&lt;/span&gt;
&lt;span class=&quot;c1&quot;&gt;// &amp;quot;{&amp;quot;property_one&amp;quot;:&amp;quot;biz&amp;quot;,&amp;quot;property_two&amp;quot;:&amp;quot;baz&amp;quot;}&amp;quot;&lt;/span&gt;
&lt;/code&gt;&lt;/pre&gt;&lt;/div&gt;

</content>
  </entry>
  
  <entry>
    <id>http://dandean.com/tubbs</id>
    <link type="text/html" rel="alternate" href="http://dandean.com/tubbs"/>
    <title>Tubbs - Database Agnostic Model Layer for Node.js</title>
    <updated>2011-12-29T00:00:00-08:00</updated>
    <author>
      <name>Dan Dean</name>
      <uri>http://dandean.com/</uri>
    </author>
    <content type="html">&lt;p&gt;More in-depth documentation can be found in &lt;a href=&quot;https://github.com/dandean/tubbs/blob/master/README.md&quot;&gt;README on GitHub&lt;/a&gt;.&lt;/p&gt;

&lt;h2 id=&quot;tubbshttpsgithubcomdandeantubbs-is-a-feature-rich-and-database-agnostic-model-layer-for-you-nodejs-applications&quot;&gt;&lt;strong&gt;&lt;a href=&quot;https://github.com/dandean/tubbs&quot;&gt;Tubbs&lt;/a&gt;&lt;/strong&gt; is a feature-rich and database-agnostic model layer for you Node.js applications.&lt;/h2&gt;

&lt;p&gt;Some of Tubbs’ excellent features are:&lt;/p&gt;

&lt;ul&gt;
  &lt;li&gt;Rails ActiveModel style property validators, like &lt;code&gt;formatOf&lt;/code&gt;, &lt;code&gt;inclusionOf&lt;/code&gt;, etc…&lt;/li&gt;
  &lt;li&gt;Hackable custom async validation&lt;/li&gt;
  &lt;li&gt;Model extensibility&lt;/li&gt;
  &lt;li&gt;ES5 getter/setter properties with configurable default values (none of that &lt;code&gt;model.set(...)&lt;/code&gt; garbage)&lt;/li&gt;
  &lt;li&gt;Non-serialized virtual properties&lt;/li&gt;
  &lt;li&gt;Can be used with any database as long as an adaptor is provided&lt;/li&gt;
  &lt;li&gt;Current built-in support for Riak and in-memory databases&lt;/li&gt;
&lt;/ul&gt;

&lt;h3 id=&quot;example-define-a-user-model-module&quot;&gt;Example: define a User model module:&lt;/h3&gt;

&lt;div class=&quot;highlight&quot;&gt;&lt;pre&gt;&lt;code class=&quot;javascript&quot;&gt;&lt;span class=&quot;kd&quot;&gt;var&lt;/span&gt; &lt;span class=&quot;nx&quot;&gt;Tubbs&lt;/span&gt; &lt;span class=&quot;o&quot;&gt;=&lt;/span&gt; &lt;span class=&quot;nx&quot;&gt;require&lt;/span&gt;&lt;span class=&quot;p&quot;&gt;(&lt;/span&gt;&lt;span class=&quot;s1&quot;&gt;&amp;#39;tubbs&amp;#39;&lt;/span&gt;&lt;span class=&quot;p&quot;&gt;);&lt;/span&gt;
&lt;span class=&quot;kd&quot;&gt;var&lt;/span&gt; &lt;span class=&quot;nx&quot;&gt;Validate&lt;/span&gt; &lt;span class=&quot;o&quot;&gt;=&lt;/span&gt; &lt;span class=&quot;nx&quot;&gt;Tubbs&lt;/span&gt;&lt;span class=&quot;p&quot;&gt;.&lt;/span&gt;&lt;span class=&quot;nx&quot;&gt;Validate&lt;/span&gt;&lt;span class=&quot;p&quot;&gt;;&lt;/span&gt;
&lt;span class=&quot;kd&quot;&gt;var&lt;/span&gt; &lt;span class=&quot;nx&quot;&gt;Regex&lt;/span&gt; &lt;span class=&quot;o&quot;&gt;=&lt;/span&gt; &lt;span class=&quot;nx&quot;&gt;require&lt;/span&gt;&lt;span class=&quot;p&quot;&gt;(&lt;/span&gt;&lt;span class=&quot;s1&quot;&gt;&amp;#39;regex&amp;#39;&lt;/span&gt;&lt;span class=&quot;p&quot;&gt;);&lt;/span&gt;

&lt;span class=&quot;kd&quot;&gt;var&lt;/span&gt; &lt;span class=&quot;nx&quot;&gt;User&lt;/span&gt; &lt;span class=&quot;o&quot;&gt;=&lt;/span&gt; &lt;span class=&quot;nx&quot;&gt;module&lt;/span&gt;&lt;span class=&quot;p&quot;&gt;.&lt;/span&gt;&lt;span class=&quot;nx&quot;&gt;exports&lt;/span&gt; &lt;span class=&quot;o&quot;&gt;=&lt;/span&gt; &lt;span class=&quot;nx&quot;&gt;Tubbs&lt;/span&gt;&lt;span class=&quot;p&quot;&gt;.&lt;/span&gt;&lt;span class=&quot;nx&quot;&gt;create&lt;/span&gt;&lt;span class=&quot;p&quot;&gt;({&lt;/span&gt;
  &lt;span class=&quot;c1&quot;&gt;// Persist our data with Riak&lt;/span&gt;
  &lt;span class=&quot;nx&quot;&gt;dataStore&lt;/span&gt;&lt;span class=&quot;o&quot;&gt;:&lt;/span&gt; &lt;span class=&quot;k&quot;&gt;new&lt;/span&gt; &lt;span class=&quot;nx&quot;&gt;Tubbs&lt;/span&gt;&lt;span class=&quot;p&quot;&gt;.&lt;/span&gt;&lt;span class=&quot;nx&quot;&gt;RiakStore&lt;/span&gt;&lt;span class=&quot;p&quot;&gt;({&lt;/span&gt; &lt;span class=&quot;nx&quot;&gt;bucket&lt;/span&gt;&lt;span class=&quot;o&quot;&gt;:&lt;/span&gt; &lt;span class=&quot;s1&quot;&gt;&amp;#39;users&amp;#39;&lt;/span&gt; &lt;span class=&quot;p&quot;&gt;}),&lt;/span&gt;
  
  &lt;span class=&quot;c1&quot;&gt;// Use the `username` property as the primary key for operations like `find`.&lt;/span&gt;
  &lt;span class=&quot;c1&quot;&gt;// Defaults to the `id` property.&lt;/span&gt;
  &lt;span class=&quot;nx&quot;&gt;primaryKey&lt;/span&gt;&lt;span class=&quot;o&quot;&gt;:&lt;/span&gt; &lt;span class=&quot;s1&quot;&gt;&amp;#39;username&amp;#39;&lt;/span&gt;&lt;span class=&quot;p&quot;&gt;,&lt;/span&gt;

  &lt;span class=&quot;nx&quot;&gt;fields&lt;/span&gt;&lt;span class=&quot;o&quot;&gt;:&lt;/span&gt; &lt;span class=&quot;p&quot;&gt;{&lt;/span&gt;
    &lt;span class=&quot;nx&quot;&gt;username&lt;/span&gt;&lt;span class=&quot;o&quot;&gt;:&lt;/span&gt; &lt;span class=&quot;kc&quot;&gt;undefined&lt;/span&gt;&lt;span class=&quot;p&quot;&gt;,&lt;/span&gt;
    &lt;span class=&quot;nx&quot;&gt;password&lt;/span&gt;&lt;span class=&quot;o&quot;&gt;:&lt;/span&gt; &lt;span class=&quot;kc&quot;&gt;undefined&lt;/span&gt;&lt;span class=&quot;p&quot;&gt;,&lt;/span&gt;
    &lt;span class=&quot;nx&quot;&gt;first&lt;/span&gt;&lt;span class=&quot;o&quot;&gt;:&lt;/span&gt; &lt;span class=&quot;kc&quot;&gt;undefined&lt;/span&gt;&lt;span class=&quot;p&quot;&gt;,&lt;/span&gt;
    &lt;span class=&quot;nx&quot;&gt;last&lt;/span&gt;&lt;span class=&quot;o&quot;&gt;:&lt;/span&gt; &lt;span class=&quot;kc&quot;&gt;undefined&lt;/span&gt;&lt;span class=&quot;p&quot;&gt;,&lt;/span&gt;
    &lt;span class=&quot;nx&quot;&gt;email&lt;/span&gt;&lt;span class=&quot;o&quot;&gt;:&lt;/span&gt; &lt;span class=&quot;kc&quot;&gt;undefined&lt;/span&gt;
  &lt;span class=&quot;p&quot;&gt;},&lt;/span&gt;

  &lt;span class=&quot;c1&quot;&gt;// Instances will have a `name` property, but it will not be serialized as&lt;/span&gt;
  &lt;span class=&quot;c1&quot;&gt;// JSON when saved to the database.&lt;/span&gt;
  &lt;span class=&quot;nx&quot;&gt;virtual&lt;/span&gt;&lt;span class=&quot;o&quot;&gt;:&lt;/span&gt; &lt;span class=&quot;p&quot;&gt;{&lt;/span&gt;
    &lt;span class=&quot;nx&quot;&gt;name&lt;/span&gt;&lt;span class=&quot;o&quot;&gt;:&lt;/span&gt; &lt;span class=&quot;kd&quot;&gt;function&lt;/span&gt;&lt;span class=&quot;p&quot;&gt;()&lt;/span&gt; &lt;span class=&quot;p&quot;&gt;{&lt;/span&gt;
      &lt;span class=&quot;k&quot;&gt;return&lt;/span&gt; &lt;span class=&quot;p&quot;&gt;((&lt;/span&gt;&lt;span class=&quot;k&quot;&gt;this&lt;/span&gt;&lt;span class=&quot;p&quot;&gt;.&lt;/span&gt;&lt;span class=&quot;nx&quot;&gt;first&lt;/span&gt; &lt;span class=&quot;o&quot;&gt;||&lt;/span&gt; &lt;span class=&quot;s1&quot;&gt;&amp;#39;&amp;#39;&lt;/span&gt;&lt;span class=&quot;p&quot;&gt;)&lt;/span&gt; &lt;span class=&quot;o&quot;&gt;+&lt;/span&gt; &lt;span class=&quot;s1&quot;&gt;&amp;#39; &amp;#39;&lt;/span&gt; &lt;span class=&quot;o&quot;&gt;+&lt;/span&gt; &lt;span class=&quot;p&quot;&gt;(&lt;/span&gt;&lt;span class=&quot;k&quot;&gt;this&lt;/span&gt;&lt;span class=&quot;p&quot;&gt;.&lt;/span&gt;&lt;span class=&quot;nx&quot;&gt;last&lt;/span&gt; &lt;span class=&quot;o&quot;&gt;||&lt;/span&gt; &lt;span class=&quot;s1&quot;&gt;&amp;#39;&amp;#39;&lt;/span&gt;&lt;span class=&quot;p&quot;&gt;)).&lt;/span&gt;&lt;span class=&quot;nx&quot;&gt;trim&lt;/span&gt;&lt;span class=&quot;p&quot;&gt;();&lt;/span&gt;
    &lt;span class=&quot;p&quot;&gt;}&lt;/span&gt;
  &lt;span class=&quot;p&quot;&gt;},&lt;/span&gt;

  &lt;span class=&quot;c1&quot;&gt;// Add some validation...&lt;/span&gt;
  &lt;span class=&quot;nx&quot;&gt;validation&lt;/span&gt;&lt;span class=&quot;o&quot;&gt;:&lt;/span&gt; &lt;span class=&quot;p&quot;&gt;[&lt;/span&gt;
    &lt;span class=&quot;nx&quot;&gt;Validate&lt;/span&gt;&lt;span class=&quot;p&quot;&gt;.&lt;/span&gt;&lt;span class=&quot;nx&quot;&gt;required&lt;/span&gt;&lt;span class=&quot;p&quot;&gt;(&lt;/span&gt;&lt;span class=&quot;s1&quot;&gt;&amp;#39;username&amp;#39;&lt;/span&gt;&lt;span class=&quot;p&quot;&gt;),&lt;/span&gt;
    &lt;span class=&quot;nx&quot;&gt;Validate&lt;/span&gt;&lt;span class=&quot;p&quot;&gt;.&lt;/span&gt;&lt;span class=&quot;nx&quot;&gt;formatOf&lt;/span&gt;&lt;span class=&quot;p&quot;&gt;(&lt;/span&gt;&lt;span class=&quot;s1&quot;&gt;&amp;#39;username&amp;#39;&lt;/span&gt;&lt;span class=&quot;p&quot;&gt;,&lt;/span&gt; &lt;span class=&quot;p&quot;&gt;{&lt;/span&gt;
      &lt;span class=&quot;kd&quot;&gt;with&lt;/span&gt;&lt;span class=&quot;o&quot;&gt;:&lt;/span&gt; &lt;span class=&quot;nx&quot;&gt;Regex&lt;/span&gt;&lt;span class=&quot;p&quot;&gt;.&lt;/span&gt;&lt;span class=&quot;nx&quot;&gt;username&lt;/span&gt;
    &lt;span class=&quot;p&quot;&gt;}),&lt;/span&gt;

    &lt;span class=&quot;nx&quot;&gt;Validate&lt;/span&gt;&lt;span class=&quot;p&quot;&gt;.&lt;/span&gt;&lt;span class=&quot;nx&quot;&gt;required&lt;/span&gt;&lt;span class=&quot;p&quot;&gt;(&lt;/span&gt;&lt;span class=&quot;s1&quot;&gt;&amp;#39;username&amp;#39;&lt;/span&gt;&lt;span class=&quot;p&quot;&gt;),&lt;/span&gt;
    &lt;span class=&quot;nx&quot;&gt;Validate&lt;/span&gt;&lt;span class=&quot;p&quot;&gt;.&lt;/span&gt;&lt;span class=&quot;nx&quot;&gt;formatOf&lt;/span&gt;&lt;span class=&quot;p&quot;&gt;(&lt;/span&gt;&lt;span class=&quot;s1&quot;&gt;&amp;#39;password&amp;#39;&lt;/span&gt;&lt;span class=&quot;p&quot;&gt;,&lt;/span&gt; &lt;span class=&quot;p&quot;&gt;{&lt;/span&gt;
      &lt;span class=&quot;kd&quot;&gt;with&lt;/span&gt;&lt;span class=&quot;o&quot;&gt;:&lt;/span&gt; &lt;span class=&quot;nx&quot;&gt;Regex&lt;/span&gt;&lt;span class=&quot;p&quot;&gt;.&lt;/span&gt;&lt;span class=&quot;nx&quot;&gt;passwordHash&lt;/span&gt;
    &lt;span class=&quot;p&quot;&gt;}),&lt;/span&gt;

    &lt;span class=&quot;nx&quot;&gt;Validate&lt;/span&gt;&lt;span class=&quot;p&quot;&gt;.&lt;/span&gt;&lt;span class=&quot;nx&quot;&gt;formatOf&lt;/span&gt;&lt;span class=&quot;p&quot;&gt;(&lt;/span&gt;&lt;span class=&quot;s1&quot;&gt;&amp;#39;email&amp;#39;&lt;/span&gt;&lt;span class=&quot;p&quot;&gt;,&lt;/span&gt; &lt;span class=&quot;p&quot;&gt;{&lt;/span&gt;
      &lt;span class=&quot;kd&quot;&gt;with&lt;/span&gt;&lt;span class=&quot;o&quot;&gt;:&lt;/span&gt; &lt;span class=&quot;nx&quot;&gt;Regex&lt;/span&gt;&lt;span class=&quot;p&quot;&gt;.&lt;/span&gt;&lt;span class=&quot;nx&quot;&gt;email&lt;/span&gt;
    &lt;span class=&quot;p&quot;&gt;})&lt;/span&gt;
  &lt;span class=&quot;p&quot;&gt;]&lt;/span&gt;
&lt;span class=&quot;p&quot;&gt;});&lt;/span&gt;
&lt;/code&gt;&lt;/pre&gt;&lt;/div&gt;

&lt;h3 id=&quot;example-the-defined-user-model-can-pull-data-from-our-database&quot;&gt;Example: the defined User model can pull data from our database:&lt;/h3&gt;

&lt;div class=&quot;highlight&quot;&gt;&lt;pre&gt;&lt;code class=&quot;javascript&quot;&gt;&lt;span class=&quot;kd&quot;&gt;var&lt;/span&gt; &lt;span class=&quot;nx&quot;&gt;user&lt;/span&gt; &lt;span class=&quot;o&quot;&gt;=&lt;/span&gt; &lt;span class=&quot;nx&quot;&gt;User&lt;/span&gt;&lt;span class=&quot;p&quot;&gt;.&lt;/span&gt;&lt;span class=&quot;nx&quot;&gt;find&lt;/span&gt;&lt;span class=&quot;p&quot;&gt;(&lt;/span&gt;&lt;span class=&quot;s1&quot;&gt;&amp;#39;dandean&amp;#39;&lt;/span&gt;&lt;span class=&quot;p&quot;&gt;);&lt;/span&gt;
&lt;span class=&quot;nx&quot;&gt;user&lt;/span&gt;&lt;span class=&quot;p&quot;&gt;.&lt;/span&gt;&lt;span class=&quot;nx&quot;&gt;email&lt;/span&gt; &lt;span class=&quot;o&quot;&gt;=&lt;/span&gt; &lt;span class=&quot;s1&quot;&gt;&amp;#39;whatever@stuff.com&amp;#39;&lt;/span&gt;&lt;span class=&quot;p&quot;&gt;;&lt;/span&gt;
&lt;span class=&quot;nx&quot;&gt;user&lt;/span&gt;&lt;span class=&quot;p&quot;&gt;.&lt;/span&gt;&lt;span class=&quot;nx&quot;&gt;save&lt;/span&gt;&lt;span class=&quot;p&quot;&gt;(&lt;/span&gt;&lt;span class=&quot;kd&quot;&gt;function&lt;/span&gt;&lt;span class=&quot;p&quot;&gt;(&lt;/span&gt;&lt;span class=&quot;nx&quot;&gt;e&lt;/span&gt;&lt;span class=&quot;p&quot;&gt;,&lt;/span&gt; &lt;span class=&quot;nx&quot;&gt;result&lt;/span&gt;&lt;span class=&quot;p&quot;&gt;)&lt;/span&gt; &lt;span class=&quot;p&quot;&gt;{&lt;/span&gt;
  &lt;span class=&quot;k&quot;&gt;if&lt;/span&gt; &lt;span class=&quot;p&quot;&gt;(&lt;/span&gt;&lt;span class=&quot;nx&quot;&gt;e&lt;/span&gt;&lt;span class=&quot;p&quot;&gt;)&lt;/span&gt; &lt;span class=&quot;p&quot;&gt;{&lt;/span&gt;
    &lt;span class=&quot;c1&quot;&gt;// Could not save, respond with the error messages&lt;/span&gt;
    &lt;span class=&quot;nx&quot;&gt;res&lt;/span&gt;&lt;span class=&quot;p&quot;&gt;.&lt;/span&gt;&lt;span class=&quot;nx&quot;&gt;send&lt;/span&gt;&lt;span class=&quot;p&quot;&gt;({&lt;/span&gt;
      &lt;span class=&quot;nx&quot;&gt;error&lt;/span&gt;&lt;span class=&quot;o&quot;&gt;:&lt;/span&gt; &lt;span class=&quot;nx&quot;&gt;e&lt;/span&gt;&lt;span class=&quot;p&quot;&gt;.&lt;/span&gt;&lt;span class=&quot;nx&quot;&gt;message&lt;/span&gt;&lt;span class=&quot;p&quot;&gt;,&lt;/span&gt;
      &lt;span class=&quot;nx&quot;&gt;errors&lt;/span&gt;&lt;span class=&quot;o&quot;&gt;:&lt;/span&gt; &lt;span class=&quot;nx&quot;&gt;user&lt;/span&gt;&lt;span class=&quot;p&quot;&gt;.&lt;/span&gt;&lt;span class=&quot;nx&quot;&gt;errors&lt;/span&gt;
    &lt;span class=&quot;p&quot;&gt;},&lt;/span&gt; &lt;span class=&quot;mi&quot;&gt;400&lt;/span&gt;&lt;span class=&quot;p&quot;&gt;);&lt;/span&gt;
  &lt;span class=&quot;p&quot;&gt;}&lt;/span&gt; &lt;span class=&quot;k&quot;&gt;else&lt;/span&gt; &lt;span class=&quot;p&quot;&gt;{&lt;/span&gt;
    &lt;span class=&quot;c1&quot;&gt;// User found, send the user bac to the client.&lt;/span&gt;
    &lt;span class=&quot;nx&quot;&gt;res&lt;/span&gt;&lt;span class=&quot;p&quot;&gt;.&lt;/span&gt;&lt;span class=&quot;nx&quot;&gt;send&lt;/span&gt;&lt;span class=&quot;p&quot;&gt;({&lt;/span&gt; &lt;span class=&quot;nx&quot;&gt;user&lt;/span&gt;&lt;span class=&quot;o&quot;&gt;:&lt;/span&gt; &lt;span class=&quot;nx&quot;&gt;user&lt;/span&gt; &lt;span class=&quot;p&quot;&gt;},&lt;/span&gt; &lt;span class=&quot;mi&quot;&gt;200&lt;/span&gt;&lt;span class=&quot;p&quot;&gt;);&lt;/span&gt;
  &lt;span class=&quot;p&quot;&gt;}&lt;/span&gt;
&lt;span class=&quot;p&quot;&gt;});&lt;/span&gt;
&lt;/code&gt;&lt;/pre&gt;&lt;/div&gt;

&lt;p&gt;&lt;a href=&quot;https://github.com/dandean/tubbs&quot;&gt;Tubbs&lt;/a&gt; can do a whole lot more, and can make your database code pretty concise and easy to work with. &lt;strong&gt;Take a look at the &lt;a href=&quot;https://github.com/dandean/tubbs&quot;&gt;repository&lt;/a&gt; for more examples and documentation&lt;/strong&gt;.&lt;/p&gt;
</content>
  </entry>
  
  <entry>
    <id>http://dandean.com/fspkg</id>
    <link type="text/html" rel="alternate" href="http://dandean.com/fspkg"/>
    <title>fspkg - File System Packager</title>
    <updated>2011-12-28T00:00:00-08:00</updated>
    <author>
      <name>Dan Dean</name>
      <uri>http://dandean.com/</uri>
    </author>
    <content type="html">&lt;h1 id=&quot;fspkg---file-system-packager&quot;&gt;&lt;code&gt;fspkg&lt;/code&gt; - File System Packager&lt;/h1&gt;

&lt;p class=&quot;date&quot;&gt;Dec 28, 2011&lt;/p&gt;

&lt;p&gt;Take a look at the &lt;a href=&quot;https://github.com/dandean/fspkg&quot;&gt;fspkg repository on GitHub&lt;/a&gt; for more detailed documentation.&lt;/p&gt;

&lt;h2 id=&quot;example---package-a-commonjs-module-from-a-directory-of-mustachejs-templates&quot;&gt;Example - package a CommonJS module from a directory of mustache.js templates:&lt;/h2&gt;

&lt;div class=&quot;highlight&quot;&gt;&lt;pre&gt;&lt;code class=&quot;javascript&quot;&gt;&lt;span class=&quot;kd&quot;&gt;var&lt;/span&gt; &lt;span class=&quot;nx&quot;&gt;pkgr&lt;/span&gt; &lt;span class=&quot;o&quot;&gt;=&lt;/span&gt; &lt;span class=&quot;k&quot;&gt;new&lt;/span&gt; &lt;span class=&quot;nx&quot;&gt;require&lt;/span&gt;&lt;span class=&quot;p&quot;&gt;(&lt;/span&gt;&lt;span class=&quot;s1&quot;&gt;&amp;#39;fspkg&amp;#39;&lt;/span&gt;&lt;span class=&quot;p&quot;&gt;).&lt;/span&gt;&lt;span class=&quot;nx&quot;&gt;Builder&lt;/span&gt;&lt;span class=&quot;p&quot;&gt;();&lt;/span&gt;
&lt;span class=&quot;kd&quot;&gt;var&lt;/span&gt; &lt;span class=&quot;nx&quot;&gt;result&lt;/span&gt; &lt;span class=&quot;o&quot;&gt;=&lt;/span&gt; &lt;span class=&quot;nx&quot;&gt;pkgr&lt;/span&gt;&lt;span class=&quot;p&quot;&gt;.&lt;/span&gt;&lt;span class=&quot;nx&quot;&gt;build&lt;/span&gt;&lt;span class=&quot;p&quot;&gt;(&lt;/span&gt;&lt;span class=&quot;s1&quot;&gt;&amp;#39;./views&amp;#39;&lt;/span&gt;&lt;span class=&quot;p&quot;&gt;);&lt;/span&gt;
&lt;span class=&quot;nx&quot;&gt;require&lt;/span&gt;&lt;span class=&quot;p&quot;&gt;(&lt;/span&gt;&lt;span class=&quot;s1&quot;&gt;&amp;#39;fs&amp;#39;&lt;/span&gt;&lt;span class=&quot;p&quot;&gt;).&lt;/span&gt;&lt;span class=&quot;nx&quot;&gt;writeFileSync&lt;/span&gt;&lt;span class=&quot;p&quot;&gt;(&lt;/span&gt;&lt;span class=&quot;s1&quot;&gt;&amp;#39;./views.js&amp;#39;&lt;/span&gt;&lt;span class=&quot;p&quot;&gt;);&lt;/span&gt;
&lt;/code&gt;&lt;/pre&gt;&lt;/div&gt;

&lt;p&gt;This would create the file “views.js”, and would look something like this:&lt;/p&gt;

&lt;div class=&quot;highlight&quot;&gt;&lt;pre&gt;&lt;code class=&quot;javascript&quot;&gt;&lt;span class=&quot;nx&quot;&gt;module&lt;/span&gt;&lt;span class=&quot;p&quot;&gt;.&lt;/span&gt;&lt;span class=&quot;nx&quot;&gt;exports&lt;/span&gt; &lt;span class=&quot;o&quot;&gt;=&lt;/span&gt; &lt;span class=&quot;p&quot;&gt;{&lt;/span&gt;
  &lt;span class=&quot;s1&quot;&gt;&amp;#39;auth/login.mustache&amp;#39;&lt;/span&gt;&lt;span class=&quot;o&quot;&gt;:&lt;/span&gt; &lt;span class=&quot;s1&quot;&gt;&amp;#39;&amp;lt;input type=&amp;quot;text&amp;quot; name=&amp;quot;username&amp;quot; value=&amp;quot;&amp;quot; placeholder=&amp;quot;Your Username&amp;quot;&amp;gt;\n&amp;lt;input type=&amp;quot;password&amp;quot; name=&amp;quot;password&amp;quot; value=&amp;quot;&amp;quot; placeholder=&amp;quot;Your Password&amp;quot;&amp;gt;\n&amp;lt;button type=&amp;quot;submit&amp;quot;&amp;gt;Login&amp;lt;/button&amp;gt;\n&amp;#39;&lt;/span&gt;&lt;span class=&quot;p&quot;&gt;,&lt;/span&gt;
  &lt;span class=&quot;s1&quot;&gt;&amp;#39;auth/register.mustache&amp;#39;&lt;/span&gt;&lt;span class=&quot;o&quot;&gt;:&lt;/span&gt; &lt;span class=&quot;s1&quot;&gt;&amp;#39;&amp;lt;input type=&amp;quot;email&amp;quot; name=&amp;quot;email&amp;quot; value=&amp;quot;&amp;quot; placeholder=&amp;quot;Email Address&amp;quot;&amp;gt;\n&amp;lt;input type=&amp;quot;text&amp;quot; name=&amp;quot;username&amp;quot; value=&amp;quot;&amp;quot; placeholder=&amp;quot;Choose Username&amp;quot;&amp;gt;\n&amp;lt;input type=&amp;quot;password&amp;quot; name=&amp;quot;password&amp;quot; value=&amp;quot;&amp;quot; placeholder=&amp;quot;Password&amp;quot;&amp;gt;\n&amp;lt;input type=&amp;quot;password&amp;quot; name=&amp;quot;passwordConfirmation&amp;quot; value=&amp;quot;&amp;quot; placeholder=&amp;quot;Password Confirmation&amp;quot;&amp;gt;\n&amp;lt;p&amp;gt;By registering you agree to Awesome\&amp;#39;s &amp;lt;a href=&amp;quot;&amp;quot;&amp;gt;terms &amp;amp;amp; conditions&amp;lt;/a&amp;gt;.&amp;lt;/p&amp;gt;\n&amp;lt;button type=&amp;quot;submit&amp;quot;&amp;gt;&amp;lt;span&amp;gt;&amp;lt;/span&amp;gt;&amp;lt;span&amp;gt;&amp;lt;/span&amp;gt;Login&amp;lt;/button&amp;gt;\n&amp;#39;&lt;/span&gt;&lt;span class=&quot;p&quot;&gt;,&lt;/span&gt;
  &lt;span class=&quot;s1&quot;&gt;&amp;#39;header.mustache&amp;#39;&lt;/span&gt;&lt;span class=&quot;o&quot;&gt;:&lt;/span&gt; &lt;span class=&quot;s1&quot;&gt;&amp;#39;\n  &amp;lt;div&amp;gt;\n    &amp;lt;h1&amp;gt;&amp;lt;span&amp;gt;Awesome&amp;lt;/span&amp;gt; &amp;amp;nbsp;&amp;amp;rarr;&amp;amp;nbsp; &amp;lt;span&amp;gt;&amp;lt;/span&amp;gt;&amp;lt;/h1&amp;gt;\n    &amp;lt;nav&amp;gt;\n      &amp;lt;a href=&amp;quot;/library/work&amp;quot;&amp;gt;Add Work&amp;lt;/a&amp;gt;\n      &amp;lt;a href=&amp;quot;/library&amp;quot;&amp;gt;Library&amp;lt;/a&amp;gt;\n      &amp;lt;a href=&amp;quot;/profile&amp;quot;&amp;gt;Profile&amp;lt;/a&amp;gt;\n      &amp;lt;a href=&amp;quot;/logout&amp;quot;&amp;gt;Logout&amp;lt;/a&amp;gt;\n    &amp;lt;/nav&amp;gt;\n  &amp;lt;/div&amp;gt;\n\n&amp;#39;&lt;/span&gt;&lt;span class=&quot;p&quot;&gt;,&lt;/span&gt;
  &lt;span class=&quot;s1&quot;&gt;&amp;#39;index.mustache&amp;#39;&lt;/span&gt;&lt;span class=&quot;o&quot;&gt;:&lt;/span&gt; &lt;span class=&quot;s1&quot;&gt;&amp;#39;&amp;#39;&lt;/span&gt;&lt;span class=&quot;p&quot;&gt;,&lt;/span&gt;
  &lt;span class=&quot;s1&quot;&gt;&amp;#39;library/collections.mustache&amp;#39;&lt;/span&gt;&lt;span class=&quot;o&quot;&gt;:&lt;/span&gt; &lt;span class=&quot;s1&quot;&gt;&amp;#39;&amp;lt;header&amp;gt;\n  &amp;lt;h1&amp;gt;Collections&amp;lt;/h1&amp;gt;\n  &amp;lt;button type=&amp;quot;button&amp;quot;&amp;gt;New Collection&amp;lt;/button&amp;gt;\n&amp;lt;/header&amp;gt;\n&amp;lt;form&amp;gt;\n  &amp;lt;input type=&amp;quot;input&amp;quot; name=&amp;quot;new-collection&amp;quot; id=&amp;quot;new-collection&amp;quot; placeholder=&amp;quot;Enter a name for your new collection...&amp;quot;&amp;gt;\n&amp;lt;/form&amp;gt;\n&amp;lt;ul&amp;gt;&amp;lt;/ul&amp;gt;\n&amp;#39;&lt;/span&gt;&lt;span class=&quot;p&quot;&gt;,&lt;/span&gt;
  &lt;span class=&quot;s1&quot;&gt;&amp;#39;library/work.mustache&amp;#39;&lt;/span&gt;&lt;span class=&quot;o&quot;&gt;:&lt;/span&gt; &lt;span class=&quot;s1&quot;&gt;&amp;#39;&amp;lt;section id=&amp;quot;work-media-well&amp;quot;&amp;gt;&amp;lt;/section&amp;gt;\n\n&amp;lt;div id=&amp;quot;work-data&amp;quot;&amp;gt;\n  &amp;lt;section id=&amp;quot;work-actions&amp;quot;&amp;gt;\n    &amp;lt;button type=&amp;quot;button&amp;quot; id=&amp;quot;save-work&amp;quot;&amp;gt;Save&amp;lt;/button&amp;gt;\n\n    &amp;lt;button type=&amp;quot;button&amp;quot; class=&amp;quot;grouped-left&amp;quot;&amp;gt;Basic Information&amp;lt;/button&amp;gt;\n    &amp;lt;button type=&amp;quot;button&amp;quot; class=&amp;quot;grouped&amp;quot;&amp;gt;Editions&amp;lt;/button&amp;gt;\n    &amp;lt;button type=&amp;quot;button&amp;quot; class=&amp;quot;grouped&amp;quot;&amp;gt;Media&amp;lt;/button&amp;gt;\n    &amp;lt;button type=&amp;quot;button&amp;quot; class=&amp;quot;grouped-right&amp;quot; tabindex=&amp;quot;-1&amp;quot;&amp;gt; &amp;lt;/button&amp;gt;\n\n    &amp;lt;button type=&amp;quot;button&amp;quot; id=&amp;quot;delete-work&amp;quot;&amp;gt;Delete&amp;lt;/button&amp;gt;\n  &amp;lt;/section&amp;gt;\n\n  &amp;lt;section id=&amp;quot;work-info&amp;quot;&amp;gt;\n    &amp;lt;input type=&amp;quot;text&amp;quot; name=&amp;quot;title&amp;quot; placeholder=&amp;quot;Title&amp;quot; value=&amp;quot;&amp;quot;&amp;gt;&amp;lt;span&amp;gt;,&amp;lt;/span&amp;gt;\n    &amp;lt;input type=&amp;quot;text&amp;quot; name=&amp;quot;year&amp;quot; placeholder=&amp;quot;Year&amp;quot; value=&amp;quot;&amp;quot;&amp;gt;\n    &amp;lt;br&amp;gt;\n\n    &amp;lt;input type=&amp;quot;text&amp;quot; name=&amp;quot;medium&amp;quot; placeholder=&amp;quot;Medium&amp;quot; value=&amp;quot;&amp;quot;&amp;gt;\n\n    &amp;lt;fieldset&amp;gt;\n      &amp;lt;input type=&amp;quot;text&amp;quot; name=&amp;quot;width&amp;quot; placeholder=&amp;quot;Width&amp;quot; value=&amp;quot;&amp;quot;&amp;gt;\n      x\n      &amp;lt;input type=&amp;quot;text&amp;quot; name=&amp;quot;height&amp;quot; placeholder=&amp;quot;Height&amp;quot; value=&amp;quot;&amp;quot;&amp;gt;\n      x\n      &amp;lt;input type=&amp;quot;text&amp;quot; name=&amp;quot;depth&amp;quot; placeholder=&amp;quot;Depth&amp;quot; value=&amp;quot;&amp;quot;&amp;gt;\n    &amp;lt;/fieldset&amp;gt;\n\n    &amp;lt;textarea name=&amp;quot;text&amp;quot; placeholder=&amp;quot;About this piece&amp;quot;&amp;gt;&amp;lt;/textarea&amp;gt;\n  &amp;lt;/section&amp;gt;\n  \n  &amp;lt;section id=&amp;quot;work-assets&amp;quot;&amp;gt;\n    &amp;lt;h2&amp;gt;Media&amp;lt;/h2&amp;gt;\n    &amp;lt;ul&amp;gt;&amp;lt;/ul&amp;gt;\n  &amp;lt;/section&amp;gt;\n&amp;lt;/div&amp;gt;\n&amp;#39;&lt;/span&gt;
&lt;span class=&quot;p&quot;&gt;}&lt;/span&gt;
&lt;/code&gt;&lt;/pre&gt;&lt;/div&gt;

&lt;p&gt;Since it’s a CommonJS module, you load it up on the client-side and use it as
simply as this:&lt;/p&gt;

&lt;div class=&quot;highlight&quot;&gt;&lt;pre&gt;&lt;code class=&quot;javascript&quot;&gt;&lt;span class=&quot;kd&quot;&gt;var&lt;/span&gt; &lt;span class=&quot;nx&quot;&gt;views&lt;/span&gt; &lt;span class=&quot;o&quot;&gt;=&lt;/span&gt; &lt;span class=&quot;nx&quot;&gt;require&lt;/span&gt;&lt;span class=&quot;p&quot;&gt;(&lt;/span&gt;&lt;span class=&quot;s1&quot;&gt;&amp;#39;./views.js&amp;#39;&lt;/span&gt;&lt;span class=&quot;p&quot;&gt;);&lt;/span&gt;
&lt;span class=&quot;kd&quot;&gt;var&lt;/span&gt; &lt;span class=&quot;nx&quot;&gt;html&lt;/span&gt; &lt;span class=&quot;o&quot;&gt;=&lt;/span&gt; &lt;span class=&quot;nx&quot;&gt;Mustache&lt;/span&gt;&lt;span class=&quot;p&quot;&gt;.&lt;/span&gt;&lt;span class=&quot;nx&quot;&gt;to_html&lt;/span&gt;&lt;span class=&quot;p&quot;&gt;(&lt;/span&gt;&lt;span class=&quot;nx&quot;&gt;views&lt;/span&gt;&lt;span class=&quot;p&quot;&gt;[&lt;/span&gt;&lt;span class=&quot;s1&quot;&gt;&amp;#39;auth/login.mustache&amp;#39;&lt;/span&gt;&lt;span class=&quot;p&quot;&gt;],&lt;/span&gt; &lt;span class=&quot;nx&quot;&gt;data&lt;/span&gt;&lt;span class=&quot;p&quot;&gt;);&lt;/span&gt;
&lt;/code&gt;&lt;/pre&gt;&lt;/div&gt;

&lt;h2 id=&quot;example-command-line-usage&quot;&gt;Example command line usage:&lt;/h2&gt;

&lt;p&gt;&lt;code&gt;fspkg&lt;/code&gt; is also a command-line application, so you can use it from any of your
programs:&lt;/p&gt;

&lt;div class=&quot;highlight&quot;&gt;&lt;pre&gt;&lt;code class=&quot;sh&quot;&gt;fspkg -s ./views.js ./views
&lt;/code&gt;&lt;/pre&gt;&lt;/div&gt;

&lt;h2 id=&quot;installation&quot;&gt;Installation&lt;/h2&gt;

&lt;p&gt;&lt;code&gt;npm install fspkg&lt;/code&gt;&lt;/p&gt;

&lt;p&gt;If you want to use the command line utility, add the &lt;code&gt;-g&lt;/code&gt; flag:&lt;/p&gt;

&lt;p&gt;&lt;code&gt;npm install -g fspkg&lt;/code&gt;&lt;/p&gt;
</content>
  </entry>
  
  <entry>
    <id>http://dandean.com/nodejs-npm-express-osx</id>
    <link type="text/html" rel="alternate" href="http://dandean.com/nodejs-npm-express-osx"/>
    <title>Installing Node, NPM and Express on Mac&amp;nbsp;OSX</title>
    <updated>2011-04-01T00:00:00-07:00</updated>
    <author>
      <name>Dan Dean</name>
      <uri>http://dandean.com/</uri>
    </author>
    <content type="html">&lt;h1 id=&quot;installing-node-npm-and-express-on-osx-from-scratch&quot;&gt;Installing Node, NPM and Express on OSX from Scratch&lt;/h1&gt;

&lt;p class=&quot;date&quot;&gt;Apr 01, 2011&lt;/p&gt;

&lt;h2 id=&quot;prerequisites&quot;&gt;Prerequisites&lt;/h2&gt;

&lt;p&gt;You need to have Git installed. By far, the easiest way to do this is with &lt;a href=&quot;http://mxcl.github.com/homebrew/&quot;&gt;Homebrew&lt;/a&gt;. Follow these &lt;a href=&quot;https://github.com/mxcl/homebrew/wiki/installation&quot;&gt;Homebrew Installation Instructions&lt;/a&gt;. &lt;/p&gt;

&lt;p&gt;Now that you’ve got Homebrew installed, use it to install Git from within your Terminal:&lt;/p&gt;

&lt;div class=&quot;highlight&quot;&gt;&lt;pre&gt;&lt;code class=&quot;bash&quot;&gt;&lt;span class=&quot;nv&quot;&gt;$ &lt;/span&gt;brew install git
&lt;/code&gt;&lt;/pre&gt;&lt;/div&gt;

&lt;h2 id=&quot;installing-node&quot;&gt;Installing Node&lt;/h2&gt;

&lt;p&gt;If you don’t have Git installed, use Homebrew to install that first.&lt;/p&gt;

&lt;p&gt;Here’s a &lt;a href=&quot;https://github.com/joyent/node/wiki/Installation&quot;&gt;basic installation guide&lt;/a&gt; for Node.&lt;/p&gt;

&lt;h3 id=&quot;getting-nodes-source-code&quot;&gt;Getting Node’s source code&lt;/h3&gt;

&lt;p&gt;If you don’t already have a place to store external source code, put it somewhere usefuls, like a “src” directory in your home folder:&lt;/p&gt;

&lt;div class=&quot;highlight&quot;&gt;&lt;pre&gt;&lt;code class=&quot;bash&quot;&gt;&lt;span class=&quot;nv&quot;&gt;$ &lt;/span&gt;mkdir ~/src
&lt;/code&gt;&lt;/pre&gt;&lt;/div&gt;

&lt;p&gt;Now that we’ve got a place to put it, let’s download Node:&lt;/p&gt;

&lt;div class=&quot;highlight&quot;&gt;&lt;pre&gt;&lt;code class=&quot;bash&quot;&gt;&lt;span class=&quot;nv&quot;&gt;$ &lt;/span&gt;&lt;span class=&quot;nb&quot;&gt;cd&lt;/span&gt; ~/src
&lt;span class=&quot;nv&quot;&gt;$ &lt;/span&gt;git clone https://github.com/joyent/node.git
&lt;span class=&quot;nv&quot;&gt;$ &lt;/span&gt;&lt;span class=&quot;nb&quot;&gt;cd &lt;/span&gt;node
&lt;/code&gt;&lt;/pre&gt;&lt;/div&gt;

&lt;h3 id=&quot;building-node&quot;&gt;Building Node&lt;/h3&gt;

&lt;p&gt;You’ll want the latest &lt;strong&gt;stable&lt;/strong&gt; version. Stable version are use even numbers, while unstable dev versions use odd. At the time of &lt;em&gt;this&lt;/em&gt; writing, the latest stable release is 0.4.7, so let’s checkout that tag before building:&lt;/p&gt;

&lt;div class=&quot;highlight&quot;&gt;&lt;pre&gt;&lt;code class=&quot;bash&quot;&gt;&lt;span class=&quot;nv&quot;&gt;$ &lt;/span&gt;git checkout v0.4.7   &lt;span class=&quot;c&quot;&gt;# you&amp;#39;ll get a note about a detached HEAD state.&lt;/span&gt;
&lt;span class=&quot;nv&quot;&gt;$ &lt;/span&gt;&lt;span class=&quot;nb&quot;&gt;export &lt;/span&gt;&lt;span class=&quot;nv&quot;&gt;JOBS&lt;/span&gt;&lt;span class=&quot;o&quot;&gt;=&lt;/span&gt;2         &lt;span class=&quot;c&quot;&gt;# optional, sets number of parallel commands.&lt;/span&gt;
&lt;span class=&quot;nv&quot;&gt;$ &lt;/span&gt;mkdir ~/local
&lt;span class=&quot;nv&quot;&gt;$ &lt;/span&gt;./configure --prefix&lt;span class=&quot;o&quot;&gt;=&lt;/span&gt;&lt;span class=&quot;nv&quot;&gt;$HOME&lt;/span&gt;/local/node
&lt;span class=&quot;nv&quot;&gt;$ &lt;/span&gt;make
&lt;span class=&quot;nv&quot;&gt;$ &lt;/span&gt;make install
&lt;/code&gt;&lt;/pre&gt;&lt;/div&gt;

&lt;h3 id=&quot;telling-your-system-where-to-find-node&quot;&gt;Telling your system where to find Node&lt;/h3&gt;

&lt;p&gt;We’ve got to add the node bin folder to your path so that you can easily use node from the command line. Open up your &lt;code&gt;.bash_profile&lt;/code&gt; and add Node’s path to your PATH.&lt;/p&gt;

&lt;div class=&quot;highlight&quot;&gt;&lt;pre&gt;&lt;code class=&quot;bash&quot;&gt;&lt;span class=&quot;nv&quot;&gt;$ &lt;/span&gt;nano ~/.bash_profile
&lt;/code&gt;&lt;/pre&gt;&lt;/div&gt;

&lt;p&gt;If you already have a line that starts with &lt;code&gt;export PATH=&lt;/code&gt;, just add Node’s path to the beginning. For example this:&lt;/p&gt;

&lt;div class=&quot;highlight&quot;&gt;&lt;pre&gt;&lt;code class=&quot;bash&quot;&gt;&lt;span class=&quot;nb&quot;&gt;export &lt;/span&gt;&lt;span class=&quot;nv&quot;&gt;PATH&lt;/span&gt;&lt;span class=&quot;o&quot;&gt;=&lt;/span&gt;/usr/local/bin:&lt;span class=&quot;nv&quot;&gt;$PATH&lt;/span&gt;
&lt;/code&gt;&lt;/pre&gt;&lt;/div&gt;

&lt;p&gt;would become:&lt;/p&gt;

&lt;div class=&quot;highlight&quot;&gt;&lt;pre&gt;&lt;code class=&quot;bash&quot;&gt;&lt;span class=&quot;nb&quot;&gt;export &lt;/span&gt;&lt;span class=&quot;nv&quot;&gt;PATH&lt;/span&gt;&lt;span class=&quot;o&quot;&gt;=&lt;/span&gt;&lt;span class=&quot;nv&quot;&gt;$HOME&lt;/span&gt;/local/node/bin:/usr/local/bin:&lt;span class=&quot;nv&quot;&gt;$PATH&lt;/span&gt;
&lt;/code&gt;&lt;/pre&gt;&lt;/div&gt;

&lt;p&gt;If you don’t already have a PATH export declared, just add this to the file and save:&lt;/p&gt;

&lt;div class=&quot;highlight&quot;&gt;&lt;pre&gt;&lt;code class=&quot;bash&quot;&gt;&lt;span class=&quot;nb&quot;&gt;export &lt;/span&gt;&lt;span class=&quot;nv&quot;&gt;PATH&lt;/span&gt;&lt;span class=&quot;o&quot;&gt;=&lt;/span&gt;&lt;span class=&quot;nv&quot;&gt;$HOME&lt;/span&gt;/local/node/bin:&lt;span class=&quot;nv&quot;&gt;$PATH&lt;/span&gt;
&lt;/code&gt;&lt;/pre&gt;&lt;/div&gt;

&lt;h3 id=&quot;testing-your-node-installation&quot;&gt;Testing your Node installation&lt;/h3&gt;

&lt;p&gt;To make sure this all worked as expected, open up a new Terminal window and run:&lt;/p&gt;

&lt;div class=&quot;highlight&quot;&gt;&lt;pre&gt;&lt;code class=&quot;bash&quot;&gt;&lt;span class=&quot;nv&quot;&gt;$ &lt;/span&gt;node -v
&amp;gt; v0.4.7
&lt;/code&gt;&lt;/pre&gt;&lt;/div&gt;

&lt;p&gt;&lt;strong&gt;Success!&lt;/strong&gt;&lt;/p&gt;

&lt;h2 id=&quot;installing-npm&quot;&gt;Installing NPM&lt;/h2&gt;

&lt;p&gt;Now, I’m guessing you’d like to install some Node programs, like &lt;a href=&quot;http://expressjs.com/&quot;&gt;Express&lt;/a&gt; or something like that. EASY! NPM is incredibly easy to install:&lt;/p&gt;

&lt;div class=&quot;highlight&quot;&gt;&lt;pre&gt;&lt;code class=&quot;bash&quot;&gt;&lt;span class=&quot;nv&quot;&gt;$ &lt;/span&gt;curl http://npmjs.org/install.sh | sh
&lt;/code&gt;&lt;/pre&gt;&lt;/div&gt;

&lt;p&gt;This should print out a bunch of stuff, ending in &lt;code&gt;It worked&lt;/code&gt;. There may also be a single &lt;code&gt;npm WARN Not installed in blah blah blah...&lt;/code&gt; line – don’t worry about it.&lt;/p&gt;

&lt;h3 id=&quot;testing-your-npm-installation&quot;&gt;Testing your NPM installation&lt;/h3&gt;

&lt;p&gt;Again, just open a new Terminal window at run:&lt;/p&gt;

&lt;div class=&quot;highlight&quot;&gt;&lt;pre&gt;&lt;code class=&quot;bash&quot;&gt;&lt;span class=&quot;nv&quot;&gt;$ &lt;/span&gt;npm -v
&amp;gt; 1.0.1rc4
&lt;/code&gt;&lt;/pre&gt;&lt;/div&gt;

&lt;p&gt;&lt;strong&gt;Another success!&lt;/strong&gt;&lt;/p&gt;

&lt;h3 id=&quot;bash-completion&quot;&gt;Bash Completion&lt;/h3&gt;

&lt;p&gt;Once incredible helpful feature of NPM is that implements Bash completion, which makes using NPM quite a bit easier at times. To enable this you’ve got to source NPM’s completion file into your .bash_profile. Open .bash_profile up again, and add this to it:&lt;/p&gt;

&lt;div class=&quot;highlight&quot;&gt;&lt;pre&gt;&lt;code class=&quot;bash&quot;&gt;&lt;span class=&quot;nb&quot;&gt;source&lt;/span&gt; ~/local/node/lib/node_modules/npm/lib/utils/completion.sh
&lt;/code&gt;&lt;/pre&gt;&lt;/div&gt;

&lt;h2 id=&quot;installing-express&quot;&gt;Installing Express&lt;/h2&gt;

&lt;p&gt;Now that we’ve got NPM installed, we can use &lt;em&gt;that&lt;/em&gt; to install all the Node.js goodness we can get our grubby little hands on, including Express!&lt;/p&gt;

&lt;p&gt;NPM 1.0 is more more opinionated than earlier releases – instead of installing modules globally by default, modules are installed at the project-level. Command-line tools, on the other hand, can be installed globally.&lt;/p&gt;

&lt;h3 id=&quot;the-express-command-line-tool&quot;&gt;The &lt;code&gt;express&lt;/code&gt; Command Line Tool&lt;/h3&gt;

&lt;p&gt;Express is both a project module, and a command line tool, so we’re going to install it in both places. Let’s start by installing it globally:&lt;/p&gt;

&lt;div class=&quot;highlight&quot;&gt;&lt;pre&gt;&lt;code class=&quot;bash&quot;&gt;&lt;span class=&quot;nv&quot;&gt;$ &lt;/span&gt;npm install -g express
&lt;/code&gt;&lt;/pre&gt;&lt;/div&gt;

&lt;p&gt;Now that we’ve got our &lt;code&gt;express&lt;/code&gt; command-line tool, let’s use that to create an Express application:&lt;/p&gt;

&lt;div class=&quot;highlight&quot;&gt;&lt;pre&gt;&lt;code class=&quot;bash&quot;&gt;&lt;span class=&quot;nv&quot;&gt;$ &lt;/span&gt;mkdir ~/Sites/bitchin-express-app
&lt;span class=&quot;nv&quot;&gt;$ &lt;/span&gt;&lt;span class=&quot;nb&quot;&gt;cd&lt;/span&gt; ~/Sites/bitchin-express-app
&lt;span class=&quot;nv&quot;&gt;$ &lt;/span&gt;express -s -t jade
&lt;/code&gt;&lt;/pre&gt;&lt;/div&gt;

&lt;p&gt;&lt;strong&gt;Done!&lt;/strong&gt;&lt;/p&gt;

&lt;h3 id=&quot;dependency-management&quot;&gt;Dependency Management&lt;/h3&gt;

&lt;p&gt;Next we need to specify our application’s dependencies. NPM gives us a clean and maintainable way to do this with the “&lt;strong&gt;package.json&lt;/strong&gt;” file. Create this by running &lt;code&gt;npm init&lt;/code&gt; from with the root of your project, and just follow the prompts:&lt;/p&gt;

&lt;div class=&quot;highlight&quot;&gt;&lt;pre&gt;&lt;code class=&quot;bash&quot;&gt;&lt;span class=&quot;nv&quot;&gt;$ &lt;/span&gt;npm init
&lt;/code&gt;&lt;/pre&gt;&lt;/div&gt;

&lt;p&gt;When you’re done with that, add your dependency declarations to the file. Express and Jade are both dependencies for me. This is what my final “package.json” looks like:&lt;/p&gt;

&lt;div class=&quot;highlight&quot;&gt;&lt;pre&gt;&lt;code class=&quot;javascript&quot;&gt;&lt;span class=&quot;p&quot;&gt;{&lt;/span&gt;
  &lt;span class=&quot;s2&quot;&gt;&amp;quot;name&amp;quot;&lt;/span&gt;&lt;span class=&quot;o&quot;&gt;:&lt;/span&gt; &lt;span class=&quot;s2&quot;&gt;&amp;quot;bitchin-express-app&amp;quot;&lt;/span&gt;&lt;span class=&quot;p&quot;&gt;,&lt;/span&gt;
  &lt;span class=&quot;s2&quot;&gt;&amp;quot;description&amp;quot;&lt;/span&gt;&lt;span class=&quot;o&quot;&gt;:&lt;/span&gt; &lt;span class=&quot;s2&quot;&gt;&amp;quot;My Bitchin&amp;#39; Express App&amp;quot;&lt;/span&gt;&lt;span class=&quot;p&quot;&gt;,&lt;/span&gt;
  &lt;span class=&quot;s2&quot;&gt;&amp;quot;version&amp;quot;&lt;/span&gt;&lt;span class=&quot;o&quot;&gt;:&lt;/span&gt; &lt;span class=&quot;s2&quot;&gt;&amp;quot;0.0.0&amp;quot;&lt;/span&gt;&lt;span class=&quot;p&quot;&gt;,&lt;/span&gt;
  &lt;span class=&quot;s2&quot;&gt;&amp;quot;repository&amp;quot;&lt;/span&gt;&lt;span class=&quot;o&quot;&gt;:&lt;/span&gt; &lt;span class=&quot;p&quot;&gt;{&lt;/span&gt;
    &lt;span class=&quot;s2&quot;&gt;&amp;quot;url&amp;quot;&lt;/span&gt;&lt;span class=&quot;o&quot;&gt;:&lt;/span&gt; &lt;span class=&quot;s2&quot;&gt;&amp;quot;&amp;quot;&lt;/span&gt;
  &lt;span class=&quot;p&quot;&gt;},&lt;/span&gt;
  &lt;span class=&quot;s2&quot;&gt;&amp;quot;author&amp;quot;&lt;/span&gt;&lt;span class=&quot;o&quot;&gt;:&lt;/span&gt; &lt;span class=&quot;s2&quot;&gt;&amp;quot;Dan Dean &amp;lt;me@dandean.com&amp;gt; (http://dandean.com)&amp;quot;&lt;/span&gt;&lt;span class=&quot;p&quot;&gt;,&lt;/span&gt;
  &lt;span class=&quot;s2&quot;&gt;&amp;quot;directories&amp;quot;&lt;/span&gt;&lt;span class=&quot;o&quot;&gt;:&lt;/span&gt; &lt;span class=&quot;p&quot;&gt;{&lt;/span&gt;
    &lt;span class=&quot;s2&quot;&gt;&amp;quot;lib&amp;quot;&lt;/span&gt;&lt;span class=&quot;o&quot;&gt;:&lt;/span&gt; &lt;span class=&quot;s2&quot;&gt;&amp;quot;.&amp;quot;&lt;/span&gt;
  &lt;span class=&quot;p&quot;&gt;},&lt;/span&gt;
  &lt;span class=&quot;s2&quot;&gt;&amp;quot;scripts&amp;quot;&lt;/span&gt;&lt;span class=&quot;o&quot;&gt;:&lt;/span&gt; &lt;span class=&quot;p&quot;&gt;{&lt;/span&gt;
    &lt;span class=&quot;s2&quot;&gt;&amp;quot;test&amp;quot;&lt;/span&gt;&lt;span class=&quot;o&quot;&gt;:&lt;/span&gt; &lt;span class=&quot;s2&quot;&gt;&amp;quot;expresso&amp;quot;&lt;/span&gt;
  &lt;span class=&quot;p&quot;&gt;},&lt;/span&gt;
  &lt;span class=&quot;s2&quot;&gt;&amp;quot;engines&amp;quot;&lt;/span&gt;&lt;span class=&quot;o&quot;&gt;:&lt;/span&gt; &lt;span class=&quot;p&quot;&gt;{&lt;/span&gt;
    &lt;span class=&quot;s2&quot;&gt;&amp;quot;node&amp;quot;&lt;/span&gt;&lt;span class=&quot;o&quot;&gt;:&lt;/span&gt; &lt;span class=&quot;s2&quot;&gt;&amp;quot;&amp;gt;= 0.4.7 &amp;lt; 0.5.0&amp;quot;&lt;/span&gt;
  &lt;span class=&quot;p&quot;&gt;},&lt;/span&gt;
  &lt;span class=&quot;s2&quot;&gt;&amp;quot;dependencies&amp;quot;&lt;/span&gt;&lt;span class=&quot;o&quot;&gt;:&lt;/span&gt; &lt;span class=&quot;p&quot;&gt;{&lt;/span&gt;
    &lt;span class=&quot;s2&quot;&gt;&amp;quot;express&amp;quot;&lt;/span&gt;&lt;span class=&quot;o&quot;&gt;:&lt;/span&gt; &lt;span class=&quot;s2&quot;&gt;&amp;quot;&amp;gt;= 2.0.0 &amp;lt; 3.0.0&amp;quot;&lt;/span&gt;&lt;span class=&quot;p&quot;&gt;,&lt;/span&gt;
    &lt;span class=&quot;s2&quot;&gt;&amp;quot;jade&amp;quot;&lt;/span&gt;&lt;span class=&quot;o&quot;&gt;:&lt;/span&gt; &lt;span class=&quot;s2&quot;&gt;&amp;quot;*&amp;quot;&lt;/span&gt;
  &lt;span class=&quot;p&quot;&gt;}&lt;/span&gt;
&lt;span class=&quot;p&quot;&gt;}&lt;/span&gt;
&lt;/code&gt;&lt;/pre&gt;&lt;/div&gt;

&lt;p&gt;Dependency management is one of NPM’s excellent features. We can automatically install &lt;strong&gt;all&lt;/strong&gt; of our application dependencies by simply asking NPM to take care of it. From within your project folder run:&lt;/p&gt;

&lt;div class=&quot;highlight&quot;&gt;&lt;pre&gt;&lt;code class=&quot;bash&quot;&gt;&lt;span class=&quot;nv&quot;&gt;$ &lt;/span&gt;npm install
&lt;/code&gt;&lt;/pre&gt;&lt;/div&gt;

&lt;p&gt;You should notice that your project now has a “node_modules” folder. Inside that you’ll see an “express” folder, which contains the Express framework module for use just with your new application.&lt;/p&gt;

&lt;h3 id=&quot;running-your-application&quot;&gt;Running Your Application&lt;/h3&gt;

&lt;p&gt;We’ve got to create a couple more little files before we’re ready to go: our “layout” and “index” files.&lt;/p&gt;

&lt;div class=&quot;highlight&quot;&gt;&lt;pre&gt;&lt;code class=&quot;bash&quot;&gt;&lt;span class=&quot;nv&quot;&gt;$ &lt;/span&gt;touch views/layout.jade views/index.jade
&lt;/code&gt;&lt;/pre&gt;&lt;/div&gt;

&lt;p&gt;You’ll notice that back when we created our application we passed the &lt;code&gt;-t jade&lt;/code&gt; argument to &lt;code&gt;express&lt;/code&gt;. This configured our app to use the &lt;a href=&quot;http://jade-lang.com/&quot;&gt;Jade&lt;/a&gt; templating engine.&lt;/p&gt;

&lt;p&gt;Open up “views/layout.jade” and paste this into it:&lt;/p&gt;

&lt;pre&gt;&lt;code&gt;!!!
html
  head
    title Hell's Yeah.
    link(rel=&quot;stylesheet&quot;, href=&quot;/stylesheets/style.css&quot;)
  body!= body
&lt;/code&gt;&lt;/pre&gt;

&lt;p&gt;And paste this into “views/index.jade”:&lt;/p&gt;

&lt;pre&gt;&lt;code&gt;h1 This is a Bitchin' Web Applications!
p Am I right?    
&lt;/code&gt;&lt;/pre&gt;

&lt;p&gt;Now all we have to do is start our fucking rad, Bitchin’ application! From the root of your project run this, the open the &lt;code&gt;http://localhost:3000&lt;/code&gt; in a browser:&lt;/p&gt;

&lt;div class=&quot;highlight&quot;&gt;&lt;pre&gt;&lt;code class=&quot;bash&quot;&gt;&lt;span class=&quot;nv&quot;&gt;$ &lt;/span&gt;node app.js
&amp;gt; Express server listening on port 3000
&lt;/code&gt;&lt;/pre&gt;&lt;/div&gt;

&lt;h2 id=&quot;in-conclusion&quot;&gt;In Conclusion&lt;/h2&gt;

&lt;p&gt;Hopefully this introduction is enough to get you up and running. There’s a whole lot going on in the community. Keep up to date by following the &lt;a href=&quot;http://blog.nodejs.org&quot;&gt;Node blog&lt;/a&gt;. If you want to explore the many modules available for use in your applications, poke around the &lt;a href=&quot;http://search.npmjs.org&quot;&gt;NPM Module Registry&lt;/a&gt;.&lt;/p&gt;
</content>
  </entry>
  
  <entry>
    <id>http://dandean.com/nodejs-on-dreamhost-shared-server</id>
    <link type="text/html" rel="alternate" href="http://dandean.com/nodejs-on-dreamhost-shared-server"/>
    <title>Installing Node.js on a Dreamhost Shared Server</title>
    <updated>2010-04-09T00:00:00-07:00</updated>
    <author>
      <name>Dan Dean</name>
      <uri>http://dandean.com/</uri>
    </author>
    <content type="html">&lt;h1 id=&quot;installing-nodejs-on-a-dreamhost-shared-server&quot;&gt;Installing Node.js on a Dreamhost Shared Server&lt;/h1&gt;

&lt;p class=&quot;date&quot;&gt;Apr 09, 2010&lt;/p&gt;

&lt;hr /&gt;

&lt;p&gt;&lt;strong&gt;UPDATE:&lt;/strong&gt; It’s worth noting that Dreamhost does not allow long-running processes, so this will not work for most production deployment needs.&lt;/p&gt;

&lt;hr /&gt;

&lt;p&gt;First, get the &lt;strong&gt;latest &lt;a href=&quot;http://nodejs.org/&quot;&gt;Node.js&lt;/a&gt; source&lt;/strong&gt; onto your server. I keep my git downloads at &lt;code&gt;~/downloads/git&lt;/code&gt;.&lt;/p&gt;

&lt;p&gt;If it doesn’t already exist, create your download directories and &lt;code&gt;cd&lt;/code&gt; into it:&lt;/p&gt;

&lt;div class=&quot;highlight&quot;&gt;&lt;pre&gt;&lt;code class=&quot;bash&quot;&gt;&lt;span class=&quot;nv&quot;&gt;$ &lt;/span&gt;mkdir ~/downloads/git
&lt;span class=&quot;nv&quot;&gt;$ &lt;/span&gt;&lt;span class=&quot;nb&quot;&gt;cd&lt;/span&gt; ~/downloads/git
&lt;/code&gt;&lt;/pre&gt;&lt;/div&gt;

&lt;p&gt;Then, pull down the latest &lt;a href=&quot;http://github.com/ry/node&quot;&gt;Node.js source code from GitHub&lt;/a&gt;:&lt;/p&gt;

&lt;div class=&quot;highlight&quot;&gt;&lt;pre&gt;&lt;code class=&quot;bash&quot;&gt;&lt;span class=&quot;nv&quot;&gt;$ &lt;/span&gt;git clone git://github.com/ry/node.git
&lt;/code&gt;&lt;/pre&gt;&lt;/div&gt;

&lt;p&gt;Since we’re on a Dreamhost shared server, we have to specify a personal directory for the node binaries to install to. This is because Dreamhost won’t allow us (for good reason) to install whatever we want into location which is shared by every other user on your server.&lt;/p&gt;

&lt;p&gt;So, lets create our OWN &lt;code&gt;/usr/local/bin&lt;/code&gt; directory:&lt;/p&gt;

&lt;div class=&quot;highlight&quot;&gt;&lt;pre&gt;&lt;code class=&quot;bash&quot;&gt;&lt;span class=&quot;nv&quot;&gt;$ &lt;/span&gt;mkdir ~/usr/local/bin
&lt;/code&gt;&lt;/pre&gt;&lt;/div&gt;

&lt;p&gt;Now that we’ve got that, let’s get into the node Git repo and configure node to use our new custom bin directory:&lt;/p&gt;

&lt;div class=&quot;highlight&quot;&gt;&lt;pre&gt;&lt;code class=&quot;bash&quot;&gt;&lt;span class=&quot;nv&quot;&gt;$ &lt;/span&gt;./configure --prefix&lt;span class=&quot;o&quot;&gt;=&lt;/span&gt;~/usr/local
&lt;/code&gt;&lt;/pre&gt;&lt;/div&gt;

&lt;p&gt;If everything went well, &lt;code&gt;make&lt;/code&gt; should handle the rest!&lt;/p&gt;

&lt;div class=&quot;highlight&quot;&gt;&lt;pre&gt;&lt;code class=&quot;bash&quot;&gt;&lt;span class=&quot;nv&quot;&gt;$ &lt;/span&gt;make
&amp;gt; ... a whole bunch of compilation output ...
&lt;span class=&quot;nv&quot;&gt;$ &lt;/span&gt;make install
&amp;gt; ... more output ...
&amp;gt; Done!
&lt;/code&gt;&lt;/pre&gt;&lt;/div&gt;

&lt;p&gt;Now, you need to do one more thing to make node visible to your own scripts: add the new node binaries to your PATH! To do this you need to add the following line to two files in your home directory: &lt;strong&gt;&lt;code&gt;.bashrc&lt;/code&gt;&lt;/strong&gt; and &lt;strong&gt;&lt;code&gt;.bash_profile&lt;/code&gt;&lt;/strong&gt;.&lt;/p&gt;

&lt;div class=&quot;highlight&quot;&gt;&lt;pre&gt;&lt;code class=&quot;bash&quot;&gt;&lt;span class=&quot;nb&quot;&gt;export &lt;/span&gt;&lt;span class=&quot;nv&quot;&gt;PATH&lt;/span&gt;&lt;span class=&quot;o&quot;&gt;=&lt;/span&gt;&lt;span class=&quot;nv&quot;&gt;$PATH&lt;/span&gt;:/home/&lt;span class=&quot;o&quot;&gt;[&lt;/span&gt;YOUR USER NAME&lt;span class=&quot;o&quot;&gt;]&lt;/span&gt;/usr/local/bin
&lt;/code&gt;&lt;/pre&gt;&lt;/div&gt;

&lt;p&gt;You’re almost done! Just save both of those files, close your connection, reconnect, and check if you can run node! You should get something like this:&lt;/p&gt;

&lt;div class=&quot;highlight&quot;&gt;&lt;pre&gt;&lt;code class=&quot;bash&quot;&gt;&lt;span class=&quot;nv&quot;&gt;$ &lt;/span&gt;node --version
&amp;gt; v0.1.33-221-gff56d63
&lt;/code&gt;&lt;/pre&gt;&lt;/div&gt;

&lt;p&gt;&lt;strong&gt;&lt;em&gt;Hot shit! Now go build some killer Node.js apps!&lt;/em&gt;&lt;/strong&gt;&lt;/p&gt;

</content>
  </entry>
  
 
</feed>