<?xml version="1.0" encoding="UTF-8"?>
<rss version="2.0"
	xmlns:content="http://purl.org/rss/1.0/modules/content/"
	xmlns:wfw="http://wellformedweb.org/CommentAPI/"
	xmlns:dc="http://purl.org/dc/elements/1.1/"
	xmlns:atom="http://www.w3.org/2005/Atom"
	xmlns:sy="http://purl.org/rss/1.0/modules/syndication/"
	xmlns:slash="http://purl.org/rss/1.0/modules/slash/"
	>

<channel>
	<title>emson...</title>
	<atom:link href="http://blog.emson.co.uk/feed/" rel="self" type="application/rss+xml" />
	<link>http://blog.emson.co.uk</link>
	<description></description>
	<lastBuildDate>Fri, 22 Jan 2010 21:32:39 +0000</lastBuildDate>
	<generator>http://wordpress.org/?v=2.8.4</generator>
	<language>en</language>
	<sy:updatePeriod>hourly</sy:updatePeriod>
	<sy:updateFrequency>1</sy:updateFrequency>
			<item>
		<title>How to Automatically Log In Using SSH On Dreamhost</title>
		<link>http://blog.emson.co.uk/2009/09/how-to-automatically-log-in-using-ssh-on-dreamhost/</link>
		<comments>http://blog.emson.co.uk/2009/09/how-to-automatically-log-in-using-ssh-on-dreamhost/#comments</comments>
		<pubDate>Fri, 25 Sep 2009 08:34:18 +0000</pubDate>
		<dc:creator>ben</dc:creator>
				<category><![CDATA[commands]]></category>
		<category><![CDATA[command line]]></category>
		<category><![CDATA[dreamhost]]></category>
		<category><![CDATA[ssh]]></category>
		<category><![CDATA[unix]]></category>

		<guid isPermaLink="false">http://blog.emson.co.uk/?p=74</guid>
		<description><![CDATA[If you build web sites and host (or want to host) them on Dreamhost, you will be well aware that at some stage you will be using SSH to log in and out of your hosting server. If you have many sites then this gradually becomes tiresome &#8211; especially if you use tools like Capistrano [...]]]></description>
			<content:encoded><![CDATA[<p>If you build web sites and <a href="http://www.dreamhost.com/r.cgi?105422">host (or want to host) them on Dreamhost</a>, you will be well aware that at some stage you will be using SSH to log in and out of your hosting server. If you have many sites then this gradually becomes tiresome &#8211; especially if you use tools like <a href="http://www.capify.org/index.php/Capistrano">Capistrano</a> to deploy your applications, as you will constantly have to re-enter your passwords.</p>

<p>Fortunately you can certify your local computer, such that it will automatically enter the SSH password for you. Here are some quick tips on how to do it.</p>

<h3>Generate Your Security Keys</h3>

<p>Generate your private/public key pair on your local machine, from your home directory:</p>

<pre><code>ssh-keygen -d

Now DON'T enter a password - just press return, otherwise you 
will still need to enter a password, when you log in with SSH.
</code></pre>

<h3>Set Privileges And Copy The Public Key To Your Server</h3>

<p>Use the following command to copy your newly created <strong>~/.ssh/id_dsa.pub</strong> file up to the server you wish to remote log in to.  Note that this command below will set the permissions both locally and remotely. The remote .ssh/* needs to be set to 0600.</p>

<p>N.B. Replace USERNAME and MY_DOMAIN with your own username and domain.</p>

<pre><code>ssh USERNAME@ftp.MY_DOMAIN.COM 'test -d .ssh || mkdir -m 0700 .ssh ; cat &gt;&gt; .ssh/authorized_keys &amp;&amp; chmod 0600 .ssh/*' &lt; ~/.ssh/id_dsa.pub

  Enter the normal USERNAME password.
</code></pre>

<h3>Log In Using SSH</h3>

<p>Now log in using:</p>

<pre><code>ssh USERNAME@ftp.MY_DOMAIN.COM

You shouldn't neet to enter a password.
</code></pre>

<h3>Taking It Further</h3>

<p>To simplify things even further you can modify the <strong>~/.ssh/config</strong> file such:</p>

<pre><code>Host NICKNAME
Hostname MY_DOMAIN.COM
User USERNAME
</code></pre>

<p>Now you only need to type:</p>

<pre><code>ssh NICKNAME

And you will be automatically logged in.
</code></pre>
]]></content:encoded>
			<wfw:commentRss>http://blog.emson.co.uk/2009/09/how-to-automatically-log-in-using-ssh-on-dreamhost/feed/</wfw:commentRss>
		<slash:comments>0</slash:comments>
		</item>
		<item>
		<title>Create Sinatra Partials The Rails Way</title>
		<link>http://blog.emson.co.uk/2009/09/create-sinatra-partials-the-rails-way/</link>
		<comments>http://blog.emson.co.uk/2009/09/create-sinatra-partials-the-rails-way/#comments</comments>
		<pubDate>Fri, 25 Sep 2009 08:09:57 +0000</pubDate>
		<dc:creator>ben</dc:creator>
				<category><![CDATA[programming]]></category>
		<category><![CDATA[ruby]]></category>
		<category><![CDATA[frameworks]]></category>
		<category><![CDATA[sinatra]]></category>
		<category><![CDATA[tips]]></category>

		<guid isPermaLink="false">http://blog.emson.co.uk/?p=71</guid>
		<description><![CDATA[This is just a quick post. I&#8217;ve been playing around with the Sinatra micro web framework, and have to say that it is excellent. It really is the perfect tool for rapidly creating small and useful Ruby micro-sites.

Being small and lightweight it doesn&#8217;t have many of the features of larger frameworks like Ruby on Rails. [...]]]></description>
			<content:encoded><![CDATA[<p>This is just a quick post. I&#8217;ve been playing around with the <a href="http://www.sinatrarb.com/">Sinatra micro web framework</a>, and have to say that it is excellent. It really is the perfect tool for rapidly creating small and useful <a href="http://www.ruby-lang.org/en/">Ruby</a> micro-sites.</p>

<p>Being small and lightweight it doesn&#8217;t have many of the features of larger frameworks like <a href="http://rubyonrails.org/">Ruby on Rails</a>. One of the features I&#8217;ve begun to need is the handling of Rails like partials.</p>

<p>Notably I need to pass both local variables and collections to the partial code and have the partials rendered accordingly.
I started implementing my own version, and then came across a nice little <a href="http://github.com/">Github</a> project: <a href="http://github.com/sbfaulkner/sinatra-helpers">Sinatra-Helpers by sbfaulkner</a>.</p>

<p>Anyway here is the code he uses for Sinatra partials:</p>

<pre><code>def haml_partial(name, options = {})
  item_name = name.to_sym
  counter_name = "#{name}_counter".to_sym
  if collection = options.delete(:collection)
    collection.enum_for(:each_with_index).collect do |item,index|
      haml_partial name, options.merge(:locals =&gt; {item_name =&gt; item, counter_name =&gt; index+1})
    end.join
  elsif object = options.delete(:object)
    haml_partial name, options.merge(:locals =&gt; {item_name =&gt; object, counter_name =&gt; nil})
  else
    haml "_#{name}".to_sym, options.merge(:layout =&gt; false)
  end
end
</code></pre>

<p>You can use his project or if you just need this feature just pop this code into your Sinatra helpers file  <strong>application_helper.rb</strong>:</p>

<pre><code>helpers do

  def partial(name, options = {})
    item_name = name.to_sym
    counter_name = "#{name}_counter".to_sym
    if collection = options.delete(:collection)
      collection.enum_for(:each_with_index).collect do |item, index|
        partial(name, options.merge(:locals =&gt; { item_name =&gt; item, counter_name =&gt; index + 1 }))
      end.join

    elsif object = options.delete(:object)
      partial name, options.merge(:locals =&gt; {item_name =&gt; object, counter_name =&gt; nil})
    else
      haml "_#{name}".to_sym, options.merge(:layout =&gt; false)
    end
  end
end
</code></pre>

<p>Now you can call the partial from a your page e.g. <strong>index.haml</strong></p>

<pre><code>= partial("mypartial", :locals =&gt; {:var1 =&gt; "value 1", :var2 =&gt; "value 2 and so on"})
</code></pre>

<p>Create a partial in the same directory as the calling page. Note that this code doesn&#8217;t like filenames truncated with a &#8216;-&#8217;, so avoid this if possible. Also like in Rails your partials should start with an underscore. e.g.  <strong>_mypartial.haml</strong></p>

<p>To access the variable from this partial simply call the local variable name in your code:</p>

<pre><code>%h2 
  This is var1:
  = var1

%p 
  And this is var2:
  = var2
</code></pre>

<p>Handling collections, again, is similar to the way Rails handles partial collections. From your page call the partial with a collection such as:</p>

<pre><code>= partial("listitem", :collection =&gt; ["item 1", "item 2 and so on"])
</code></pre>

<p>Now in the <strong>_listitem.haml</strong> partial code simply provide the partial name as a variable or the partialname with _counter for the increment number e.g.</p>

<pre><code>%li
  = listitem
  is the 
  = listitem_counter
  in this array
</code></pre>

<p>Anyway all pretty basic stuff but I hope it helps the casual Sinatra surfer.</p>

<p>Goodluck.</p>
]]></content:encoded>
			<wfw:commentRss>http://blog.emson.co.uk/2009/09/create-sinatra-partials-the-rails-way/feed/</wfw:commentRss>
		<slash:comments>0</slash:comments>
		</item>
		<item>
		<title>18 Useful bash scripts for web developers</title>
		<link>http://blog.emson.co.uk/2009/06/18-useful-bash-scripts-for-web-developers/</link>
		<comments>http://blog.emson.co.uk/2009/06/18-useful-bash-scripts-for-web-developers/#comments</comments>
		<pubDate>Fri, 05 Jun 2009 10:22:15 +0000</pubDate>
		<dc:creator>ben</dc:creator>
				<category><![CDATA[Uncategorized]]></category>

		<guid isPermaLink="false">http://blog.emson.co.uk/?p=58</guid>
		<description><![CDATA[Using bash scripts to become a more efficient web developer

Here are a few scripts, that I find really useful for speeding up my web development time.

I&#8217;ve been building up this list as I needed to use them &#8211; so they maybe a little raw.

For example often clients send me images with filenames that don&#8217;t match [...]]]></description>
			<content:encoded><![CDATA[<h2>Using bash scripts to become a more efficient web developer</h2>

<p>Here are a few scripts, that I find really useful for speeding up my web development time.</p>

<p>I&#8217;ve been building up this list as I needed to use them &#8211; so they maybe a little raw.</p>

<p>For example often clients send me images with filenames that don&#8217;t match my naming standard, so running the appropriate script really helps keep me focussed on the job in hand and not waste too much time reformatting filenames etc.</p>

<p>Finally if you have any useful little bash scripts why don&#8217;t you add them to the comments below?</p>

<h3>Bash script to append a .txt extension to a filename</h3>

<p>Iterate over the current directory, get all files with .log and append .txt to the end of the entire filename:</p>

<pre><code>for i in *.log*; do mv "$i" "$i.txt"; done
</code></pre>

<h3>Script to make filenames lowercase</h3>

<p>Converts all the file names in a directory and converts them to lowercase.</p>

<p>echo version:</p>

<pre><code>for i in *.log*; do echo mv \"$i\" \"`echo $i| tr [A-Z] [a-z]`\"; done
</code></pre>

<p>real version:</p>

<pre><code>for i in *.txt; do mv "$i" "`echo $i| tr [A-Z] [a-z]`"; done
</code></pre>

<h3>Quick note on how to use grep to search for a string in file</h3>

<p>-o print Only the matched parts of a matching line, with each part on a separate line.
-H print the filename for each match.
-n prefix each line of output with the 1 based line number.
-R, -r recursively read all files under subdirectories.</p>

<pre><code>grep -oHnr "some pattern"  *.txt
</code></pre>

<p>{txt,log} this globs the file extensions together.
2>/dev/null this passes all errors to a blackhole, so that they won&#8217;t be displayed.</p>

<pre><code>grep 123741 ./adapter_logs/*.{txt,log} 2&gt;/dev/null
</code></pre>

<p>Find all occurrences of 123741 in all .txt and .log files in all subdirectories.</p>

<pre><code>for i in 'find . -type d'; do grep 123741 $i/*.{txt,log}; done 2&gt;/dev/null
</code></pre>

<h3>List all files that match this regular expression in the current direcory</h3>

<p>All files with the number 5 in their name.</p>

<pre><code>ls | grep -e .*5.*
</code></pre>

<h3>Bash script to check whether a tag exists in a subversion repository</h3>

<pre><code>svn ls http://www.mysvnserver.co.uk/myproject/tags | grep mytag-0.7.0.1/
</code></pre>

<p>The [ ] is known as a Test, by default it tests integers
Also to end an if statement you use fi</p>

<pre><code>if [ 1 = 1 ] ; then echo YES; else echo NO; fi

if [ "`svn ls http://mysvnserver/mysvnrepository/myproject/tags | grep R-9.20.400.0/`" = "R-9.20.400.0/" ]; then echo YES; else echo NO; fi
</code></pre>

<p>Note need the / in the evaluation part of &#8220;it-0.9.0.7/&#8221;, don&#8217;t really need it in grep it-0.9.0.7/</p>

<pre><code>$ if [ "`svn ls http://www.mysvnserver.co.uk/myproject/tags | grep it-0.7.0.1/`" = "it-0.7.0.1/" ]; then echo YES; else echo NO; fi
</code></pre>

<h3>Quick note on how to increment a variable, in a bash script</h3>

<pre><code>j=0; j=$(($j+1))
</code></pre>

<p>incrementing in a loop</p>

<pre><code>j=0;for i in *.txt; do echo "some_file_"$j".txt"; j=$(($j+1)); done
</code></pre>

<h3>Using a bash for loop to list all text files and append whoopee</h3>

<pre><code>for i in *.txt; do echo $i"whoopee"; done
</code></pre>

<h3>Change all filenames to be a specific incremented name, starting from file 16</h3>

<pre><code>j=16;for i in *.jpg; do mv "$i" "gallery_"$j".jpg"; j=$(($j+1)); done;ls
</code></pre>

<h3>Script to loop through all .txt filenames and make them lower case</h3>

<pre><code>for i in *.txt; do mv "$i" "`echo $i| tr [A-Z] [a-z]`"; done
</code></pre>

<h3>Get all JPG files and create the appropriate HTML list tags for them and add them to a file</h3>

<p>Create an HTML version:</p>

<pre><code>for i in *.jpg; do echo "\t&lt;li&gt;\r\t\t&lt;img src='images/$i' alt='' /&gt;\r\t&lt;/li&gt;"; done &gt; list_items.html
</code></pre>

<p>Create a HAML version:</p>

<pre><code>for i in *.jpg; do echo "\t%li\r\t\t%img{ :src =&gt; 'images/$i', :alt =&gt; '' }\r"; done &gt; imgs.haml
</code></pre>

<h3>Batch change a misspelled filename of certain files, using string replacement</h3>

<pre><code>for i in aples*.jpg; do mv $i ${i/aples/apples} ; done
</code></pre>

<h3>Script to batch create files based on filenames in a file</h3>

<p>Create a file called something like &#8220;my_files.txt&#8221; with the following content:</p>

<blockquote>
  <p>archive_error_112480_0040.txt
  archive_error_114390_0043.txt
  etc&#8230;</p>
</blockquote>

<p>Commands:</p>

<pre><code>for i in `sed -n -e 'p' my_files.txt`; do mkdir a_test/$i; done
or
while read x; do touch $x; done &lt; my_files.txt
or
cat my_files.txt | xargs touch
(xargs passes each line as an argument into EACH touch)
</code></pre>

<h3>Using bash Expansions, and allow escapes</h3>

<p>-e is an undocumented flag that allows escapes
Expansion ${command/parameter/substitution} everything else needs to be escaped.</p>

<pre><code>echo -e ${PATH//\:/\\n}
</code></pre>

<h3>Executing a .bash_script after making changes</h3>

<pre><code>source .bash_profile
or
. .bash_profile
</code></pre>

<p>NB: you can &#8216;include&#8217; other bash .sh scripts in a .bash_profile file by using &#8217;source&#8217; or &#8216;.&#8217;</p>

<h3>Quick tip on using curl for downloading files off the web</h3>

<p>Use -O to name the remote file, curl will save it locally but remove the rest of the path.</p>

<pre><code>curl -O http://rubyforge-files.ruby-forum.com/rubygems/rubygems-0.9.0.tgz
</code></pre>

<h3>Bash command for testing the existence of files and directories</h3>

<p>If a directory does NOT exist create it</p>

<pre><code>[ -d "/var/cache/git" ] || mkdir /var/cache/git
</code></pre>

<p>If a file exists echo a message:</p>

<pre><code>[ -f "./new_file.txt" ] &amp;&amp; echo "its there"
</code></pre>

<h3>Bash command to remove spaces from filenames</h3>

<pre><code>for i in *.html; do mv "$i" "`echo $i| tr -d ' '`"; done
</code></pre>

<p>replace spaces for underscores</p>

<pre><code>for i in *.html; do mv "$i" "`echo $i| tr ' ' '_'`"; done
</code></pre>

<p>Vim regex to replace spaces in images file names of ah HTML page</p>

<pre><code>:%s:\(images\/\)\(\w\+\)\s\(\w\+\.jpg\):\1\2_\3:g
</code></pre>

<h3>Copy text to the clipboard</h3>

<pre><code>echo 'hello world'|pbcopy
cmd + v
</code></pre>

<h2>Conclusion</h2>

<p>Some of these are quite basic but useful none-the-less, please add your own to the comments below.
Many thanks, and good luck.</p>

<h2>Updated&#8230;</h2>

<h3>Script function for .bash_profile to cd to the last opened finder location</h3>

<p>This is a script written by a colleague.  <a href="http://www.visualcortex.co.uk/">James Power</a>.
Add the following function to your <strong>.bash_profile</strong> in Apple OSX.  Now open a directory in Finder, then open terminal and type <strong>cdf</strong>, your terminal will now change directory to the same one as the last Finder opened.</p>

<pre><code># function to change directory to the one set in the last opened finder.
cdf () {
   currFolderPath=$( /usr/bin/osascript &lt;&lt;"         EOT"
       tell application "Finder"
           try
               set currFolder to (folder of the front window as alias)
           on error
               set currFolder to (path to desktop folder as alias)
           end try
           POSIX path of currFolder
       end tell
            EOT
   )
   echo "cd to \"$currFolderPath\""
   cd "$currFolderPath"
}
</code></pre>

<p>Also for a much more comprehensive list of commands check out: <a href="http://www.commandlinefu.com/commands/tagged/34/bash">http://www.commandlinefu.com/commands/tagged/34/bash</a></p>

<h3>Ruby Rush command-line tool</h3>

<p>If you use <strong>Ruby</strong> maybe check out <a href="http://rush.heroku.com/">Rush</a>, it allows you do use Ruby in a bash command-line like way.</p>
]]></content:encoded>
			<wfw:commentRss>http://blog.emson.co.uk/2009/06/18-useful-bash-scripts-for-web-developers/feed/</wfw:commentRss>
		<slash:comments>46</slash:comments>
		</item>
		<item>
		<title>Halcyon Events logo on Jenson Button&#8217;s Formula One helmet</title>
		<link>http://blog.emson.co.uk/2009/03/halcyon-events-logo-on-jenson-buttons-formula-one-helmet/</link>
		<comments>http://blog.emson.co.uk/2009/03/halcyon-events-logo-on-jenson-buttons-formula-one-helmet/#comments</comments>
		<pubDate>Sat, 28 Mar 2009 14:26:30 +0000</pubDate>
		<dc:creator>ben</dc:creator>
				<category><![CDATA[rails]]></category>
		<category><![CDATA[sport]]></category>

		<guid isPermaLink="false">http://blog.emson.co.uk/?p=35</guid>
		<description><![CDATA[Jenson Button has just got pole position ready for the Australian Formula One race tomorrow.  This is pretty exciting as on either side of his helmet is the Halcyon Events Ltd. logo.

Halcyon Events is a company that specialises in high end bespoke Formula One events.  Through their contacts they can take you and [...]]]></description>
			<content:encoded><![CDATA[<p>Jenson Button has just got pole position ready for the Australian Formula One race tomorrow.  This is pretty exciting as on either side of his helmet is the <a href="http://www.halcyonsport.com">Halcyon Events Ltd. logo.</a></p>

<p><div id="attachment_39" class="wp-caption alignnone" style="width: 510px"><a href="http://www.halcyonsport.com"><img src="http://blog.emson.co.uk/wp-content/uploads/2009/03/helmet_logo.jpg" alt="Jenson Button&#039;s Helmet with Halcyon Logo" title="helmet_logo" width="500" height="333" class="size-full wp-image-39" /></a><p class="wp-caption-text">Jenson Button's Helmet with Halcyon Logo</p></div></p>

<p><a href="http://www.halcyonsport.com">Halcyon Events</a> is a company that specialises in high end bespoke Formula One events.  Through their contacts they can take you and your clients behind the scenes to areas not normally permitted, and give you a unique experience into Formula One (F1).</p>

<p>The web site was built by me, the design was created by <a href="http://www.scamperbranding.com/">Scamper Branding</a> and the logo on Jenson&#8217;s helmet was designed by <a href="http://www.fireflycreative.co.uk/">Firefly Creative</a>.</p>

<p><a href="http://www.fireflycreative.com"><img src="http://blog.emson.co.uk/wp-content/uploads/2009/03/fireflylogo_sml.jpg" alt="Firefly Creative logo" title="Firefly Creative logo" width="150" height="49" /></a></p>

<p>Anyway fingers crossed for Jenson Button to win the Australian Grand Prix!.</p>

<p><strong>&#8211; Update &#8211;</strong> Fantastic Jenson Button won the Melbourne Grand Prix!  How exciting.</p>
]]></content:encoded>
			<wfw:commentRss>http://blog.emson.co.uk/2009/03/halcyon-events-logo-on-jenson-buttons-formula-one-helmet/feed/</wfw:commentRss>
		<slash:comments>2</slash:comments>
		</item>
		<item>
		<title>An apology and a promise</title>
		<link>http://blog.emson.co.uk/2009/03/an-apology-and-a-promise/</link>
		<comments>http://blog.emson.co.uk/2009/03/an-apology-and-a-promise/#comments</comments>
		<pubDate>Thu, 12 Mar 2009 16:44:25 +0000</pubDate>
		<dc:creator>ben</dc:creator>
				<category><![CDATA[general]]></category>

		<guid isPermaLink="false">http://blog.emson.co.uk/?p=27</guid>
		<description><![CDATA[This is just a quick note to apologise for not posting for the last couple of months.  A lot has been happening and I have actually written a number of posts but never quite finished them.  Also I promise to write more regularly come the end of March 2009 (hopefully).

Well my New Year [...]]]></description>
			<content:encoded><![CDATA[<p>This is just a quick note to apologise for not posting for the last couple of months.  A lot has been happening and I have actually written a number of posts but never quite finished them.  Also I promise to write more regularly come the end of March 2009 (hopefully).</p>

<p>Well my New Year started with a &#8216;<a href="http://www.theloonydook.co.uk/">Looney Dook</a>&#8216; in the <a href="http://maps.google.co.uk/maps?f=q&amp;source=s_q&amp;hl=en&amp;geocode=&amp;q=elie,+scotland&amp;sll=53.800651,-4.064941&amp;sspn=14.253717,33.925781&amp;ie=UTF8&amp;ll=56.193812,-2.82177&amp;spn=0.052339,0.132523&amp;z=13&amp;iwloc=addr">Firth of Fourth</a> on New Years day.  Man it was cold and a struggle to get in, but I felt fantastic afterwards.  Its seems like quite a good analogy of how my year has been so far.</p>

<p>Anyway I&#8217;ve been busy building a couple of web sites, with a number still under development, if you get a moment please check them out and let me know what you think:</p>

<ul>
<li><a href="http://www.halcyonsport.com">www.halcyonsport.com</a></li>
<li><a href="http://www.guygoodfellow.com">www.guygoodfellow.com</a></li>
<li><a href="http://www.ledudy.com">www.ledudy.com</a></li>
</ul>

<p>I&#8217;ve also been coming up with a number of little side line projects which I hope to share with you soon.  One of them involves using <a href="http://www.twitter.com">Twitter</a> and if you want to hear more when the time comes you can follow me on <a href="http://www.twitter.com/emson">twitter/emson</a>.</p>

<p>Finally this year for me, and I&#8217;m sure everyone, seems to be about how to restructure and think in terms of business and income.  I expect if you are open to change and think a bit laterally there are many opportunities, if you don&#8217;t change you are likely to struggle.</p>

<p>The business world is changing beneath our feet and we need to be quick to act on the opportunities it presents us.  <a href="http://sethgodin.typepad.com/seths_blog/2009/03/pivots-for-change-swords-and-plowshares.html">Seth Godin&#8217;s quick article</a> highlights this rather well.</p>

<p>So I&#8217;ll start putting together some interesting articles from the beginning of April onwards &#8211; I hope you can wait till then, and thanks for following me.</p>

<p>Ben&#8230;</p>
]]></content:encoded>
			<wfw:commentRss>http://blog.emson.co.uk/2009/03/an-apology-and-a-promise/feed/</wfw:commentRss>
		<slash:comments>0</slash:comments>
		</item>
		<item>
		<title>Chrome is a Desktop Web Application platform</title>
		<link>http://blog.emson.co.uk/2008/09/chrome-is-a-desktop-web-application-platform/</link>
		<comments>http://blog.emson.co.uk/2008/09/chrome-is-a-desktop-web-application-platform/#comments</comments>
		<pubDate>Thu, 04 Sep 2008 15:00:22 +0000</pubDate>
		<dc:creator>ben</dc:creator>
				<category><![CDATA[Uncategorized]]></category>
		<category><![CDATA[browsers]]></category>
		<category><![CDATA[google]]></category>
		<category><![CDATA[web apps]]></category>

		<guid isPermaLink="false">http://blog.emson.co.uk/2008/09/chrome-is-a-desktop-web-application-platform/</guid>
		<description><![CDATA[Google Chrome is not just a browser

Google Chrome was launched a few days ago on the 2nd September 2008, since then there has been much hype and articles written about it.  So what is it?
Well, Wikipedia describes it: &#8220;Google Chrome is a free and open source web browser developed by Google.&#8221;, however it is [...]]]></description>
			<content:encoded><![CDATA[<h2>Google Chrome is not just a browser</h2>

<p>Google Chrome was launched a few days ago on the 2nd September 2008, since then there has been much hype and articles written about it.  So what is it?
Well, Wikipedia describes it: <a href="http://en.wikipedia.org/wiki/Google_Chrome">&#8220;Google Chrome is a free and open source web browser developed by Google.&#8221;</a>, however it is more than that.</p>

<p>It comes dressed as a web browser but is actually a <strong>Desktop Web Application platform</strong>.  It facilitates the creation of Web Applications that are desktop like in functionality.
These Web Applications will, be much more responsive, secure and stable than the previous generation of web applications because these new technologies are forming a suitable infrasructure.</p>

<p>It&#8217;s one of the technologies ushering in a new era for the Internet.</p>

<p>I wrote an article recently that describes how these technologies are laying down foundations for applications should use the web: <a href="http://rapidappsgroup.com/content/desktop-web-applications-using-sproutcore/">Desktop web applications using SproutCore/</a></p>

<h2>Why is Chrome significant</h2>

<p>Recently a number of the big Internet centred companies have been making strides to enable the next generation of Web Applications.</p>

<p>Adobe with its AIR technology, Microsoft with Silverlight, Apple with its endorsement of the SproutCore JavaScript framework, and Google, until this announcement, Gears.</p>

<p>The problem is none of these offerings is perfect, and some of them are very much propietary, tying users into their technology.</p>

<p>The problem Google has is that Gears is actually a very good product, but why would anybody download and install it if there aren&#8217;t may web sites using it?  At the moment this is an additional step resulting in the fact that most users have no compelling reason to install it.  In a nut shell nobody is using it.</p>

<p>However with Chrome Google is able to hedge its bets, it has merged several standalone technologies into one very capable and pleasing package.</p>

<ul>
<li>It has an awesome JavaScript engine enabling JavaScript to approach Desktop Application speeds.</li>
<li>It has Gears enabling developers to create offline applications that can interact with your desktop.</li>
<li>It can open a Web Application directly in its own window, without any of the traditional browser tool bar and menu overheads.  Making Web Applications look like Desktop Applications.</li>
<li>It has added stability by making each tab a separate process, essentially each tab behaves like its very own browser.</li>
<li>It is secure in that it has been designed from the ground up following proven security models, such as sandboxing.</li>
<li>Its elegant, meaning that it feels small, light and fit for purpose.  It has taken some leaves out of Apple&#8217;s book and made the UI simple yet powerful.</li>
</ul>

<h2>Chrome is OpenSource and follows standards</h2>

<p>This next era of the Internet is going to very busy.  Everyday there are vast numbers of web pages and Web Applications created, and with this colosal amounts of data and information to sift through.</p>

<p>For an individual it is becoming harder and harder to focus and extract the useful information from all that data.  In essance <strong>attention is a currency</strong> and with all these web sites and applications vying for our eyeballs how do we as users filter the wheat from the chaff?</p>

<p>That part of the Internet isn&#8217;t completely written yet but for certain, by following Web Standards and by incorporating OpenSource technologies we are laying the foundations for future tools to help us do this.  Chrome is one such OpenSource technology.</p>

<p>Chrome needs to follow standards as these will pull it along and it will evolve into something very powerful.  Even if it doesn&#8217;t some of its components may find there way into some technology that does.  I dare say that Google will have a finger in that pie no matter.  As a result it is a win win situation for Google.</p>

<p>This also highlights the point that Microsoft&#8217;s Internet Explorer browser is gradually getting left behind.  Admittedly standards aren&#8217;t followed by all these companies but Microsoft has certainly been more relunctant to endorse them.</p>

<h2>JavaScript is a key web technology</h2>

<p>JavaScript is old, it appeared in the early browser wars and there hasn&#8217;t been any significant changes since.  Its been buggy, doesn&#8217;t scale well, and there are differences on just about every browser implementation, but it is everywhere.</p>

<p>Recently, with Web 2.0, JavaScript has had a bit of a resurgance and some very useful frameworks have emerged which mitigate the implementation issues and improve its stability.  However up until recently it has been slow.  Too slow to be useful in terms of creating sophisticated Desktop like Web Applications.</p>

<p>It seems that in order to compete in the new Desktop Web Application arena companies need to implement a fast JavaScript engine.
Apple&#8217;s Safari is implementing SquirrelFish, and Firefox is implementing TraceMonkey and now Google has created V8.</p>

<p>John Resig has done a <a href="http://ejohn.org/blog/javascript-performance-rundown/">comparison of the relevant JavaScript engines</a> and it seems that V8 is very fast.
Matthieu Riou says that V8 is <a href="http://offthelip.org/?p=113">closer to a compiler than a traditional VM</a>.  It takes JavaScript code and converts it into low level byte code.  It is still early days but we can expect this performance to keep improving.</p>

<h2>Desktop Web Applications, Slickening the Web.</h2>

<p>This era of the Internet is seeing a &#8217;slickening of the web&#8217;.  Web Applications are becoming more Desktop like.  Platforms like Chrome are only going to push us faster along this path.</p>

<p>We can expect to see more applications like Gmail, MobileMe, GoogleMaps, GoogleDocs, etc. but Chrome puts Google very definately in one of the front seats for the future.</p>

<p>Its not fully there yet as its still missing features but it will evolve quickly.
Google has vast resources and is able to test the browser against millions of web sites before it ever sees a user.  This will only help to refine and improve it.</p>

<p>With Google Chrome, the Web is changing up a Gear.</p>
]]></content:encoded>
			<wfw:commentRss>http://blog.emson.co.uk/2008/09/chrome-is-a-desktop-web-application-platform/feed/</wfw:commentRss>
		<slash:comments>5</slash:comments>
		</item>
		<item>
		<title>Cannot select text with mouse in Microsoft Word, fix.</title>
		<link>http://blog.emson.co.uk/2008/08/cannot-select-text-with-mouse-in-microsoft-word-fix/</link>
		<comments>http://blog.emson.co.uk/2008/08/cannot-select-text-with-mouse-in-microsoft-word-fix/#comments</comments>
		<pubDate>Thu, 21 Aug 2008 11:47:30 +0000</pubDate>
		<dc:creator>ben</dc:creator>
				<category><![CDATA[windows]]></category>
		<category><![CDATA[word problem]]></category>

		<guid isPermaLink="false">http://blog.emson.co.uk/2008/08/cannot-select-text-with-mouse-in-microsoft-word-fix/</guid>
		<description><![CDATA[A friend had the following problem with their laptop the other day.
When they open Microsoft Word they cannot select any text with the mouse, they couldn&#8217;t even place the cursor into the text by clicking the mouse on the text.

She said that the situation seemed to have occured when Norton Antivirus requested an update at [...]]]></description>
			<content:encoded><![CDATA[<p>A friend had the following problem with their laptop the other day.
When they open Microsoft Word they cannot select any text with the mouse, they couldn&#8217;t even place the cursor into the text by clicking the mouse on the text.</p>

<p>She said that the situation seemed to have occured when Norton Antivirus requested an update at the same time she was doing something in Word.</p>

<p>I suspected that it was that Word had somehow got corrupted, so I ran a repair, by inserting her Microsoft Office DVD and bring up the installer, and selecting <em>Repair</em>.</p>

<p>This made no difference, I then reinstalled Office, still the problem persisted.  This made me think that the problem was related to the Registry, so I did a Google search.</p>

<h2>Fixing Word text selection</h2>

<p>I found these articles:</p>

<ul>
<li><a href="http://support.microsoft.com/kb/921541">http://support.microsoft.com/kb/921541</a> which describes how to troubleshoot problems with Microsoft Word 2007/2003/2002. (Really I&#8217;m not impressed it just stinks of shoddy programming.)</li>
<li><a href="http://www.vistax64.com/vista-general/39390-cant-select-text-word-2007-vista.html">http://www.vistax64.com/vista-general/39390-cant-select-text-word-2007-vista.html</a></li>
</ul>

<p>To summarise the fix:</p>

<ul>
<li>Backup the Word\Data part of the Registry first</li>
<li>delete the the Word\Data section</li>
<li>restart Word </li>
<li>if it works then its completed, else restore the backup and keep Google searching.</li>
</ul>

<h3>Warning about Word registry changes</h3>

<p>This fix involves removing the Word/Data registry key.  By deleting this key you will loose some options you have set, this just means that you will need to reset them again.  Additionally you will loose the list of files in your <em>recently used files list</em> at the bottom of the file menu.</p>

<p>Additionally be really careful about deleting anything out of the registry, because it can cause serious problems.  All the main Windows programs use it, and you could end up reinstalling everything including your copy of Windows.</p>

<h3>Backup the offending part of your computer&#8217;s registry:</h3>

<ol>
<li>Exit all Office programs, Word, Excel, Outlook etc if they are running.</li>
<li>Open regedit by: Clicking <strong>Start/Run</strong>, then type <strong>regedit</strong>, and select <strong>OK</strong>.</li>
<li><p>Navigate the registry and select the appropriate Word registry subkey:</p>

<ul>
<li><strong>Word 2002:</strong> <br/>HKEY_CURRENT_USER\Software\Microsoft Office\10.0\Word\Data</li>
<li><strong>Word 2003:</strong> <br/>HKEY_CURRENT_USER\Software\Microsoft Office\11.0\Word\Data</li>
<li><strong>Word 2007:</strong> <br/>HKEY_CURRENT_USER\Software\Microsoft\Office\12.0\Word\Data</li>
</ul></li>
<li><p>Select the Data node, then from the <strong>File</strong> menu choose <strong>Export</strong>.</p></li>
<li>Name this backup file something like <strong>word_data.reg</strong>, and save it your desktop.</li>
</ol>

<h3>Delete the Word\Data registry node</h3>

<ol>
<li>Select the appropriate <strong>Word\Data</strong> node mentioned in part 3.</li>
<li>From the <strong>Edit</strong> menu select <strong>Delete</strong>, and then click <strong>Yes</strong>.</li>
<li>Exit regedit.</li>
</ol>

<h3>Restart Word</h3>

<ol>
<li>Restart Word.  This will cause Word to recreate this registry node, but you may have to re-enter some of your Word options.  If everything is working as expected you can finish.  If you still have a problem follow the next section.</li>
</ol>

<h3>Restore the backed up registry node</h3>

<p>If the problem still persists then restore your registry back, and keep looking for a solution.
To restore the registry back to normal simply:</p>

<ul>
<li>Double-click the <strong>word_data.reg</strong> file on your desktop.</li>
<li>and select <strong>Yes</strong>, and then <strong>OK</strong>.</li>
</ul>
]]></content:encoded>
			<wfw:commentRss>http://blog.emson.co.uk/2008/08/cannot-select-text-with-mouse-in-microsoft-word-fix/feed/</wfw:commentRss>
		<slash:comments>47</slash:comments>
		</item>
		<item>
		<title>Everyday MySQL Commands</title>
		<link>http://blog.emson.co.uk/2008/08/everyday-mysql-commands/</link>
		<comments>http://blog.emson.co.uk/2008/08/everyday-mysql-commands/#comments</comments>
		<pubDate>Tue, 19 Aug 2008 00:45:51 +0000</pubDate>
		<dc:creator>ben</dc:creator>
				<category><![CDATA[databases]]></category>
		<category><![CDATA[sql]]></category>
		<category><![CDATA[mysql]]></category>
		<category><![CDATA[tips]]></category>

		<guid isPermaLink="false">http://blog.emson.co.uk/2008/08/everyday-mysql-commands/</guid>
		<description><![CDATA[I&#8217;m trying to put together a number of blog articles and many of them use the MySQL database, so I figured that I would post up some of my most used everyday MySQL SQL commands.  Most likely I will append further commands as I write more articles so this is page is really a [...]]]></description>
			<content:encoded><![CDATA[<p>I&#8217;m trying to put together a number of blog articles and many of them use the MySQL database, so I figured that I would post up some of my most used everyday MySQL SQL commands.  Most likely I will append further commands as I write more articles so this is page is really a work in progress.</p>

<p>I&#8217;ve also assumed that you want to have full rights when executing these commands so I&#8217;ve used <strong>sudo</strong>, however you may not need this depending on your set up.</p>

<p>Finally if some other web site covers the command better or I&#8217;m feeling lazy I&#8217;ll just pop it in the links list at the bottom of this page.</p>

<h2>Useful MySQL Commands</h2>

<h3>Starting MySQL Demon</h3>

<p>Start your MySQL database and get it running as a background process:</p>

<pre><code>sudo mysqld_safe
Ctrl + Z
bg
</code></pre>

<h3>MySQL create databases script</h3>

<p>Make a SQL script that creates 3 databases and assigns all rights to my username.
Copy the following SQL and paste it into a file called <strong>create_databases.sql</strong>:</p>

<pre><code>create database mydb_development;
create database mydb_test;
create database mydb_production;
grant all on mydb_development.* to 'my_username'@'localhost';
grant all on mydb_test.* to 'my_username'@'localhost';
grant all on mydb_production.* to 'my_username'@'localhost' identified by 'my_password';
</code></pre>

<h3>MySQL drop databases script</h3>

<p>Make a script to drop databases.
Copy the following SQL and paste it into a file called <strong>drop_databases.sql</strong>:</p>

<pre><code>drop database nemos_production;
drop database mydb_development;
drop database nemos_test;
</code></pre>

<h3>Executing a script from MySQL</h3>

<p>The above scripts can be executed from the command-line with the either of these commands:</p>

<pre><code>sudo mysql &lt; create_database.sql
or
sudo mysql &lt; drop_database.sql
</code></pre>

<h3>Showing MySQL databases</h3>

<p>To check that the databases were created :</p>

<pre><code>sudo mysqlshow
or
sudo mysql
show databases;
</code></pre>

<h3>Displaying database tables</h3>

<p>Displaying the tables of a database:</p>

<pre><code>sudo mysqlshow mydb_development
or
sudo mysql
show tables from mydb_development;
</code></pre>

<h3>Displaying details about a database table</h3>

<p>Displaying details about a particular database table:</p>

<pre><code>sudo mysqlshow mydb_development mytable
</code></pre>

<h3>Droping a database table</h3>

<p>Dropping a table from a database:</p>

<pre><code>sudo mysql
use mydb_development;
drop table mytable;
</code></pre>

<h3>Displaying information about a table</h3>

<p>Displaying the fields and field metadata about a table:</p>

<pre><code>show fields from my_table; 
or
desc my_table;
</code></pre>

<h2>Useful Links</h2>

<ul>
<li><a href="http://openmaniak.com/mysql.php">http://openmaniak.com/mysql.php</a></li>
</ul>

<p>These are just a few quick and simple MySQL commands that you will always use.
Hope this helps.</p>
]]></content:encoded>
			<wfw:commentRss>http://blog.emson.co.uk/2008/08/everyday-mysql-commands/feed/</wfw:commentRss>
		<slash:comments>0</slash:comments>
		</item>
		<item>
		<title>SproutCore and Web Applications</title>
		<link>http://blog.emson.co.uk/2008/08/sproutcore-and-web-applications/</link>
		<comments>http://blog.emson.co.uk/2008/08/sproutcore-and-web-applications/#comments</comments>
		<pubDate>Mon, 18 Aug 2008 10:00:56 +0000</pubDate>
		<dc:creator>ben</dc:creator>
				<category><![CDATA[business]]></category>
		<category><![CDATA[javascript]]></category>
		<category><![CDATA[ruby]]></category>
		<category><![CDATA[sproutcore javascript ruby]]></category>

		<guid isPermaLink="false">http://blog.emson.co.uk/?p=15</guid>
		<description><![CDATA[It&#8217;s been a wee while since my last article, which has largely been due to my summer holiday.
Anyway I&#8217;ve been reading up and experimenting with the SproutCore JavaScript framework.

Its excellent but I wanted to explain why companies and developers should consider using it.  So I&#8217;ve written an article on my business partner&#8217;s web site [...]]]></description>
			<content:encoded><![CDATA[<p>It&#8217;s been a wee while since my last article, which has largely been due to my summer holiday.
Anyway I&#8217;ve been reading up and experimenting with the <a href="http://www.sproutcore.com">SproutCore</a> JavaScript framework.</p>

<p>Its excellent but I wanted to explain why companies and developers should consider using it.  So I&#8217;ve written an article on my business partner&#8217;s web site <a href="http://rapidappsgroup.com/content/desktop-web-applications-using-sproutcore/">http://rapidappsgroup.com/content/desktop-web-applications-using-sproutcore/</a>. <br/></p>

<p>Please check it out as it tries to answer a lot of the general questions about web applications and JavaScript frameworks.</p>

<p>BE&#8230;</p>
]]></content:encoded>
			<wfw:commentRss>http://blog.emson.co.uk/2008/08/sproutcore-and-web-applications/feed/</wfw:commentRss>
		<slash:comments>0</slash:comments>
		</item>
		<item>
		<title>An Almost Fix for Creating RubyGems on Windows</title>
		<link>http://blog.emson.co.uk/2008/06/an-almost-fix-for-creating-rubygems-on-windows/</link>
		<comments>http://blog.emson.co.uk/2008/06/an-almost-fix-for-creating-rubygems-on-windows/#comments</comments>
		<pubDate>Wed, 25 Jun 2008 14:20:25 +0000</pubDate>
		<dc:creator>ben</dc:creator>
				<category><![CDATA[ruby]]></category>
		<category><![CDATA[windows]]></category>
		<category><![CDATA[gems]]></category>

		<guid isPermaLink="false">http://blog.emson.co.uk/2008/06/an-almost-fix-for-creating-rubygems-on-windows/</guid>
		<description><![CDATA[Introduction

I wrote this article originally so that I could write command-line apps using Ruby, as I got further and further down the line I realised that what I really wanted to do was create a command-line app using RubyGems.  I use both Windows and an Apple Mac and I quickly found myself having problems [...]]]></description>
			<content:encoded><![CDATA[<h2>Introduction</h2>

<p>I wrote this article originally so that I could write command-line apps using Ruby, as I got further and further down the line I realised that what I really wanted to do was create a command-line app using RubyGems.  I use both Windows and an Apple Mac and I quickly found myself having problems trying to create RubyGems on Windows.</p>

<p>In this article I try to explain my thought process and the problems I encountered.  Unfortunately I had to employ a manual process when trying to package up my project into a <em>tar</em> file, as there isn&#8217;t a simple way to do this in Windows (let me know if you have a solution), however everything else seems to work.</p>

<h2>What&#8217;s a RubyGem?</h2>

<p>One of the joys of Ruby is the <a href="http://www.rubygems.org/">RubyGems</a> packaging system. 
It is essentially a tool written in Ruby, for packaging up source code for deployment.</p>

<p>The RubyGems site describes it as follows:</p>

<blockquote>
  <p>RubyGems is the premier ruby packaging system. It provides:</p>
  
  <ul>
  <li>A standard format for destributing Ruby programs and libraries.</li>
  <li>An easy to use tool for managing the installation of gem packages.</li>
  <li>A gem server utility for serving gems from any machine where RubyGems is installed.</li>
  </ul>
</blockquote>

<h2>Why should I create a RubyGem?</h2>

<p>Maybe a better question should be <em>when</em> should I package my code up into a RubyGem.  Obviously there are no hard and fast rules but if you are going to share your code libraries with others or even with other applications of yours, you should think about using a gem.</p>

<p>Now you might think that you don&#8217;t want to make all your code public on <a href="http://rubyforge.org/">RubyForge</a>, and there are very good reason not to publish every gem, so you don&#8217;t have to.
RubyGems comes with its own <em>local</em> gem server so you can create your own gem library and share it amoung your other Ruby applications.</p>

<p>This is really quite useful, you get the power of RubyGems without the commitment and maintenance work of making your code OpenSource.  Plus at any point in time you can then make it OpenSource, and live off the joy of the Ruby community <img src='http://blog.emson.co.uk/wp-includes/images/smilies/icon_smile.gif' alt=':)' class='wp-smiley' /> .</p>

<p>The reason I wrote this article is because I wanted to create a simple command-line application using Ruby. I went through a number of steps before realising that the best way was to use RubyGems.</p>

<p>I started by creating my own command-line structure and then found this great article by <a href="http://blog.infinitered.com/entries/show/5">Todd Werth</a>.  He has a single Ruby file that you just replace various sections and viola you have a very simple command-line app.  But it wasn&#8217;t quite what I wanted.  I didn&#8217;t want to have to type:</p>

<pre><code>./my_super_app 'some params'
</code></pre>

<p>I wanted to type:</p>

<pre><code>my_super_app 'some params'
</code></pre>

<p>I also wanted the structure of the application to follow a standard structure and I didn&#8217;t want to put &#8216;.&#8217; into my path, for security reasons.
<a href="http://drnicwilliams.com/">Dr Nic</a> came to the rescue with a couple of excellent articles describing how to <a href="http://drnicwilliams.com/2006/10/11/generating-new-gems/">create gems using <strong>newgem</strong></a> and specifically <a href="http://drnicwilliams.com/2006/10/18/create-and-deploy-command-line-apps-with-rubygems/">command-line apps as gems</a>.</p>

<h2>Installing newgem on Windows</h2>

<p>To install <strong>newgem</strong> on Windows use the RubyGems install method.</p>

<pre><code>gem install newgem
</code></pre>

<p>This will install the gem and its dependencies.  However one of its dependencies is the <a href="http://seattlerb.rubyforge.org/hoe/">Hoe gem</a>, and there is a slight issue using it on Windows.</p>

<h3>What is hoe?</h3>

<p>Hoe is a compliment to <strong>rake</strong>, it was created by <a href="http://zenspider.com/">Ryan Davis</a> and provides <strong>rake</strong> tasks for testing, packaging, and releasing RubyGems.  <a href="http://nubyonrails.com/articles/tutorial-publishing-rubygems-with-hoe">Geoffrey Grosenbach has a nice tutorial for using hoe</a> and also describes how to create a project structure using the <strong>sow</strong> task.</p>

<p>Hoe uses a <strong>.hoerc</strong> file for configuration, and this file should reside in the user&#8217;s home directory, something like:</p>

<pre><code>C:\Documents and Settings\MyUserName
</code></pre>

<p>An example <strong>.hoerc</strong> file should look like the one below.  Please note that this is a <a href="http://en.wikipedia.org/wiki/YAML">YAML</a> file and if you copy it from here remember to follow the indentation convention:</p>

<pre><code>---
publish_on_announce: false
exclude: !ruby/regexp/tmp$|CVS|\.svn|_darcs|\.git|log$|local/.*\.rb$|Makefile|.*\.o$|.*\.bundle$|.*\.so$|.*\.dll$/ 
str: ""
"@taguri": tag:ruby.yaml.org,2002:regexp/tmp$|CVS|\.svn|_darcs|\.git|log$|local/.*\.rb$|Makefile|.*\.o$|.*\.bundle$|.*\.so$|.*\.dll$/
blogs:
- user: user
  url: url
  extra_headers:
    mt_convert_breaks: markdown
  blog_id: blog_id
  password: password
</code></pre>

<p>On Unix systems there is a shortcut to the user&#8217;s home directory which is &#8216;~&#8217; and on Windows this isn&#8217;t a shortcut.  Windows however does have an environment variable <strong>HOMEPATH</strong> which will point to the user&#8217;s home directory.  The problem is that the Hoe gem code uses &#8216;~&#8217; in its <strong>hoe.rb</strong> file and this causes problems for Windows users.</p>

<h3>Patching the hoe.rb file</h3>

<p>OK, be brave, lets tweak the hoe.rb file so that it will work on the Windows platform.
The Hoe gem <strong>hoe.rb</strong> file can be found in the following directory (assuming you installed Ruby to the standard location):</p>

<pre><code>C:\ruby\lib\ruby\gems\1.8\gems\hoe-1.6.0\lib
</code></pre>

<p>To make it work for Windows PCs you will need to modify this file with the following changes.</p>

<p>Locate the <strong>define_tasks</strong> method:</p>

<pre><code>def define_tasks # :nodoc:
  def with_config # :nodoc:
    rc = File.expand_path("~/.hoerc")
    exists = File.exist? rc
    config = exists ? YAML.load_file(rc) : {}
    yield(config, rc)
  end
</code></pre>

<p>And add a new method above it such as this, and modify the line <strong>rc = File.expand_path(&#8221;~/.hoerc&#8221;)</strong> as below:</p>

<pre><code>def get_home_dir
  home_file_path = "~/"
  home_file_path = "#{ENV['HOMEPATH']}\\" if WINDOZE
  home_file_path
end

def define_tasks # :nodoc:
 def with_config # :nodoc:
   rc = File.expand_path(get_home_dir + '.hoerc')
   exists = File.exist? rc
   config = exists ? YAML.load_file(rc) : {}
   yield(config, rc)
 end
</code></pre>

<p>Finally you will need to locate and change the <strong>task :config_hoe</strong> so that it reads:</p>

<pre><code>"signing_key_file" =&gt; "#{get_home_dir}.gem/gem-private_key.pem",
"signing_cert_file" =&gt; "#{get_home_dir}.gem/gem-public_cert.pem",
</code></pre>

<p>If all has gone correctly save this file and you are now ready to create a RubyGem.</p>

<h2>Creating a basic RubyGem</h2>

<p>Using the <strong>newgem</strong> RubyGem enter the following command at the command prompt:</p>

<pre><code>newgem my_app -b greetings -T rspec -W
</code></pre>

<p>This will create a <strong>my_app</strong> subdirectory, with a command-line command app called <em>greetings</em> located in the <strong>bin</strong> directory.  It will use the testing framework <em>RSpec</em> and finally will not generate the RubyForge web site code.  This is assuming you don&#8217;t want to relese your code as OpenSource.
The output will be something like this:</p>

<pre><code>     create
     create  config
     create  doc
     create  lib
     create  script
     ... blah ...
     create  script/console
     create  script/console.cmd
     create  Manifest.txt
     readme  readme
Important
=========

* Open config/hoe.rb
* Update missing details (gem description, dependent gems, etc.)
</code></pre>

<p>If you want to add <a href="http://blog.emson.co.uk/2008/06/understanding-rspec-stories-a-tutorial/">RSpec Stories</a> to this project there is a useful command-line generator to do this.  First navigate into the root of you new project app directory, in this case <strong>my_app</strong>.  Now execute the generate script:</p>

<pre><code>ruby script/generate install_rspec_stories
</code></pre>

<p>You should then get the following output:</p>

<pre><code>  create  stories/steps
  create  stories/steps/my_app_steps.rb
  create  stories/sell_my_app.story
  create  stories/all.rb
</code></pre>

<p>Modify your <strong>greetings</strong> command so that it does something.  Do this by editing the file located here:</p>

<pre><code>my_app/bin/greetings
</code></pre>

<p>Open up this file and at the very end, add some code such as this, and save the file:</p>

<pre><code># do stuff
puts 'Greetings the world is my oyster!'
</code></pre>

<h3>Packaging caveat</h3>

<p>As mentioned in the begining of this article I couldn&#8217;t use <strong>rake</strong> to <em>tar</em> this project up for deployment to RubyForge.
The reason is that <strong>rake</strong> makes a Unix platform dependent call to <em>tar</em> the package using a Ruby task file <strong>packagetask.rb</strong> located:</p>

<pre><code>C:\ruby\lib\ruby\gems\1.8\gems\rake-0.8.1\lib\rake 
</code></pre>

<p>This means that on Windows you will have to manually <em>tar</em> this file.</p>

<p>However you can still create the gem using the rake task, and a gem file <strong>my_app-0.0.1.gem</strong>, will appear in the <strong>pkg</strong> directory:</p>

<pre><code>rake gem
</code></pre>

<p>This new RubyGem can now be installed by using the <strong>gem install</strong> commands:</p>

<pre><code>gem install pkg/my_app-0.0.1.gem
</code></pre>

<p>You should get the following output:</p>

<pre><code>For more information on my_app, see http://my_app.rubyforge.org

NOTE: Change this information in PostInstall.txt
You can also delete it if you don't want it.


Successfully installed my_app, version 0.0.1
Installing ri documentation for my_app-0.0.1...
Installing RDoc documentation for my_app-0.0.1...
</code></pre>

<p>Finally you should now be able to execute your command-line command in the command prompt, simply by typing:</p>

<pre><code>greetings
</code></pre>

<p>I hope this is useful and helps with your understanding of how RubyGems work, specifically on Windows, also please jot down some comments if you have any ideas or suggestions.</p>

<h2>Links</h2>

<p>Here is a list of useful RubyGems links:</p>

<ul>
<li><a href="http://www.rubygems.org/">RubyGems.org</a></li>
<li><a href="http://www.linuxjournal.com/article/8967">Linux Journal article about RubyGems</a></li>
<li><a href="http://drnicwilliams.com/2006/10/11/generating-new-gems/">Dr Nic&#8217;s generating new gems article</a></li>
<li><a href="http://drnicwilliams.com/2006/10/18/create-and-deploy-command-line-apps-with-rubygems/">Dr Nic&#8217;s article for creating and deploying command line apps</a></li>
<li><a href="http://nubyonrails.com/articles/tutorial-publishing-rubygems-with-hoe">NubyOnRails article for using Hoe</a></li>
<li><a href="http://blog.jayfields.com/2006/10/ruby-project-tree.html">Jay Fields Ruby Project Tree</a></li>
</ul>
]]></content:encoded>
			<wfw:commentRss>http://blog.emson.co.uk/2008/06/an-almost-fix-for-creating-rubygems-on-windows/feed/</wfw:commentRss>
		<slash:comments>5</slash:comments>
		</item>
	</channel>
</rss>
