<?xml version="1.0" encoding="UTF-8"?>
<?xml-stylesheet type="text/xsl" media="screen" href="/~d/styles/atom10full.xsl"?><?xml-stylesheet type="text/css" media="screen" href="http://feeds.shapeshed.com/~d/styles/itemcontent.css"?><feed xmlns="http://www.w3.org/2005/Atom" xmlns:feedburner="http://rssnamespace.org/feedburner/ext/1.0" xml:lang="en">
  <title type="text">Shape Shed</title>
  <link rel="alternate" type="text/html" href="http://shapeshed.com/journal/" />
  <subtitle type="text">Articles on web applications and user interface design</subtitle>
  <link rel="alternate" type="text/html" href="http://shapeshed.com/journal/" />
  
  <updated>2010-08-31T08:28:46+01:00</updated>
  <rights>Copyright (c) 2009, George Ornbo</rights>
  <generator uri="http://github.com/mojombo/jekyll" version="0.5.4">Jekyll</generator>

  <id>tag:shapeshed.com,2009:09:04</id>
  <author>
   <name>George Ornbo</name>
   <email>no-reply@shapeshed.com</email>
  </author>
 
 
 <atom10:link xmlns:atom10="http://www.w3.org/2005/Atom" rel="self" type="application/atom+xml" href="http://feeds.shapeshed.com/shapeshed" /><feedburner:info uri="shapeshed" /><atom10:link xmlns:atom10="http://www.w3.org/2005/Atom" rel="hub" href="http://pubsubhubbub.appspot.com/" /><link rel="license" type="text/html" href="http://creativecommons.org/licenses/by/3.0/" /><xhtml:meta xmlns:xhtml="http://www.w3.org/1999/xhtml" name="robots" content="noindex" /><feedburner:emailServiceId>shapeshed</feedburner:emailServiceId><feedburner:feedburnerHostname>http://feedburner.google.com</feedburner:feedburnerHostname><entry>
   <title>Setting up node.js and npm on Mac OSX</title>
   <link href="http://feeds.shapeshed.com/~r/shapeshed/~3/xDQO1HC0tnM/" />
   <updated>2010-08-30T00:00:00+01:00</updated>
   <published>2010-08-30T00:00:00+01:00</published>
   <id>http://shapeshed.com/journal/setting-up-nodejs-and-npm-on-mac-osx</id>
   <content type="html">
   &lt;h2&gt;Install Homebrew&lt;/h2&gt;

&lt;p&gt;&lt;a href="http://github.com/mxcl/homebrew"&gt;Homebrew&lt;/a&gt; is the package manager that Apple forgot. Written in Ruby it allows you to quickly and easily compile software on your Mac. Instructions for installing Homebrew are in the &lt;a href="http://github.com/mxcl/homebrew/blob/master/README.md"&gt;README&lt;/a&gt; so I won't repeat them here. You will need to install Developer Tools for Mac which you are installed as part of &lt;a href="http://developer.apple.com/technologies/xcode.html"&gt;Xcode&lt;/a&gt;. Xcode is available for free - it is a pretty hefty download but you'll need it.&lt;/p&gt;

&lt;h2&gt;Install node.js via homebrew&lt;/h2&gt;

&lt;p&gt;Once Homebrew is installed you can go ahead and install node.js&lt;/p&gt;

&lt;div class="highlight"&gt;&lt;pre&gt;&lt;code class="bash"&gt;brew install node
&lt;/code&gt;&lt;/pre&gt;
&lt;/div&gt;


&lt;p&gt;Easy! Now create a file called server.js and paste in the example server code&lt;/p&gt;

&lt;div class="highlight"&gt;&lt;pre&gt;&lt;code class="javascript"&gt;&lt;span class="kd"&gt;var&lt;/span&gt; &lt;span class="nx"&gt;http&lt;/span&gt; &lt;span class="o"&gt;=&lt;/span&gt; &lt;span class="nx"&gt;require&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="s1"&gt;&amp;#39;http&amp;#39;&lt;/span&gt;&lt;span class="p"&gt;);&lt;/span&gt;
&lt;span class="nx"&gt;http&lt;/span&gt;&lt;span class="p"&gt;.&lt;/span&gt;&lt;span class="nx"&gt;createServer&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="kd"&gt;function&lt;/span&gt; &lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="nx"&gt;req&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt; &lt;span class="nx"&gt;res&lt;/span&gt;&lt;span class="p"&gt;)&lt;/span&gt; &lt;span class="p"&gt;{&lt;/span&gt;
  &lt;span class="nx"&gt;res&lt;/span&gt;&lt;span class="p"&gt;.&lt;/span&gt;&lt;span class="nx"&gt;writeHead&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="mi"&gt;200&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt; &lt;span class="p"&gt;{&lt;/span&gt;&lt;span class="s1"&gt;&amp;#39;Content-Type&amp;#39;&lt;/span&gt;&lt;span class="o"&gt;:&lt;/span&gt; &lt;span class="s1"&gt;&amp;#39;text/plain&amp;#39;&lt;/span&gt;&lt;span class="p"&gt;});&lt;/span&gt;
  &lt;span class="nx"&gt;res&lt;/span&gt;&lt;span class="p"&gt;.&lt;/span&gt;&lt;span class="nx"&gt;end&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="s1"&gt;&amp;#39;Hello World\n&amp;#39;&lt;/span&gt;&lt;span class="p"&gt;);&lt;/span&gt;
&lt;span class="p"&gt;}).&lt;/span&gt;&lt;span class="nx"&gt;listen&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="mi"&gt;8124&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt; &lt;span class="s2"&gt;&amp;quot;127.0.0.1&amp;quot;&lt;/span&gt;&lt;span class="p"&gt;);&lt;/span&gt;
&lt;span class="nx"&gt;console&lt;/span&gt;&lt;span class="p"&gt;.&lt;/span&gt;&lt;span class="nx"&gt;log&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="s1"&gt;&amp;#39;Server running at http://127.0.0.1:8124/&amp;#39;&lt;/span&gt;&lt;span class="p"&gt;);&lt;/span&gt;
&lt;/code&gt;&lt;/pre&gt;
&lt;/div&gt;


&lt;p&gt;Save the file and from the console run&lt;/p&gt;

&lt;div class="highlight"&gt;&lt;pre&gt;&lt;code class="bash"&gt;node server.js
&lt;/code&gt;&lt;/pre&gt;
&lt;/div&gt;


&lt;p&gt;Now you can visit http://127.0.0.1:8124/ with your favourite browser and you are up and running with server side JavaScript.&lt;/p&gt;

&lt;p&gt;At this point it is probably a good idea to consult the excellent &lt;a href="http://nodejs.org/api.html"&gt;node.js documentation&lt;/a&gt;. This will help you understand what node.js is and what it can do.&lt;/p&gt;

&lt;h2&gt;Installing npm&lt;/h2&gt;

&lt;p&gt;node.js is pretty low level so lots of people have created modules for node. Thankfully there is already a package manager for node in &lt;a href="http://github.com/isaacs/npm"&gt;npm&lt;/a&gt; to help you manage these.&lt;/p&gt;

&lt;p&gt;You can install it using Homebrew&lt;/p&gt;

&lt;div class="highlight"&gt;&lt;pre&gt;&lt;code class="bash"&gt;brew install npm
&lt;/code&gt;&lt;/pre&gt;
&lt;/div&gt;


&lt;p&gt;The install will spit out some advice about paths. I found on my setup everything worked other than having to set NODE_PATH.&lt;/p&gt;

&lt;p&gt;NODE_PATH tells node.js where to look for modules. This means you can do things like&lt;/p&gt;

&lt;div class="highlight"&gt;&lt;pre&gt;&lt;code class="javascript"&gt;&lt;span class="kd"&gt;var&lt;/span&gt; &lt;span class="nx"&gt;client&lt;/span&gt; &lt;span class="o"&gt;=&lt;/span&gt; &lt;span class="nx"&gt;require&lt;/span&gt; &lt;span class="s1"&gt;&amp;#39;redis-client&amp;#39;&lt;/span&gt;
&lt;/code&gt;&lt;/pre&gt;
&lt;/div&gt;


&lt;p&gt;instead of specifying the full path.&lt;/p&gt;

&lt;p&gt;To make sure my shell knows where to find node modules I added&lt;/p&gt;

&lt;div class="highlight"&gt;&lt;pre&gt;&lt;code class="bash"&gt;&lt;span class="nb"&gt;export &lt;/span&gt;&lt;span class="nv"&gt;NODE_PATH&lt;/span&gt;&lt;span class="o"&gt;=&lt;/span&gt;&lt;span class="s2"&gt;&amp;quot;/usr/local/lib/node&amp;quot;&lt;/span&gt;
&lt;/code&gt;&lt;/pre&gt;
&lt;/div&gt;


&lt;p&gt;to my .bash_profile file. As some modules have executables you will also need to add /usr/local/share/npm/bin to your PATH. Here's how mine looks&lt;/p&gt;

&lt;div class="highlight"&gt;&lt;pre&gt;&lt;code class="bash"&gt;&lt;span class="nb"&gt;export &lt;/span&gt;&lt;span class="nv"&gt;PATH&lt;/span&gt;&lt;span class="o"&gt;=&lt;/span&gt;&lt;span class="s2"&gt;&amp;quot;/usr/local/bin:/usr/local/sbin:/usr/local/mysql/bin:/usr/local/share/npm/bin:$PATH&amp;quot;&lt;/span&gt;
&lt;/code&gt;&lt;/pre&gt;
&lt;/div&gt;


&lt;p&gt;Make sure you reload your shell with&lt;/p&gt;

&lt;div class="highlight"&gt;&lt;pre&gt;&lt;code class="bash"&gt;&lt;span class="nb"&gt;source&lt;/span&gt; ~/.bash_profile
&lt;/code&gt;&lt;/pre&gt;
&lt;/div&gt;


