<?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>metal &#38; gin &#187; code</title>
	<atom:link href="http://blog.craig-mackenzie.com/category/code/feed/" rel="self" type="application/rss+xml" />
	<link>http://blog.craig-mackenzie.com</link>
	<description>(a weblog by craig t mackenzie)</description>
	<lastBuildDate>Thu, 19 Mar 2009 20:56:55 +0000</lastBuildDate>
	<generator>http://wordpress.org/?v=2.9.2</generator>
	<language>en</language>
	<sy:updatePeriod>hourly</sy:updatePeriod>
	<sy:updateFrequency>1</sy:updateFrequency>
			<item>
		<title>Pixel Path: Take 2</title>
		<link>http://blog.craig-mackenzie.com/2008/03/29/pixel-path-take-2/</link>
		<comments>http://blog.craig-mackenzie.com/2008/03/29/pixel-path-take-2/#comments</comments>
		<pubDate>Sat, 29 Mar 2008 21:54:41 +0000</pubDate>
		<dc:creator>craig mackenzie</dc:creator>
				<category><![CDATA[code]]></category>
		<category><![CDATA[i am geek]]></category>
		<category><![CDATA[art]]></category>
		<category><![CDATA[design]]></category>
		<category><![CDATA[generated]]></category>
		<category><![CDATA[generative art]]></category>
		<category><![CDATA[processing]]></category>

		<guid isPermaLink="false">http://blog.craig-mackenzie.com/2008/03/29/pixel-path-take-2/</guid>
		<description><![CDATA[
Following on from my previous experiments with generative art and processing I decided to elaborate on my code and introduce more complex shape generation. I knew I wanted to introduce 3D and alpha blending, as well as refining the curves used to generate the lines. 
A Beautiful Mistake
After getting my head around the 3D space [...]]]></description>
			<content:encoded><![CDATA[<p><img src="/stuff/processing/processing-29-march-08/title.jpg" width="625" height="150" alt="Title" /></p>
<p>Following on from my <a href="http://blog.craig-mackenzie.com/2008/02/25/pixel-path-my-preliminary-steps-into-generative-art/" title="metal &amp; gin &raquo; Pixel Path: my preliminary steps into generative art">previous experiments</a> with generative art and processing I decided to elaborate on my code and introduce more complex shape generation. I knew I wanted to introduce 3D and alpha blending, as well as refining the curves used to generate the lines. </p>
<h2>A Beautiful Mistake</h2>
<p>After getting my head around the 3D space and doing some rudimentary experiments I was ready to port my existing code into this new 3D world. I started playing some more with the brilliant <a href="http://www.cise.ufl.edu/~kdamkjer/processing/libraries/ocd/" title="Obsessive Camera Direction">OCD Library</a> and had something I was kind of happy with.</p>
<p>At some point in tweaking and playing with the code I must have removed the line <code>background(0);</code> and (naturally) the screen was never cleared. What this produced when left to run for about 2000 frames was stunning.
</p>
<h2>The Result</h2>
<p>So here they are, my beautiful mistakes generated by taking an image, getting a random pixel, positioning it randomly in 3d space then connecting an arbitrary amount of other random points to this point with bezier curves. The frame buffer is never cleared and the image are let to build up over thousands of frames.</p>
<p><span id="more-64"></span></p>
<p>Simply click on a thumbnail to view the enlarged version or you can view larger images on <a href="http://flickr.com/photos/craigtmackenzie/sets/72157604304432493/" title="Pixel Path: Take 2 - a photoset on Flickr">my flickr account</a> or my <a href="http://blog.craig-mackenzie.com/stuff/processing/gallery/bezier-curve-form.html" onclick="window.open(this.href,null, 'width=1300,height=740,status=yes,toolbar=no,menubar=no,location=no'); return false;">HD gallery</a>.</p>
<div>
<ul class="zoom-gallery">
<li><a href="/stuff/processing/processing-29-march-08/gallery/images/beziercurve/SD/creatures-001.jpg"><img src="/stuff/processing/processing-29-march-08/gallery/images/beziercurve/thumb/creatures-001.jpg" width="150" height="130" /></a></li>
<li><a href="/stuff/processing/processing-29-march-08/gallery/images/beziercurve/SD/creatures-002.jpg"><img src="/stuff/processing/processing-29-march-08/gallery/images/beziercurve/thumb/creatures-002.jpg" width="150" height="130" /></a></li>
<li><a href="/stuff/processing/processing-29-march-08/gallery/images/beziercurve/SD/creatures-003.jpg"><img src="/stuff/processing/processing-29-march-08/gallery/images/beziercurve/thumb/creatures-003.jpg" width="150" height="130" /></a></li>
<li><a href="/stuff/processing/processing-29-march-08/gallery/images/beziercurve/SD/creatures-004.jpg"><img src="/stuff/processing/processing-29-march-08/gallery/images/beziercurve/thumb/creatures-004.jpg" width="150" height="130" /></a></li>
<li><a href="/stuff/processing/processing-29-march-08/gallery/images/beziercurve/SD/creatures-005.jpg"><img src="/stuff/processing/processing-29-march-08/gallery/images/beziercurve/thumb/creatures-005.jpg" width="150" height="130" /></a></li>
<li><a href="/stuff/processing/processing-29-march-08/gallery/images/beziercurve/SD/creatures-006.jpg"><img src="/stuff/processing/processing-29-march-08/gallery/images/beziercurve/thumb/creatures-006.jpg" width="150" height="130" /></a></li>
<li><a href="/stuff/processing/processing-29-march-08/gallery/images/beziercurve/SD/creatures-007.jpg"><img src="/stuff/processing/processing-29-march-08/gallery/images/beziercurve/thumb/creatures-007.jpg" width="150" height="130" /></a></li>
<li><a href="/stuff/processing/processing-29-march-08/gallery/images/beziercurve/SD/creatures-008.jpg"><img src="/stuff/processing/processing-29-march-08/gallery/images/beziercurve/thumb/creatures-008.jpg" width="150" height="130" /></a></li>
<li><a href="/stuff/processing/processing-29-march-08/gallery/images/beziercurve/SD/creatures-009.jpg"><img src="/stuff/processing/processing-29-march-08/gallery/images/beziercurve/thumb/creatures-009.jpg" width="150" height="130" /></a></li>
<li><a href="/stuff/processing/processing-29-march-08/gallery/images/beziercurve/SD/creatures-010.jpg"><img src="/stuff/processing/processing-29-march-08/gallery/images/beziercurve/thumb/creatures-010.jpg" width="150" height="130" /></a></li>
<li><a href="/stuff/processing/processing-29-march-08/gallery/images/beziercurve/SD/creatures-011.jpg"><img src="/stuff/processing/processing-29-march-08/gallery/images/beziercurve/thumb/creatures-011.jpg" width="150" height="130" /></a></li>
<li><a href="/stuff/processing/processing-29-march-08/gallery/images/beziercurve/SD/creatures-012.jpg"><img src="/stuff/processing/processing-29-march-08/gallery/images/beziercurve/thumb/creatures-012.jpg" width="150" height="130" /></a></li>
<li><a href="/stuff/processing/processing-29-march-08/gallery/images/beziercurve/SD/creatures-013.jpg"><img src="/stuff/processing/processing-29-march-08/gallery/images/beziercurve/thumb/creatures-013.jpg" width="150" height="130" /></a></li>
<li><a href="/stuff/processing/processing-29-march-08/gallery/images/beziercurve/SD/creatures-014.jpg"><img src="/stuff/processing/processing-29-march-08/gallery/images/beziercurve/thumb/creatures-014.jpg" width="150" height="130" /></a></li>
</ul>
<div class="clear"></div>
</div>
<h2>Now in Moving Picture&trade; format!</h2>
<p>I&#8217;ve also got a couple of videos of the images being generated. The low-res previews which vimeo outputs don&#8217;t really do it justice, but at least you can view it in HD on vimeo (which you can&#8217;t with you tube.)</p>
<div class="video-wrap vimeo">
  <object type="application/x-shockwave-flash" width="624" height="351" data="http://www.vimeo.com/moogaloop.swf?clip_id=783154&amp;server=www.vimeo.com&amp;fullscreen=1&amp;show_title=1&amp;show_byline=1&amp;show_portrait=1&amp;color=00adef"><param name="quality" value="best" /><param name="allowfullscreen" value="true" /><param name="scale" value="showAll" /><param name="movie" value="http://www.vimeo.com/moogaloop.swf?clip_id=783154 &amp;server=www.vimeo.com&amp;fullscreen=1&amp;show_title=1&amp;show_byline=1&amp;show_portrait=1&amp;color=00adef" /></object><br />
    <br />
    <a href="http://www.vimeo.com/783154/l:embed_783154">view this in HD (which is highly recommended)</a>
</div>
<p></p>
<div class="video-wrap vimeo">
  <object type="application/x-shockwave-flash" width="624" height="351" data="http://www.vimeo.com/moogaloop.swf?clip_id=783249&amp;server=www.vimeo.com&amp;fullscreen=1&amp;show_title=1&amp;show_byline=1&amp;show_portrait=1&amp;color=00adef"><param name="quality" value="best" /><param name="allowfullscreen" value="true" /><param name="scale" value="showAll" /><param name="movie" value="http://www.vimeo.com/moogaloop.swf?clip_id=783249 &amp;server=www.vimeo.com&amp;fullscreen=1&amp;show_title=1&amp;show_byline=1&amp;show_portrait=1&amp;color=00adef" /></object><br />
    <br />
    <a href="http://www.vimeo.com/783249/l:embed_783249">view this in HD (which is highly recommended)</a>
</div>
<p></p>
<h2>Now with a Z axis!</h2>
<p>My next step is to try and generate these images in true 3D form, with camera control and give the whole thing a sense of depth. This is my first attempt.</p>
<div class="video-wrap vimeo">
  <object type="application/x-shockwave-flash" width="624" height="351" data="http://www.vimeo.com/moogaloop.swf?clip_id=837947&amp;server=www.vimeo.com&amp;fullscreen=1&amp;show_title=1&amp;show_byline=1&amp;show_portrait=1&amp;color=00adef"><param name="quality" value="best" /><param name="allowfullscreen" value="true" /><param name="scale" value="showAll" /><param name="movie" value="http://www.vimeo.com/moogaloop.swf?clip_id=837947 &amp;server=www.vimeo.com&amp;fullscreen=1&amp;show_title=1&amp;show_byline=1&amp;show_portrait=1&amp;color=00adef" /></object><br />
    <br />
    <a href="http://www.vimeo.com/837947/l:embed_837947">view this in HD (which is highly recommended)</a>
</div>
<p></p>
]]></content:encoded>
			<wfw:commentRss>http://blog.craig-mackenzie.com/2008/03/29/pixel-path-take-2/feed/</wfw:commentRss>
		<slash:comments>4</slash:comments>
		</item>
		<item>
		<title>Pixel Path: my preliminary steps into generative art</title>
		<link>http://blog.craig-mackenzie.com/2008/02/25/pixel-path-my-preliminary-steps-into-generative-art/</link>
		<comments>http://blog.craig-mackenzie.com/2008/02/25/pixel-path-my-preliminary-steps-into-generative-art/#comments</comments>
		<pubDate>Mon, 25 Feb 2008 06:03:20 +0000</pubDate>
		<dc:creator>craig mackenzie</dc:creator>
				<category><![CDATA[code]]></category>
		<category><![CDATA[i am geek]]></category>
		<category><![CDATA[art]]></category>
		<category><![CDATA[design]]></category>
		<category><![CDATA[generated]]></category>
		<category><![CDATA[generative art]]></category>
		<category><![CDATA[processing]]></category>

		<guid isPermaLink="false">http://blog.craig-mackenzie.com/2008/02/25/pixel-path-my-preliminary-steps-into-generative-art/</guid>
		<description><![CDATA[

	I first discovered Processing in the summer of 2005. I downloaded the source code, had a play around with it and decided it wasn&#8217;t going to be worth me learning it. At the time I was very much design oriented in my endeavors and although I knew vaguely what the capabilities of Processing were, it&#8217;s [...]]]></description>
			<content:encoded><![CDATA[<p><img src="/stuff/processing/generative-art-25-feb-08/title.jpg" /></p>
<p>
	I first discovered <a href="http://processing.org/">Processing</a> in the summer of 2005. I downloaded the source code, had a play around with it and decided it wasn&#8217;t going to be worth me learning it. At the time I was very much design oriented in my endeavors and although I knew vaguely what the capabilities of Processing were, it&#8217;s lack of a substantial IDE or drawing tools made it no competitor to my main focus at the time: Flash.
</p>
<h2>Rediscovery <span class="amp">&amp;</span> Inspiration</h2>
<p>
	Fast forward 3 years and I&#8217;m now a developer, a code junkie, a command-line ninja. Although I sometimes miss the creativity that you get with design, I still love the <em>art</em> of writing code. I want the excitement of motion, interaction and form but also want the <em>challenge</em> of writing elegant software&#8230; I&#8217;d been thinking about re-visiting processing for a long time, hopefully it would satisfy these needs. I often kept an eye on the likes of <a href="http://www.number27.org/">Jonathan Harris</a> &amp; <a href="http://www.flight404.com/">Flight 404</a> to see what they were up to, and was always inspired by the cool things these guys were doing with processing + generative art in general.
</p>
<p>
	It was when a guy at work, <a href="http://www.davidstanden.com">David Standen</a> started going on about processing, and his love for it that I thought &#8220;maybe i should look at this again&#8221;. I am after all now a programmer, and Processing is a DSL around Java, so why not learn it? I downloaded the latest version and started playing around&#8230;
</p>
<p><span id="more-63"></span></p>
<h2>Enter Pixel Path</h2>
<p>
	I wanted something different, I ignored &#8220;good code&#8221; and went straight for the fun and creative, something non-interactive maybe. So what to do? I&#8217;ve always been really annoyed by the fact that I can&#8217;t really draw very well and I&#8217;ve never painted a picture in my life, so I decided to try and create some software that would create gorgeous looking &#8220;things&#8221;. Generative Art.
</p>
<p>
	Inspired by <a href="http://www.davidstanden.com/blog/?p=19">this post</a> I set about creating what would later become known as &#8220;Pixel Path&#8221;. The idea was simple, to analyze a given image, pixel by pixel and map every pixel to all other pixels of the same colour. Pixels would be identified by a dot and connected by lines, hopefully creating a sense of depth, texture and form.
</p>
<h2>Version 1 &#8211; Moss</h2>
<p>
	The first version is based on a macro shot of a leaf, it maps every 100th pixel to up to another 100 pixels of identical colour. (Galleries each have 5 parts, use the thumbnails to scroll through them all.)
</p>
<p>
	Total Pixels: <strong>1,296,000</strong> | Analyzed: <strong>12,960</strong> | Paths: <strong>1,296,000</strong>
</p>
<div class="scroll-gallery">
  <span>p1 &#8211; Moss</span></p>
<div class="gal-main" style="height:375px;">
<div id="moss-container">
      <img src="/stuff/processing/generative-art-25-feb-08/web/p1-moss-01_web.jpg" /><br />
      <img src="/stuff/processing/generative-art-25-feb-08/web/p1-moss-02_web.jpg" /><br />
      <img src="/stuff/processing/generative-art-25-feb-08/web/p1-moss-03_web.jpg" /><br />
      <img src="/stuff/processing/generative-art-25-feb-08/web/p1-moss-04_web.jpg" /><br />
      <img src="/stuff/processing/generative-art-25-feb-08/web/p1-moss-05_web.jpg" />
    </div>
</p></div>
<ul>
<li><a href="#" onclick="scrollGallery('moss-container',0); return false;"    title="part 1"><img src="/stuff/processing/generative-art-25-feb-08/thumb/p1-moss-01_tn.jpg" /></a></li>
<li><a href="#" onclick="scrollGallery('moss-container',375); return false;"  title="part 2"><img src="/stuff/processing/generative-art-25-feb-08/thumb/p1-moss-02_tn.jpg" /></a></li>
<li><a href="#" onclick="scrollGallery('moss-container',750); return false;"  title="part 3"><img src="/stuff/processing/generative-art-25-feb-08/thumb/p1-moss-03_tn.jpg" /></a></li>
<li><a href="#" onclick="scrollGallery('moss-container',1125); return false;" title="part 4"><img src="/stuff/processing/generative-art-25-feb-08/thumb/p1-moss-04_tn.jpg" /></a></li>
<li><a href="#" onclick="scrollGallery('moss-container',1500); return false;" title="part 5"><img src="/stuff/processing/generative-art-25-feb-08/thumb/p1-moss-05_tn.jpg" /></a></li>
</ul>
<p>      <span class="flickr-link"><a href="http://www.flickr.com/photos/craigtmackenzie/sets/72157603983153085/" title="Pixel Path - a photoset on Flickr">view larger on flickr</a></span><br />
      
</div>
<h2>Version 2 &#8211; Skin</h2>
<p>
	In the second version I tweaked the algorithms to introduce more depth, points are rendered at 80% opacity and paths at 20%. The amount of pixels to be analyzed was also reduced to every 3500th, but the mapping limit increased to 1000 paths. The reference image was a macro shot of a group of feathers.
</p>
<p>
	Total Pixels: <strong>1,296,000</strong> | Analyzed: <strong>370</strong> | Paths: <strong>370,000</strong>
</p>
<div class="scroll-gallery">
  <span>p2 &#8211; Skin</span></p>
<div class="gal-main" style="height:375px;">
<div id="skin-container">
      <img src="/stuff/processing/generative-art-25-feb-08/web/p2-skin-01_web.jpg" /><br />
      <img src="/stuff/processing/generative-art-25-feb-08/web/p2-skin-02_web.jpg" /><br />
      <img src="/stuff/processing/generative-art-25-feb-08/web/p2-skin-03_web.jpg" /><br />
      <img src="/stuff/processing/generative-art-25-feb-08/web/p2-skin-04_web.jpg" /><br />
      <img src="/stuff/processing/generative-art-25-feb-08/web/p2-skin-05_web.jpg" />
    </div>
</p></div>
<ul>
<li><a href="#" onclick="scrollGallery('skin-container',0); return false;"    title="part 1"><img src="/stuff/processing/generative-art-25-feb-08/thumb/p2-skin-01_tn.jpg" /></a></li>
<li><a href="#" onclick="scrollGallery('skin-container',375); return false;"  title="part 2"><img src="/stuff/processing/generative-art-25-feb-08/thumb/p2-skin-02_tn.jpg" /></a></li>
<li><a href="#" onclick="scrollGallery('skin-container',750); return false;"  title="part 3"><img src="/stuff/processing/generative-art-25-feb-08/thumb/p2-skin-03_tn.jpg" /></a></li>
<li><a href="#" onclick="scrollGallery('skin-container',1125); return false;" title="part 4"><img src="/stuff/processing/generative-art-25-feb-08/thumb/p2-skin-04_tn.jpg" /></a></li>
<li><a href="#" onclick="scrollGallery('skin-container',1500); return false;" title="part 5"><img src="/stuff/processing/generative-art-25-feb-08/thumb/p2-skin-05_tn.jpg" /></a></li>
</ul>
<p>  <span class="flickr-link"><a href="http://www.flickr.com/photos/craigtmackenzie/sets/72157603983153085/" title="Pixel Path - a photoset on Flickr">view larger on flickr</a></span><br />
  
</div>
<h2>Version 3 &#8211; Paprika</h2>
<p>
	The third version used bezier curves to draw the paths with control points offset against the difference between the reference and target pixel. Every 850th pixel was analyzed up to 100 paths. The reference pixels in this version were distinguished with near 100% opacity. The image used was that of a red rose petal.
</p>
<p>
	Total Pixels: <strong>1,296,000</strong> | Analyzed: <strong>1,524</strong> | Paths: <strong>152,400</strong>
</p>
<div class="scroll-gallery">
  <span>p3 &#8211; Paprika</span></p>
<div class="gal-main" style="height:375px;">
<div id="paprika-container">
      <img src="/stuff/processing/generative-art-25-feb-08/web/p3-paprika-01_web.jpg" /><br />
      <img src="/stuff/processing/generative-art-25-feb-08/web/p3-paprika-02_web.jpg" /><br />
      <img src="/stuff/processing/generative-art-25-feb-08/web/p3-paprika-03_web.jpg" /><br />
      <img src="/stuff/processing/generative-art-25-feb-08/web/p3-paprika-04_web.jpg" /><br />
      <img src="/stuff/processing/generative-art-25-feb-08/web/p3-paprika-05_web.jpg" />
    </div>
</p></div>
<ul>
<li><a href="#" onclick="scrollGallery('paprika-container',0); return false;"    title="part 1"><img src="/stuff/processing/generative-art-25-feb-08/thumb/p3-paprika-01_tn.jpg" /></a></li>
<li><a href="#" onclick="scrollGallery('paprika-container',375); return false;"  title="part 2"><img src="/stuff/processing/generative-art-25-feb-08/thumb/p3-paprika-02_tn.jpg" /></a></li>
<li><a href="#" onclick="scrollGallery('paprika-container',750); return false;"  title="part 3"><img src="/stuff/processing/generative-art-25-feb-08/thumb/p3-paprika-03_tn.jpg" /></a></li>
<li><a href="#" onclick="scrollGallery('paprika-container',1125); return false;" title="part 4"><img src="/stuff/processing/generative-art-25-feb-08/thumb/p3-paprika-04_tn.jpg" /></a></li>
<li><a href="#" onclick="scrollGallery('paprika-container',1500); return false;" title="part 5"><img src="/stuff/processing/generative-art-25-feb-08/thumb/p3-paprika-05_tn.jpg" /></a></li>
</ul>
<p>  <span class="flickr-link"><a href="http://www.flickr.com/photos/craigtmackenzie/sets/72157603983153085/" title="Pixel Path - a photoset on Flickr">view larger on flickr</a></span><br />
  
</div>
<h2>Version 4 &#8211; Rose</h2>
<p>
	For version 4 I abandoned the dots for marking pixels, and instead relied on just the paths. The bezier curves were tweaked slightly to create smoother lines and only every 250th pixel was analyzed, up to 100 paths. The reference image was another rose petal, in pink.
</p>
<p>
	Total Pixels: <strong>1,296,000</strong> | Analyzed: <strong>5,184</strong> | Paths: <strong>518,400</strong>
</p>
<div class="scroll-gallery">
  <span>p4 &#8211; Rose</span></p>
<div class="gal-main" style="height:375px;">
<div id="rose-container">
      <img src="/stuff/processing/generative-art-25-feb-08/web/p4-rose-01_web.jpg" /><br />
      <img src="/stuff/processing/generative-art-25-feb-08/web/p4-rose-02_web.jpg" /><br />
      <img src="/stuff/processing/generative-art-25-feb-08/web/p4-rose-03_web.jpg" /><br />
      <img src="/stuff/processing/generative-art-25-feb-08/web/p4-rose-04_web.jpg" /><br />
      <img src="/stuff/processing/generative-art-25-feb-08/web/p4-rose-05_web.jpg" />
    </div>
</p></div>
<ul>
<li><a href="#" onclick="scrollGallery('rose-container',0); return false;"    title="part 1"><img src="/stuff/processing/generative-art-25-feb-08/thumb/p4-rose-01_tn.jpg" /></a></li>
<li><a href="#" onclick="scrollGallery('rose-container',375); return false;"  title="part 2"><img src="/stuff/processing/generative-art-25-feb-08/thumb/p4-rose-02_tn.jpg" /></a></li>
<li><a href="#" onclick="scrollGallery('rose-container',750); return false;"  title="part 3"><img src="/stuff/processing/generative-art-25-feb-08/thumb/p4-rose-03_tn.jpg" /></a></li>
<li><a href="#" onclick="scrollGallery('rose-container',1125); return false;" title="part 4"><img src="/stuff/processing/generative-art-25-feb-08/thumb/p4-rose-04_tn.jpg" /></a></li>
<li><a href="#" onclick="scrollGallery('rose-container',1500); return false;" title="part 5"><img src="/stuff/processing/generative-art-25-feb-08/thumb/p4-rose-05_tn.jpg" /></a></li>
</ul>
<p>  <span class="flickr-link"><a href="http://www.flickr.com/photos/craigtmackenzie/sets/72157603983153085/" title="Pixel Path - a photoset on Flickr">view larger on flickr</a></span><br />
  
</div>
<h2>Version 5 &#8211; White</h2>
<p>
	Version 5 was a slight departure from the norm, I inverted the canvas colour and this time decided to map the reference pixel to it&#8217;s first match, then all other matches to the next match (creating a flowing path) This version also draws two sets of paths for every match, one straight and one curved. Opacities were also massively reduced to only 5% and analyzed pixels increased to every 900th for up to 1000 paths. The first reference image was a different set of feathers and the second a forest scene.
</p>
<p>
	Total Pixels: <strong>1,296,000</strong> | Analyzed: <strong>1,440</strong> | Paths: <strong>1,440,000</strong>
</p>
<div class="scroll-gallery">
  <span>p5 &#8211; White</span></p>
<div class="gal-main" style="height:375px;">
<div id="white-container">
      <img src="/stuff/processing/generative-art-25-feb-08/web/p5-white-01_web.jpg" /><br />
      <img src="/stuff/processing/generative-art-25-feb-08/web/p5-white-02_web.jpg" /><br />
      <img src="/stuff/processing/generative-art-25-feb-08/web/p5-white-03_web.jpg" /><br />
      <img src="/stuff/processing/generative-art-25-feb-08/web/p5-white-04_web.jpg" /><br />
      <img src="/stuff/processing/generative-art-25-feb-08/web/p5-white-05_web.jpg" />
    </div>
</p></div>
<ul>
<li><a href="#" onclick="scrollGallery('white-container',0); return false;"    title="part 1"><img src="/stuff/processing/generative-art-25-feb-08/thumb/p5-white-01_tn.jpg" /></a></li>
<li><a href="#" onclick="scrollGallery('white-container',375); return false;"  title="part 2"><img src="/stuff/processing/generative-art-25-feb-08/thumb/p5-white-02_tn.jpg" /></a></li>
<li><a href="#" onclick="scrollGallery('white-container',750); return false;"  title="part 3"><img src="/stuff/processing/generative-art-25-feb-08/thumb/p5-white-03_tn.jpg" /></a></li>
<li><a href="#" onclick="scrollGallery('white-container',1125); return false;" title="part 4"><img src="/stuff/processing/generative-art-25-feb-08/thumb/p5-white-04_tn.jpg" /></a></li>
<li><a href="#" onclick="scrollGallery('white-container',1500); return false;" title="part 5"><img src="/stuff/processing/generative-art-25-feb-08/thumb/p5-white-05_tn.jpg" /></a></li>
</ul>
<p>  <span class="flickr-link"><a href="http://www.flickr.com/photos/craigtmackenzie/sets/72157603983153085/" title="Pixel Path - a photoset on Flickr">view larger on flickr</a></span><br />
  
</div>
<h2>Version 5 &#8211; Forest</h2>
<div class="scroll-gallery">
  <span>p5 &#8211; Forest</span></p>
<div class="gal-main" style="height:375px;">
<div id="forest-container">
      <img src="/stuff/processing/generative-art-25-feb-08/web/p5-forest-01_web.jpg" /><br />
      <img src="/stuff/processing/generative-art-25-feb-08/web/p5-forest-02_web.jpg" /><br />
      <img src="/stuff/processing/generative-art-25-feb-08/web/p5-forest-03_web.jpg" /><br />
      <img src="/stuff/processing/generative-art-25-feb-08/web/p5-forest-04_web.jpg" /><br />
      <img src="/stuff/processing/generative-art-25-feb-08/web/p5-forest-05_web.jpg" />
    </div>
</p></div>
<ul>
<li><a href="#" onclick="scrollGallery('forest-container',0); return false;"    title="part 1"><img src="/stuff/processing/generative-art-25-feb-08/thumb/p5-forest-01_tn.jpg" /></a></li>
<li><a href="#" onclick="scrollGallery('forest-container',375); return false;"  title="part 2"><img src="/stuff/processing/generative-art-25-feb-08/thumb/p5-forest-02_tn.jpg" /></a></li>
<li><a href="#" onclick="scrollGallery('forest-container',750); return false;"  title="part 3"><img src="/stuff/processing/generative-art-25-feb-08/thumb/p5-forest-03_tn.jpg" /></a></li>
<li><a href="#" onclick="scrollGallery('forest-container',1125); return false;" title="part 4"><img src="/stuff/processing/generative-art-25-feb-08/thumb/p5-forest-04_tn.jpg" /></a></li>
<li><a href="#" onclick="scrollGallery('forest-container',1500); return false;" title="part 5"><img src="/stuff/processing/generative-art-25-feb-08/thumb/p5-forest-05_tn.jpg" /></a></li>
</ul>
<p>  <span class="flickr-link"><a href="http://www.flickr.com/photos/craigtmackenzie/sets/72157603983153085/" title="Pixel Path - a photoset on Flickr">view larger on flickr</a></span><br />
  
</div>
<h2>Next Steps</h2>
<ul>
<li>Introduce an element of randomness.</li>
<li>Experiment with noise.</li>
<li>Experiment with blending.</li>
<li>Introduce the z-axis.</li>
<li>Try using particles to generate &#8220;ink splats&#8221;.</li>
</ul>
]]></content:encoded>
			<wfw:commentRss>http://blog.craig-mackenzie.com/2008/02/25/pixel-path-my-preliminary-steps-into-generative-art/feed/</wfw:commentRss>
		<slash:comments>8</slash:comments>
		</item>
		<item>
		<title>simple bread crumbs in ruby on rails</title>
		<link>http://blog.craig-mackenzie.com/2007/08/09/simple-bread-crumbs-in-ruby-on-rails/</link>
		<comments>http://blog.craig-mackenzie.com/2007/08/09/simple-bread-crumbs-in-ruby-on-rails/#comments</comments>
		<pubDate>Thu, 09 Aug 2007 15:55:10 +0000</pubDate>
		<dc:creator>craig mackenzie</dc:creator>
				<category><![CDATA[code]]></category>
		<category><![CDATA[ruby/rails]]></category>
		<category><![CDATA[breadcrumbs]]></category>
		<category><![CDATA[rails]]></category>
		<category><![CDATA[ruby]]></category>

		<guid isPermaLink="false">http://blog.craig-mackenzie.com/2007/08/09/simple-bread-crumbs-in-ruby-on-rails/</guid>
		<description><![CDATA[below is a simple implementation of bread-crumbs for use in ruby on rails, you can pass in the level separator as the first argument and a boolean to indicate inclusion of home link.
it relies on the requested path to work out how to split the breadcrumbs, it alsoo requires that every component of your path [...]]]></description>
			<content:encoded><![CDATA[<p>below is a simple implementation of bread-crumbs for use in ruby on rails, you can pass in the level separator as the first argument and a boolean to indicate inclusion of home link.</p>
<p>it relies on the requested path to work out how to split the breadcrumbs, it alsoo requires that every component of your path is accessable, should be a good starting block though.</p>
<pre class="textmate-source"><span class="source source_ruby source_ruby_rails"><span class="meta meta_rails meta_rails_helper">  <span class="meta meta_function meta_function_method meta_function_method_with-arguments meta_function_method_with-arguments_ruby"><span class="keyword keyword_control keyword_control_def keyword_control_def_ruby">def</span> <span class="entity entity_name entity_name_function entity_name_function_ruby">breadcrumbs</span><span class="punctuation punctuation_definition punctuation_definition_parameters punctuation_definition_parameters_ruby">(</span><span class="variable variable_parameter variable_parameter_function variable_parameter_function_ruby">sep <span class="keyword keyword_operator keyword_operator_assignment keyword_operator_assignment_ruby">=</span> <span class="string string_quoted string_quoted_double string_quoted_double_ruby"><span class="punctuation punctuation_definition punctuation_definition_string punctuation_definition_string_begin punctuation_definition_string_begin_ruby">"</span>Â»<span class="punctuation punctuation_definition punctuation_definition_string punctuation_definition_string_end punctuation_definition_string_end_ruby">"</span></span><span class="punctuation punctuation_separator punctuation_separator_object punctuation_separator_object_ruby">,</span> include_home <span class="keyword keyword_operator keyword_operator_assignment keyword_operator_assignment_ruby">=</span> <span class="constant constant_language constant_language_ruby">true</span></span><span class="punctuation punctuation_definition punctuation_definition_parameters punctuation_definition_parameters_ruby">)</span></span>
    levels <span class="keyword keyword_operator keyword_operator_assignment keyword_operator_assignment_ruby">=</span> request<span class="punctuation punctuation_separator punctuation_separator_method punctuation_separator_method_ruby">.</span>path<span class="punctuation punctuation_separator punctuation_separator_method punctuation_separator_method_ruby">.</span>split<span class="punctuation punctuation_section punctuation_section_function punctuation_section_function_ruby">(</span><span class="string string_quoted string_quoted_single string_quoted_single_ruby"><span class="punctuation punctuation_definition punctuation_definition_string punctuation_definition_string_begin punctuation_definition_string_begin_ruby">'</span>?<span class="punctuation punctuation_definition punctuation_definition_string punctuation_definition_string_end punctuation_definition_string_end_ruby">'</span></span><span class="punctuation punctuation_section punctuation_section_function punctuation_section_function_ruby">)</span><span class="punctuation punctuation_section punctuation_section_array punctuation_section_array_ruby">[</span><span class="constant constant_numeric constant_numeric_ruby">0</span><span class="punctuation punctuation_section punctuation_section_array punctuation_section_array_ruby">]</span><span class="punctuation punctuation_separator punctuation_separator_method punctuation_separator_method_ruby">.</span>split<span class="punctuation punctuation_section punctuation_section_function punctuation_section_function_ruby">(</span><span class="string string_quoted string_quoted_single string_quoted_single_ruby"><span class="punctuation punctuation_definition punctuation_definition_string punctuation_definition_string_begin punctuation_definition_string_begin_ruby">'</span>/<span class="punctuation punctuation_definition punctuation_definition_string punctuation_definition_string_end punctuation_definition_string_end_ruby">'</span></span><span class="punctuation punctuation_section punctuation_section_function punctuation_section_function_ruby">)</span>
    levels<span class="punctuation punctuation_separator punctuation_separator_method punctuation_separator_method_ruby">.</span>delete_at<span class="punctuation punctuation_section punctuation_section_function punctuation_section_function_ruby">(</span><span class="constant constant_numeric constant_numeric_ruby">0</span><span class="punctuation punctuation_section punctuation_section_function punctuation_section_function_ruby">)</span>

    links <span class="keyword keyword_operator keyword_operator_assignment keyword_operator_assignment_ruby">=</span> <span class="string string_quoted string_quoted_double string_quoted_double_ruby"><span class="punctuation punctuation_definition punctuation_definition_string punctuation_definition_string_begin punctuation_definition_string_begin_ruby">"</span>You are here: <span class="punctuation punctuation_definition punctuation_definition_string punctuation_definition_string_end punctuation_definition_string_end_ruby">"</span></span>
    links <span class="keyword keyword_operator keyword_operator_assignment keyword_operator_assignment_augmented keyword_operator_assignment_augmented_ruby">+=</span> content_tag<span class="punctuation punctuation_section punctuation_section_function punctuation_section_function_ruby">(</span><span class="string string_quoted string_quoted_single string_quoted_single_ruby"><span class="punctuation punctuation_definition punctuation_definition_string punctuation_definition_string_begin punctuation_definition_string_begin_ruby">'</span>a<span class="punctuation punctuation_definition punctuation_definition_string punctuation_definition_string_end punctuation_definition_string_end_ruby">'</span></span><span class="punctuation punctuation_separator punctuation_separator_object punctuation_separator_object_ruby">,</span> <span class="string string_quoted string_quoted_double string_quoted_double_ruby"><span class="punctuation punctuation_definition punctuation_definition_string punctuation_definition_string_begin punctuation_definition_string_begin_ruby">"</span>home<span class="punctuation punctuation_definition punctuation_definition_string punctuation_definition_string_end punctuation_definition_string_end_ruby">"</span></span><span class="punctuation punctuation_separator punctuation_separator_object punctuation_separator_object_ruby">,</span> <span class="constant constant_other constant_other_symbol constant_other_symbol_ruby"><span class="punctuation punctuation_definition punctuation_definition_constant punctuation_definition_constant_ruby">:</span>href</span> <span class="punctuation punctuation_separator punctuation_separator_key-value">=></span> <span class="string string_quoted string_quoted_double string_quoted_double_ruby"><span class="punctuation punctuation_definition punctuation_definition_string punctuation_definition_string_begin punctuation_definition_string_begin_ruby">"</span>/<span class="punctuation punctuation_definition punctuation_definition_string punctuation_definition_string_end punctuation_definition_string_end_ruby">"</span></span><span class="punctuation punctuation_section punctuation_section_function punctuation_section_function_ruby">)</span> <span class="keyword keyword_control keyword_control_ruby">if</span> include_home

    levels<span class="punctuation punctuation_separator punctuation_separator_method punctuation_separator_method_ruby">.</span>each_with_index <span class="keyword keyword_control keyword_control_ruby keyword_control_ruby_start-block">do </span><span class="punctuation punctuation_separator punctuation_separator_variable punctuation_separator_variable_ruby">|</span><span class="variable variable_other variable_other_block variable_other_block_ruby">level</span><span class="punctuation punctuation_separator punctuation_separator_variable punctuation_separator_variable_ruby">,</span> <span class="variable variable_other variable_other_block variable_other_block_ruby">index</span><span class="punctuation punctuation_separator punctuation_separator_variable punctuation_separator_variable_ruby">|</span>
      links <span class="keyword keyword_operator keyword_operator_assignment keyword_operator_assignment_augmented keyword_operator_assignment_augmented_ruby">+=</span> <span class="string string_quoted string_quoted_double string_quoted_double_ruby"><span class="punctuation punctuation_definition punctuation_definition_string punctuation_definition_string_begin punctuation_definition_string_begin_ruby">"</span> <span class="source source_ruby source_ruby_embedded source_ruby_embedded_source"><span class="punctuation punctuation_section punctuation_section_embedded punctuation_section_embedded_ruby">#{</span>sep<span class="punctuation punctuation_section punctuation_section_embedded punctuation_section_embedded_ruby">}</span></span> <span class="source source_ruby source_ruby_embedded source_ruby_embedded_source"><span class="punctuation punctuation_section punctuation_section_embedded punctuation_section_embedded_ruby">#{</span>content_tag<span class="punctuation punctuation_section punctuation_section_function punctuation_section_function_ruby">(</span><span class="string string_quoted string_quoted_single string_quoted_single_ruby"><span class="punctuation punctuation_definition punctuation_definition_string punctuation_definition_string_begin punctuation_definition_string_begin_ruby">'</span>a<span class="punctuation punctuation_definition punctuation_definition_string punctuation_definition_string_end punctuation_definition_string_end_ruby">'</span></span><span class="punctuation punctuation_separator punctuation_separator_object punctuation_separator_object_ruby">,</span> level<span class="punctuation punctuation_separator punctuation_separator_method punctuation_separator_method_ruby">.</span>downcase<span class="punctuation punctuation_separator punctuation_separator_method punctuation_separator_method_ruby">.</span>gsub<span class="punctuation punctuation_section punctuation_section_function punctuation_section_function_ruby">(</span><span class="string string_regexp string_regexp_classic string_regexp_classic_ruby"><span class="punctuation punctuation_definition punctuation_definition_string punctuation_definition_string_ruby">/</span>_<span class="punctuation punctuation_definition punctuation_definition_string punctuation_definition_string_ruby">/</span></span><span class="punctuation punctuation_separator punctuation_separator_object punctuation_separator_object_ruby">,</span> <span class="string string_quoted string_quoted_single string_quoted_single_ruby"><span class="punctuation punctuation_definition punctuation_definition_string punctuation_definition_string_begin punctuation_definition_string_begin_ruby">'</span> <span class="punctuation punctuation_definition punctuation_definition_string punctuation_definition_string_end punctuation_definition_string_end_ruby">'</span></span><span class="punctuation punctuation_section punctuation_section_function punctuation_section_function_ruby">)</span><span class="punctuation punctuation_separator punctuation_separator_object punctuation_separator_object_ruby">,</span> <span class="constant constant_other constant_other_symbol constant_other_symbol_ruby"><span class="punctuation punctuation_definition punctuation_definition_constant punctuation_definition_constant_ruby">:</span>href</span> <span class="punctuation punctuation_separator punctuation_separator_key-value">=></span> <span class="string string_quoted string_quoted_single string_quoted_single_ruby"><span class="punctuation punctuation_definition punctuation_definition_string punctuation_definition_string_begin punctuation_definition_string_begin_ruby">'</span>/<span class="punctuation punctuation_definition punctuation_definition_string punctuation_definition_string_end punctuation_definition_string_end_ruby">'</span></span><span class="keyword keyword_operator keyword_operator_arithmetic keyword_operator_arithmetic_ruby">+</span>levels<span class="punctuation punctuation_section punctuation_section_array punctuation_section_array_ruby">[</span><span class="constant constant_numeric constant_numeric_ruby">0</span><span class="punctuation punctuation_separator punctuation_separator_method punctuation_separator_method_ruby">..</span>index<span class="punctuation punctuation_section punctuation_section_array punctuation_section_array_ruby">]</span><span class="punctuation punctuation_separator punctuation_separator_method punctuation_separator_method_ruby">.</span>join<span class="punctuation punctuation_section punctuation_section_function punctuation_section_function_ruby">(</span><span class="string string_quoted string_quoted_single string_quoted_single_ruby"><span class="punctuation punctuation_definition punctuation_definition_string punctuation_definition_string_begin punctuation_definition_string_begin_ruby">'</span>/<span class="punctuation punctuation_definition punctuation_definition_string punctuation_definition_string_end punctuation_definition_string_end_ruby">'</span></span><span class="punctuation punctuation_section punctuation_section_function punctuation_section_function_ruby">))</span><span class="punctuation punctuation_section punctuation_section_embedded punctuation_section_embedded_ruby">}</span></span><span class="punctuation punctuation_definition punctuation_definition_string punctuation_definition_string_end punctuation_definition_string_end_ruby">"</span></span>
    <span class="keyword keyword_control keyword_control_ruby">end</span>

    content_tag<span class="punctuation punctuation_section punctuation_section_function punctuation_section_function_ruby">(</span><span class="string string_quoted string_quoted_double string_quoted_double_ruby"><span class="punctuation punctuation_definition punctuation_definition_string punctuation_definition_string_begin punctuation_definition_string_begin_ruby">"</span>div<span class="punctuation punctuation_definition punctuation_definition_string punctuation_definition_string_end punctuation_definition_string_end_ruby">"</span></span><span class="punctuation punctuation_separator punctuation_separator_object punctuation_separator_object_ruby">,</span> content_tag<span class="punctuation punctuation_section punctuation_section_function punctuation_section_function_ruby">(</span><span class="string string_quoted string_quoted_double string_quoted_double_ruby"><span class="punctuation punctuation_definition punctuation_definition_string punctuation_definition_string_begin punctuation_definition_string_begin_ruby">"</span>p<span class="punctuation punctuation_definition punctuation_definition_string punctuation_definition_string_end punctuation_definition_string_end_ruby">"</span></span><span class="punctuation punctuation_separator punctuation_separator_object punctuation_separator_object_ruby">,</span> links <span class="punctuation punctuation_section punctuation_section_function punctuation_section_function_ruby">)</span><span class="punctuation punctuation_separator punctuation_separator_object punctuation_separator_object_ruby">,</span> <span class="constant constant_other constant_other_symbol constant_other_symbol_ruby"><span class="punctuation punctuation_definition punctuation_definition_constant punctuation_definition_constant_ruby">:</span>id</span> <span class="punctuation punctuation_separator punctuation_separator_key-value">=></span> <span class="string string_quoted string_quoted_double string_quoted_double_ruby"><span class="punctuation punctuation_definition punctuation_definition_string punctuation_definition_string_begin punctuation_definition_string_begin_ruby">"</span>breadcrumb<span class="punctuation punctuation_definition punctuation_definition_string punctuation_definition_string_end punctuation_definition_string_end_ruby">"</span></span><span class="punctuation punctuation_section punctuation_section_function punctuation_section_function_ruby">)</span>
  <span class="keyword keyword_control keyword_control_ruby">end</span></span></span></pre>
]]></content:encoded>
			<wfw:commentRss>http://blog.craig-mackenzie.com/2007/08/09/simple-bread-crumbs-in-ruby-on-rails/feed/</wfw:commentRss>
		<slash:comments>5</slash:comments>
		</item>
		<item>
		<title>Deploying Multiple Instances of an Application With Capistrano</title>
		<link>http://blog.craig-mackenzie.com/2007/01/04/deploying-multiple-instances-of-an-application-with-capistrano/</link>
		<comments>http://blog.craig-mackenzie.com/2007/01/04/deploying-multiple-instances-of-an-application-with-capistrano/#comments</comments>
		<pubDate>Thu, 04 Jan 2007 14:50:26 +0000</pubDate>
		<dc:creator>craig mackenzie</dc:creator>
				<category><![CDATA[code]]></category>
		<category><![CDATA[ruby/rails]]></category>

		<guid isPermaLink="false">http://blog.craig-mackenzie.com/2007/01/04/deploying-multiple-instances-of-an-application-with-capistrano/</guid>
		<description><![CDATA[Like most people I use capistrano to deploy my rails applications, at work we host with the excellent railsmachine and they have really helped simplify the process of deploying to their servers using the railsmachine gem, which builds on top of the excellent functionality of capistrano. 
The way these tools work by default they only [...]]]></description>
			<content:encoded><![CDATA[<p>Like most people I use capistrano to deploy my rails applications, at work we host with the excellent <a href="http://railsmachine.com/">railsmachine</a> and they have really helped simplify the process of deploying to their servers using the <a href="https://support.railsmachine.com/index.php?pg=kb.chapter&#038;id=18">railsmachine gem</a>, which builds on top of the excellent functionality of capistrano. </p>
<p>The way these tools work by default they only allow you to deploy one instance of your application, which is fine, that&#8217;s all they&#8217;re are intended to do. But in the client facing world you&#8217;re probably going to want to have at least two versions of the same application at different stages of development running on the same server.</p>
<p>A live forward facing version (my-app.com) and a staging version (staging.my-app.com) for client approval / production testing (not code testing, that should stay on your development box) / progressive reviews etc.</p>
<p>So how do we achieve that? The idea is to determine what context you are deploying your application in, and use the fact the capistrano tasks can be chained together to set everything up ready for deploying a revision of your application to a targeted url, independent of other deployments.</p>
<h2>Step 1</h2>
<p>The first thing to do is to require the railsmachine recipes and setup some variables, as you will see later some of these variables are redundant, and the code has a fair bit of duplication, but this is a work in progress and I hope to clean it up when I have some more spare time.</p>
<pre class="textmate-source"><span class="source source_ruby source_ruby_rails"><span class="meta meta_require meta_require_ruby"><span class="keyword keyword_other keyword_other_special-method keyword_other_special-method_ruby">require</span> <span class="string string_quoted string_quoted_single string_quoted_single_ruby"><span class="punctuation punctuation_definition punctuation_definition_string punctuation_definition_string_begin punctuation_definition_string_begin_ruby">'</span>railsmachine/recipes<span class="punctuation punctuation_definition punctuation_definition_string punctuation_definition_string_end punctuation_definition_string_end_ruby">'</span></span></span>

set <span class="constant constant_other constant_other_symbol constant_other_symbol_ruby"><span class="punctuation punctuation_definition punctuation_definition_constant punctuation_definition_constant_ruby">:</span>application</span>, <span class="string string_quoted string_quoted_double string_quoted_double_ruby"><span class="punctuation punctuation_definition punctuation_definition_string punctuation_definition_string_begin punctuation_definition_string_begin_ruby">"</span>my-app<span class="punctuation punctuation_definition punctuation_definition_string punctuation_definition_string_end punctuation_definition_string_end_ruby">"</span></span>
set <span class="constant constant_other constant_other_symbol constant_other_symbol_ruby"><span class="punctuation punctuation_definition punctuation_definition_constant punctuation_definition_constant_ruby">:</span>deploy_to</span>, <span class="string string_quoted string_quoted_double string_quoted_double_ruby"><span class="punctuation punctuation_definition punctuation_definition_string punctuation_definition_string_begin punctuation_definition_string_begin_ruby">"</span>/var/www/apps/<span class="source source_ruby source_ruby_embedded source_ruby_embedded_source"><span class="punctuation punctuation_section punctuation_section_embedded punctuation_section_embedded_ruby">#{</span>application<span class="punctuation punctuation_section punctuation_section_embedded punctuation_section_embedded_ruby">}</span></span><span class="punctuation punctuation_definition punctuation_definition_string punctuation_definition_string_end punctuation_definition_string_end_ruby">"</span></span>
set <span class="constant constant_other constant_other_symbol constant_other_symbol_ruby"><span class="punctuation punctuation_definition punctuation_definition_constant punctuation_definition_constant_ruby">:</span>main_domain</span>, <span class="string string_quoted string_quoted_double string_quoted_double_ruby"><span class="punctuation punctuation_definition punctuation_definition_string punctuation_definition_string_begin punctuation_definition_string_begin_ruby">"</span>my-app.com<span class="punctuation punctuation_definition punctuation_definition_string punctuation_definition_string_end punctuation_definition_string_end_ruby">"</span></span>

set <span class="constant constant_other constant_other_symbol constant_other_symbol_ruby"><span class="punctuation punctuation_definition punctuation_definition_constant punctuation_definition_constant_ruby">:</span>user</span>, <span class="string string_quoted string_quoted_double string_quoted_double_ruby"><span class="punctuation punctuation_definition punctuation_definition_string punctuation_definition_string_begin punctuation_definition_string_begin_ruby">"</span>deploy<span class="punctuation punctuation_definition punctuation_definition_string punctuation_definition_string_end punctuation_definition_string_end_ruby">"</span></span>
set <span class="constant constant_other constant_other_symbol constant_other_symbol_ruby"><span class="punctuation punctuation_definition punctuation_definition_constant punctuation_definition_constant_ruby">:</span>repository</span>, <span class="string string_quoted string_quoted_double string_quoted_double_ruby"><span class="punctuation punctuation_definition punctuation_definition_string punctuation_definition_string_begin punctuation_definition_string_begin_ruby">"</span>svn+ssh://<span class="source source_ruby source_ruby_embedded source_ruby_embedded_source"><span class="punctuation punctuation_section punctuation_section_embedded punctuation_section_embedded_ruby">#{</span>user<span class="punctuation punctuation_section punctuation_section_embedded punctuation_section_embedded_ruby">}</span></span>@my-svn-server.com/var/svn/<span class="source source_ruby source_ruby_embedded source_ruby_embedded_source"><span class="punctuation punctuation_section punctuation_section_embedded punctuation_section_embedded_ruby">#{</span>main_domain<span class="punctuation punctuation_section punctuation_section_embedded punctuation_section_embedded_ruby">}</span></span>/trunk<span class="punctuation punctuation_definition punctuation_definition_string punctuation_definition_string_end punctuation_definition_string_end_ruby">"</span></span>
set <span class="constant constant_other constant_other_symbol constant_other_symbol_ruby"><span class="punctuation punctuation_definition punctuation_definition_constant punctuation_definition_constant_ruby">:</span>rails_env</span>, <span class="string string_quoted string_quoted_double string_quoted_double_ruby"><span class="punctuation punctuation_definition punctuation_definition_string punctuation_definition_string_begin punctuation_definition_string_begin_ruby">"</span>production<span class="punctuation punctuation_definition punctuation_definition_string punctuation_definition_string_end punctuation_definition_string_end_ruby">"</span></span>

role <span class="constant constant_other constant_other_symbol constant_other_symbol_ruby"><span class="punctuation punctuation_definition punctuation_definition_constant punctuation_definition_constant_ruby">:</span>scm</span>, <span class="string string_quoted string_quoted_double string_quoted_double_ruby"><span class="punctuation punctuation_definition punctuation_definition_string punctuation_definition_string_begin punctuation_definition_string_begin_ruby">"</span>my-svn-server.com<span class="punctuation punctuation_definition punctuation_definition_string punctuation_definition_string_end punctuation_definition_string_end_ruby">"</span></span></span></pre>
<p>You&#8217;ll notice that I&#8217;m keeping my my project on separate svn server, by default the railsmachine gem will create an svn repo for you as part of the project tree, this is really useful at first, but when you&#8217;re deploying multiple instances of the same application you&#8217;re going to want your svn repo independent.</p>
<h2>Step 2</h2>
<p>Now comes the clever bit, creating the tasks which will be called before our regular cap commands, like so <code>$ cap -a staging deploy</code> (which would deploy the current revision of your application to the staging server)</p>
<pre class="textmate-source"><span class="source source_ruby source_ruby_rails">desc <span class="string string_quoted string_quoted_double string_quoted_double_ruby"><span class="punctuation punctuation_definition punctuation_definition_string punctuation_definition_string_begin punctuation_definition_string_begin_ruby">"</span>Set staging instance variables<span class="punctuation punctuation_definition punctuation_definition_string punctuation_definition_string_end punctuation_definition_string_end_ruby">"</span></span>
task <span class="constant constant_other constant_other_symbol constant_other_symbol_ruby"><span class="punctuation punctuation_definition punctuation_definition_constant punctuation_definition_constant_ruby">:</span>staging</span> <span class="keyword keyword_control keyword_control_ruby keyword_control_ruby_start-block">do
</span>    set <span class="constant constant_other constant_other_symbol constant_other_symbol_ruby"><span class="punctuation punctuation_definition punctuation_definition_constant punctuation_definition_constant_ruby">:</span>application</span>, <span class="string string_quoted string_quoted_double string_quoted_double_ruby"><span class="punctuation punctuation_definition punctuation_definition_string punctuation_definition_string_begin punctuation_definition_string_begin_ruby">"</span>my-app-staging<span class="punctuation punctuation_definition punctuation_definition_string punctuation_definition_string_end punctuation_definition_string_end_ruby">"</span></span>
    set <span class="constant constant_other constant_other_symbol constant_other_symbol_ruby"><span class="punctuation punctuation_definition punctuation_definition_constant punctuation_definition_constant_ruby">:</span>domain</span>, <span class="string string_quoted string_quoted_double string_quoted_double_ruby"><span class="punctuation punctuation_definition punctuation_definition_string punctuation_definition_string_begin punctuation_definition_string_begin_ruby">"</span>staging.my-app.com<span class="punctuation punctuation_definition punctuation_definition_string punctuation_definition_string_end punctuation_definition_string_end_ruby">"</span></span>
    set <span class="constant constant_other constant_other_symbol constant_other_symbol_ruby"><span class="punctuation punctuation_definition punctuation_definition_constant punctuation_definition_constant_ruby">:</span>apache_proxy_port</span>, <span class="constant constant_numeric constant_numeric_ruby">8010</span>
    set <span class="constant constant_other constant_other_symbol constant_other_symbol_ruby"><span class="punctuation punctuation_definition punctuation_definition_constant punctuation_definition_constant_ruby">:</span>database_yml</span>, <span class="string string_quoted string_quoted_double string_quoted_double_ruby"><span class="punctuation punctuation_definition punctuation_definition_string punctuation_definition_string_begin punctuation_definition_string_begin_ruby">"</span>database-staging.yml<span class="punctuation punctuation_definition punctuation_definition_string punctuation_definition_string_end punctuation_definition_string_end_ruby">"</span></span>
    set <span class="constant constant_other constant_other_symbol constant_other_symbol_ruby"><span class="punctuation punctuation_definition punctuation_definition_constant punctuation_definition_constant_ruby">:</span>deploy_to</span>, <span class="string string_quoted string_quoted_double string_quoted_double_ruby"><span class="punctuation punctuation_definition punctuation_definition_string punctuation_definition_string_begin punctuation_definition_string_begin_ruby">"</span>/var/www/apps/<span class="source source_ruby source_ruby_embedded source_ruby_embedded_source"><span class="punctuation punctuation_section punctuation_section_embedded punctuation_section_embedded_ruby">#{</span>application<span class="punctuation punctuation_section punctuation_section_embedded punctuation_section_embedded_ruby">}</span></span><span class="punctuation punctuation_definition punctuation_definition_string punctuation_definition_string_end punctuation_definition_string_end_ruby">"</span></span>

    role <span class="constant constant_other constant_other_symbol constant_other_symbol_ruby"><span class="punctuation punctuation_definition punctuation_definition_constant punctuation_definition_constant_ruby">:</span>web</span>, domain
    role <span class="constant constant_other constant_other_symbol constant_other_symbol_ruby"><span class="punctuation punctuation_definition punctuation_definition_constant punctuation_definition_constant_ruby">:</span>app</span>, domain
    role <span class="constant constant_other constant_other_symbol constant_other_symbol_ruby"><span class="punctuation punctuation_definition punctuation_definition_constant punctuation_definition_constant_ruby">:</span>db</span>,  domain, <span class="constant constant_other constant_other_symbol constant_other_symbol_ruby"><span class="punctuation punctuation_definition punctuation_definition_constant punctuation_definition_constant_ruby">:</span>primary</span> =&gt; <span class="constant constant_language constant_language_ruby">true</span>
<span class="keyword keyword_control keyword_control_ruby">end</span>

desc <span class="string string_quoted string_quoted_double string_quoted_double_ruby"><span class="punctuation punctuation_definition punctuation_definition_string punctuation_definition_string_begin punctuation_definition_string_begin_ruby">"</span>Set production instance variables<span class="punctuation punctuation_definition punctuation_definition_string punctuation_definition_string_end punctuation_definition_string_end_ruby">"</span></span>
task <span class="constant constant_other constant_other_symbol constant_other_symbol_ruby"><span class="punctuation punctuation_definition punctuation_definition_constant punctuation_definition_constant_ruby">:</span>production</span> <span class="keyword keyword_control keyword_control_ruby keyword_control_ruby_start-block">do
</span>    set <span class="constant constant_other constant_other_symbol constant_other_symbol_ruby"><span class="punctuation punctuation_definition punctuation_definition_constant punctuation_definition_constant_ruby">:</span>application</span>, <span class="string string_quoted string_quoted_double string_quoted_double_ruby"><span class="punctuation punctuation_definition punctuation_definition_string punctuation_definition_string_begin punctuation_definition_string_begin_ruby">"</span>my-app-production<span class="punctuation punctuation_definition punctuation_definition_string punctuation_definition_string_end punctuation_definition_string_end_ruby">"</span></span>
    set <span class="constant constant_other constant_other_symbol constant_other_symbol_ruby"><span class="punctuation punctuation_definition punctuation_definition_constant punctuation_definition_constant_ruby">:</span>domain</span>, <span class="string string_quoted string_quoted_double string_quoted_double_ruby"><span class="punctuation punctuation_definition punctuation_definition_string punctuation_definition_string_begin punctuation_definition_string_begin_ruby">"</span>my-app.com<span class="punctuation punctuation_definition punctuation_definition_string punctuation_definition_string_end punctuation_definition_string_end_ruby">"</span></span>
    set <span class="constant constant_other constant_other_symbol constant_other_symbol_ruby"><span class="punctuation punctuation_definition punctuation_definition_constant punctuation_definition_constant_ruby">:</span>apache_proxy_port</span>, <span class="constant constant_numeric constant_numeric_ruby">8000</span>
    set <span class="constant constant_other constant_other_symbol constant_other_symbol_ruby"><span class="punctuation punctuation_definition punctuation_definition_constant punctuation_definition_constant_ruby">:</span>database_yml</span>, <span class="string string_quoted string_quoted_double string_quoted_double_ruby"><span class="punctuation punctuation_definition punctuation_definition_string punctuation_definition_string_begin punctuation_definition_string_begin_ruby">"</span>database-production.yml<span class="punctuation punctuation_definition punctuation_definition_string punctuation_definition_string_end punctuation_definition_string_end_ruby">"</span></span>
    set <span class="constant constant_other constant_other_symbol constant_other_symbol_ruby"><span class="punctuation punctuation_definition punctuation_definition_constant punctuation_definition_constant_ruby">:</span>deploy_to</span>, <span class="string string_quoted string_quoted_double string_quoted_double_ruby"><span class="punctuation punctuation_definition punctuation_definition_string punctuation_definition_string_begin punctuation_definition_string_begin_ruby">"</span>/var/www/apps/<span class="source source_ruby source_ruby_embedded source_ruby_embedded_source"><span class="punctuation punctuation_section punctuation_section_embedded punctuation_section_embedded_ruby">#{</span>application<span class="punctuation punctuation_section punctuation_section_embedded punctuation_section_embedded_ruby">}</span></span><span class="punctuation punctuation_definition punctuation_definition_string punctuation_definition_string_end punctuation_definition_string_end_ruby">"</span></span>

    role <span class="constant constant_other constant_other_symbol constant_other_symbol_ruby"><span class="punctuation punctuation_definition punctuation_definition_constant punctuation_definition_constant_ruby">:</span>web</span>, domain
    role <span class="constant constant_other constant_other_symbol constant_other_symbol_ruby"><span class="punctuation punctuation_definition punctuation_definition_constant punctuation_definition_constant_ruby">:</span>app</span>, domain
    role <span class="constant constant_other constant_other_symbol constant_other_symbol_ruby"><span class="punctuation punctuation_definition punctuation_definition_constant punctuation_definition_constant_ruby">:</span>db</span>,  domain, <span class="constant constant_other constant_other_symbol constant_other_symbol_ruby"><span class="punctuation punctuation_definition punctuation_definition_constant punctuation_definition_constant_ruby">:</span>primary</span> =&gt; <span class="constant constant_language constant_language_ruby">true</span>
<span class="keyword keyword_control keyword_control_ruby">end</span></span></pre>
<p>What this does is set all of the variables which any command you&#8217;ll call after staging or production will need, it&#8217;s pretty ugly at the moment and I hope to clean it up and make it a lot smarter, but for the moment it works, and in it&#8217;s ugliness it does make it clear what it&#8217;s doing.</p>
<h2>Step 3</h2>
<p>Next we overwrite the railsmachine setup_scm task and one of the tasks it calls, we&#8217;re doing this because we are using a custom location for our repository and not the one which the railsmachine gem tries to create for us. </p>
<p>In my particular situation I have an external server used for svn, but the repository could just as easily be on the same server as your application just so long as the folder you create the repo in is in the deploy group. Also in my situation I am creating a new repo for each project I deploy, if you already have a repo that you deploy all projects to you could easily just remove the setup_svn_repo task call from the setup_scm task.</p>
<p>Enough talk, on with the code:</p>
<pre class="textmate-source"><span class="source source_ruby source_ruby_rails">desc <span class="string string_quoted string_quoted_double string_quoted_double_ruby"><span class="punctuation punctuation_definition punctuation_definition_string punctuation_definition_string_begin punctuation_definition_string_begin_ruby">"</span>Setup svn repository<span class="punctuation punctuation_definition punctuation_definition_string punctuation_definition_string_end punctuation_definition_string_end_ruby">"</span></span>
task <span class="constant constant_other constant_other_symbol constant_other_symbol_ruby"><span class="punctuation punctuation_definition punctuation_definition_constant punctuation_definition_constant_ruby">:</span>setup_svn_repo</span>, <span class="constant constant_other constant_other_symbol constant_other_symbol_ruby"><span class="punctuation punctuation_definition punctuation_definition_constant punctuation_definition_constant_ruby">:</span>roles</span> =&gt; <span class="constant constant_other constant_other_symbol constant_other_symbol_ruby"><span class="punctuation punctuation_definition punctuation_definition_constant punctuation_definition_constant_ruby">:</span>scm</span> <span class="keyword keyword_control keyword_control_ruby keyword_control_ruby_start-block">do
</span>  dir = <span class="string string_quoted string_quoted_double string_quoted_double_ruby"><span class="punctuation punctuation_definition punctuation_definition_string punctuation_definition_string_begin punctuation_definition_string_begin_ruby">"</span>/var/svn/<span class="source source_ruby source_ruby_embedded source_ruby_embedded_source"><span class="punctuation punctuation_section punctuation_section_embedded punctuation_section_embedded_ruby">#{</span>main_domain<span class="punctuation punctuation_section punctuation_section_embedded punctuation_section_embedded_ruby">}</span></span><span class="punctuation punctuation_definition punctuation_definition_string punctuation_definition_string_end punctuation_definition_string_end_ruby">"</span></span>
  run <span class="string string_quoted string_quoted_double string_quoted_double_ruby"><span class="punctuation punctuation_definition punctuation_definition_string punctuation_definition_string_begin punctuation_definition_string_begin_ruby">"</span>mkdir -p <span class="source source_ruby source_ruby_embedded source_ruby_embedded_source"><span class="punctuation punctuation_section punctuation_section_embedded punctuation_section_embedded_ruby">#{</span>dir<span class="punctuation punctuation_section punctuation_section_embedded punctuation_section_embedded_ruby">}</span></span><span class="punctuation punctuation_definition punctuation_definition_string punctuation_definition_string_end punctuation_definition_string_end_ruby">"</span></span>
  run <span class="string string_quoted string_quoted_double string_quoted_double_ruby"><span class="punctuation punctuation_definition punctuation_definition_string punctuation_definition_string_begin punctuation_definition_string_begin_ruby">"</span>chmod 770 <span class="source source_ruby source_ruby_embedded source_ruby_embedded_source"><span class="punctuation punctuation_section punctuation_section_embedded punctuation_section_embedded_ruby">#{</span>dir<span class="punctuation punctuation_section punctuation_section_embedded punctuation_section_embedded_ruby">}</span></span><span class="punctuation punctuation_definition punctuation_definition_string punctuation_definition_string_end punctuation_definition_string_end_ruby">"</span></span>
  run <span class="string string_quoted string_quoted_double string_quoted_double_ruby"><span class="punctuation punctuation_definition punctuation_definition_string punctuation_definition_string_begin punctuation_definition_string_begin_ruby">"</span>svnadmin create <span class="source source_ruby source_ruby_embedded source_ruby_embedded_source"><span class="punctuation punctuation_section punctuation_section_embedded punctuation_section_embedded_ruby">#{</span>dir<span class="punctuation punctuation_section punctuation_section_embedded punctuation_section_embedded_ruby">}</span></span><span class="punctuation punctuation_definition punctuation_definition_string punctuation_definition_string_end punctuation_definition_string_end_ruby">"</span></span>
<span class="keyword keyword_control keyword_control_ruby">end</span>

desc <span class="string string_quoted string_quoted_double string_quoted_double_ruby"><span class="punctuation punctuation_definition punctuation_definition_string punctuation_definition_string_begin punctuation_definition_string_begin_ruby">"</span>Setup source control server.<span class="punctuation punctuation_definition punctuation_definition_string punctuation_definition_string_end punctuation_definition_string_end_ruby">"</span></span>
task <span class="constant constant_other constant_other_symbol constant_other_symbol_ruby"><span class="punctuation punctuation_definition punctuation_definition_constant punctuation_definition_constant_ruby">:</span>setup_scm</span>, <span class="constant constant_other constant_other_symbol constant_other_symbol_ruby"><span class="punctuation punctuation_definition punctuation_definition_constant punctuation_definition_constant_ruby">:</span>roles</span> =&gt; <span class="constant constant_other constant_other_symbol constant_other_symbol_ruby"><span class="punctuation punctuation_definition punctuation_definition_constant punctuation_definition_constant_ruby">:</span>scm</span>  <span class="keyword keyword_control keyword_control_ruby keyword_control_ruby_start-block">do
</span>  setup_svn_repo
  import_svn
<span class="keyword keyword_control keyword_control_ruby">end</span></span></pre>
<h2>Step 4</h2>
<p>Because different instances of our application are going to need different databases we have to overwrite the method which read&#8217;s in the database configuration when setting up the database for the first time. The way it works at the moment we also need to remove the database.yml file from svn control, and recreate it from the correct file after every code update.</p>
<pre class="textmate-source"><span class="source source_ruby source_ruby_rails">task <span class="constant constant_other constant_other_symbol constant_other_symbol_ruby"><span class="punctuation punctuation_definition punctuation_definition_constant punctuation_definition_constant_ruby">:</span>clean_db_yml</span> <span class="keyword keyword_control keyword_control_ruby keyword_control_ruby_start-block">do
</span>  puts <span class="string string_quoted string_quoted_double string_quoted_double_ruby"><span class="punctuation punctuation_definition punctuation_definition_string punctuation_definition_string_begin punctuation_definition_string_begin_ruby">"</span>removing database.yml from svn<span class="punctuation punctuation_definition punctuation_definition_string punctuation_definition_string_end punctuation_definition_string_end_ruby">"</span></span>
  system <span class="string string_quoted string_quoted_double string_quoted_double_ruby"><span class="punctuation punctuation_definition punctuation_definition_string punctuation_definition_string_begin punctuation_definition_string_begin_ruby">"</span>svn remove config/database.yml<span class="punctuation punctuation_definition punctuation_definition_string punctuation_definition_string_end punctuation_definition_string_end_ruby">"</span></span>
  puts <span class="string string_quoted string_quoted_double string_quoted_double_ruby"><span class="punctuation punctuation_definition punctuation_definition_string punctuation_definition_string_begin punctuation_definition_string_begin_ruby">"</span>ignoring database.yml<span class="punctuation punctuation_definition punctuation_definition_string punctuation_definition_string_end punctuation_definition_string_end_ruby">"</span></span>
  system <span class="string string_quoted string_quoted_double string_quoted_double_ruby"><span class="punctuation punctuation_definition punctuation_definition_string punctuation_definition_string_begin punctuation_definition_string_begin_ruby">"</span>svn propset svn:ignore 'database.yml' config/<span class="punctuation punctuation_definition punctuation_definition_string punctuation_definition_string_end punctuation_definition_string_end_ruby">"</span></span>
  system <span class="string string_quoted string_quoted_double string_quoted_double_ruby"><span class="punctuation punctuation_definition punctuation_definition_string punctuation_definition_string_begin punctuation_definition_string_begin_ruby">"</span>svn update config/<span class="punctuation punctuation_definition punctuation_definition_string punctuation_definition_string_end punctuation_definition_string_end_ruby">"</span></span>
  puts <span class="string string_quoted string_quoted_double string_quoted_double_ruby"><span class="punctuation punctuation_definition punctuation_definition_string punctuation_definition_string_begin punctuation_definition_string_begin_ruby">"</span>committing changes<span class="punctuation punctuation_definition punctuation_definition_string punctuation_definition_string_end punctuation_definition_string_end_ruby">"</span></span>
  system <span class="string string_quoted string_quoted_double string_quoted_double_ruby"><span class="punctuation punctuation_definition punctuation_definition_string punctuation_definition_string_begin punctuation_definition_string_begin_ruby">"</span>svn commit -m 'Removed and ignored database.yml file'<span class="punctuation punctuation_definition punctuation_definition_string punctuation_definition_string_end punctuation_definition_string_end_ruby">"</span></span>
<span class="keyword keyword_control keyword_control_ruby">end</span>

<span class="meta meta_function meta_function_method meta_function_method_without-arguments meta_function_method_without-arguments_ruby"><span class="keyword keyword_control keyword_control_def keyword_control_def_ruby">def</span> <span class="entity entity_name entity_name_function entity_name_function_ruby">read_config</span></span>
  db_config = <span class="variable variable_other variable_other_constant variable_other_constant_ruby">YAML</span>.load_file(<span class="string string_quoted string_quoted_double string_quoted_double_ruby"><span class="punctuation punctuation_definition punctuation_definition_string punctuation_definition_string_begin punctuation_definition_string_begin_ruby">"</span>config/<span class="source source_ruby source_ruby_embedded source_ruby_embedded_source"><span class="punctuation punctuation_section punctuation_section_embedded punctuation_section_embedded_ruby">#{</span>database_yml<span class="punctuation punctuation_section punctuation_section_embedded punctuation_section_embedded_ruby">}</span></span><span class="punctuation punctuation_definition punctuation_definition_string punctuation_definition_string_end punctuation_definition_string_end_ruby">"</span></span>)
  set <span class="constant constant_other constant_other_symbol constant_other_symbol_ruby"><span class="punctuation punctuation_definition punctuation_definition_constant punctuation_definition_constant_ruby">:</span>db_user</span>, db_config[rails_env][<span class="string string_quoted string_quoted_double string_quoted_double_ruby"><span class="punctuation punctuation_definition punctuation_definition_string punctuation_definition_string_begin punctuation_definition_string_begin_ruby">"</span>username<span class="punctuation punctuation_definition punctuation_definition_string punctuation_definition_string_end punctuation_definition_string_end_ruby">"</span></span>]
  set <span class="constant constant_other constant_other_symbol constant_other_symbol_ruby"><span class="punctuation punctuation_definition punctuation_definition_constant punctuation_definition_constant_ruby">:</span>db_password</span>, db_config[rails_env][<span class="string string_quoted string_quoted_double string_quoted_double_ruby"><span class="punctuation punctuation_definition punctuation_definition_string punctuation_definition_string_begin punctuation_definition_string_begin_ruby">"</span>password<span class="punctuation punctuation_definition punctuation_definition_string punctuation_definition_string_end punctuation_definition_string_end_ruby">"</span></span>]
  set <span class="constant constant_other constant_other_symbol constant_other_symbol_ruby"><span class="punctuation punctuation_definition punctuation_definition_constant punctuation_definition_constant_ruby">:</span>db_name</span>, db_config[rails_env][<span class="string string_quoted string_quoted_double string_quoted_double_ruby"><span class="punctuation punctuation_definition punctuation_definition_string punctuation_definition_string_begin punctuation_definition_string_begin_ruby">"</span>database<span class="punctuation punctuation_definition punctuation_definition_string punctuation_definition_string_end punctuation_definition_string_end_ruby">"</span></span>]
<span class="keyword keyword_control keyword_control_ruby">end</span>

task <span class="constant constant_other constant_other_symbol constant_other_symbol_ruby"><span class="punctuation punctuation_definition punctuation_definition_constant punctuation_definition_constant_ruby">:</span>after_update_code</span>, <span class="constant constant_other constant_other_symbol constant_other_symbol_ruby"><span class="punctuation punctuation_definition punctuation_definition_constant punctuation_definition_constant_ruby">:</span>roles</span> =&gt; <span class="constant constant_other constant_other_symbol constant_other_symbol_ruby"><span class="punctuation punctuation_definition punctuation_definition_constant punctuation_definition_constant_ruby">:</span>app</span> <span class="keyword keyword_control keyword_control_ruby keyword_control_ruby_start-block">do
</span>   correct_db_yml
<span class="keyword keyword_control keyword_control_ruby">end</span>

task <span class="constant constant_other constant_other_symbol constant_other_symbol_ruby"><span class="punctuation punctuation_definition punctuation_definition_constant punctuation_definition_constant_ruby">:</span>correct_db_yml</span> <span class="keyword keyword_control keyword_control_ruby keyword_control_ruby_start-block">do
</span>  put(<span class="support support_class support_class_ruby">File</span>.read(<span class="string string_quoted string_quoted_double string_quoted_double_ruby"><span class="punctuation punctuation_definition punctuation_definition_string punctuation_definition_string_begin punctuation_definition_string_begin_ruby">"</span>config/<span class="source source_ruby source_ruby_embedded source_ruby_embedded_source"><span class="punctuation punctuation_section punctuation_section_embedded punctuation_section_embedded_ruby">#{</span>database_yml<span class="punctuation punctuation_section punctuation_section_embedded punctuation_section_embedded_ruby">}</span></span><span class="punctuation punctuation_definition punctuation_definition_string punctuation_definition_string_end punctuation_definition_string_end_ruby">"</span></span>), <span class="string string_quoted string_quoted_double string_quoted_double_ruby"><span class="punctuation punctuation_definition punctuation_definition_string punctuation_definition_string_begin punctuation_definition_string_begin_ruby">"</span><span class="source source_ruby source_ruby_embedded source_ruby_embedded_source"><span class="punctuation punctuation_section punctuation_section_embedded punctuation_section_embedded_ruby">#{</span>release_path<span class="punctuation punctuation_section punctuation_section_embedded punctuation_section_embedded_ruby">}</span></span>/config/database.yml<span class="punctuation punctuation_definition punctuation_definition_string punctuation_definition_string_end punctuation_definition_string_end_ruby">"</span></span>, <span class="constant constant_other constant_other_symbol constant_other_symbol_ruby"><span class="punctuation punctuation_definition punctuation_definition_constant punctuation_definition_constant_ruby">:</span>mode</span> =&gt; <span class="constant constant_numeric constant_numeric_ruby">0444</span>)
<span class="keyword keyword_control keyword_control_ruby">end</span></span></pre>
<p>Thats all there is to it, I run the following commands to set up an instance of my app:</p>
<pre>
cap -a staging setup
cap -a staging setup_scm
cap -a staging setup_servers
../[new directory]
cap -a staging clean_db_yml
cap -a staging cold_deploy
cap -a staging restart_web

cap -a staging deploy
cap -a staging deploy_with_migrations
</pre>
<h2>The End</h2>
<p>There you have it, it works, it&#8217;s not the most elegant solution and definitely something I want to work further on. The last section with database.yml stuff is by far the ugliest, but it is a work in progress, and I plan to make further amendments to it.</p>
]]></content:encoded>
			<wfw:commentRss>http://blog.craig-mackenzie.com/2007/01/04/deploying-multiple-instances-of-an-application-with-capistrano/feed/</wfw:commentRss>
		<slash:comments>3</slash:comments>
		</item>
	</channel>
</rss>
