<?xml version="1.0" encoding="utf-8"?>
<feed xmlns="http://www.w3.org/2005/Atom">

  <title><![CDATA[Glenn Stovall]]></title>
  <link href="http://gsto.github.com/atom.xml" rel="self"/>
  <link href="http://gsto.github.com/"/>
  <updated>2012-05-10T08:44:39-04:00</updated>
  <id>http://gsto.github.com/</id>
  <author>
    <name><![CDATA[Glenn Stovall]]></name>
    
  </author>
  <generator uri="http://octopress.org/">Octopress</generator>

  
  <entry>
    <title type="html"><![CDATA[Rapid Development with Node.js and CoffeeScript]]></title>
    <link href="http://gsto.github.com/blog/2012/05/07/rapid-development-with-node-dot-js-and-coffeescript/"/>
    <updated>2012-05-07T21:57:00-04:00</updated>
    <id>http://gsto.github.com/blog/2012/05/07/rapid-development-with-node-dot-js-and-coffeescript</id>
    <content type="html"><![CDATA[<p><img class="left" src="http://gsto.github.com/images/articles/coffeescript.jpg">
Node.js and CoffeeScript have been all the rage in the web development community as of late. In this tutorial, I&#8217;ll be walking though how to set up your development environment to quickly write &amp; test Node.js apps completly in CoffeeScript, and have your development app update automatically without having to compile CoffeeScript <em>or</em> restart your Node.js server.</p>

<!-- more -->


<h3>Step 1: Installing CoffeeScript</h3>

<p>like most other Node.js packages, installing coffeescript is easy:</p>

<pre><code>npm install coffee-script
</code></pre>

<p>Now that we have CoffeeScript installed, we can write a basic &#8216;hello world&#8217; server is CoffeeScript. If you aren&#8217;t familiar with the CoffeeScript syntax, you can refer to the (CoffeeScript Documentation)[http://coffeescript.org/]. Write the following to a <code>hello.coffee</code> file:</p>

<figure class='code'><figcaption><span>hello.coffee</span></figcaption><div class="highlight"><table><tr><td class="gutter"><pre class="line-numbers"><span class='line-number'>1</span>
<span class='line-number'>2</span>
<span class='line-number'>3</span>
<span class='line-number'>4</span>
<span class='line-number'>5</span>
</pre></td><td class='code'><pre><code class='coffeescript'><span class='line'><span class="nx">require</span> <span class="nv">http = </span><span class="s1">&#39;http&#39;</span>
</span><span class='line'><span class="nx">http</span><span class="p">.</span><span class="nx">createServer</span> <span class="nf">(req, res) -&gt;</span>
</span><span class='line'>        <span class="nx">res</span><span class="p">.</span><span class="nx">writeHead</span> <span class="mi">200</span>
</span><span class='line'>        <span class="nx">res</span><span class="p">.</span><span class="nx">end</span> <span class="s1">&#39;Hello, World!&#39;</span>
</span><span class='line'><span class="p">.</span><span class="nx">listen</span> <span class="mi">4000</span>
</span></code></pre></td></tr></table></div></figure>


<h3>Step 2: Compilation</h3>

<p>CoffeeScript files can&#8217;t be executed directly by node, they have to be compiled to JavaScript first. We can run the following command to compile our <code>hello.coffee</code> file:</p>

<pre><code>coffee --compile hello.coffee
</code></pre>

<p>This will generate a <code>hello.js</code> file. now we can run <code>node hello.js</code> and see our message at localhost:4000. Here is the resulting compiled JavaScript:</p>

<figure class='code'><figcaption><span>hello.js</span></figcaption><div class="highlight"><table><tr><td class="gutter"><pre class="line-numbers"><span class='line-number'>1</span>
<span class='line-number'>2</span>
<span class='line-number'>3</span>
<span class='line-number'>4</span>
<span class='line-number'>5</span>
<span class='line-number'>6</span>
<span class='line-number'>7</span>
<span class='line-number'>8</span>
<span class='line-number'>9</span>
<span class='line-number'>10</span>
<span class='line-number'>11</span>
</pre></td><td class='code'><pre><code class='javascript'><span class='line'><span class="p">(</span><span class="kd">function</span><span class="p">()</span> <span class="p">{</span>
</span><span class='line'>  <span class="kd">var</span> <span class="nx">http</span><span class="p">;</span>
</span><span class='line'>
</span><span class='line'>  <span class="nx">http</span> <span class="o">=</span> <span class="nx">require</span><span class="p">(</span><span class="s1">&#39;http&#39;</span><span class="p">);</span>
</span><span class='line'>
</span><span class='line'>  <span class="nx">http</span><span class="p">.</span><span class="nx">createServer</span><span class="p">(</span><span class="kd">function</span><span class="p">(</span><span class="nx">req</span><span class="p">,</span> <span class="nx">res</span><span class="p">)</span> <span class="p">{</span>
</span><span class='line'>    <span class="nx">res</span><span class="p">.</span><span class="nx">writeHead</span><span class="p">(</span><span class="mi">200</span><span class="p">);</span>
</span><span class='line'>    <span class="k">return</span> <span class="nx">res</span><span class="p">.</span><span class="nx">end</span><span class="p">(</span><span class="s1">&#39;Another Message!&#39;</span><span class="p">);</span>
</span><span class='line'>  <span class="p">}).</span><span class="nx">listen</span><span class="p">(</span><span class="mi">4000</span><span class="p">);</span>
</span><span class='line'>
</span><span class='line'><span class="p">}).</span><span class="nx">call</span><span class="p">(</span><span class="k">this</span><span class="p">);</span>
</span></code></pre></td></tr></table></div></figure>


<p>The resulting JavaScript is more verbose than what we wrote originally, but it is still very easy to see how the CoffeeScript maps to the resulting code. Unfortunately this constant compilation isn&#8217;t very rapid, now is it? Let&#8217;s look at how we can streamline this process.</p>

<h3>Step 3: Automation</h3>

<p>The CoffeeScript compiler has a <code>--watch</code> option, which we can use to tell it to automatically compile any <code>.coffee</code> file whenever there is a change. Run the following command, and set it to a background process:</p>

<pre><code>coffee --compile --watch *.coffee
</code></pre>

<p>That will take care of the compilation issue. However, you will still have to wait until everything compiles, and then restart your server, right? Wrong! Now we are going to install a second package, called (Nodemon)[http://remysharp.com/2010/10/12/nodejs-rapid-development-nodemon/] which will listen for changes to files, and automatically restart the Node.js server whenver one is detected. Start by installing the package:</p>

<pre><code>npm install nodemon
</code></pre>

<p>Now, you&#8217;ll want to create a file named <code>nodemon-ignore</code> in your app&#8217;s main directory, and add an exception for .coffee files:</p>

<figure class='code'><figcaption><span>nodemon-ignore</span></figcaption><div class="highlight"><table><tr><td class="gutter"><pre class="line-numbers"><span class='line-number'>1</span>
<span class='line-number'>2</span>
</pre></td><td class='code'><pre><code class='text'><span class='line'>#creates an exception for .coffee files
</span><span class='line'>*.coffee
</span></code></pre></td></tr></table></div></figure>


<p>This way, you won&#8217;t have any conflicts with the CoffeeScript compiler.  When the files compile, it will cause the .js files to change, but the server won&#8217;t restart before those files are ready. When you are ready to begin, run the following command:</p>

<pre><code>nodemon hello.js
</code></pre>

<p>Nodemon will listen to changes to all of your non-CoffeeScript files, and automatically restart the server whenever it detects a change. And now you are able to write your node apps in CoffeeScript, and not have to worry about compiling or server restarts, enabling you to write and develop more quickly.</p>
]]></content>
  </entry>
  
  <entry>
    <title type="html"><![CDATA[Terminals for Absolute Beginners: Part 2]]></title>
    <link href="http://gsto.github.com/blog/2012/03/07/terminals-for-absolute-beginners-part-2/"/>
    <updated>2012-03-07T08:14:00-05:00</updated>
    <id>http://gsto.github.com/blog/2012/03/07/terminals-for-absolute-beginners-part-2</id>
    <content type="html"><![CDATA[<h3>Manipulating Files</h3>

<p><img class="left" src="http://gsto.github.com/images/articles/terminal.jpg" width="260"></p>

<ul>
<li>Read Part 1 <a href="blog/2012/02/15/terminals-for-absolute-beginners/">Here</a></li>
</ul>


<p>Now that we have learned the basics of navigating the terminal, lets start looking at how to we affect the file system we&#8217;re working in. In this tutorial, we&#8217;ll cover the following: creating and deleting directories, copying and moving files and directories, and creating and deleting files.</p>

<p> <!-- more --></p>

<p> ###Creating and Deleting Directories</p>

<p> Wherever you left off in the last lesson, let&#8217;s start by going back to home directory, and working from there. Remember that we can do this by running the command <code>cd ~</code>. Now, since we will be manipulating the file system in this tutortial, let&#8217;s create a new directory that we can work in. You can do this by using the <code>mkdir</code> command. mkdir is short for &#8220;make directory&#8221;. just type mkdir and the name of the folder you would like to create. For this example, we&#8217;ll call it &#8216;terminal-tutorial&#8217;</p>

<pre><code>mkdir terminal-tutorial
ls
</code></pre>

<p>When you run <code>ls</code>, you&#8217;ll see that a new directory has been created. <code>mkdir</code> defaults to creating the directory inside the directory you are currently located. if you define a path, it will created the directory there. For example, lets make a directory inside of our terminal-tutorial directory, and then navigate there.</p>

<pre><code>mkdir terminal-tutorial/to-delete
cd terminal-tutorial
ls
</code></pre>

<p>You should see just the to-delete directory. If you tried to create a directory in a directory that did not exist, you would get an error. You can create nested directories at once by using the <code>-p</code> option, Like so:</p>

<pre><code>mkdir -p multiple/subdirectory/example
</code></pre>

<p>creates 3 new directories with those paths. Now lets says you need to get rid of a directory. For this we can use the <code>rmdir</code> command, which is short for &#8216;remove directory&#8217;. Lets get rid of that pesky <code>to-delete</code> folder we made earlier, and the multiple directory example</p>

<pre><code>rmdir to-delete
rmdir multiple
rmdir: failed to remove `multiple': Directory not empty
</code></pre>

<p>You&#8217;ll see that you get the following error message since <code>multiple</code> is not empty. <code>rmdir</code> can only remove empty directories.  Later in this artice we will discuss how can remove entire directories of files</p>

<h3>Creating and Deleting Files</h3>

<p>Now we can start creating and deleting files as well as directories. Let&#8217;s start with the <code>touch</code> command. <code>touch</code> is to files what <code>mkdir</code> is to directories. so let&#8217;s create a file:</p>

<pre><code>touch to-delete
ls
</code></pre>

<p>This creates an empty file named <code>to-delete</code>. To actually delete this file, we use the <code>rm</code> command, which is short for remove:</p>

<pre><code>rm to-delete
</code></pre>

<p>rm can also be used on directories, by using the <code>-r</code> option, which is short for recursive. This will also remove all the contents inside of a directory.  Occasionally you may get a prompt asking if you are sure you want to delete something. You can get rid of this with the <code>-f</code> option. You can use this to get rid of the <code>multiple</code> directory you created earlier</p>

<pre><code>rm -rf multiple
</code></pre>

<p>If you want to open and edit text files, you will need to get accquainted with a good text editor. <a href="http://www.vim.org/">Vim</a> and <a href="http://www.gnu.org/software/emacs/">Emacs</a> Are the two most popular, but both are very complex and a whole series of tutorials could be written on either one.</p>

<p><strong>WARNING</strong></p>

<p>It is a common joke on the internet to try to get people to run the command <code>rm -rf /</code> in the terminal. <code>/</code> refers to the base directory of your entire filesystem, so <code>rm -rf /</code> basically translates into &#8220;delete my everything forever, and don&#8217;t ask for my permission&#8221;. It is a <em>seriously</em> dangerous command to run, and now you know why.</p>

<h3>Copying And Moving Files and Directories</h3>

<p>Let&#8217;s start by creating a couple more directories for this section:</p>

<pre><code>mkdir cars
mkdir vechicles
</code></pre>

<p>You may have decided that you made a mistake, and the <code>cars</code> directory should be inside of the <code>vehicles</code> directory. For situations like these, we have the <code>mv</code> command, which is short for move:</p>

<pre><code>mv cars vechicles/cars
</code></pre>

<p>The first option of the <code>mv</code> command is the directory you would like to move, the second argument being where you would like it to go. Since the names do not nessicarily have to match, <code>mv</code> also acts as a &#8216;rename&#8217; operation for files and directories. If you want to <em>guarantee</em> the names match (and save you some typing), you can replace the final name of the file/directory with a <code>.</code> character, so these two commands are equivalent:</p>

<pre><code>mv cars vehicles/cars
mv cars vehicles/.
</code></pre>

<p>If you wanted to maintain the original <code>cars</code> directory and just put a copy of it in the <code>vehicles</code> directory, then you can do that wih the <code>cp</code> command, which is short for &#8220;copy&#8221;.  Much like <code>rm</code>, <code>cp</code> works with both files and directories, but requires a <code>-r</code> for directories. The structure of the arguments is the same as <code>mv</code> though. So copying <code>cars</code> would have looked like this:</p>

<pre><code>cp -r cars vehicles/.
</code></pre>

<p>Note that the <code>.</code> syntax to keep the same name still works here as well.</p>

<h3>Protip: Tab Completion</h3>

<p>All of this typing on the command line can get tiresome. One of the best tricks to learn to cut down on the amount of keystrokes it takes to type commands is to learn about and get used to frequently using tab completion. If you type the first few letters of a directory or file name and hit tab, the shell will complete it for you! You must type enough characters for it to be unique. If not, pressing tab twice on most shells will show you all the directories and files that match the start of the name you typed. so for example, if you typed this:</p>

<pre><code>mkdir terminal-tutorial
cd te   
</code></pre>

<p>and this pressed the tab button, the terminal should automatically fill out:</p>

<pre><code>cd terminal-tutorial
</code></pre>

<p>Now we have a good set of tools for working with and manipulating the file system. Next time we&#8217;ll take a look at users, groups, and the permissions system that UNIX is based on.</p>
]]></content>
  </entry>
  
  <entry>
    <title type="html"><![CDATA[My Eureka Moment With Regular Expressions]]></title>
    <link href="http://gsto.github.com/blog/2012/03/06/my-eureka-moment-with-regular-expressions/"/>
    <updated>2012-03-06T13:49:00-05:00</updated>
    <id>http://gsto.github.com/blog/2012/03/06/my-eureka-moment-with-regular-expressions</id>
    <content type="html"><![CDATA[<p><img class="left" src="http://gsto.github.com/images/articles/my_eureka_moment.jpg">
Regular expressions are a tough cookie for most programmers to figure out. They are <em>terrifying</em> to look at with their daunting syntax. There is also nothing quite like regular expressions anywhere in programming. programmers may learn to hack together basic regex expressions, or how to cut and paste some they find online for their needs, but it can be tricky to get a real grasp of the concept. Here I&#8217;d like to explain the line of thinking that finally led to me grokking regex.</p>

<!-- more -->


<p>For reference, I&#8217;ll be using the PERL-style regular expression syntax used by languages like PHP. Here&#8217;s a <a href="http://www.cheatography.com/davechild/cheat-sheets/regular-expressions/">Regular Expressions Cheat Sheet</a> That I&#8217;ll be referencing throughout this article, and it is a great resource to keep around.</p>

<h2>Regular Expressions: A Language Unto Itself</h2>

<p>The tricky thing about regular expressions is that it is its own language within a programming language. It has its own collection of symbols and syntax. Those long, scary strings that regexes are made up of are collections of these <em>symbols</em> and are used to make the <em>pattern</em> you want to match. Think of a regular expression as a <em>sentence</em>, and each one of the symbols as a <em>word</em>.</p>

<h2>Writing &#8220;Words&#8221; in Regular Expressions</h2>

<p>Most of the words of your regular expression are going to be made of a few different language constructs:</p>

<ul>
<li><strong>Ranges</strong> : defining a set of characters that can match. Common examples are <code>[A-Z]</code>, which means all capital letters, <code>[0-9]</code> or which means all digits. These can be combined as well. A common on is <code>[A-Za-z0-9-_]</code> which would match all letters, numbers, hyphens, and underscores.</li>
<li><strong>Character Classes</strong> : similar to ranges. <code>\s</code> means &#8216;any white space character&#8217;, where <code>\S</code> means &#8216;any non-white space character&#8217;.</li>
<li><strong>Metacharacters</strong> : characters that have thier own special meaning, the most common being the pipe <code>|</code> character, which means &#8216;or&#8217; similar to <code>||</code> in most programming languages. A subset of metacharacters is <em>anchors</em>, where can denote the beginning of a string (<code>^</code>) or the end of a string (<code>$</code>).</li>
<li><strong>Quantifiers</strong> : quantifiers are a kind of &#8216;modifier&#8217; to the above patterns. These let you tell the pattern how many of the previous pattern to look for. The common ones are: <code>*</code> for 0 or more, <code>+</code> for 1 or more, and <code>?</code> for 0 or 1. You can also explicity state an amount with something like <code>{5}</code> for 5 characters, or a range, such as <code>{3-6}</code>, which matches anywhere between three and six characters.</li>
</ul>


<h2>Building Patterns with Words</h2>

<p>Let&#8217;s look at the following example problem:</p>

<pre><code>we have a system that has to match social security numbers. 
They can look like any of the following:

123-45-6789
123/45/6789
123456789
</code></pre>

<p>so, now that we have the set of patterns we want to match, we can start building up smaller words to match each part of the pattern. Writing regular expressions is similar to writing functions or classes: you start by breaking down the problem, figuring out smaller parts of it, and then start working on combining these smaller solutions into a large one. So let&#8217;s start by writing out our pattern in plain english:</p>

<ul>
<li>We have the start of the string,</li>
<li>then three digits,</li>
<li>then either a hyphen, forward slash, or neither,</li>
<li>then two digits,</li>
<li>then either a hyphen, forward slash, or neither,</li>
<li>then four digits,</li>
<li>and that is the end of the string.</li>
</ul>


<p>So, let&#8217;s look at this step by step:</p>

<ul>
<li><strong>We have the start of the string</strong> : this is where we start with one of the anchors we mentioned earlier, <code>^</code>.</li>
<li><strong>Three Digits</strong> : We discussed the range of digits earlier (<code>[0-9]</code>), but that only matches a single digit. To match exactly 3, we will need a quantifier as well. So this word can be writen as <code>[0-9]{3}</code>.</li>
<li><strong>Either a hyphen, forward slash, or neither</strong> : this is going to take another quantifier, but which one? It helps if we rephrase this statement a bit, and think of it as this: &#8220;exactly 0 or 1 hyphen or forward slash&#8221;. Now we can see that we need the <code>?</code> quantifier. We also see that we&#8217;ll need to use an &#8216;or&#8217; for this statement. For statements like this, you can wrap this part of the expression in parenthesis so that its clear whats going on. The answer here is <code>(-|/)?</code>. Declaring parts of a regular expression inside of parenthesis like this is called defining a <em>subpattern</em></li>
<li><strong>Two Digits</strong> : similar to above: <code>[0-9]{2}</code>.</li>
<li><strong>Either a hyphen, forward slash, or neither</strong> : same as above: <code>(-|/)?</code>.</li>
<li><strong>Four Digits</strong> : similar to above: <code>[0-9]{4}</code>.</li>
<li><strong>End of the String</strong> : another anchor, the <code>$</code> one this time.</li>
</ul>


<p>So, now let&#8217;s put that all together, and we have a full regular expression:</p>

<p><code>^[0-9]{3}(-|/)?[0-9]{2}(-|/)?[0-9]{4}$</code></p>

<p>Tada! Now that you can see how the regular expressions is really just a bunch of small parts that fit together, hopefully you can figure out how to both write your own regular expressions, and read other ones you come across.</p>

<p>This is just the tip of the regex iceberg though. There is a whole lot more you can do with it that is much more than the span of this article. Play around with them, refer back to the cheatsheet, and see what you can come up with.</p>

<p><strong>Edit</strong></p>

<p>I realized there was a small problem with the regular expression above. While this work for most of our cases, there is the scenario of getting a number formatted like so: <code>123-45/6789</code> which the pattern would match, even though it is not in a valid format. I asked about this on <a href="http://stackoverflow.com/questions/9624081/matching-delimiters-with-regular-expressions/9624128">Stack Overflow</a> And learned about using <em>backreferences</em> for situations like this. you can use the syntax <code>\1</code> where 1 is the number of the subpattern you want to reference. By doing so, you can make sure that the second delimiter matches the first. So our regular expression would now look like this:</p>

<p><code>^[0-9]{3}(-|/)?[0-9]{2}\1?[0-9]{4}$</code></p>
]]></content>
  </entry>
  
  <entry>
    <title type="html"><![CDATA[Setting Up a Template and Assets in CodeIgniter]]></title>
    <link href="http://gsto.github.com/blog/2012/02/28/setting-up-a-template-and-assets-in-codeigniter/"/>
    <updated>2012-02-28T09:06:00-05:00</updated>
    <id>http://gsto.github.com/blog/2012/02/28/setting-up-a-template-and-assets-in-codeigniter</id>
    <content type="html"><![CDATA[<p><img class="left" src="images/articles/codeigniter.jpg" width="260">
In this article, I&#8217;d like to walk you though my first few steps when setting up a new CodeIgniter Project:
 - Setting up a way to render pages in a layout
 - Setting up a way to easily handle assets (CSS &amp; JavaScript files)</p>

<!-- more -->


<h3>Step 1: Creating A Template</h3>

<p>To start, we are going to make two new files, a layout view, and a localized controller. Let&#8217;s start by creating a <code>layout.php</code> file in <code>views</code>, and add the following:</p>

<figure class='code'><figcaption><span>application/views/layout.php  </span></figcaption>
 <div class="highlight"><table><tr><td class="gutter"><pre class="line-numbers"><span class='line-number'>1</span>
<span class='line-number'>2</span>
<span class='line-number'>3</span>
<span class='line-number'>4</span>
<span class='line-number'>5</span>
<span class='line-number'>6</span>
<span class='line-number'>7</span>
<span class='line-number'>8</span>
<span class='line-number'>9</span>
<span class='line-number'>10</span>
<span class='line-number'>11</span>
<span class='line-number'>12</span>
<span class='line-number'>13</span>
<span class='line-number'>14</span>
<span class='line-number'>15</span>
<span class='line-number'>16</span>
<span class='line-number'>17</span>
<span class='line-number'>18</span>
<span class='line-number'>19</span>
</pre></td><td class='code'><pre><code class='html'><span class='line'><span class="cp">&lt;!doctype html&gt;</span>
</span><span class='line'><span class="c">&lt;!--[if lt IE 7]&gt; &lt;html class=&quot;no-js lt-ie9 lt-ie8 lt-ie7&quot; lang=&quot;en&quot;&gt; &lt;![endif]--&gt;</span>
</span><span class='line'><span class="c">&lt;!--[if IE 7]&gt;    &lt;html class=&quot;no-js lt-ie9 lt-ie8&quot; lang=&quot;en&quot;&gt; &lt;![endif]--&gt;</span>
</span><span class='line'><span class="c">&lt;!--[if IE 8]&gt;    &lt;html class=&quot;no-js lt-ie9&quot; lang=&quot;en&quot;&gt; &lt;![endif]--&gt;</span>
</span><span class='line'><span class="c">&lt;!--[if gt IE 8]&gt;&lt;!--&gt;</span> <span class="nt">&lt;html</span> <span class="na">lang=</span><span class="s">&quot;en&quot;</span><span class="nt">&gt;</span> <span class="c">&lt;!--&lt;![endif]--&gt;</span>
</span><span class='line'><span class="nt">&lt;meta</span> <span class="na">charset=</span><span class="s">&#39;UTF-8&#39;</span><span class="nt">&gt;</span>
</span><span class='line'><span class="nt">&lt;meta</span> <span class="na">http-equiv=</span><span class="s">&#39;X-UA-Compatible&#39;</span> <span class="na">content=</span><span class="s">&#39;IE=edge,chrome=1&#39;</span><span class="nt">&gt;</span>
</span><span class='line'><span class="nt">&lt;meta</span> <span class="na">name=</span><span class="s">&quot;viewport&quot;</span> <span class="na">content=</span><span class="s">&quot;width=device-width&quot;</span> <span class="nt">/&gt;</span>
</span><span class='line'><span class="nt">&lt;title&gt;</span>Title Goes Here<span class="nt">&lt;/title&gt;</span>
</span><span class='line'><span class="c">&lt;!--[if IE 9]&gt;</span>
</span><span class='line'><span class="c">  &lt;style type=&quot;text/css&quot;&gt; .gradient { filter: none;} &lt;/style&gt;</span>
</span><span class='line'><span class="c">&lt;![endif]--&gt;</span>
</span><span class='line'><span class="c">&lt;!--[if lt IE 9]&gt;</span>
</span><span class='line'><span class="c">&lt;script src=&quot;http://html5shiv.googlecode.com/svn/trunk/html5.js&quot;&gt;&lt;/script&gt;</span>
</span><span class='line'><span class="c">&lt;![endif]--&gt;</span>
</span><span class='line'><span class="nt">&lt;/head&gt;</span>
</span><span class='line'><span class="nt">&lt;body&gt;</span>
</span><span class='line'><span class="nt">&lt;/body&gt;</span>
</span><span class='line'><span class="nt">&lt;/html&gt;</span>
</span></code></pre></td></tr></table></div></figure>


<p>This is based on the <a href="paulirish.com/2008/conditional-stylesheets-vs-css-hacks-answer-neither/">HTML5 set up from Paul Irish</a>. We&#8217;ll use this as the basis for all of our pages. Now, to use this, we are going to create a <code>MY_Controller</code> inside of <code>appliction/core/MY_Controller.php</code>, and create a new function that we&#8217;ll call <code>render</code></p>

<figure class='code'><figcaption><span>application/core/MY_Controller.php  </span></figcaption>
 <div class="highlight"><table><tr><td class="gutter"><pre class="line-numbers"><span class='line-number'>1</span>
<span class='line-number'>2</span>
<span class='line-number'>3</span>
<span class='line-number'>4</span>
<span class='line-number'>5</span>
<span class='line-number'>6</span>
<span class='line-number'>7</span>
<span class='line-number'>8</span>
<span class='line-number'>9</span>
<span class='line-number'>10</span>
<span class='line-number'>11</span>
</pre></td><td class='code'><pre><code class='php'><span class='line'><span class="cp">&lt;?php</span> <span class="k">if</span> <span class="p">(</span> <span class="o">!</span> <span class="nb">defined</span><span class="p">(</span><span class="s1">&#39;BASEPATH&#39;</span><span class="p">))</span> <span class="k">exit</span><span class="p">(</span><span class="s1">&#39;No direct script access allowed&#39;</span><span class="p">);</span>
</span><span class='line'>
</span><span class='line'><span class="k">class</span> <span class="nc">MY_Controller</span> <span class="k">extends</span> <span class="nx">CI_Controller</span> <span class="p">{</span>
</span><span class='line'>  <span class="k">protected</span> <span class="nv">$layout</span> <span class="o">=</span> <span class="s1">&#39;layout&#39;</span><span class="p">;</span>
</span><span class='line'>  <span class="k">protected</span> <span class="k">function</span> <span class="nf">render</span><span class="p">(</span><span class="nv">$content</span><span class="p">)</span> <span class="p">{</span>
</span><span class='line'>    <span class="nv">$view_data</span> <span class="o">=</span> <span class="k">array</span><span class="p">(</span>
</span><span class='line'>      <span class="s1">&#39;content&#39;</span> <span class="o">=&gt;</span> <span class="nv">$content</span>
</span><span class='line'>    <span class="p">);</span>
</span><span class='line'>    <span class="nv">$this</span><span class="o">-&gt;</span><span class="na">load</span><span class="o">-&gt;</span><span class="na">view</span><span class="p">(</span><span class="nv">$this</span><span class="o">-&gt;</span><span class="na">layout</span><span class="p">,</span><span class="nv">$view_data</span><span class="p">);</span>
</span><span class='line'>  <span class="p">}</span>
</span><span class='line'><span class="p">}</span>
</span></code></pre></td></tr></table></div></figure>


<p>This will allow us to use the layout file to wrap all of our content. We&#8217;ve also stored the layout file as a protected variable of the MY_Controller, so that we can use different layouts for different controllers if we so choose. Now, let&#8217;s modify the template file to be able to render the content. Change the body tag so that it looks like this:</p>

<figure class='code'><figcaption><span>application/views/layout.php  </span></figcaption>
 <div class="highlight"><table><tr><td class="gutter"><pre class="line-numbers"><span class='line-number'>1</span>
<span class='line-number'>2</span>
<span class='line-number'>3</span>
</pre></td><td class='code'><pre><code class='html'><span class='line'><span class="nt">&lt;body&gt;</span>
</span><span class='line'>  <span class="cp">&lt;?= $content; ?&gt;</span>
</span><span class='line'><span class="nt">&lt;/body&gt;</span>
</span></code></pre></td></tr></table></div></figure>


<p>Now, let&#8217;s set up an example view and an example controller to see how it works.</p>

<figure class='code'><figcaption><span>application/views/example/index.php  </span></figcaption>
 <div class="highlight"><table><tr><td class="gutter"><pre class="line-numbers"><span class='line-number'>1</span>
<span class='line-number'>2</span>
</pre></td><td class='code'><pre><code class='html'><span class='line'>  <span class="nt">&lt;h1&gt;</span>Hello, World!<span class="nt">&lt;/h1&gt;</span>
</span><span class='line'>  <span class="nt">&lt;p&gt;</span> Example page using layouts <span class="nt">&lt;/p&gt;</span>
</span></code></pre></td></tr></table></div></figure>




<figure class='code'><figcaption><span>application/controllers/example.php  </span></figcaption>
 <div class="highlight"><table><tr><td class="gutter"><pre class="line-numbers"><span class='line-number'>1</span>
<span class='line-number'>2</span>
<span class='line-number'>3</span>
<span class='line-number'>4</span>
<span class='line-number'>5</span>
<span class='line-number'>6</span>
<span class='line-number'>7</span>
<span class='line-number'>8</span>
</pre></td><td class='code'><pre><code class='php'><span class='line'><span class="cp">&lt;?php</span> <span class="k">if</span> <span class="p">(</span> <span class="o">!</span> <span class="nb">defined</span><span class="p">(</span><span class="s1">&#39;BASEPATH&#39;</span><span class="p">))</span> <span class="k">exit</span><span class="p">(</span><span class="s1">&#39;No direct script access allowed&#39;</span><span class="p">);</span>
</span><span class='line'>
</span><span class='line'><span class="k">class</span> <span class="nc">Example</span> <span class="k">extends</span> <span class="nx">MY_Controller</span> <span class="p">{</span>
</span><span class='line'>  <span class="k">public</span> <span class="k">function</span> <span class="nf">index</span><span class="p">()</span> <span class="p">{</span>
</span><span class='line'>    <span class="nv">$content</span> <span class="o">=</span> <span class="nv">$this</span><span class="o">-&gt;</span><span class="na">load</span><span class="o">-&gt;</span><span class="na">view</span><span class="p">(</span><span class="s1">&#39;example/index&#39;</span><span class="p">,</span><span class="k">null</span><span class="p">,</span><span class="k">true</span><span class="p">);</span>
</span><span class='line'>    <span class="nv">$this</span><span class="o">-&gt;</span><span class="na">render</span><span class="p">(</span><span class="nv">$content</span><span class="p">);</span>
</span><span class='line'>  <span class="p">}</span>
</span><span class='line'><span class="p">}</span>
</span></code></pre></td></tr></table></div></figure>


<h3>Step 2: Adding the Asset Helper</h3>

<p>To help us manage our CSS, JavaScript, and image files, we are going to add some tools for asset manage. First, let&#8217;s include this <a href="http://codeigniter.com/wiki/Asset_Helper">Asset Helper</a> In our project, and update our <code>autoload.php</code> file so that it is automatically included. Now we are going to set up the directory structure for this. Here is how to do it from the base of your CodeIgniter project (assuming you are using the standard naming conventions):</p>

<pre><code>mkdir assets
mkdir assets/css
touch assets/css/app.css
mkdir assets/js
touch assets/js/app.js
mkdir assets/images
</code></pre>

<p>Now, we are going to keep a list of all of the standard CSS and JavaScript files inside of our MY_Controller, and pass them along to the layout:</p>

<figure class='code'><figcaption><span>application/core/MY_Controller.php  </span></figcaption>
 <div class="highlight"><table><tr><td class="gutter"><pre class="line-numbers"><span class='line-number'>1</span>
<span class='line-number'>2</span>
<span class='line-number'>3</span>
<span class='line-number'>4</span>
<span class='line-number'>5</span>
<span class='line-number'>6</span>
<span class='line-number'>7</span>
<span class='line-number'>8</span>
<span class='line-number'>9</span>
<span class='line-number'>10</span>
<span class='line-number'>11</span>
<span class='line-number'>12</span>
<span class='line-number'>13</span>
<span class='line-number'>14</span>
<span class='line-number'>15</span>
<span class='line-number'>16</span>
<span class='line-number'>17</span>
<span class='line-number'>18</span>
<span class='line-number'>19</span>
<span class='line-number'>20</span>
<span class='line-number'>21</span>
<span class='line-number'>22</span>
<span class='line-number'>23</span>
<span class='line-number'>24</span>
<span class='line-number'>25</span>
<span class='line-number'>26</span>
<span class='line-number'>27</span>
<span class='line-number'>28</span>
</pre></td><td class='code'><pre><code class='php'><span class='line'><span class="cp">&lt;?php</span> <span class="k">if</span> <span class="p">(</span> <span class="o">!</span> <span class="nb">defined</span><span class="p">(</span><span class="s1">&#39;BASEPATH&#39;</span><span class="p">))</span> <span class="k">exit</span><span class="p">(</span><span class="s1">&#39;No direct script access allowed&#39;</span><span class="p">);</span>
</span><span class='line'>
</span><span class='line'><span class="k">class</span> <span class="nc">MY_Controller</span> <span class="k">extends</span> <span class="nx">CI_Controller</span> <span class="p">{</span>
</span><span class='line'>  <span class="k">protected</span> <span class="nv">$layout</span> <span class="o">=</span> <span class="s1">&#39;layout&#39;</span><span class="p">;</span>
</span><span class='line'>  <span class="k">protected</span> <span class="nv">$stylesheets</span> <span class="o">=</span> <span class="k">array</span><span class="p">(</span>
</span><span class='line'>    <span class="s1">&#39;app.css&#39;</span>
</span><span class='line'>  <span class="p">);</span>
</span><span class='line'>  <span class="k">protected</span> <span class="nv">$javascripts</span> <span class="o">=</span> <span class="k">array</span><span class="p">(</span>
</span><span class='line'>  <span class="s1">&#39;app.js&#39;</span>
</span><span class='line'>  <span class="p">);</span>
</span><span class='line'>
</span><span class='line'>  <span class="k">protected</span> <span class="k">function</span> <span class="nf">render</span><span class="p">(</span><span class="nv">$content</span><span class="p">)</span> <span class="p">{</span>
</span><span class='line'>    <span class="nv">$view_data</span> <span class="o">=</span> <span class="k">array</span><span class="p">(</span>
</span><span class='line'>      <span class="s1">&#39;content&#39;</span> <span class="o">=&gt;</span> <span class="nv">$content</span><span class="p">,</span>
</span><span class='line'>      <span class="s1">&#39;stylesheets&#39;</span> <span class="o">=&gt;</span> <span class="nv">$this</span><span class="o">-&gt;</span><span class="na">get_stylesheets</span><span class="p">(),</span>
</span><span class='line'>      <span class="s1">&#39;javascripts&#39;</span> <span class="o">=&gt;</span> <span class="nv">$this</span><span class="o">-&gt;</span><span class="na">get_javascripts</span><span class="p">()</span>
</span><span class='line'>    <span class="p">);</span>
</span><span class='line'>    <span class="nv">$this</span><span class="o">-&gt;</span><span class="na">load</span><span class="o">-&gt;</span><span class="na">view</span><span class="p">(</span><span class="nv">$this</span><span class="o">-&gt;</span><span class="na">layout</span><span class="p">,</span><span class="nv">$view_data</span><span class="p">);</span>
</span><span class='line'>  <span class="p">}</span>
</span><span class='line'>
</span><span class='line'>  <span class="k">protected</span> <span class="k">function</span> <span class="nf">get_stylesheets</span><span class="p">()</span> <span class="p">{</span>
</span><span class='line'>    <span class="k">return</span> <span class="nv">$this</span><span class="o">-&gt;</span><span class="na">stylesheets</span><span class="p">;</span>
</span><span class='line'>  <span class="p">}</span>
</span><span class='line'>
</span><span class='line'>  <span class="k">protected</span> <span class="k">function</span> <span class="nf">get_javascripts</span><span class="p">()</span> <span class="p">{</span>
</span><span class='line'>    <span class="k">return</span> <span class="nv">$this</span><span class="o">-&gt;</span><span class="na">javascripts</span><span class="p">;</span>
</span><span class='line'>  <span class="p">}</span>
</span><span class='line'><span class="p">}</span>
</span></code></pre></td></tr></table></div></figure>


<p>And now we&#8217;ll update our template using the <code>css_asset()</code> and <code>js_asset()</code> functions from the helper we included earlier:</p>

<figure class='code'><figcaption><span>application/views/layout.php  </span></figcaption>
 <div class="highlight"><table><tr><td class="gutter"><pre class="line-numbers"><span class='line-number'>1</span>
<span class='line-number'>2</span>
<span class='line-number'>3</span>
<span class='line-number'>4</span>
<span class='line-number'>5</span>
<span class='line-number'>6</span>
<span class='line-number'>7</span>
<span class='line-number'>8</span>
<span class='line-number'>9</span>
</pre></td><td class='code'><pre><code class='php'><span class='line'><span class="x">&lt;!-- in the &lt;head&gt; .. --&gt;</span>
</span><span class='line'><span class="cp">&lt;?</span> <span class="k">foreach</span><span class="p">(</span><span class="nv">$stylesheets</span> <span class="k">as</span> <span class="nv">$stylesheet</span><span class="p">)</span><span class="o">:</span> <span class="cp">?&gt;</span><span class="x"></span>
</span><span class='line'><span class="x">  </span><span class="cp">&lt;?</span><span class="o">=</span> <span class="nx">css_asset</span><span class="p">(</span><span class="nv">$stylesheet</span><span class="p">);</span> <span class="cp">?&gt;</span><span class="x">    </span>
</span><span class='line'><span class="cp">&lt;?</span> <span class="k">endforeach</span><span class="p">;</span> <span class="cp">?&gt;</span><span class="x"></span>
</span><span class='line'>
</span><span class='line'><span class="x">&lt;!-- right before &lt;body&gt; --&gt;</span>
</span><span class='line'><span class="cp">&lt;?</span> <span class="k">foreach</span><span class="p">(</span><span class="nv">$javascripts</span> <span class="k">as</span> <span class="nv">$javascript</span><span class="p">)</span><span class="o">:</span> <span class="cp">?&gt;</span><span class="x"></span>
</span><span class='line'><span class="x">  </span><span class="cp">&lt;?</span><span class="o">=</span> <span class="nx">js_asset</span><span class="p">(</span><span class="nv">$javascript</span><span class="p">);</span> <span class="cp">?&gt;</span><span class="x"></span>
</span><span class='line'><span class="cp">&lt;?</span> <span class="k">endforeach</span><span class="p">;</span> <span class="cp">?&gt;</span><span class="x"></span>
</span></code></pre></td></tr></table></div></figure>


<p>If you view the source, you should see that your <code>app.css</code> and <code>app.js</code> files are now included.</p>

<h3>Step 3: Adding Local Assets</h3>

<p>One of the better ideas Rails 3.0 brought to the table was the idea of the &#8216;asset pipeline&#8217;, which includes being able to define JavaScript and CSS files that are specific to a particular controller. Now let&#8217;s set up our CodeIgniter project to be able to behave in a similar manner.</p>

<p>This was my motivation for writing the <code>get_stylesheets()</code> and <code>get_javascripts()</code> functions in the <code>MY_Controller</code> class earlier. since we are going to be changing how we get the arrays, we can now do so without touching the <code>render()</code> function since we have abstracted out the interface in which we get our files.</p>

<p>So let&#8217;s update those two functions, and add two more protected variables to our <code>MY_Controller</code> file:</p>

<figure class='code'><figcaption><span>application/core/MY_Controller.php  </span></figcaption>
 <div class="highlight"><table><tr><td class="gutter"><pre class="line-numbers"><span class='line-number'>1</span>
<span class='line-number'>2</span>
<span class='line-number'>3</span>
<span class='line-number'>4</span>
<span class='line-number'>5</span>
<span class='line-number'>6</span>
<span class='line-number'>7</span>
<span class='line-number'>8</span>
<span class='line-number'>9</span>
<span class='line-number'>10</span>
<span class='line-number'>11</span>
<span class='line-number'>12</span>
<span class='line-number'>13</span>
<span class='line-number'>14</span>
<span class='line-number'>15</span>
<span class='line-number'>16</span>
<span class='line-number'>17</span>
<span class='line-number'>18</span>
<span class='line-number'>19</span>
<span class='line-number'>20</span>
<span class='line-number'>21</span>
<span class='line-number'>22</span>
<span class='line-number'>23</span>
</pre></td><td class='code'><pre><code class='php'><span class='line'><span class="cp">&lt;?php</span> <span class="k">if</span> <span class="p">(</span> <span class="o">!</span> <span class="nb">defined</span><span class="p">(</span><span class="s1">&#39;BASEPATH&#39;</span><span class="p">))</span> <span class="k">exit</span><span class="p">(</span><span class="s1">&#39;No direct script access allowed&#39;</span><span class="p">);</span>
</span><span class='line'><span class="k">class</span> <span class="nc">MY_Controller</span> <span class="k">extends</span> <span class="nx">CI_Controller</span> <span class="p">{</span>
</span><span class='line'>  <span class="k">protected</span> <span class="nv">$layout</span> <span class="o">=</span> <span class="s1">&#39;layout&#39;</span><span class="p">;</span>
</span><span class='line'>  <span class="k">protected</span> <span class="nv">$stylesheets</span> <span class="o">=</span> <span class="k">array</span><span class="p">(</span>
</span><span class='line'>    <span class="s1">&#39;app.css&#39;</span>
</span><span class='line'>  <span class="p">);</span>
</span><span class='line'>  <span class="k">protected</span> <span class="nv">$javascripts</span> <span class="o">=</span> <span class="k">array</span><span class="p">(</span>
</span><span class='line'>  <span class="s1">&#39;app.js&#39;</span>
</span><span class='line'>  <span class="p">);</span>
</span><span class='line'>  <span class="k">protected</span> <span class="nv">$local_stylesheets</span> <span class="o">=</span> <span class="k">array</span><span class="p">();</span>
</span><span class='line'>  <span class="k">protected</span> <span class="nv">$local_javascripts</span> <span class="o">=</span> <span class="k">array</span><span class="p">();</span>
</span><span class='line'>
</span><span class='line'>  <span class="c1">//other parts of the class..</span>
</span><span class='line'>
</span><span class='line'>  <span class="k">protected</span> <span class="k">function</span> <span class="nf">get_stylesheets</span><span class="p">()</span> <span class="p">{</span>
</span><span class='line'>    <span class="k">return</span> <span class="nb">array_merge</span><span class="p">(</span><span class="nv">$this</span><span class="o">-&gt;</span><span class="na">stylesheets</span><span class="p">,</span><span class="nv">$this</span><span class="o">-&gt;</span><span class="na">local_stylesheets</span><span class="p">);</span>
</span><span class='line'>  <span class="p">}</span>
</span><span class='line'>
</span><span class='line'>  <span class="k">protected</span> <span class="k">function</span> <span class="nf">get_javascripts</span><span class="p">()</span> <span class="p">{</span>
</span><span class='line'>    <span class="k">return</span> <span class="nb">array_merge</span><span class="p">(</span><span class="nv">$this</span><span class="o">-&gt;</span><span class="na">javascripts</span><span class="p">,</span><span class="nv">$this</span><span class="o">-&gt;</span><span class="na">local_javascripts</span><span class="p">);</span>
</span><span class='line'>  <span class="p">}</span>
</span><span class='line'>
</span><span class='line'><span class="p">}</span>
</span></code></pre></td></tr></table></div></figure>


<p>Now we are able to add additional asset files to the <code>local_stylesheets</code> and <code>local_javascripts</code> variables in classes that extend <code>MY_Controller</code>, allowing us to keep our code seperated and more organized. With this and templates, we now have a good system in place to manage the visual aspects of our web application.</p>
]]></content>
  </entry>
  
  <entry>
    <title type="html"><![CDATA[Terminals for Absolute Beginners: Part 1]]></title>
    <link href="http://gsto.github.com/blog/2012/02/15/terminals-for-absolute-beginners/"/>
    <updated>2012-02-15T09:35:00-05:00</updated>
    <id>http://gsto.github.com/blog/2012/02/15/terminals-for-absolute-beginners</id>
    <content type="html"><![CDATA[<h3>Directories and Commands</h3>

<p><img class="left" src="http://gsto.github.com/images/articles/terminal.jpg" width="260"></p>

<p>You&#8217;ve woken up in a strange place. Maybe you&#8217;ve decided you want to be a power user with your mac. Maybe you&#8217;ve finally decided to check out this strangle &#8216;Linux&#8217; thing you&#8217;ve heard so much about.  Maybe its your first day in software engineering class and the teacher is telling you you are going to have to work on the school&#8217;s server to turn in all of your work. Either way, you find yourself eye-to-eye with a terminal (commonly called the <em>command line</em>) and you don&#8217;t know what to do.</p>

<!-- more -->


<h3>Where Are We?</h3>

<p>Let&#8217;s start by doing what anyone would do when dropped off in a new strange land. Let&#8217;s figure out where we are and take stock of our surroundings.  Type the following command:</p>

<pre><code>pwd
</code></pre>

<p>this will tell you the directory you are currently in. It may look something like this:</p>

<pre><code>/home/glenn/
</code></pre>

<p>Let&#8217;s make sure we are still who we think we are:</p>

<pre><code>whoami
</code></pre>

<p>This will tell you your username:</p>

<pre><code>glenn
</code></pre>

<p>Now, let&#8217;s see what else is in the directory with us:</p>

<pre><code>ls
</code></pre>

<p>this gives us a list of all the files and directories in the directory we are currently in. but maybe we want a bit more information about this. let&#8217;s type the following command:</p>

<pre><code>ls -la
</code></pre>

<p>and we get something like this:</p>

<pre><code>drwxr-xr-x 70 grp   glenn    4096 2012-02-15 09:35 .
drwxr-xr-x  3 root  root     4096 2011-03-15 16:55 ..
drwxr-xr-x  2 grp   glenn    4096 2012-02-07 09:21 Pictures
drwxr-xr-x  2 grp   glenn    4096 2011-08-23 15:29 Public
drwxr-xr-x  5 grp   glenn    4096 2011-09-28 13:30 Rails
drwxr-xr-x  6 grp   glenn    4096 2011-11-08 16:35 Repositories
drwxr-xr-x 12 grp   glenn    4096 2012-01-15 17:09 Server
drwxr-xr-x  2 grp   glenn    4096 2011-03-15 17:03 Templates
drwxrwxr-x  2 grp   glenn    4096 2011-08-11 08:46 Ubuntu One
drwxr-xr-x  2 grp   glenn    4096 2011-03-15 17:03 Videos
</code></pre>

<p>Whoa! there is a lot to take in here. Why did adding <code>-la</code> to the <code>ls</code> command change the output so much, And what is all of this stuff in front of the file names now? Why are there two files named <code>.</code> and <code>..</code>?</p>

<h3>Commands And Options</h3>

<p><code>ls</code> and <code>pwd</code> are both <em>commands</em>. <code>pwd</code> is short for <strong>P</strong>rint <strong>W</strong>orking <strong>D</strong>irectory and well, prints your current working directory. <code>ls</code> is shorthand for list and lists the contents of the current working directory. These are the first of many commands we&#8217;ll  be going over. You can pass options to commands to change how they work. These are almost always formatted in the form of a single hyphen and a single letter, or two hypens and a complete word.  You can combine single letter options with one hyphen, which is what we did when we typed <code>ls -la</code>. You could also write <code>ls -l</code> and <code>ls -a</code> and both would be valid commands. the <code>-l</code> argument tells the <code>ls</code> command to list the files on a single line with additional details. The <code>-a</code> command tells <code>ls</code> to show all files, including hidden ones. All directories contain at least two hidden directories, one called <code>.</code> and one called <code>..</code>, but we&#8217;ll get to those in a moment.</p>

<p>Many commands have similar options, where the same arguments have similar effects with similar commands. There is one option that works with almost every command on the terminal, and its the most important one you&#8217;ll ever learn. Are you ready? Got a pen?</p>

<pre><code>--help
</code></pre>

<p>This will print out an explination of the commands function, and a list of options it can take and what they do. Go try running the following commands and checkout the output:</p>

<pre><code>whoami --help
ls --help
</code></pre>

<p>You&#8217;ll see that <code>whoami</code> is a relatively simple command with very few arguments, where <code>ls</code> has a lot more options availble. I could just replace a lot of text in this and upcoming articles with &#8220;just run <code>--help</code>&#8221;, but I&#8217;m not going to. Feel free to explore some of the other commands and options that are available to them, and see what you can do with them.</p>

<h3>Traversing Directories</h3>

<p>Now I bet you are still wondering about that <code>.</code> and <code>..</code> stuff. These are both directories, or rather things that point to directories, that can be found in every single directory inside of linux based system. <code>.</code> Always points to the current directory. <code>..</code> Always points to the parent directory. If your current working directory is <code>/home/glenn/</code>, then <code>..</code> would point to <code>/home/</code>. If you make it all the way to the bottom directory (<code>/</code>), then <code>..</code> will still be there, but will also point to <code>/</code>.</p>

<p>Now let&#8217;s learn how to change our working directory so that we can start traversing the folders around us. This brings us to our next command and last one of this article:</p>

<pre><code>cd
</code></pre>

<p><code>cd</code> is short for &#8216;Change Directory&#8217;. To use this, we&#8217;ll look at another thing we can do with commands: pass <strong>arguments</strong> to them.</p>

<h3>Passing Arguments</h3>

<p>Commands take arguments when they need additional information on what they do. You could think of it as a &#8216;target&#8217; for the command. Commands can take multiple arguments, but in this case we&#8217;ll only need one: Telling cd what directory we would like to change our directory too. So, if we want to go into the <code>Pictures</code> directory earlier. try running these two commands:</p>

<pre><code>cd Pictures
pwd
</code></pre>

<p>Now, based on the folder structure we looked at earlier, we should get an output similar to this:</p>

<pre><code>/home/glenn/Pictures
</code></pre>

<p>If we wanted to go back to where we were, we can reference that <code>..</code> directory:</p>

<pre><code>cd ..
pwd
</code></pre>

<p>and we are back at</p>

<pre><code>/home/glenn
</code></pre>

<h3>cd ProTips</h3>

<p>You can chain together directories to move multiple steps at once, like so:</p>

<pre><code>cd Pictures/Vacations/Vegas
cd ../../../
</code></pre>

<p>There are also two handy shortcuts available to the <code>cd</code> command:</p>

<pre><code>cd -
cd ~
</code></pre>

<p>the first is sort of an &#8216;undo&#8217; option. if will take you back to your last working directory. the tilde (<code>~</code>) is short hand for your <em>home directory</em> which every user has.</p>
]]></content>
  </entry>
  
  <entry>
    <title type="html"><![CDATA[Blogging With Octopress]]></title>
    <link href="http://gsto.github.com/blog/2012/02/11/blogging-with-octopress/"/>
    <updated>2012-02-11T10:00:00-05:00</updated>
    <id>http://gsto.github.com/blog/2012/02/11/blogging-with-octopress</id>
    <content type="html"><![CDATA[<p><img class="left" src="http://gsto.github.com/images/articles/blog_with_octopress.png" width="260">
If you&#8217;re reading this, then I&#8217;ve successfully got my octopress blog up and running on Github pages. Why the switch to octopress?</p>

<!-- more -->


<h2>Writing with Octopress</h2>

<p>I love being able to write in emacs using markdown. It feels simple. It feels easy. It feels right.</p>

<h2>Deploying with Github</h2>

<p>This also allows me to host with github pages for free, and use git for deployment. So many headaches just went away for me when it comes to writing.</p>

<h2>Version Control based writing.</h2>

<p>I can take the same approach to writing as I can with coding, publishing fast, fixing mistakes as they are found, and changing content as need be. What you are currently reading isn&#8217;t the first version of the post, and likely not the last.
I also like the idea of &#8216;open source&#8217; writing. If anyone has anything they would like to add or change, feel free to send a pull request to this repo, and I&#8217;ll take it under consideration.</p>

<h2>The Right Plugins</h2>

<p>There aren&#8217;t many plugins or themes available for octopress (yet), but it has all the things that are needed to get good content going. That&#8217;s what I love about it, it is all content based. The default theme is a beautiful starting off point, it&#8217;s clear and responsive.</p>
]]></content>
  </entry>
  
</feed>