&lt;p&gt;so the changes are applied.&lt;/p&gt;

&lt;h2&gt;Installing modules&lt;/h2&gt;

&lt;p&gt;Now we are set up we can install node modules using npm. &lt;a href="http://expressjs.com/"&gt;Express&lt;/a&gt; is a good place to start - it is a node framework inspired by &lt;a href="http://www.sinatrarb.com/"&gt;Sinatra&lt;/a&gt;.&lt;/p&gt;

&lt;div class="highlight"&gt;&lt;pre&gt;&lt;code class="bash"&gt;npm install express
&lt;/code&gt;&lt;/pre&gt;
&lt;/div&gt;


&lt;p&gt;This provides a solid base to start developing with node.js including &lt;a href="http://jade-lang.com/"&gt;jade&lt;/a&gt; the haml inspired node tempting engine. There is more &lt;a href="http://expressjs.com/guide.html"&gt;excellent documentation&lt;/a&gt; available for express too.&lt;/p&gt;

&lt;p&gt;That's it - go create!&lt;/p&gt;
&lt;/content&gt;
   
 &lt;img src="http://feeds.feedburner.com/~r/shapeshed/~4/xDQO1HC0tnM" height="1" width="1"/&gt;</content>
 <feedburner:origLink>http://shapeshed.com/journal/setting-up-nodejs-and-npm-on-mac-osx/</feedburner:origLink></entry>
 
 <entry>
   <title>Developing subdomain Rails sites locally</title>
   <link href="http://feeds.shapeshed.com/~r/shapeshed/~3/Qn25r7wFX9Q/" />
   <updated>2010-07-29T00:00:00+01:00</updated>
   <published>2010-07-29T00:00:00+01:00</published>
   <id>http://shapeshed.com/journal/developing-subdomain-rails-sites-locally</id>
   <content type="html">
   &lt;h2&gt;The problem&lt;/h2&gt;

&lt;p&gt;If you are developing a Rails site locally with subdomains and you boot your application from WEBrick then you'll get a URL like http://0.0.0.0:3000. The DNS for this resolves to your local machine so you'll be able to see the site straight away with zero configuration.&lt;/p&gt;

&lt;p&gt;The problem arises if you are developing an application that relies on subdomains. So a user can create an account and access the application at something like http://myaccount.example.com/. To get this working we need to a bit of work.&lt;/p&gt;

&lt;h2&gt;Solution 1 - WEBrick&lt;/h2&gt;

&lt;p&gt;To test subdomains you can just add a record to your hosts file. On Unix style systems you can generally find this at /etc/hosts&lt;/p&gt;

&lt;div class="highlight"&gt;&lt;pre&gt;&lt;code class="bash"&gt;127.0.0.1   theateam.example.com
&lt;/code&gt;&lt;/pre&gt;
&lt;/div&gt;


&lt;p&gt;This will resolve the domain to the application running on your localhost, but you'll still need to apply the port number. So accessing http://theateam.example.com:3000 will serve the site. You'll need to do the logic as to what to show based on the subdomain in your application of course.&lt;/p&gt;

&lt;p&gt;This solution is quicker to setup but has the disadvantage of having to add a new record to your hosts file each time you create a subdomain.&lt;/p&gt;

&lt;h2&gt;Solution 2 - Passenger&lt;/h2&gt;

&lt;p&gt;A much better way is to serve your site locally from Passenger. If you deploy using Passenger you have the added advantage of developing on the same platform that you'll be deploying to.&lt;/p&gt;

&lt;p&gt;First you'll need to &lt;a href="http://www.modrails.com/install.html"&gt;install Passenger&lt;/a&gt;. This is reasonably straightforward:&lt;/p&gt;

&lt;div class="highlight"&gt;&lt;pre&gt;&lt;code class="bash"&gt;gem install passenger
&lt;/code&gt;&lt;/pre&gt;
&lt;/div&gt;


&lt;p&gt;Followed by&lt;/p&gt;

&lt;div class="highlight"&gt;&lt;pre&gt;&lt;code class="bash"&gt;passenger-install-apache2-module
&lt;/code&gt;&lt;/pre&gt;
&lt;/div&gt;


&lt;p&gt;There will be some instructions after the second command that you'll need to add passenger.conf file. Once that's done you need to set up the virtual host.&lt;/p&gt;

&lt;p&gt;I've covered &lt;a href="http://shapeshed.com/journal/setting_up_local_websites_on_snow_leopard/"&gt;serving sites locally on OSX&lt;/a&gt; before so if you need a brush up consult that article.&lt;/p&gt;

&lt;p&gt;&lt;a href="http://tbaggery.com/"&gt;Tim Pope&lt;/a&gt; recognised the problem of subdomains and &lt;a href="http://tbaggery.com/2010/03/04/smack-a-ho-st.html"&gt;registered the domain smackaho.st&lt;/a&gt; and pointed it to 127.0.0.1. This means it will resolve to your local machine without any configuration. This means that we can set up a virtual host based on this domain and use a wildcard to also serve subdomains on that domain. Here's how my virtual host setup looks:&lt;/p&gt;

&lt;div class="highlight"&gt;&lt;pre&gt;&lt;code class="apache"&gt;&lt;span class="nt"&gt;&amp;lt;VirtualHost&lt;/span&gt; &lt;span class="s"&gt;*:80&lt;/span&gt;&lt;span class="nt"&gt;&amp;gt;&lt;/span&gt;
        &lt;span class="nt"&gt;&amp;lt;Directory&lt;/span&gt; &lt;span class="s"&gt;/Users/george/Sites/mysite&lt;/span&gt;&lt;span class="nt"&gt;&amp;gt;&lt;/span&gt;
        &lt;span class="nb"&gt;Options&lt;/span&gt; +FollowSymlinks +SymLinksIfOwnerMatch
        &lt;span class="nb"&gt;AllowOverride&lt;/span&gt; &lt;span class="k"&gt;All&lt;/span&gt;
        &lt;span class="nt"&gt;&amp;lt;/Directory&amp;gt;&lt;/span&gt;
        &lt;span class="nb"&gt;DocumentRoot&lt;/span&gt; &lt;span class="sx"&gt;/Users/george/Sites/mysite/public&lt;/span&gt; 
        &lt;span class="nb"&gt;ServerName&lt;/span&gt; smackaho.st
        &lt;span class="nb"&gt;ServerAlias&lt;/span&gt; *.smackahost.st
        &lt;span class="nb"&gt;RackEnv&lt;/span&gt; development 
        &lt;span class="c"&gt;# RailsEnv development # for Rails 2.x.x apps&lt;/span&gt;
&lt;span class="nt"&gt;&amp;lt;/VirtualHost&amp;gt;&lt;/span&gt;
&lt;/code&gt;&lt;/pre&gt;
&lt;/div&gt;


&lt;p&gt;Restart Apache and you should be good to go&lt;/p&gt;

&lt;div class="highlight"&gt;&lt;pre&gt;&lt;code class="bash"&gt;sudo apachectl restart
&lt;/code&gt;&lt;/pre&gt;
&lt;/div&gt;


&lt;p&gt;Now any subdomain you visit on smackahost.st will be served from your Rails application. No need to keep adding subdomains to your hosts file.&lt;/p&gt;

&lt;p&gt;There is also another domain that serves the same purpose if you prefer it - lvh.me.&lt;/p&gt;

&lt;h2&gt;Further reading&lt;/h2&gt;

&lt;ul&gt;
&lt;li&gt;&lt;a href="http://www.modrails.com/install.html"&gt;Installing Passenger&lt;/a&gt;&lt;/li&gt;
&lt;li&gt;&lt;a href="http://tbaggery.com/2010/03/04/smack-a-ho-st.html"&gt;tbaggery - Smack a Ho.st&lt;/a&gt;&lt;/li&gt;
&lt;li&gt;&lt;a href="http://shapeshed.com/journal/setting_up_local_websites_on_snow_leopard/"&gt;Setting up local websites on Snow Leopard&lt;/a&gt;&lt;/li&gt;
&lt;li&gt;&lt;a href="http://tbaggery.com/"&gt;Subdomains in Rails 3&lt;/a&gt;&lt;/li&gt;
&lt;/ul&gt;

&lt;/content&gt;
   
 &lt;img src="http://feeds.feedburner.com/~r/shapeshed/~4/Qn25r7wFX9Q" height="1" width="1"/&gt;</content>
 <feedburner:origLink>http://shapeshed.com/journal/developing-subdomain-rails-sites-locally/</feedburner:origLink></entry>
 
 <entry>
   <title>Nifty Unix Tools - tr</title>
   <link href="http://feeds.shapeshed.com/~r/shapeshed/~3/d336X8trirY/" />
   <updated>2010-07-23T00:00:00+01:00</updated>
   <published>2010-07-23T00:00:00+01:00</published>
   <id>http://shapeshed.com/journal/nifty-unix-tools-tr</id>
   <content type="html">
   &lt;h2&gt;tr - a simple translation tool&lt;/h2&gt;

&lt;p&gt;I'm an unashamed command line &lt;del&gt;kid&lt;/del&gt; old git. For getting things done quickly and efficiently there are a wealth of tools at your fingertips. tr is just one of those tools. It lets you quickly and simply translate characters in a string.&lt;/p&gt;

&lt;p&gt;It doesn't have the power of other tools like &lt;a href="http://unixhelp.ed.ac.uk/CGI/man-cgi?sed"&gt;sed&lt;/a&gt; or &lt;a href="http://unixhelp.ed.ac.uk/CGI/man-cgi?awk"&gt;awk&lt;/a&gt; but for basic string manipulation it is pretty good. One example would be that we want to change uppercase text to lower case&lt;/p&gt;

