<?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>Dakin Design</title>
	<atom:link href="http://www.dakindesign.com/blog/?feed=rss2" rel="self" type="application/rss+xml" />
	<link>http://www.dakindesign.com/blog</link>
	<description>Tales of Amaranthine Wanderlust</description>
	<lastBuildDate>Sun, 28 Aug 2011 21:24:16 +0000</lastBuildDate>
	<language>en</language>
	<sy:updatePeriod>hourly</sy:updatePeriod>
	<sy:updateFrequency>1</sy:updateFrequency>
	<generator>http://wordpress.org/?v=3.2.1</generator>
		<item>
		<title>Windows Workstations in Amazon EC2</title>
		<link>http://www.dakindesign.com/blog/?p=156</link>
		<comments>http://www.dakindesign.com/blog/?p=156#comments</comments>
		<pubDate>Fri, 26 Aug 2011 01:51:20 +0000</pubDate>
		<dc:creator>admin</dc:creator>
				<category><![CDATA[Technology]]></category>

		<guid isPermaLink="false">http://www.dakindesign.com/blog/?p=156</guid>
		<description><![CDATA[I don&#8217;t like Windows. Unfortunately, I regularly use a few applications that require Windows. Options (not requiring theft) Buy a dedicated Windows box &#8211; BAD (expensive, extra baggage) Dual-boot Windows on my Mac &#8211; BAD (don&#8217;t want to close OSX) Run a Windows VM inside OSX &#8211; OK (but ties me to my Mac and [...]]]></description>
			<content:encoded><![CDATA[<p>I don&#8217;t like Windows.</p>
<p>Unfortunately, I regularly use a few applications that require Windows.</p>
<p><strong>Options (not requiring theft)</strong></p>
<ul>
<li>Buy a dedicated Windows box &#8211; <strong>BAD</strong> (expensive, extra baggage)</li>
<li>Dual-boot Windows on my Mac &#8211; <strong>BAD</strong> (don&#8217;t want to close OSX)</li>
<li>Run a Windows VM inside OSX &#8211; <strong>OK</strong> (but ties me to my Mac and requires a license)</li>
<li>Rent time on a hosted Windows box &#8211; <strong>GOOD</strong> (cheap, accessible from anywhere)</li>
</ul>
<p><strong>Where to Host</strong></p>
<p>So I looked into hosting options. I was hoping for a pay-per-CPU plan, but it doesn&#8217;t seem like you can get a full shell/root install on those plans (they seem to be services that host applications rather than operating systems, e.g. Google App Engine).</p>
<p>That left me with the obvious choices: Rackspace and Amazon (and some small players that I didn&#8217;t investigate), both of whom offer Windows Server 2003 and 2008, both 32 or 64 bit.</p>
<p><strong>Which OS</strong></p>
<p>I went with Windows Server 2008 32 bit (assuming that 32-bit uses less resources than 64-bit on the underlying Citrix boxes and I&#8217;ll therefore get more bang for my buck &#8211; I have absolutely no idea if this is a fair assumption; would love feedback).</p>
<p><strong>Pricing</strong></p>
<p>Now, the cheapest usable plans for hosting Windows on either Rackspace or Amazon still cost you a lot of money (Rackspace: $58.40/mo. for a 1GB instance, which is the smallest on which you can run Windows; Amazon: $87.60/mo. for the standard &#8220;Small&#8221; on-demand instance).</p>
<p>NOTE: Amazon&#8217;s &#8220;Micro&#8221; on-demand instance runs you $21.90 per month, but I found it to be unusable for a Remote Desktop situation due to not having any guaranteed level of EC2 Compute Units (it bursts up to 2 EC2 Compute Units, but when that extra power isn&#8217;t available on your hardware, it lags desperately).</p>
<p>NOTE: You can also save money with Amazon by purchasing a Reserved Instance, which is basically an up-front fee following which you enjoy reduced hourly rates.</p>
<p>NOTE: With Amazon and Rackspace, you pay per instance hour. That&#8217;s the amount of time that your server <em>exists</em> (whether or not it&#8217;s online or powered off).</p>
<p>Clearly, I don&#8217;t want to spend over $50 per month just to run a couple applications. So&#8230;</p>
<p><strong>The Solution</strong></p>
<p>I decided to take a &#8220;when you need it&#8221; approach and create a server when I want to use it, then delete it when I&#8217;m done.</p>
<p>Kind of a pain, just to run some Windows apps? Yeah, but with the extensive APIs provided by Amazon and Rackspace, it&#8217;s all just a Perl script away.</p>
<p><strong>Getting off the Fence</strong></p>
<p>Rackspace or Amazon?</p>
<p>I settled on Amazon because of their EBS (Elastic Block Storage) offering. It&#8217;s like NAS for the cloud. Rackspace doesn&#8217;t offer block-level storage right now, and while you could hack together a virtual drive that stores your files away in CloudFiles, why bother. Amazon has all the tools.</p>
<p><strong>Specifics</strong></p>
<p>So here&#8217;s the big idea.</p>
<ol>
<li>Create an EBS volume. This is where your data will live. Think of it as an external hard drive that lives in the cloud. Every time you&#8217;re done using your ephemeral Windows instance, you&#8217;re basically throwing your computer out the window, but hanging onto that drive so you can plug it into a new computer next time. You&#8217;ll probably need to set up a security group, key pair, etc. if this is the first time you&#8217;ve used Windows with EC2.</li>
<li>Ensure that you can successfully Remote Desktop to your new instance&#8217;s public IP address. Everything following assumes that you can. If not, stop here and work it out.</li>
<li>Build an EC2 instance from one of Amazon&#8217;s Windows images (an &#8220;AMI&#8221;). NOTE: When you do this, Amazon will automatically create a second EBS volume to host this instance. This second volume is ephemeral and will die when you terminate your server instance. That&#8217;s why we don&#8217;t store anything on it! Store data that you care about on the EBS volume that you just manually created, as it will persist whereas EC2 ephemeral disks will not.</li>
<li>Attach the EBS volume that you created to your Windows instance. The first time you do this, you&#8217;ll need to format it.</li>
<li>Tweak the OS to be how you like it (Windows updates, security settings, etc.)</li>
<li>Install your apps. Ensure that you tell the apps to store their data on your EBS volume (which for me appears as the D: drive). For example, the Quicken <em>application</em> is installed on my Windows instance (technically on the 30GB ephemeral EBS volume &#8220;backing&#8221; my Windows instance: the one that Amazon magically created) whereas my Quicken <em>data</em> resides on my persistent EBS volume.</li>
<li>Detach your EBS volume from your instance (otherwise, Amazon will make a copy of it when you generate an AMI from your instance, but we don&#8217;t want that; we want to use the same EBS volume to persist data across instances).</li>
<li>Generate an AMI from your instance.</li>
</ol>
<p>OK, now you&#8217;re pretty much set up.</p>
<p><strong>Usage</strong></p>
<p>When you want to use Windows:</p>
<ol>
<li>Start an instance of your AMI</li>
<li>Attach your EBS volume to the AMI.</li>
</ol>
<p>When you&#8217;re done using Windows:</p>
<ol>
<li>Shut down and terminate your instance (the EBS volume will auto-detach)</li>
</ol>
<p><strong>Enhancements</strong></p>
<p>Wait, didn&#8217;t I say something about a Perl script?</p>
<p>Yep: <a href="http://pastebin.com/gwu6834M" title="http://pastebin.com/gwu6834M" target="_blank">http://pastebin.com/gwu6834M</a></p>
<p>Replace the &#8220;xxx&#8221; in the variables near the top, then run it. This assumes you:</p>
<ul>
<li>Have the EC2 API tools (get them from Amazon&#8217;s site)</li>
<li>Have configured your system such that the EC2 API tools work (e.g. I had to add &#8220;export JAVA_HOME=/System/Library/Frameworks/JavaVM.framework/Versions/CurrentJDK/Home&#8221; to my .bash_profile)</li>
<li>Have generated, downloaded, and exported EC2_PRIVATE_KEY and EC2_CERT variables pointing to your Amazon X.509 certificate and private key.</li>
</ul>
<p>You&#8217;ll notice some domain name and IP address stuff in the Perl script. Just comment it out if you don&#8217;t have a domain name that you want to point to your windows instance. However, it&#8217;s useful! To use this:</p>
<ol>
<li>Allocate an Amazon Elastic IP Address</li>
<li>Point a domain name to this IP address</li>
</ol>
<p>Now when you run the Perl file:</p>
<ul>
<li>An instance will be started from your AMI</li>
<li>Your EBS volume will be attached to the instance (and a snapshot will be taken)</li>
<li>Your elastic IP address will be associated with the instance</li>
</ul>
<p>Remote Desktop to your Windows address and you&#8217;re all set! Shut down the computer when you&#8217;re done, and all clean-up will happen automatically (instance termination, EBS volume detachment, elastic IP disassociation).</p>
<p>NOTE: the Perl script specifies that your instance should terminate (rather than stop) when you shut down Windows internally. That allows us to tear it all down by just using the Windows regular shutdown method, instead of using the Amazon web interface or API.</p>
<div style='display:none' id="post-refEl-156"></div>]]></content:encoded>
			<wfw:commentRss>http://www.dakindesign.com/blog/?feed=rss2&#038;p=156</wfw:commentRss>
		<slash:comments>0</slash:comments>
		</item>
		<item>
		<title>Maximum Recursion Depth in FireFox 4 (Mac)</title>
		<link>http://www.dakindesign.com/blog/?p=151</link>
		<comments>http://www.dakindesign.com/blog/?p=151#comments</comments>
		<pubDate>Mon, 04 Apr 2011 22:41:47 +0000</pubDate>
		<dc:creator>admin</dc:creator>
				<category><![CDATA[Technology]]></category>

		<guid isPermaLink="false">http://www.dakindesign.com/blog/?p=151</guid>
		<description><![CDATA[Seems to be 6299 (6300 fails).]]></description>
			<content:encoded><![CDATA[<p>Seems to be 6299 (6300 fails).</p>
<div style='display:none' id="post-refEl-151"></div>]]></content:encoded>
			<wfw:commentRss>http://www.dakindesign.com/blog/?feed=rss2&#038;p=151</wfw:commentRss>
		<slash:comments>0</slash:comments>
		</item>
		<item>
		<title>Promote JS</title>
		<link>http://www.dakindesign.com/blog/?p=149</link>
		<comments>http://www.dakindesign.com/blog/?p=149#comments</comments>
		<pubDate>Mon, 18 Oct 2010 19:45:10 +0000</pubDate>
		<dc:creator>admin</dc:creator>
				<category><![CDATA[Technology]]></category>
		<category><![CDATA[Documentation]]></category>
		<category><![CDATA[JavaScript]]></category>
		<category><![CDATA[Promote JS]]></category>

		<guid isPermaLink="false">http://www.dakindesign.com/blog/?p=149</guid>
		<description><![CDATA[Promote JS]]></description>
			<content:encoded><![CDATA[<p><a title="JavaScript Array .toString" href="https://developer.mozilla.org/en/JavaScript/Reference/Global_Objects/Array"><img src="http://static.jsconf.us/promotejsv.gif" alt="JavaScript Array .toString" width="160" height="280" /></a></p>
<p><a href="http://promotejs.com/">Promote JS</a></p>
<div style='display:none' id="post-refEl-149"></div>]]></content:encoded>
			<wfw:commentRss>http://www.dakindesign.com/blog/?feed=rss2&#038;p=149</wfw:commentRss>
		<slash:comments>0</slash:comments>
		</item>
		<item>
		<title>JavaScript switch statement uses type checking</title>
		<link>http://www.dakindesign.com/blog/?p=141</link>
		<comments>http://www.dakindesign.com/blog/?p=141#comments</comments>
		<pubDate>Mon, 02 Aug 2010 05:38:43 +0000</pubDate>
		<dc:creator>admin</dc:creator>
				<category><![CDATA[Technology]]></category>
		<category><![CDATA[JavaScript]]></category>

		<guid isPermaLink="false">http://www.dakindesign.com/blog/?p=141</guid>
		<description><![CDATA[It looks like the switch statement uses type checking (i.e. ===, not ==).]]></description>
			<content:encoded><![CDATA[<p>I was just bitten by this:</p>
<pre>
    var foo = "2";
    var bar = 2;

    switch (parseInt(foo)) {
        case bar:
            alert("match");
            break;
        default:
            alert("no match");
    }
</pre>
<p>That code should alert &#8220;match&#8221; &#8211; but take out the parseInt, and you get &#8220;no match.&#8221;</p>
<p>It looks like the switch statement uses type checking (i.e. ===, not ==) in FireFox 3.6.8 for Mac (haven&#8217;t tried other browsers).</p>
<div style='display:none' id="post-refEl-141"></div>]]></content:encoded>
			<wfw:commentRss>http://www.dakindesign.com/blog/?feed=rss2&#038;p=141</wfw:commentRss>
		<slash:comments>0</slash:comments>
		</item>
		<item>
		<title>Fun with Google Voice</title>
		<link>http://www.dakindesign.com/blog/?p=138</link>
		<comments>http://www.dakindesign.com/blog/?p=138#comments</comments>
		<pubDate>Thu, 22 Apr 2010 01:54:22 +0000</pubDate>
		<dc:creator>admin</dc:creator>
				<category><![CDATA[Technology]]></category>

		<guid isPermaLink="false">http://www.dakindesign.com/blog/?p=138</guid>
		<description><![CDATA[Love it.]]></description>
			<content:encoded><![CDATA[<p><object type="application/x-shockwave-flash" data="https://clients4.google.com/voice/embed/webCallButton" width="230" height="85"><param name="wmode" value="transparent"><param name="FlashVars" value="id=073ffe621c229cce902576377c4850cc4fc283da&#038;style=0" /></object><br />
<br />
Love it.</p>
<div style='display:none' id="post-refEl-138"></div>]]></content:encoded>
			<wfw:commentRss>http://www.dakindesign.com/blog/?feed=rss2&#038;p=138</wfw:commentRss>
		<slash:comments>0</slash:comments>
		</item>
		<item>
		<title>Best Homepage of the Day</title>
		<link>http://www.dakindesign.com/blog/?p=136</link>
		<comments>http://www.dakindesign.com/blog/?p=136#comments</comments>
		<pubDate>Tue, 20 Apr 2010 06:52:25 +0000</pubDate>
		<dc:creator>admin</dc:creator>
				<category><![CDATA[Technology]]></category>

		<guid isPermaLink="false">http://www.dakindesign.com/blog/?p=136</guid>
		<description><![CDATA[http://miketaylr.com]]></description>
			<content:encoded><![CDATA[<p><a href="http://miketaylr.com">http://miketaylr.com</a></p>
<div style='display:none' id="post-refEl-136"></div>]]></content:encoded>
			<wfw:commentRss>http://www.dakindesign.com/blog/?feed=rss2&#038;p=136</wfw:commentRss>
		<slash:comments>0</slash:comments>
		</item>
		<item>
		<title>jQuery Event Delegation and Nested Tables</title>
		<link>http://www.dakindesign.com/blog/?p=122</link>
		<comments>http://www.dakindesign.com/blog/?p=122#comments</comments>
		<pubDate>Sat, 06 Feb 2010 23:31:56 +0000</pubDate>
		<dc:creator>admin</dc:creator>
				<category><![CDATA[Technology]]></category>
		<category><![CDATA[event delegation]]></category>
		<category><![CDATA[JavaScript]]></category>
		<category><![CDATA[jQuery]]></category>

		<guid isPermaLink="false">http://www.dakindesign.com/blog/?p=122</guid>
		<description><![CDATA[A solution for dealing with nested DOM elements of the same type when implementing event delegation with jQuery.]]></description>
			<content:encoded><![CDATA[<p>I was reading a <a href="http://www.learningjquery.com/2008/03/working-with-events-part-1">blog post about jQuery event delegation</a> by Karl Swedberg yesterday. One corner case I found in his examples is dealing with nested DOM elements of the same type (e.g. divs within divs, or in the following example tables within tables).</p>
<p>Here&#8217;s a solution (albeit possibly not the best) that makes use of jQuery&#8217;s <a href="http://api.jquery.com/parentsUntil/">parentsUntil()</a> method, added in version 1.4:</p>
<p style="font-family: monospace; ">&lt;!DOCTYPE html PUBLIC &#8220;-//W3C//DTD XHTML 1.0 Strict//EN&#8221;<br />
&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&#8221;http://www.w3.org/TR/xhtml1/DTD/xhtml1-strict.dtd&#8221;&gt;<br />
&lt;html xmlns=&#8221;http://www.w3.org/1999/xhtml&#8221; xml:lang=&#8221;en-us&#8221; lang=&#8221;en-us&#8221;<br />
&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;xmlns:v=&#8221;urn:schemas-microsoft-com:vml&#8221;&gt;<br />
&nbsp;&nbsp;&lt;head profile=&#8221;http://www.w3.org/2005/10/profile&#8221;&gt;<br />
&nbsp;&nbsp;&nbsp;&nbsp;&lt;script type=&#8221;text/javascript&#8221;&gt;<br />
&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;$(function() {<br />
&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;$(&#8220;#outer&#8221;).click(function(event) {<br />
&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;var parentCells = $(event.target).parentsUntil(this).filter(&#8220;td&#8221;);<br />
&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;var outermostCell = $.merge($(event.target), parentCells).last();<br />
&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;$(&#8220;#output&#8221;).text(outermostCell.text());<br />
&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;});<br />
&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;});<br />
&nbsp;&nbsp;&nbsp;&nbsp;&lt;/script&gt;<br />
&nbsp;&nbsp;&lt;/head&gt;<br />
&nbsp;&nbsp;&lt;body&gt;<br />
&nbsp;&nbsp;&nbsp;&nbsp;&lt;div id=&#8221;output&#8221;&gt;[Nothing clicked]&lt;/div&gt;<br />
&nbsp;&nbsp;&nbsp;&nbsp;&lt;br /&gt;<br />
&nbsp;&nbsp;&nbsp;&nbsp;&lt;table id=&#8221;outer&#8221; border=&#8221;1&#8243; cellpadding=&#8221;15&#8243;&gt;<br />
&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&lt;tr&gt;<br />
&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&lt;td&gt;a&lt;/td&gt;<br />
&nbsp;&nbsp;&nbsp;&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&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&lt;/td&gt;<br />
&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&lt;td&gt;e&lt;/td&gt;<br />
&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&lt;/tr&gt;<br />
&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&lt;tr&gt;<br />
&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&lt;td&gt;f&lt;/td&gt;<br />
&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&lt;td&gt;g&lt;/td&gt;<br />
&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&lt;td&gt;h&lt;/td&gt;<br />
&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&lt;/tr&gt;<br />
&nbsp;&nbsp;&nbsp;&nbsp;&lt;/table&gt;<br />
&nbsp;&nbsp;&lt;/body&gt;<br />
&lt;/html&gt;</p>
<div style='display:none' id="post-refEl-122"></div>]]></content:encoded>
			<wfw:commentRss>http://www.dakindesign.com/blog/?feed=rss2&#038;p=122</wfw:commentRss>
		<slash:comments>0</slash:comments>
		</item>
		<item>
		<title>Deleting Multiple Items from a JavaScript Array</title>
		<link>http://www.dakindesign.com/blog/?p=119</link>
		<comments>http://www.dakindesign.com/blog/?p=119#comments</comments>
		<pubDate>Wed, 18 Nov 2009 20:02:13 +0000</pubDate>
		<dc:creator>admin</dc:creator>
				<category><![CDATA[Technology]]></category>
		<category><![CDATA[JavaScript]]></category>
		<category><![CDATA[programming]]></category>

		<guid isPermaLink="false">http://www.dakindesign.com/blog/?p=119</guid>
		<description><![CDATA[Here&#8217;s a handy way to delete multiple items (that may not be contiguous) from a JavaScript array. This hinges around using splice() in a for() loop. The trouble is that every time you slice, the index of each of the following items in the array gets decremented but you&#8217;re still increasing your index variable with [...]]]></description>
			<content:encoded><![CDATA[<p>Here&#8217;s a handy way to delete multiple items (that may not be contiguous) from a JavaScript array.</p>
<p>This hinges around using splice() in a for() loop. The trouble is that every time you slice, the index of each of the following items in the array gets decremented but you&#8217;re still increasing your index variable with each iteration.</p>
<p>For example:</p>
<p><code><br />
var arr = [<br />
    { name: 'a', active: true },<br />
    { name: 'b', active: false },<br />
    { name: 'c', active: true },<br />
    { name: 'd', active: false },<br />
    { name: 'e', active: true }<br />
];</p>
<p>// let's kill the inactive objects<br />
var kill = [];<br />
for (var i = 0; i < arr.length; i++) {<br />
    if (!arr[i].active)<br />
        kill.push(i);<br />
}</p>
<p>// now 'kill' contains [1, 3]<br />
</code></p>
<p>We're fine so far: now we have the indexes that we want to remove. Here's where the trouble starts:</p>
<p><code><br />
// remove inactive elements from array - BAD<br />
for (var i = 0; i < kill.length; i++)<br />
    arr.splice(kill[i], 1);<br />
</code></p>
<p>As mentioned above, this is bad because each time you remove an element from the array, the following elements will all have their indexes decremented. That means that the next "kill" index you come across will reference the wrong element!</p>
<p>Here's a simple way to mitigate:</p>
<p><code><br />
// remove inactive elements from array - GOOD<br />
for (var i = 0; i < kill.length; i++)<br />
    arr.splice(kill[i] - i, 1);<br />
</code></p>
<p>Note the change in the splice index from "kill[i]" to "kill[i] - i", which accounts for the decremented array indexes.</p>
<p>By the way, you may be asking, "Why not use 'delete'?" Well, delete leaves holes in your array, which we don't want.</p>
<p>You may also be asking, "Why not use foreach() instead of for(), thereby, bypassing the need for an index variable?" Well, it's unsafe to use foreach() on an array. You should only ever use foreach() on an object, for reasons that I won't get into here.</p>
<p>Hope this helps someone.</p>
<div style='display:none' id="post-refEl-119"></div>]]></content:encoded>
			<wfw:commentRss>http://www.dakindesign.com/blog/?feed=rss2&#038;p=119</wfw:commentRss>
		<slash:comments>0</slash:comments>
		</item>
		<item>
		<title></title>
		<link>http://www.dakindesign.com/blog/?p=112</link>
		<comments>http://www.dakindesign.com/blog/?p=112#comments</comments>
		<pubDate>Fri, 14 Aug 2009 19:46:59 +0000</pubDate>
		<dc:creator>admin</dc:creator>
				<category><![CDATA[Music]]></category>

		<guid isPermaLink="false">http://www.dakindesign.com/blog/?p=112</guid>
		<description><![CDATA[Question: Who can get Eric Clapton to join him for a sold-out modern day blues show at the prestigious Royal Albert Hall in London? Answer: &#160;]]></description>
			<content:encoded><![CDATA[<p><b>Question:</b></p>
<blockquote><p>Who can get Eric Clapton to join him for a sold-out modern day blues show at the prestigious Royal Albert Hall in London?</p></blockquote>
<p><b>Answer:</b></p>
<p><a href="http://www.jbonamassa.com/affiliates/idevaffiliate.php?id=1276_0_1_50" target="_blank"><img border="0" src="http://www.jbonamassa.com/affiliates/banners/250X250WPRELOGO.jpg" width="250" height="250"></a></p>
<p>&nbsp;</p>
<div style='display:none' id="post-refEl-112"></div>]]></content:encoded>
			<wfw:commentRss>http://www.dakindesign.com/blog/?feed=rss2&#038;p=112</wfw:commentRss>
		<slash:comments>0</slash:comments>
		</item>
		<item>
		<title>How To Project On 3D Geometry</title>
		<link>http://www.dakindesign.com/blog/?p=105</link>
		<comments>http://www.dakindesign.com/blog/?p=105#comments</comments>
		<pubDate>Mon, 08 Jun 2009 16:40:28 +0000</pubDate>
		<dc:creator>admin</dc:creator>
				<category><![CDATA[Technology]]></category>

		<guid isPermaLink="false">http://www.dakindesign.com/blog/?p=105</guid>
		<description><![CDATA[Awesome: http://vvvv.org/tiki-index.php?page=How+To+Project+On+3D+Geometry]]></description>
			<content:encoded><![CDATA[<p><a href="http://vvvv.org/tiki-index.php?page=How+To+Project+On+3D+Geometry"><img class="alignnone size-full wp-image-108" title="3D Image on Geometric Surface" src="http://www.dakindesign.com/blog/wp-content/uploads/2009/06/projected-desktop.jpg" alt="3D Image on Geometric Surface" /></a></p>
<p>Awesome: <a href="http://vvvv.org/tiki-index.php?page=How+To+Project+On+3D+Geometry">http://vvvv.org/tiki-index.php?page=How+To+Project+On+3D+Geometry</a></p>
<div style='display:none' id="post-refEl-105"></div>]]></content:encoded>
			<wfw:commentRss>http://www.dakindesign.com/blog/?feed=rss2&#038;p=105</wfw:commentRss>
		<slash:comments>0</slash:comments>
		</item>
	</channel>
</rss>