&lt;div class="highlight"&gt;&lt;pre&gt;&lt;code class="bash"&gt;&lt;span class="nb"&gt;echo&lt;/span&gt; &lt;span class="s1"&gt;&amp;#39;HI THERE&amp;#39;&lt;/span&gt; |  tr &lt;span class="s1"&gt;&amp;#39;[:upper:]&amp;#39;&lt;/span&gt; &lt;span class="s1"&gt;&amp;#39;[:lower:]&amp;#39;&lt;/span&gt;
hi there
&lt;/code&gt;&lt;/pre&gt;
&lt;/div&gt;


&lt;p&gt;Or we might have a comma separated list that we want to strip the commas out of and to replace them with a new line&lt;/p&gt;

&lt;div class="highlight"&gt;&lt;pre&gt;&lt;code class="bash"&gt;cat file.csv | tr &lt;span class="s1"&gt;&amp;#39;,&amp;#39;&lt;/span&gt; &lt;span class="s1"&gt;&amp;#39;\n&amp;#39;&lt;/span&gt; &amp;gt; new.txt
&lt;/code&gt;&lt;/pre&gt;
&lt;/div&gt;


&lt;p&gt;This translates each comma to a new line so 'dog, cat, horse' becomes&lt;/p&gt;

&lt;p&gt;dog&lt;br /&gt;
cat&lt;br /&gt;
horse&lt;/p&gt;

&lt;h2&gt;Deleting characters&lt;/h2&gt;

&lt;p&gt;tr also lets you delete characters. So if you need to quickly clean up a string you can do:&lt;/p&gt;

&lt;div class="highlight"&gt;&lt;pre&gt;&lt;code class="bash"&gt;&lt;span class="nb"&gt;echo&lt;/span&gt; &lt;span class="s1"&gt;&amp;#39;clean$ me$ $up$ please$&amp;#39;&lt;/span&gt; | tr -d &lt;span class="s1"&gt;&amp;#39;$&amp;#39;&lt;/span&gt;
clean me up please
&lt;/code&gt;&lt;/pre&gt;
&lt;/div&gt;


&lt;p&gt;Because Unix lets you pipe the output we can write this to a file easily&lt;/p&gt;

&lt;div class="highlight"&gt;&lt;pre&gt;&lt;code class="bash"&gt;&lt;span class="nb"&gt;echo&lt;/span&gt; &lt;span class="s1"&gt;&amp;#39;clean$ me$ $up$ please$&amp;#39;&lt;/span&gt; | tr -d &lt;span class="s1"&gt;&amp;#39;$&amp;#39;&lt;/span&gt; &amp;gt; file.txt
&lt;/code&gt;&lt;/pre&gt;
&lt;/div&gt;


&lt;p&gt;We could also read in a big file, pipe it to the tr command and then send the output to another file&lt;/p&gt;

&lt;div class="highlight"&gt;&lt;pre&gt;&lt;code class="bash"&gt;cat big_file.txt | tr -d &lt;span class="s1"&gt;&amp;#39;$&amp;#39;&lt;/span&gt; &amp;gt; clean_file.txt
&lt;/code&gt;&lt;/pre&gt;
&lt;/div&gt;


&lt;h2&gt;More complex uses&lt;/h2&gt;

&lt;p&gt;You can pipe replacements together for more complex translations. Let's say someone sends you a file with spaces in it. You want to remove the spaces and whilst you are at it make the filename lowercase.&lt;/p&gt;

&lt;div class="highlight"&gt;&lt;pre&gt;&lt;code class="bash"&gt;mv Crap&lt;span class="se"&gt;\ &lt;/span&gt;File&lt;span class="se"&gt;\ &lt;/span&gt;nAme.txt &lt;span class="sb"&gt;`&lt;/span&gt;&lt;span class="nb"&gt;echo &lt;/span&gt;Crap&lt;span class="se"&gt;\ &lt;/span&gt;File&lt;span class="se"&gt;\ &lt;/span&gt;nAme.txt | tr -d &lt;span class="s1"&gt;&amp;#39;\&amp;#39; | tr &amp;#39;&lt;/span&gt; &lt;span class="s1"&gt;&amp;#39; &amp;#39;&lt;/span&gt;_&lt;span class="s1"&gt;&amp;#39; | tr &amp;#39;&lt;/span&gt;&lt;span class="o"&gt;[&lt;/span&gt;:upper:&lt;span class="o"&gt;]&lt;/span&gt;&lt;span class="s1"&gt;&amp;#39; &amp;#39;&lt;/span&gt;&lt;span class="o"&gt;[&lt;/span&gt;:lower:&lt;span class="o"&gt;]&lt;/span&gt;&lt;span class="err"&gt;&amp;#39;&lt;/span&gt;&lt;span class="sb"&gt;`&lt;/span&gt;
&lt;/code&gt;&lt;/pre&gt;
&lt;/div&gt;


&lt;p&gt;This will rename 'Crap File nAme.txt' to 'crap_file_name.txt'&lt;/p&gt;

&lt;p&gt;These little commands are really useful. If you find yourself doing the same thing over and over again you can save it to an executable script. I regularly get clients sending me documents for the web with spaces in. So I use &lt;a href="http://github.com/shapeshed/dotfiles/blob/master/bin/clean_filenames.sh"&gt;this script&lt;/a&gt; to quickly lowercase the filenames and clean up. This lets me run clean_filenames.sh in any directory and the filenames will be cleaned up. If you put your scripts in your bin folder and make them executable they'll be available via tab completion too. So you can just type 'clean_' hit tab, then return and you are done.&lt;/p&gt;

&lt;p&gt;tr is a simple tool that can't compete with the power of sed or awk but there are times when using a more heavyweight is unnecessary.&lt;/p&gt;

&lt;p&gt;For more run 'man tr' from the command line.&lt;/p&gt;
&lt;/content&gt;
   
 &lt;img src="http://feeds.feedburner.com/~r/shapeshed/~4/d336X8trirY" height="1" width="1"/&gt;</content>
 <feedburner:origLink>http://shapeshed.com/journal/nifty-unix-tools-tr/</feedburner:origLink></entry>
 
 <entry>
   <title>Smile You're on Video</title>
   <link href="http://feeds.shapeshed.com/~r/shapeshed/~3/pWNpqfJlHKY/" />
   <updated>2010-05-20T00:00:00+01:00</updated>
   <published>2010-05-20T00:00:00+01:00</published>
   <id>http://shapeshed.com/journal/smile_youre_on_video</id>
   <content type="html">
   &lt;h2&gt;An attempt to solve the video issue&lt;/h2&gt;

&lt;p&gt;The video tag is now well established in &lt;a href="http://www.whatwg.org/specs/web-apps/current-work/"&gt;HTML5 specification&lt;/a&gt;. I've &lt;a href="http://shapeshed.com/journal/HTML5-video-for-all-well-almost/"&gt;written previously&lt;/a&gt; about cross-browser problems, namely the complete lack of support in Internet Explorer and that different codecs are used by different browser vendors. To use HTML5 to serve video and access all users web authors face using two different methods (flash and the video tag). On top of that authors are currently required to export two different video formats to support differing codecs.&lt;/p&gt;

&lt;p&gt;When I created &lt;a href="http://shapeshed.com/examples/HTML5-video-element/"&gt;this demo&lt;/a&gt; I it was great that I could now use a browser API, rather than a third party plugin. But the fact I was doing more work to use this method and duplicating videos seemed a bit counter intuitive. What happened to don't repeat yourself?&lt;/p&gt;

&lt;p&gt;From a developer perspective anyone that has worked with &lt;a href="http://www.ffmpeg.org/"&gt;ffmpeg&lt;/a&gt; soon realises the complexity of different video formats, frame rates, video sizes and codecs. But from an end user perspective (and that is always the most important) creating a video for use on the web is still a bewildering prospect. Of course you can use a service like &lt;a href="http://vimeo.com/"&gt;Vimeo&lt;/a&gt; or &lt;a href="http://www.youtube.com/"&gt;YouTube&lt;/a&gt; but video is such an integral part of the web that it should be possible to easily create content for the web, and it should be open.&lt;/p&gt;

&lt;h2&gt;Enter Google on a white horse&lt;/h2&gt;

&lt;p&gt;It would seem Google agrees that video should be open. Earlier this year Google purchased On2 Technologies, a video compression business and with it the &lt;a href="http://en.wikipedia.org/wiki/VP8"&gt;VP8 video codec&lt;/a&gt;. In the week that &lt;a href="http://37signals.com/svn/posts/2341-microsoft-patent-trolls-salesforce"&gt;Microsoft launched a patent suit&lt;/a&gt; against Salesforce and Adobe and Apple &lt;a href="http://www.apple.com/hotnews/thoughts-on-flash/"&gt;continue&lt;/a&gt; to &lt;a href="http://www.nowpublic.com/tech-biz/adobe-apple-ad-campaign-we-love-apple-open-letter-apple-2616766.html"&gt;squabble&lt;/a&gt; about who is really open Google did something incredible. They open sourced the VP8 codec. That's the VP8 codec they acquired for $124.6 million. Opera and Mozilla are &lt;a href="http://blog.mozilla.com/blog/2010/05/19/open-web-open-video-and-webm/"&gt;also&lt;/a&gt; &lt;a href="http://dev.opera.com/articles/view/opera-supports-webm-video/"&gt;on board&lt;/a&gt; with this effort which leaves just Apple, who are championing the H.264 format. Even Microsoft will be &lt;a href="http://windowsteamblog.com/windows/b/bloggingwindows/archive/2010/05/19/another-follow-up-on-html5-video-in-ie9.aspx"&gt;supporting VP8 in IE9&lt;/a&gt;.&lt;/p&gt;

&lt;p&gt;It will be interesting to see how Apple respond. They have invested heavily in the H.264 codec for both their desktop and browser products. With Google Chrome being based on Webkit and covered by a BSD license, Apple could presumably leverage the work that Google has already done for their Safari browser. If Apple hold out it looks probable that web authors would continue to have to publish two video formats to ensure cross-browser compatibility leaving us in much the same boat.&lt;/p&gt;

&lt;h2&gt;A good day for the open web&lt;/h2&gt;

&lt;p&gt;This announcement should be celebrated as a step forward for the open web. Google have shared a commercial product under a BSD license that they paid over millions of dollars for in the interests of the web as a whole. At a time when other companies are arguing about how open they really are Google can have their moment in the sun.&lt;/p&gt;

&lt;h2&gt;Related links&lt;/h2&gt;

&lt;ul&gt;
&lt;li&gt;&lt;a href="http://www.youtube.com/googledevelopers"&gt;Google I/O YouTube channel&lt;/a&gt; - Watch the keynote&lt;/li&gt;
&lt;li&gt;&lt;a href="http://dev.opera.com/articles/view/opera-supports-webm-video/"&gt;Opera builds for VP8&lt;/a&gt; - Download links under the second paragraph&lt;/li&gt;
&lt;li&gt;&lt;a href="http://windowsteamblog.com/windows/b/bloggingwindows/archive/2010/05/19/another-follow-up-on-html5-video-in-ie9.aspx"&gt;Microsoft to support VP8 in IE9&lt;/a&gt; - Supported if the codec is installed&lt;/li&gt;
&lt;li&gt;&lt;a href="http://nightly.mozilla.org/webm/"&gt;Firefox WebM builds for VP8&lt;/a&gt; - WebM enabled Nightly builds for Firefox&lt;/li&gt;
&lt;li&gt;&lt;a href="http://blog.chromium.org/2010/05/webm-and-vp8-land-in-chromium.html"&gt;WebM and VP8 land in Chromium&lt;/a&gt; - Chromium announcement on VP8&lt;/li&gt;
&lt;li&gt;&lt;a href="http://www.whatwg.org/specs/web-apps/current-work/multipage/video.html"&gt;Working draft of HTML5 video spec&lt;/a&gt; - Current work in progress for the HTML5 video spec&lt;/li&gt;
&lt;/ul&gt;

&lt;/content&gt;
   
 &lt;img src="http://feeds.feedburner.com/~r/shapeshed/~4/pWNpqfJlHKY" height="1" width="1"/&gt;</content>
 <feedburner:origLink>http://shapeshed.com/journal/smile_youre_on_video/</feedburner:origLink></entry>
 
 <entry>
   <title>Basics of Objective-C</title>
   <link href="http://feeds.shapeshed.com/~r/shapeshed/~3/KRs1tEYxY1w/" />
   <updated>2010-04-30T00:00:00+01:00</updated>
   <published>2010-04-30T00:00:00+01:00</published>
   <id>http://shapeshed.com/journal/basics-of-objective-c</id>
   <content type="html">
   &lt;h2&gt;Objective-C 101&lt;/h2&gt;

&lt;p&gt;The second Stanford iPhone development course assignment focusses on understanding more Objective-C. At the time of writing the PDF is still available from the &lt;a href="http://www.stanford.edu/class/cs193p/cgi-bin/drupal/system/files/assignments/Assignment1B_0.pdf"&gt;Stanford CS193P&lt;/a&gt; website.&lt;/p&gt;

&lt;h2&gt;A simple command line script&lt;/h2&gt;

&lt;p&gt;The assignment is to create a simple command line script to make an introduction to Objective-C.&lt;/p&gt;

&lt;p&gt;The first thing that was a little bit different for me was understanding main which basically functions a bit like a constructor class in PHP (excuse my Objective-C ignorance if this is totally wrong). Objective C is also upside down from what I'm used to so main comes at the end.&lt;/p&gt;

&lt;div class="highlight"&gt;&lt;pre&gt;&lt;code class="objectivec"&gt;&lt;span class="cp"&gt;#import &amp;lt;Foundation/Foundation.h&amp;gt;&lt;/span&gt;
&lt;span class="o"&gt;-&lt;/span&gt; &lt;span class="kt"&gt;void&lt;/span&gt; &lt;span class="n"&gt;PrintPathInfo&lt;/span&gt;&lt;span class="p"&gt;()&lt;/span&gt; &lt;span class="p"&gt;{&lt;/span&gt;
  &lt;span class="c1"&gt;// Code from path info section here&lt;/span&gt;
&lt;span class="p"&gt;}&lt;/span&gt;
&lt;span class="kt"&gt;int&lt;/span&gt; &lt;span class="n"&gt;main&lt;/span&gt; &lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="kt"&gt;int&lt;/span&gt; &lt;span class="n"&gt;argc&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt; &lt;span class="k"&gt;const&lt;/span&gt; &lt;span class="kt"&gt;char&lt;/span&gt; &lt;span class="o"&gt;*&lt;/span&gt; &lt;span class="n"&gt;argv&lt;/span&gt;&lt;span class="p"&gt;[])&lt;/span&gt; &lt;span class="p"&gt;{&lt;/span&gt; 
  &lt;span class="n"&gt;NSAutoreleasepool&lt;/span&gt; &lt;span class="o"&gt;*&lt;/span&gt; &lt;span class="n"&gt;pool&lt;/span&gt; &lt;span class="o"&gt;=&lt;/span&gt; &lt;span class="p"&gt;[[&lt;/span&gt;&lt;span class="n"&gt;NSAutoreleasePool&lt;/span&gt; &lt;span class="n"&gt;alloc&lt;/span&gt;&lt;span class="p"&gt;]&lt;/span&gt; &lt;span class="n"&gt;init&lt;/span&gt;&lt;span class="p"&gt;];&lt;/span&gt;
  &lt;span class="n"&gt;PrintPathInfo&lt;/span&gt;&lt;span class="p"&gt;();&lt;/span&gt; 
  &lt;span class="n"&gt;PrintProcessInfo&lt;/span&gt;&lt;span class="p"&gt;();&lt;/span&gt; 
  &lt;span class="n"&gt;PrintBookmarkInfo&lt;/span&gt;&lt;span class="p"&gt;();&lt;/span&gt; 
  &lt;span class="n"&gt;PrintIntrospectionInfo&lt;/span&gt;&lt;span class="p"&gt;();&lt;/span&gt; 
&lt;/code&gt;&lt;/pre&gt;
&lt;/div&gt;


&lt;p&gt;Syntax is more verbose from say Ruby so declaring a string is&lt;/p&gt;

&lt;div class="highlight"&gt;&lt;pre&gt;&lt;code class="objectivec"&gt;&lt;span class="n"&gt;NSString&lt;/span&gt; &lt;span class="o"&gt;*&lt;/span&gt;&lt;span class="n"&gt;path&lt;/span&gt; &lt;span class="o"&gt;=&lt;/span&gt; &lt;span class="s"&gt;@&amp;quot;~&amp;quot;&lt;/span&gt;&lt;span class="p"&gt;;&lt;/span&gt;
&lt;/code&gt;&lt;/pre&gt;
&lt;/div&gt;


&lt;p&gt;instead of&lt;/p&gt;

&lt;div class="highlight"&gt;&lt;pre&gt;&lt;code class="ruby"&gt;&lt;span class="n"&gt;path&lt;/span&gt; &lt;span class="o"&gt;=&lt;/span&gt; &lt;span class="s2"&gt;&amp;quot;~&amp;quot;&lt;/span&gt;
&lt;/code&gt;&lt;/pre&gt;
&lt;/div&gt;


&lt;p&gt;The whole NS thing relates to &lt;a href="http://en.wikipedia.org/wiki/NeXTSTEP"&gt;NeXTSTEP&lt;/a&gt;, an operating system that Apple bought back in the day. The NS prefix has stuck around (I'm not really sure why) so pretty NS is everywhere in Objective C - NSLog, NSAutoreleasepool etc.&lt;/p&gt;

&lt;h2&gt;Creating the project&lt;/h2&gt;

&lt;p&gt;I'm on the iPhone 4.0 SDK and the menus had moved around a bit. To create a Foundation Command Line Tool go to Mac OSX &gt; Application &gt; Command Line tool and then select Foundation from the Type dropdown.&lt;/p&gt;

&lt;p&gt;&lt;img src="/images/articles/creating_a_foundation_command_line_tool.jpg" alt="Creating a Foundation Command Line Tool" /&gt;&lt;/p&gt;

&lt;p&gt;When you run the application you want the console up so you can see what's happening. You can access this via Run &gt; Console&lt;/p&gt;

&lt;h2&gt;Working through the tasks&lt;/h2&gt;

&lt;p&gt;There are four tasks in the assignment which relate to the functions in the code above. I found the following documentation really useful in understanding the requirements:&lt;/p&gt;

&lt;ul&gt;
&lt;li&gt;&lt;a href="http://developer.apple.com/mac/library/documentation/Cocoa/Reference/Foundation/Classes/NSString_Class/Reference/NSString.html"&gt;NSString documentation&lt;/a&gt;, especially &lt;a href="http://developer.apple.com/mac/library/documentation/Cocoa/Reference/Foundation/Classes/NSString_Class/Reference/NSString.html#//apple_ref/occ/instm/NSString/stringByExpandingTildeInPath"&gt;stringByExpandingTildeInPath&lt;/a&gt; for the first task.&lt;/li&gt;
&lt;li&gt;&lt;a href="http://developer.apple.com/mac/library/documentation/Cocoa/Reference/Foundation/Classes/NSProcessInfo_Class/Reference/Reference.html"&gt;NSProcessInfo documentation&lt;/a&gt; for the second task&lt;/li&gt;
&lt;li&gt;&lt;a href="http://developer.apple.com/mac/library/documentation/Cocoa/Reference/Foundation/Classes/NSMutableDictionary_Class/Reference/Reference.html"&gt;NSMutableDictionary&lt;/a&gt; for the third task&lt;/li&gt;
&lt;li&gt;&lt;a href="http://developer.apple.com/mac/library/documentation/cocoa/Reference/Foundation/Protocols/NSObject_Protocol/Reference/NSObject.html"&gt;NSObject Protocol Reference&lt;/a&gt; for the final task especially &lt;a href="http://developer.apple.com/mac/library/documentation/cocoa/Reference/Foundation/Protocols/NSObject_Protocol/Reference/NSObject.html#//apple_ref/occ/intfm/NSObject/isMemberOfClass:"&gt;isMemberOfClass&lt;/a&gt;, &lt;a href="http://developer.apple.com/mac/library/documentation/cocoa/Reference/Foundation/Protocols/NSObject_Protocol/Reference/NSObject.html#//apple_ref/occ/intfm/NSObject/isKindOfClass:"&gt;isKindOfClass&lt;/a&gt;, &lt;a href="http://developer.apple.com/mac/library/documentation/cocoa/Reference/Foundation/Protocols/NSObject_Protocol/Reference/NSObject.html#//apple_ref/occ/intfm/NSObject/respondsToSelector:"&gt;respondsToSelector&lt;/a&gt; and &lt;a href="http://developer.apple.com/mac/library/documentation/cocoa/Reference/Foundation/Protocols/NSObject_Protocol/Reference/NSObject.html#//apple_ref/occ/intfm/NSObject/conformsToProtocol:"&gt;conformToProtocol&lt;/a&gt;&lt;/li&gt;
&lt;/ul&gt;


&lt;h2&gt;Outputting to the console&lt;/h2&gt;

&lt;p&gt;The task isn't sexy but helped me to understand Objective-C a lot more&lt;/p&gt;

&lt;p&gt;&lt;img src="/images/articles/xcode_console.png" alt="Objective-C console" /&gt;&lt;/p&gt;

&lt;h2&gt;Source code&lt;/h2&gt;

&lt;p&gt;I've made the source code for my working through the examples available on &lt;a href="http://github.com/shapeshed/StanfordExamples"&gt;Github&lt;/a&gt;. Bear in mind I'm starting out so I'm not suggesting this is best practice code.&lt;/p&gt;
&lt;/content&gt;
   
 &lt;img src="http://feeds.feedburner.com/~r/shapeshed/~4/KRs1tEYxY1w" height="1" width="1"/&gt;</content>
 <feedburner:origLink>http://shapeshed.com/journal/basics-of-objective-c/</feedburner:origLink></entry>
 
 <entry>
   <title>Adding a vignette to a video using Photoshop and Abobe Premier</title>
   <link href="http://feeds.shapeshed.com/~r/shapeshed/~3/EcyEKegntWA/" />
   <updated>2010-04-30T00:00:00+01:00</updated>
   <published>2010-04-30T00:00:00+01:00</published>
   <id>http://shapeshed.com/journal/adding_a_vignette_to_a_video_using_photoshop_and_adobe_premier</id>
   <content type="html">
   &lt;h2&gt;Background&lt;/h2&gt;

&lt;p&gt;My brother &lt;a href="http://www.samornbo.com/"&gt;Sam Ornbo&lt;/a&gt; is a freelance television Producer and Director and has recently been doing some work for a Scooter company. He shot a short promotional film for them and wanted to recreate the vignette effect that is used heavily in &lt;a href="http://www.topgear.com/"&gt;Top Gear&lt;/a&gt;. He uses &lt;a href="http://www.adobe.com/products/premiere/"&gt;Adobe Premier&lt;/a&gt; to edit videos which allows you to import PSD files, so asked me for some help in creating the vignette.&lt;/p&gt;

&lt;h2&gt;Creating the vignette&lt;/h2&gt;

&lt;p&gt;To create the vignette first select the Ellipse Tool and draw an Ellipse like this&lt;/p&gt;

&lt;p&gt;&lt;img src="/images/articles/vignette_ellipse.png" alt="Creating the ellipse" /&gt;&lt;/p&gt;

&lt;p&gt;Then in the layers menu (F7) select the shape you have just drawn by holding the ⌘ key (Ctrl on windows I think) and click the layer thumbnail. You should then see the ant trail (a black and white line around the ellipse you have just drawn.&lt;/p&gt;

&lt;p&gt;&lt;img src="/images/articles/vignette_layers.jpg" alt="Selecting the ellipse" /&gt;&lt;/p&gt;

&lt;p&gt;Then go to Select &gt; Inverse. Create a new layer by going to Layer &gt; New... &gt; Layer and fill the selection with Black.&lt;/p&gt;

&lt;p&gt;Turn off the original ellipse layer you created and you'll be left with the inverse:&lt;/p&gt;

&lt;p&gt;&lt;img src="/images/articles/vignette_inverse_ellipse.jpg" alt="The inverse ellipse" /&gt;&lt;/p&gt;

&lt;p&gt;Then go to Select &gt; Deselect to remove the marching ants.&lt;/p&gt;

&lt;p&gt;Next convert the layer to a Smart Object so we can apply filters non-destructively (this makes it easier to change things). To do this go to Filter &gt; Convert for Smart Filters.&lt;/p&gt;

&lt;p&gt;Then we apply a Gaussian Blur - Filters &gt; Blur &gt; Gaussian Blur. You should end up with something like this:&lt;/p&gt;

&lt;p&gt;&lt;img src="/images/articles/vignette_finished.jpg" alt="The finished vignette" /&gt;&lt;/p&gt;

&lt;p&gt;Save your file as a PSD and it is ready to use in Adobe Premier. Drag the file into your bin it will be available for you to use in your project.&lt;/p&gt;

&lt;h2&gt;The finished effect&lt;/h2&gt;

&lt;p&gt;Applied over the video the Vignette gives us the effect we are looking for:&lt;/p&gt;

&lt;p&gt;&lt;img src="/images/articles/vignette_biker.jpg" alt="The final effect" /&gt;&lt;/p&gt;
&lt;/content&gt;
   
 &lt;img src="http://feeds.feedburner.com/~r/shapeshed/~4/EcyEKegntWA" height="1" width="1"/&gt;</content>
 <feedburner:origLink>http://shapeshed.com/journal/adding_a_vignette_to_a_video_using_photoshop_and_adobe_premier/</feedburner:origLink></entry>
 
 <entry>
   <title>Learning iPhone Development - Interface Builder</title>
   <link href="http://feeds.shapeshed.com/~r/shapeshed/~3/Vk942eBKdH4/" />
   <updated>2010-04-27T00:00:00+01:00</updated>
   <published>2010-04-27T00:00:00+01:00</published>
   <id>http://shapeshed.com/journal/learning_iphone_development_interface_builder</id>
   <content type="html">
   &lt;h2&gt;Assigment 1A&lt;/h2&gt;

&lt;p&gt;Assigment 1A at the time of writing is still available &lt;a href="http://www.stanford.edu/class/cs193p/cgi-bin/drupal/system/files/assignments/Assignment1A_0.pdf"&gt;to download&lt;/a&gt; from the Stanford Site. It is very simple - to create a view with some text and an image in it.&lt;/p&gt;

&lt;p&gt;The assignment doesn't even need any code and can be created just using Interface Builder.&lt;/p&gt;

&lt;h2&gt;Creating the project&lt;/h2&gt;

&lt;p&gt;I'm just starting out so I'm going to list the steps for creating the project.&lt;/p&gt;

&lt;p&gt;So we need to create a new project in Xcode. Launch Xcode and you'll see this screen and we want 'Create a new Xcode Project'.&lt;/p&gt;

&lt;p&gt;&lt;img src="/images/articles/assignment_1a_choose_project.png" alt="Creating a new Xcode Project" /&gt;&lt;/p&gt;

&lt;p&gt;Then we need to chose the type of Project. In this case an iPhone OS application and a 'Window Based Application'. I'm going to be creating a view with my favorite comedian Les Dawson on so I called the application LesDawson.&lt;/p&gt;

&lt;p&gt;&lt;img src="/images/articles/assignment_1a_select_project.png" alt="Choosing a new project in Xcode" /&gt;&lt;/p&gt;

&lt;h2&gt;Working in Xcode&lt;/h2&gt;

&lt;p&gt;I'm a long term TextMate user so Xcode wasn't entirely unfamiliar. I chose to change the theme to Dusk by going to Preferences &gt; Fonts &amp;amp; Colors.&lt;/p&gt;

&lt;p&gt;In terms of this assignment the file we want to edit is the MainWindow.xib file. If you double click it Interface Builder will launch. This will bring up some windows, but you'll want to make sure that you can see 'Window' and 'Library'. If you can't see the 'Library' window go go to Tools &gt; Library.&lt;/p&gt;

&lt;p&gt;&lt;img src="/images/articles/assignment_1a_main_window.png" alt="Launching the Interface Builder" /&gt;&lt;/p&gt;

&lt;p&gt;Now select the Library window. At the bottom is a settings icon. I found changing the option to View Icons and Labels was more helpful to me. Then you can just start to drag elements into the main window. I dragged a label into the window and changed the text.&lt;/p&gt;

&lt;p&gt;In the attributes window you can style the text. I added a shadow to the text.&lt;/p&gt;

&lt;p&gt;&lt;img src="/images/articles/assignement_1a_label_attributes.png" alt="Styling the text" /&gt;&lt;/p&gt;

&lt;h2&gt;Adding a resource&lt;/h2&gt;

&lt;p&gt;I need to add an image so to do this you simply drag the image from your network or filesystem into the resources folder. Make sure you check 'Copy items into destination group's folder'. Now back in Interface Builder you can drag an Image View into the window. Once you've done that you can edit the UIImageView's properties and select the Image from the Image dropdown. You might need to set the image size - you can do this under Image View Size. So you should be done with Interface Builder, but don't forget to save by going to File &gt; Save.&lt;/p&gt;

&lt;p&gt;Now back in Xcode you can hit the 'Build and Run' button and you should see your view launch in the Simulator.&lt;/p&gt;

&lt;p&gt;&lt;img src="/images/articles/assignment_1a_application.png" alt="The finished Les Dawson application" /&gt;&lt;/p&gt;

&lt;h2&gt;Source code&lt;/h2&gt;

&lt;p&gt;I've created a &lt;a href="http://github.com/shapeshed/StanfordExamples"&gt;Github repository&lt;/a&gt; for these examples if it is useful to anyone.&lt;/p&gt;
&lt;/content&gt;
   
 &lt;img src="http://feeds.feedburner.com/~r/shapeshed/~4/Vk942eBKdH4" height="1" width="1"/&gt;</content>
 <feedburner:origLink>http://shapeshed.com/journal/learning_iphone_development_interface_builder/</feedburner:origLink></entry>
 
 <entry>
   <title>Beginning iPhone Development</title>
   <link href="http://feeds.shapeshed.com/~r/shapeshed/~3/WF_ZKuso7u4/" />
   <updated>2010-04-26T00:00:00+01:00</updated>
   <published>2010-04-26T00:00:00+01:00</published>
   <id>http://shapeshed.com/journal/beginning_iphone_development</id>
   <content type="html">
   &lt;h2&gt;Textmate to Xcode&lt;/h2&gt;

&lt;p&gt;I've been developing web applications for 7 years, so I should be an experienced web developer by now. I write PHP, Perl and Ruby as well as having a good understanding of *nix systems. I'm comfortable with interface design and front end technologies.&lt;/p&gt;

&lt;p&gt;I'm a Mac user and I have had an iPhone since it came out. I've decided to learn how to develop for the iPhone and iPad. I'm starting from scratch and I have no prior experience of the platform, frameworks or Objective-C. In short I'm a noob.&lt;/p&gt;

&lt;h2&gt;Starting out&lt;/h2&gt;

&lt;p&gt;Firstly I enrolled in the &lt;a href="http://developer.apple.com/iphone/program/"&gt;iPhone developer program&lt;/a&gt;. Frankly it was a good decision. The resources available for new developers are first class and it is clear that Apple want to make it easy for new developers to come to the platform.&lt;/p&gt;

&lt;p&gt;I started out by working through the &lt;a href="https://deimos.apple.com/WebObjects/Core.woa/BrowsePrivately/adc.apple.com.1479953497.01479953503.1521820368?i=1458839104"&gt;Getting Started videos (itunes link)&lt;/a&gt; which are a high level introduction to concepts and the frameworks and technologies available on the platform. After watching the videos I wasn't able to start programming but I had a good understanding of the concepts and ideas behind the platform.&lt;/p&gt;

&lt;h2&gt;Installing Xcode&lt;/h2&gt;

&lt;p&gt;If you are not enrolled in the iPhone developer program you can download the iPhone SDK for free &lt;a href="http://developer.apple.com/iphone/index.action"&gt;right on the home page&lt;/a&gt;. If you are enrolled you get access to the latest versions and beta of upcoming software.&lt;/p&gt;

&lt;p&gt;Installing the SDK is pretty straightforward so I'm not going to cover that.&lt;/p&gt;

&lt;h2&gt;Hello World&lt;/h2&gt;

&lt;p&gt;Next I worked through the &lt;a href="http://developer.apple.com/iphone/library/documentation/Xcode/Conceptual/iphone_development/100-iPhone_Development_Quick_Start/iphone_development_quick_start.html#//apple_ref/doc/uid/TP40007959-CH3-SW9"&gt;Hello World example&lt;/a&gt;. In pretty much no time I had an iPhone application running on my simulator. Instant gratification!&lt;/p&gt;

&lt;p&gt;&lt;img src="/images/articles/hello_world_iphone.png" alt="Hello World iPhone app" /&gt;&lt;/p&gt;

&lt;h2&gt;Delving deeper&lt;/h2&gt;

&lt;p&gt;I'm very much in the early stages of learning but the &lt;a href="http://developer.apple.com/iphone/library/navigation/index.html"&gt;iPhone OS Reference Library&lt;/a&gt; is first class.&lt;/p&gt;

&lt;p&gt;I've also been taking the &lt;a href="http://deimos3.apple.com/WebObjects/Core.woa/Browse/itunes.stanford.edu.3124430053.03124430055.3145764870?i=1399672464"&gt;Stanford University iPhone Application Development class (iTunes link)&lt;/a&gt;.&lt;/p&gt;

&lt;h2&gt;Code examples&lt;/h2&gt;

&lt;p&gt;Apple also provide example &lt;a href="http://developer.apple.com/iphone/library/navigation/index.html?section=Resource+Types&amp;amp;topic=Sample+C#section=Resource%20Types&amp;amp;topic=Sample%20Code"&gt;code and applications&lt;/a&gt; which I have found really useful in picking through and understanding how things work.&lt;/p&gt;

&lt;p&gt;I'll blog here about my progress. If anyone has any good resources for beginners please feel free to leave a comment.&lt;/p&gt;

&lt;h2&gt;Related links&lt;/h2&gt;

&lt;ul&gt;
&lt;li&gt;&lt;a href="https://deimos.apple.com/WebObjects/Core.woa/BrowsePrivately/adc.apple.com.1479953497.01479953503.1521820368?i=1458839104"&gt;Apple iPhone Getting Started Videos&lt;/a&gt; - Series of high level videos on developing for the iPhone (iTunes link)&lt;/li&gt;
&lt;li&gt;&lt;a href="http://developer.apple.com/iphone/library/documentation/Xcode/Conceptual/iphone_development/100-iPhone_Development_Quick_Start/iphone_development_quick_start.html#//apple_ref/doc/uid/TP40007959-CH3-SW9"&gt;Hello World iPhone App&lt;/a&gt; - Walkthrough of a simple iPhone app&lt;/li&gt;
&lt;li&gt;&lt;a href="http://developer.apple.com/iphone/library/navigation/index.html"&gt;iPhone reference library&lt;/a&gt; - Excellent resource of iPhone OS documentation&lt;/li&gt;
&lt;li&gt;&lt;a href="http://developer.apple.com/iphone/library/navigation/index.html?section=Resource+Types&amp;amp;topic=Sample+C#section=Resource%20Types&amp;amp;topic=Sample%20Code"&gt;Example code and applications&lt;/a&gt; - Large resource of sample code and applications&lt;/li&gt;
&lt;li&gt;&lt;a href="http://deimos3.apple.com/WebObjects/Core.woa/Browse/itunes.stanford.edu.3124430053.03124430055.3145764870?i=1399672464"&gt;Stanford University iPhone course&lt;/a&gt; - Detailed lectures on iPhone development (iTunes link)&lt;/li&gt;
&lt;li&gt;&lt;a href="http://developer.apple.com/iphone/program/"&gt;iPhone developer program&lt;/a&gt; - Paid for Apple iPhone program&lt;/li&gt;
&lt;/ul&gt;

&lt;/content&gt;
   
 &lt;img src="http://feeds.feedburner.com/~r/shapeshed/~4/WF_ZKuso7u4" height="1" width="1"/&gt;</content>
 <feedburner:origLink>http://shapeshed.com/journal/beginning_iphone_development/</feedburner:origLink></entry>
 
 <entry>
   <title>Setting up Git for multiple developers</title>
   <link href="http://feeds.shapeshed.com/~r/shapeshed/~3/FW5ki328Y0A/" />
   <updated>2010-03-31T00:00:00+01:00</updated>
   <published>2010-03-31T00:00:00+01:00</published>
   <id>http://shapeshed.com/journal/setting_up_git_for_multiple_developers</id>
   <content type="html">
   &lt;h2&gt;The problem&lt;/h2&gt;

&lt;p&gt;You have a git repository that you want to allow other developers to access and may wish to specify read or read/write access.&lt;/p&gt;

&lt;h2&gt;Solution 1&lt;/h2&gt;

&lt;p&gt;You could choose to use *nix user accounts to allow access to the git repository. I tried this route and found it didn't work very well. You need to move all users to have the same primary group and change the default umask on the server to allow everyone in that group to read and write. If you are interested in this technique there is a pretty good write up &lt;a href="http://serverfault.com/questions/26954/how-do-i-share-a-git-repository-with-multiple-users-on-a-machine"&gt;on Serverfault&lt;/a&gt;.&lt;/p&gt;

&lt;p&gt;In my usage of this I encountered problems where the git cache wasn't respecting the default umask so users were then unable to write to the repository. It meant that whenever anyone wanted to push I would have to reset the permissions on the repository. Not ideal.&lt;/p&gt;

&lt;p&gt;The other thing I don't like about this technique is that users need to have an account, which seems a bit like overkill for accessing a repository.&lt;/p&gt;

&lt;h2&gt;Solution 2&lt;/h2&gt;

&lt;p&gt;The solution I tried next and which has been working really well for around two weeks now is &lt;a href="http://scie.nti.st/2007/11/14/hosting-git-repositories-the-easy-and-secure-way"&gt;gitosis&lt;/a&gt;. Gitosis has been around for a while but if you are a &lt;a href="http://github.com/"&gt;Github&lt;/a&gt; user you'll be familiar with the approach. Instead of creating a user for each developer you want to access the repository there is a single git user. Access is then assigned on the basis of shared keys. So you don't need to create accounts and all you need to give a developer access is a shared key.&lt;/p&gt;

&lt;h2&gt;Installation&lt;/h2&gt;

&lt;p&gt;This walkthrough is for Ubuntu and the usual stuff applies. You travel at your own risk, take backups etc..&lt;/p&gt;

&lt;p&gt;Install gitosis as detailed &lt;a href="http://scie.nti.st/2007/11/14/hosting-git-repositories-the-easy-and-secure-way"&gt;here&lt;/a&gt;. You need to create a git user (the command is on the link).&lt;/p&gt;

&lt;p&gt;If you've got this far you should have installed gitosis ok and have set up the git user.&lt;/p&gt;

&lt;p&gt;Gitosis allows access using public keys so (assuming you are on OSX or Linux) you need to generate one if you don't have one&lt;/p&gt;

&lt;div class="highlight"&gt;&lt;pre&gt;&lt;code class="bash"&gt;ssh-keygen -t rsa
&lt;/code&gt;&lt;/pre&gt;
&lt;/div&gt;


&lt;p&gt;This generates a public key on your local machine that you'll find in ./.ssh/id_rsa.pub&lt;/p&gt;

&lt;p&gt;Then you need to copy this file to the remote server (where you installed gitosis). The gitosis documentation recommends copying it to the /tmp folder so lets do that. Replace 'myuser@7123.456.789.0' with your server details.&lt;/p&gt;

&lt;div class="highlight"&gt;&lt;pre&gt;&lt;code class="bash"&gt;scp ~/.ssh/id_rsa.pub myuser@7123.456.789.0:~/tmp
&lt;/code&gt;&lt;/pre&gt;
&lt;/div&gt;


&lt;p&gt;Once copied over on the remote machine import the key for the git user&lt;/p&gt;

&lt;div class="highlight"&gt;&lt;pre&gt;&lt;code class="bash"&gt;sudo -H -u git gitosis-init &amp;lt; /tmp/id_rsa.pub
&lt;/code&gt;&lt;/pre&gt;
&lt;/div&gt;


&lt;p&gt;Finally the documentation advises use to make sure the post-update hook is executable&lt;/p&gt;

&lt;div class="highlight"&gt;&lt;pre&gt;&lt;code class="bash"&gt;sudo chmod 755 /home/git/repositories/gitosis-admin.git/hooks/post-update
&lt;/code&gt;&lt;/pre&gt;
&lt;/div&gt;


&lt;h2&gt;Administration&lt;/h2&gt;

&lt;p&gt;So far we've set up gitosis, added a git user and added our public key to the git user. So now on our local machine we can clone the repository that defines access to other git repositories.&lt;/p&gt;

&lt;div class="highlight"&gt;&lt;pre&gt;&lt;code class="bash"&gt;git clone git@YOUR_SERVER_HOSTNAME:gitosis-admin.git
&lt;/code&gt;&lt;/pre&gt;
&lt;/div&gt;


&lt;p&gt;If everything has gone to plan this will pull down a git repository.&lt;/p&gt;

&lt;p&gt;Look inside this and you'll see the a gitosis.conf file and a 'keydir' folder. The 'keydir' folder houses the public keys that give access to repositories and the gitosis.conf file defines what users can do. Simple.&lt;/p&gt;

&lt;p&gt;Your gitosis.conf file might look something like this&lt;/p&gt;

&lt;div class="highlight"&gt;&lt;pre&gt;&lt;code class="bash"&gt;&lt;span class="o"&gt;[&lt;/span&gt;gitosis&lt;span class="o"&gt;]&lt;/span&gt;

&lt;span class="o"&gt;[&lt;/span&gt;group gitosis-admin&lt;span class="o"&gt;]&lt;/span&gt;
&lt;span class="nv"&gt;writable&lt;/span&gt; &lt;span class="o"&gt;=&lt;/span&gt; gitosis-admin
&lt;span class="nv"&gt;members&lt;/span&gt; &lt;span class="o"&gt;=&lt;/span&gt; george_ornbo an_other_developer

&lt;span class="o"&gt;[&lt;/span&gt;group myproject&lt;span class="o"&gt;]&lt;/span&gt;
&lt;span class="nv"&gt;writable&lt;/span&gt; &lt;span class="o"&gt;=&lt;/span&gt; myproject
&lt;span class="nv"&gt;members&lt;/span&gt; &lt;span class="o"&gt;=&lt;/span&gt; george_ornbo an_other_developer third_developer 
&lt;/code&gt;&lt;/pre&gt;
&lt;/div&gt;


&lt;p&gt;The first group defines who can edit the gitosis-admin repository. This means anyone in this group can grant access to repositories. The second group 'myproject' defines who can acess the myproject repository. The members refers to the names of keys in the the 'keydir' directory. So 'george_ornbo.pub' becomes 'george_ornbo'. Repositories need to sit inside /home/git/repositories. You can change the home directory of the git user if you wish to something like /var/git/. This would mean repositories would sit in /var/git/repositories.&lt;/p&gt;

&lt;p&gt;So now if a new developer comes on board we can just add the key to the 'keydir' directory, update the group members, push the git repository and it is done.&lt;/p&gt;

&lt;p&gt;In the above example the 'myproject' repo would be available at git@YOUR_SERVER_HOSTNAME:myproject.git&lt;/p&gt;

&lt;h2&gt;Limited documentation&lt;/h2&gt;

&lt;p&gt;I found that documentation was a little patchy - the best place for documentation is &lt;a href="http://scie.nti.st/2007/11/14/hosting-git-repositories-the-easy-and-secure-way"&gt;here&lt;/a&gt;.&lt;/p&gt;

&lt;h2&gt;A great solution&lt;/h2&gt;

&lt;p&gt;Gitosis is so much better than using *nix accounts to provide access to a repository. With a shared key a developer can easily be given access to one or more repositories, be locked to just read access or given full permissions. It is working really well for me. Highly recommended!&lt;/p&gt;

&lt;h2&gt;Related links&lt;/h2&gt;

&lt;ul&gt;
&lt;li&gt;&lt;a href="http://serverfault.com/questions/26954/how-do-i-share-a-git-repository-with-multiple-users-on-a-machine"&gt;How do I share a Git repository with multiple users on a machine?&lt;/a&gt; - Serverfault question on sharing git repositories&lt;/li&gt;
&lt;li&gt;&lt;a href="http://scie.nti.st/2007/11/14/hosting-git-repositories-the-easy-and-secure-way"&gt;Gitosis&lt;/a&gt; - Hosting Git repositories, The Easy (and Secure) Way&lt;/li&gt;
&lt;li&gt;&lt;a href="http://github.com/"&gt;Github&lt;/a&gt; - Github&lt;/li&gt;
&lt;li&gt;&lt;a href="http://shapeshed.com/journal/using_shared_keys_with_ssh_on_centos_5/"&gt;Using Shared Keys with SSH on Centos 5&lt;/a&gt; - Introduction to shared keys&lt;/li&gt;
&lt;/ul&gt;

&lt;/content&gt;
   
 &lt;img src="http://feeds.feedburner.com/~r/shapeshed/~4/FW5ki328Y0A" height="1" width="1"/&gt;</content>
 <feedburner:origLink>http://shapeshed.com/journal/setting_up_git_for_multiple_developers/</feedburner:origLink></entry>
 
 <entry>
   <title>Easing Rails development with Hirb</title>
   <link href="http://feeds.shapeshed.com/~r/shapeshed/~3/QJr800AUzHE/" />
   <updated>2010-03-10T00:00:00+00:00</updated>
   <published>2010-03-10T00:00:00+00:00</published>
   <id>http://shapeshed.com/journal/easing_rails_development_with_hirb</id>
   <content type="html">
   &lt;h2&gt;Rails Console&lt;/h2&gt;

&lt;p&gt;When developing in Rails I spend a lot of time in the console. If you are a Rails developer you know you can fire it up in rails 2.3.x with&lt;/p&gt;

&lt;div class="highlight"&gt;&lt;pre&gt;&lt;code class="bash"&gt;script/console
&lt;/code&gt;&lt;/pre&gt;
&lt;/div&gt;


&lt;p&gt;Once in the console you can do lots of things like run ActiveRecord queries&lt;/p&gt;

&lt;div class="highlight"&gt;&lt;pre&gt;&lt;code class="console"&gt;&lt;span class="gp"&gt;&amp;gt;&lt;/span&gt;&amp;gt; User.find_by_last_name&lt;span class="o"&gt;(&lt;/span&gt;&lt;span class="s1"&gt;&amp;#39;Ornbo&amp;#39;&lt;/span&gt;&lt;span class="o"&gt;)&lt;/span&gt;
&lt;span class="go"&gt;=&amp;gt; #&amp;lt;User id: 17283, login: &amp;quot;gornbo&amp;quot;, email: &amp;quot;george@shapeshed.com&amp;quot;, crypted_password: &amp;quot;05b80fd4308e8590d2892aeb774bb3a993053e26357a1a8938b...&amp;quot;, password_salt: &amp;quot;rDRzbrh-YmgpTTTDGhQC&amp;quot;, persistence_token: &amp;quot;109b4284438cd9c0238ebf1ffc6aea8091c8ad756c345677c2d...&amp;quot;, single_access_token: &amp;quot;hqP7auU76mHQkpLxhqVI&amp;quot;, perishable_token: &amp;quot;pwUKq8id1PhgCOhPkxIU&amp;quot;, login_count: 4, failed_login_count: 0, last_request_at: &amp;quot;2010-03-09 18:09:35&amp;quot;, current_login_at: &amp;quot;2010-03-08 11:17:13&amp;quot;, last_login_at: &amp;quot;2010-03-08 10:52:05&amp;quot;, current_login_ip: &amp;quot;127.0.0.1&amp;quot;, last_login_ip: &amp;quot;127.0.0.1&amp;quot;, deleted: nil, created_at: &amp;quot;2010-03-04 12:37:38&amp;quot;, updated_at: &amp;quot;2010-03-09 18:09:35&amp;quot;, first_name: &amp;quot;George&amp;quot;, last_name: &amp;quot;Ornbo&amp;quot;, photo_file_name: &amp;quot;avatar.jpg&amp;quot;, photo_content_type: &amp;quot;image/jpeg&amp;quot;, photo_file_size: 4268, photo_updated_at: &amp;quot;2010-03-04 18:15:30&amp;quot;&amp;gt;&lt;/span&gt;
&lt;/code&gt;&lt;/pre&gt;
&lt;/div&gt;


&lt;p&gt;Ick. That's not hugely readable.&lt;/p&gt;

&lt;h2&gt;Hirb to the rescue&lt;/h2&gt;

&lt;p&gt;&lt;a href="http://github.com/cldwalker/hirb"&gt;Hirb&lt;/a&gt; is a gem that makes the console more user friendly. In hirb's words is is&lt;/p&gt;

&lt;blockquote&gt;&lt;p&gt;A mini view framework for console/irb that's easy to use, even while under its influence. Console goodies include a no-wrap table, auto-pager, tree and menu.&lt;/p&gt;&lt;/blockquote&gt;

&lt;p&gt;Returning to our previous version hirb makes the output useful&lt;/p&gt;

&lt;div class="highlight"&gt;&lt;pre&gt;&lt;code class="console"&gt;&lt;span class="gp"&gt;&amp;gt;&lt;/span&gt;&amp;gt; User.find_by_last_name&lt;span class="o"&gt;(&lt;/span&gt;&lt;span class="s1"&gt;&amp;#39;Ornbo&amp;#39;&lt;/span&gt;&lt;span class="o"&gt;)&lt;/span&gt;
&lt;span class="go"&gt;  User Load (40.2ms)   SELECT * FROM `users` WHERE (`users`.`last_name` = &amp;#39;Ornbo&amp;#39;) LIMIT 1&lt;/span&gt;
&lt;span class="go"&gt;+-------+------------+-----------+&lt;/span&gt;
&lt;span class="go"&gt;| id    | first_name | last_name |&lt;/span&gt;
&lt;span class="go"&gt;+-------+------------+-----------+&lt;/span&gt;
&lt;span class="go"&gt;| 17283 | George     | Ornbo     |&lt;/span&gt;
&lt;span class="go"&gt;+-------+------------+-----------+&lt;/span&gt;
&lt;span class="go"&gt;1 row in set&lt;/span&gt;
&lt;/code&gt;&lt;/pre&gt;
&lt;/div&gt;


&lt;p&gt;Nice. We've got the query and a concise, readable view.&lt;/p&gt;

&lt;p&gt;So how do we get it to work? Documentation is available round the web but takes a little piecing together so here it is in one place.&lt;/p&gt;

&lt;h2&gt;Installing Hirb&lt;/h2&gt;

&lt;p&gt;This is easy enough. Just run&lt;/p&gt;

&lt;div class="highlight"&gt;&lt;pre&gt;&lt;code class="bash"&gt;sudo gem install hirb
&lt;/code&gt;&lt;/pre&gt;
&lt;/div&gt;


&lt;p&gt;To use hirb in Rails when you are using the console add a few lines to .ircbc.&lt;/p&gt;

&lt;div class="highlight"&gt;&lt;pre&gt;&lt;code class="bash"&gt;vi ~/.irbrc
&lt;/code&gt;&lt;/pre&gt;
&lt;/div&gt;


&lt;p&gt;Then the following to the file&lt;/p&gt;

&lt;div class="highlight"&gt;&lt;pre&gt;&lt;code class="bash"&gt;&lt;span class="k"&gt;if &lt;/span&gt;ENV&lt;span class="o"&gt;[&lt;/span&gt;&lt;span class="s1"&gt;&amp;#39;RAILS_ENV&amp;#39;&lt;/span&gt;&lt;span class="o"&gt;]&lt;/span&gt;
  require &lt;span class="s1"&gt;&amp;#39;rubygems&amp;#39;&lt;/span&gt;
  require &lt;span class="s1"&gt;&amp;#39;hirb&amp;#39;&lt;/span&gt;
  require &lt;span class="s1"&gt;&amp;#39;active_record&amp;#39;&lt;/span&gt;
  Hirb.enable
  ActiveRecord::Base.logger &lt;span class="o"&gt;=&lt;/span&gt; Logger.new&lt;span class="o"&gt;(&lt;/span&gt;STDOUT&lt;span class="o"&gt;)&lt;/span&gt;
end
&lt;/code&gt;&lt;/pre&gt;
&lt;/div&gt;


&lt;p&gt;Save and quit.&lt;/p&gt;

&lt;p&gt;Now go into the console and run a query. You'll see that the output should be changed to use hirb. If your records have lots of columns you'll likely see&lt;/p&gt;

&lt;div class="highlight"&gt;&lt;pre&gt;&lt;code class="console"&gt;&lt;span class="go"&gt;** Error: Too many fields for the current width. Configure your width and/or fields to avoid this error. Defaulting to a vertical table. **&lt;/span&gt;
&lt;/code&gt;&lt;/pre&gt;
&lt;/div&gt;


&lt;p&gt;So you'll need to customise it..&lt;/p&gt;

&lt;h2&gt;Customising Hirb&lt;/h2&gt;

&lt;p&gt;You can set which columns are shown in the console and other options in a hirb.yml file. In the /config folder of your rails app create a file called hirb.yml. A feature that I really like is that you can specify which columns show for models. So for this example I can specify what shows for the User model using&lt;/p&gt;

&lt;div class="highlight"&gt;&lt;pre&gt;&lt;code class="yaml"&gt;&lt;span class="l-Scalar-Plain"&gt;:output&lt;/span&gt;&lt;span class="p-Indicator"&gt;:&lt;/span&gt;
  &lt;span class="l-Scalar-Plain"&gt;User&lt;/span&gt;&lt;span class="p-Indicator"&gt;:&lt;/span&gt;
    &lt;span class="l-Scalar-Plain"&gt;:options&lt;/span&gt;&lt;span class="p-Indicator"&gt;:&lt;/span&gt;
      &lt;span class="l-Scalar-Plain"&gt;:fields&lt;/span&gt;&lt;span class="p-Indicator"&gt;:&lt;/span&gt;
        &lt;span class="p-Indicator"&gt;-&lt;/span&gt; &lt;span class="l-Scalar-Plain"&gt;id&lt;/span&gt;
        &lt;span class="p-Indicator"&gt;-&lt;/span&gt; &lt;span class="l-Scalar-Plain"&gt;first_name&lt;/span&gt;
        &lt;span class="p-Indicator"&gt;-&lt;/span&gt; &lt;span class="l-Scalar-Plain"&gt;last_name&lt;/span&gt;
&lt;/code&gt;&lt;/pre&gt;
&lt;/div&gt;


&lt;p&gt;Now when I run the query only those fields will show in the console as we saw earlier.&lt;/p&gt;

&lt;div class="highlight"&gt;&lt;pre&gt;&lt;code class="console"&gt;&lt;span class="gp"&gt;&amp;gt;&lt;/span&gt;&amp;gt; User.find_by_last_name&lt;span class="o"&gt;(&lt;/span&gt;&lt;span class="s1"&gt;&amp;#39;Ornbo&amp;#39;&lt;/span&gt;&lt;span class="o"&gt;)&lt;/span&gt;
&lt;span class="go"&gt;  User Load (40.2ms)   SELECT * FROM `users` WHERE (`users`.`last_name` = &amp;#39;Ornbo&amp;#39;) LIMIT 1&lt;/span&gt;
&lt;span class="go"&gt;+-------+------------+-----------+&lt;/span&gt;
&lt;span class="go"&gt;| id    | first_name | last_name |&lt;/span&gt;
&lt;span class="go"&gt;+-------+------------+-----------+&lt;/span&gt;
&lt;span class="go"&gt;| 17283 | George     | Ornbo     |&lt;/span&gt;
&lt;span class="go"&gt;+-------+------------+-----------+&lt;/span&gt;
&lt;span class="go"&gt;1 row in set&lt;/span&gt;
&lt;/code&gt;&lt;/pre&gt;
&lt;/div&gt;


&lt;p&gt;In the project I'm working on I've created a configuration for each model so I only see what I need to see when working in the console.&lt;/p&gt;

&lt;p&gt;There are lots more options available - refer to the &lt;a href="http://tagaholic.me/hirb/doc/"&gt;Rdocs&lt;/a&gt; for more good stuff. I've found hirb really useful so encourage you to give it a go.&lt;/p&gt;

&lt;h2&gt;Related links&lt;/h2&gt;

&lt;ul&gt;
&lt;li&gt;&lt;a href="http://tagaholic.me/2009/03/13/hirb-irb-on-the-good-stuff.html"&gt;Tagaholic: Hirb - Irb On The Good Stuff&lt;/a&gt; - Great introduction to using Hirb&lt;/li&gt;
&lt;li&gt;&lt;a href="http://github.com/cldwalker/hirb"&gt;Hirb Github Repo / README&lt;/a&gt; - The README and Source&lt;/li&gt;
&lt;li&gt;&lt;a href="http://tagaholic.me/hirb/doc/"&gt;Hirb RDocs&lt;/a&gt; - The lowdown on Hirb&lt;/li&gt;
&lt;li&gt;&lt;a href="http://railscasts.com/episodes/176-searchlogic"&gt;Railscast demonstrating Hirb&lt;/a&gt; - Ryan Bates shows hirb in action&lt;/li&gt;
&lt;/ul&gt;

&lt;/content&gt;
   
 &lt;img src="http://feeds.feedburner.com/~r/shapeshed/~4/QJr800AUzHE" height="1" width="1"/&gt;</content>
 <feedburner:origLink>http://shapeshed.com/journal/easing_rails_development_with_hirb/</feedburner:origLink></entry>
 
 
</feed>
