<?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/"
	xmlns:georss="http://www.georss.org/georss" >

<channel>
	<title>Even the wrong words seem to rhyme &#187; programming</title>
	<atom:link href="http://www.kevinblake.co.uk/tag/programming/feed/" rel="self" type="application/rss+xml" />
	<link>http://www.kevinblake.co.uk</link>
	<description>a blog-life by Kevin Blake</description>
	<lastBuildDate>Thu, 13 May 2010 22:27:44 +0000</lastBuildDate>
	<language>en</language>
	<sy:updatePeriod>hourly</sy:updatePeriod>
	<sy:updateFrequency>1</sy:updateFrequency>
	<generator>http://wordpress.org/?v=3.0</generator>
		<item>
		<title>Google Wave &#8211; My First Bot</title>
		<link>http://www.kevinblake.co.uk/google-wave-my-first-bot/706/</link>
		<comments>http://www.kevinblake.co.uk/google-wave-my-first-bot/706/#comments</comments>
		<pubDate>Sun, 01 Nov 2009 21:31:37 +0000</pubDate>
		<dc:creator>Kevin</dc:creator>
				<category><![CDATA[Uncategorized]]></category>
		<category><![CDATA[Add new tag]]></category>
		<category><![CDATA[api]]></category>
		<category><![CDATA[googe wave]]></category>
		<category><![CDATA[programming]]></category>
		<category><![CDATA[technology]]></category>
		<category><![CDATA[wave]]></category>
		<category><![CDATA[wave robot]]></category>

		<guid isPermaLink="false">http://www.kevinblake.co.uk/?p=706</guid>
		<description><![CDATA[Last week, I went to the Google Technology User Group in London, which was all on the subject of Google Wave.  Lars and Steph, of Google Wave video, and Google Maps fame gave an excellent talk on Wave, how it was doing, where it was going, and the challenges they&#8217;re still facing in getting Wave [...]]]></description>
			<content:encoded><![CDATA[<p>Last week, I went to the Google Technology User Group in London, which was all on the subject of Google Wave.  Lars and Steph, of Google Wave video, and Google Maps fame gave an excellent talk on Wave, how it was doing, where it was going, and the challenges they&#8217;re still facing in getting Wave ready for prime time and a public release.</p>
<p>I&#8217;ve had a developer account for some time now, and the talk finally got me motivated into messing around with more of the APIs.  So I created a bot.  Then I created another one.  Because the first one didn&#8217;t do anything.</p>
<p><strong>1.  Get Eclipse</strong></p>
<p>So far, the choices for creating Google bots are rather limited because there are rules that they must be hosted on AppEngine (for now).   So first off, get Eclipse &#8211; because it makes the entire process of doing that incredibly easy.  You can <a href="http://www.eclipse.org/downloads/" target="_blank">download Eclipse here</a>.</p>
<p><strong>2.  Get the AppEngine SDK.</strong></p>
<p>Once you&#8217;ve got Eclipse installed and running, go to Help -&gt; Install New Software.  Enter this URL to get at the Google AppEngine SDK.</p>
<pre>http://dl.google.com/eclipse/plugin/3.5</pre>
<p><strong>3.  Create your project.</strong></p>
<p>Go to File-&gt;New, and select Web Application Project.  If you don&#8217;t have that option, something&#8217;s gone wrong with your SDK download, so check step 2.</p>
<p>Uncheck the Googe Web Toolkit, we don&#8217;t need that.  But otherwise fill out the Project Name and Package as you see fit.</p>
<p><strong>4.  Add the libraries from the <a href="http://code.google.com/p/wave-robot-java-client/" target="_blank">Wave extensions SDK</a></strong></p>
<p>Download wave-robots-api.jar, json.jar, and jsonrpc.jar and drop those into your project under war/WEB-INF/lib/.</p>
<p>Once you&#8217;ve done that, select File-&gt;Refresh, then Project-&gt;Properties from the main menu, and select Java Build Path.  Click Libraries, and Add JARs, to select the three that you&#8217;ve just added.</p>
<p><strong>5.  Write your servlet class.</strong></p>
<p>This is where the bulk of your bot logic (or lack of it), goes.</p>
<div id="wpshdo_1" class="wp-synhighlighter-outer"><div id="wpshdt_1" class="wp-synhighlighter-expanded"><table border="0" width="100%"><tr><td align="left" width="80%"><a name="#codesyntax_1"></a><a id="wpshat_1" class="wp-synhighlighter-title" href="#codesyntax_1"  onClick="javascript:wpsh_toggleBlock(1)" title="Click to show/hide code block">Code block</a></td><td align="right"><a href="#codesyntax_1" onClick="javascript:wpsh_code(1)" title="Show code only"><img border="0" style="border: 0 none" src="http://www.kevinblake.co.uk/wp-content/plugins/wp-synhighlight/themes/default/images/code.png" /></a>&nbsp;<a href="#codesyntax_1" onClick="javascript:wpsh_print(1)" title="Print code"><img border="0" style="border: 0 none" src="http://www.kevinblake.co.uk/wp-content/plugins/wp-synhighlight/themes/default/images/printer.png" /></a>&nbsp;<a href="http://www.kevinblake.co.uk/wp-content/plugins/wp-synhighlight/About.html" target="_blank" title="Show plugin information"><img border="0" style="border: 0 none" src="http://www.kevinblake.co.uk/wp-content/plugins/wp-synhighlight/themes/default/images/info.gif" /></a>&nbsp;</td></tr></table></div><div id="wpshdi_1" class="wp-synhighlighter-inner" style="display: block;"><pre class="java" style="font-family:monospace;"><span class="kw1">package</span> <span class="co2">helloworld</span><span class="sy0">;</span>
<span class="kw1">import</span> <span class="co2">com.google.wave.api.*</span><span class="sy0">;</span>
<span class="kw1">public</span> <span class="kw1">class</span> HelloWorldServlet <span class="kw1">extends</span> AbstractRobotServlet <span class="br0">&#123;</span>
	<span class="kw1">public</span> <span class="kw4">void</span> processEvents<span class="br0">&#40;</span>RobotMessageBundle bundle<span class="br0">&#41;</span> <span class="br0">&#123;</span>
		<span class="kw1">for</span> <span class="br0">&#40;</span><a href="http://www.google.com/search?hl=en&amp;q=allinurl%3Aevent+java.sun.com&amp;btnI=I%27m%20Feeling%20Lucky"><span class="kw3">Event</span></a> e<span class="sy0">:</span> bundle.<span class="me1">getEvents</span><span class="br0">&#40;</span><span class="br0">&#41;</span><span class="br0">&#41;</span> <span class="br0">&#123;</span>
			<span class="kw1">if</span> <span class="br0">&#40;</span>e.<span class="me1">getType</span><span class="br0">&#40;</span><span class="br0">&#41;</span> <span class="sy0">==</span> EventType.<span class="me1">BLIP_SUBMITTED</span><span class="br0">&#41;</span> <span class="br0">&#123;</span>
			Blip blip <span class="sy0">=</span> e.<span class="me1">getBlip</span><span class="br0">&#40;</span><span class="br0">&#41;</span>.<span class="me1">createChild</span><span class="br0">&#40;</span><span class="br0">&#41;</span><span class="sy0">;</span>
			TextView textView <span class="sy0">=</span> blip.<span class="me1">getDocument</span><span class="br0">&#40;</span><span class="br0">&#41;</span><span class="sy0">;</span>
			textView.<span class="me1">append</span><span class="br0">&#40;</span><span class="st0">&quot;Hello.  Are you the world?&quot;</span><span class="br0">&#41;</span><span class="sy0">;</span>
			<span class="kw1">break</span><span class="sy0">;</span>
			<span class="br0">&#125;</span>
		<span class="br0">&#125;</span>
	<span class="br0">&#125;</span>
<span class="br0">&#125;</span></pre></div></div>
<p><strong>6.  Add a servlet mapping.</strong></p>
<p>Edit the file, war/WEB-INF/web.xml and add a servet-mapping just below the one you have already.</p>
<div id="wpshdo_2" class="wp-synhighlighter-outer"><div id="wpshdt_2" class="wp-synhighlighter-expanded"><table border="0" width="100%"><tr><td align="left" width="80%"><a name="#codesyntax_2"></a><a id="wpshat_2" class="wp-synhighlighter-title" href="#codesyntax_2"  onClick="javascript:wpsh_toggleBlock(2)" title="Click to show/hide code block">Code block</a></td><td align="right"><a href="#codesyntax_2" onClick="javascript:wpsh_code(2)" title="Show code only"><img border="0" style="border: 0 none" src="http://www.kevinblake.co.uk/wp-content/plugins/wp-synhighlight/themes/default/images/code.png" /></a>&nbsp;<a href="#codesyntax_2" onClick="javascript:wpsh_print(2)" title="Print code"><img border="0" style="border: 0 none" src="http://www.kevinblake.co.uk/wp-content/plugins/wp-synhighlight/themes/default/images/printer.png" /></a>&nbsp;<a href="http://www.kevinblake.co.uk/wp-content/plugins/wp-synhighlight/About.html" target="_blank" title="Show plugin information"><img border="0" style="border: 0 none" src="http://www.kevinblake.co.uk/wp-content/plugins/wp-synhighlight/themes/default/images/info.gif" /></a>&nbsp;</td></tr></table></div><div id="wpshdi_2" class="wp-synhighlighter-inner" style="display: block;"><pre class="xml" style="font-family:monospace;"><span class="sc3"><span class="re1">&lt;servlet-mapping<span class="re2">&gt;</span></span></span>
<span class="sc3"><span class="re1">&lt;servlet-name<span class="re2">&gt;</span></span></span>HelloWorld<span class="sc3"><span class="re1">&lt;servlet-name<span class="re2">&gt;</span></span></span>
<span class="sc3"><span class="re1">&lt;url-pattern<span class="re2">&gt;</span></span></span>/_wave/robot/jsonrpc<span class="sc3"><span class="re1">&lt;/url-pattern<span class="re2">&gt;</span></span></span>
<span class="sc3"><span class="re1">&lt;/servlet-mapping<span class="re2">&gt;</span></span></span></pre></div></div>
<p><strong>7.  Add a capabilities file.</strong></p>
<p>Add a folder under war/_wave.  Create a file under that called capabilities.xml.  This tells Wave which events your robot is going to respond to.  In our case, we&#8217;re going to respond whenever a blip is saved (blip_submitted)./  There is a <a href="http://wave-robot-java-client.googlecode.com/svn/trunk/doc/com/google/wave/api/EventType.html" target="_blank">full list of capabilities</a> in the full api docs.</p>
<div id="wpshdo_3" class="wp-synhighlighter-outer"><div id="wpshdt_3" class="wp-synhighlighter-expanded"><table border="0" width="100%"><tr><td align="left" width="80%"><a name="#codesyntax_3"></a><a id="wpshat_3" class="wp-synhighlighter-title" href="#codesyntax_3"  onClick="javascript:wpsh_toggleBlock(3)" title="Click to show/hide code block">Code block</a></td><td align="right"><a href="#codesyntax_3" onClick="javascript:wpsh_code(3)" title="Show code only"><img border="0" style="border: 0 none" src="http://www.kevinblake.co.uk/wp-content/plugins/wp-synhighlight/themes/default/images/code.png" /></a>&nbsp;<a href="#codesyntax_3" onClick="javascript:wpsh_print(3)" title="Print code"><img border="0" style="border: 0 none" src="http://www.kevinblake.co.uk/wp-content/plugins/wp-synhighlight/themes/default/images/printer.png" /></a>&nbsp;<a href="http://www.kevinblake.co.uk/wp-content/plugins/wp-synhighlight/About.html" target="_blank" title="Show plugin information"><img border="0" style="border: 0 none" src="http://www.kevinblake.co.uk/wp-content/plugins/wp-synhighlight/themes/default/images/info.gif" /></a>&nbsp;</td></tr></table></div><div id="wpshdi_3" class="wp-synhighlighter-inner" style="display: block;"><pre class="xml" style="font-family:monospace;"><span class="sc3"><span class="re1">&lt;?xml</span> <span class="re0">version</span>=<span class="st0">&quot;1.0&quot;</span> <span class="re0">encoding</span>=<span class="st0">&quot;utf-8&quot;</span><span class="re2">?&gt;</span></span>
<span class="sc3"><span class="re1">&lt;w:robot</span> <span class="re0">xmlns:w</span>=<span class="st0">&quot;http://wave.google.com/extensions/robots/1.0&quot;</span><span class="re2">&gt;</span></span>
<span class="sc3"><span class="re1">&lt;w:capabilities<span class="re2">&gt;</span></span></span>
<span class="sc3"><span class="re1">&lt;w:capability</span> <span class="re0">name</span>=<span class="st0">&quot;BLIP_SUBMITTED&quot;</span> <span class="re0">content</span>=<span class="st0">&quot;true&quot;</span> <span class="re2">/&gt;</span></span>
<span class="sc3"><span class="re1">&lt;/w:capabilities<span class="re2">&gt;</span></span></span>
<span class="sc3"><span class="re1">&lt;w:version<span class="re2">&gt;</span></span></span>3<span class="sc3"><span class="re1">&lt;/w:version<span class="re2">&gt;</span></span></span>
<span class="sc3"><span class="re1">&lt;/w:robot<span class="re2">&gt;</span></span></span></pre></div></div>
<p><strong>8.  Get an AppEngine account.</strong></p>
<p>That kind of finishes off the Wave-bot.  So you&#8217;ll need an <a href="http://appengine.google.com/" target="_blank">AppEngine account</a> to continue.  So go ahead and sign up, and create an application.  Incidently, I couldn&#8217;t find my created apps since I have a Google Apps / Domain account.  if that&#8217;s the case for you as well, you can find your apps list at http://appengine.google.com/a/&lt;domain&gt;.  Not sure why Google don&#8217;t detect that, but there we go.</p>
<p><strong>9.  Deploy to AppEngine</strong></p>
<p>Click the friendly little icon <a href="http://www.kevinblake.co.uk/wp-content/uploads/2009/11/ae_deploy_button.png" rel="lightbox"><img class="size-full wp-image-709 alignnone" title="ae_deploy_button" src="http://www.kevinblake.co.uk/wp-content/uploads/2009/11/ae_deploy_button.png" alt="ae_deploy_button" width="22" height="22" /></a> from your Eclipse toolbar, and enter your details to deploy you new robot.  Try not to scream &#8220;fly my pretties&#8221; as you do so.  I dare you.  Make sure you click the App Engine Project Settings button, and provide you Application ID, the same as you created in step 8.</p>
<p><strong>10.  Add your app to a wave</strong></p>
<p>The address of your robot will be <em>applicationid</em>@appspot.com, and you can add it just like any other robot.</p>
<p>You should now be able to interact with your bot.</p>
<p><a href="http://www.kevinblake.co.uk/wp-content/uploads/2009/11/bot1.JPG" rel="lightbox"><img class="size-full wp-image-711 alignnone" title="bot" src="http://www.kevinblake.co.uk/wp-content/uploads/2009/11/bot1.JPG" alt="bot" width="459" height="307" /></a></p>
<p>And if you&#8217;d like to see my first bot in action &#8211; please drop in and say hello by adding it to your wave: <em><strong>insulteveryone@appspot.com</strong></em>.</p>
<p>Now. World peace.  Where did I leave that file?</p>
]]></content:encoded>
			<wfw:commentRss>http://www.kevinblake.co.uk/google-wave-my-first-bot/706/feed/</wfw:commentRss>
		<slash:comments>1</slash:comments>
		</item>
		<item>
		<title>Rescuscitating AMM with Amazon Web Service signed requests</title>
		<link>http://www.kevinblake.co.uk/rescuscitating-amm-with-amazon-web-service-signed-requests/656/</link>
		<comments>http://www.kevinblake.co.uk/rescuscitating-amm-with-amazon-web-service-signed-requests/656/#comments</comments>
		<pubDate>Wed, 26 Aug 2009 12:19:39 +0000</pubDate>
		<dc:creator>Kevin</dc:creator>
				<category><![CDATA[Uncategorized]]></category>
		<category><![CDATA[amazon]]></category>
		<category><![CDATA[amm]]></category>
		<category><![CDATA[aws]]></category>
		<category><![CDATA[php]]></category>
		<category><![CDATA[programming]]></category>
		<category><![CDATA[technology]]></category>
		<category><![CDATA[wordpress]]></category>

		<guid isPermaLink="false">http://www.kevinblake.co.uk/rescuscitating-amm-with-amazon-web-service-signed-requests/656/</guid>
		<description><![CDATA[A few days ago Amazon added a requirement to their AWS that all requests to the service be signed, lest they be rejected. I&#8217;ve been using Sozu&#8217;s excellent Amazon Media Manager plugin for a while now to manage the currently reading list on this blog. It&#8217;s been a great way to keep track of exactly [...]]]></description>
			<content:encoded><![CDATA[<p>A few days ago Amazon added a requirement to their AWS that all <a href="http://docs.amazonwebservices.com/AWSECommerceService/latest/DG/index.html?rest-signature.html" target="_blank">requests to the service be signed</a>, lest they be rejected.  I&#8217;ve been using Sozu&#8217;s excellent <a href="http://www.sozu.co.uk/software/amm/" target="_blank">Amazon Media Manager plugin</a> for a while now to manage the currently reading list on this blog.  It&#8217;s been a great way to keep track of exactly what I have read (avoiding the need to, like, remember), as well as masking my illiteracy by pasting a giant list of what is commonly known as airport trash.</p>
<p>Unfortunately, this is one plugin that hasn&#8217;t been updated in quite a while (after all, if ain&#8217;t broke&#8230;), so it broke.  Being the sort of developer that&#8217;s quite happy to pick up a block of php and hack it until it works, I stumbled across this blog entitled &#8216;<a href="http://mierendo.com/software/aws_signed_query/" target="_blank">Amazon® AWS HMAC signed request using PHP</a>&#8216;, which has a function to download.</p>
<p>So to fix AMM:</p>
<p>1. <a href="http://mierendo.com/software/aws_signed_query/aws_signed_request.zip">Download that file</a>, and copy the contents into the bottom of amm_parser.php.</p>
<p>2.  In the same file (amm_parser.php), replace your _setUrl function with this one:</p>
<div id="wpshdo_4" class="wp-synhighlighter-outer"><div id="wpshdt_4" class="wp-synhighlighter-expanded"><table border="0" width="100%"><tr><td align="left" width="80%"><a name="#codesyntax_4"></a><a id="wpshat_4" class="wp-synhighlighter-title" href="#codesyntax_4"  onClick="javascript:wpsh_toggleBlock(4)" title="Click to show/hide code block">Code block</a></td><td align="right"><a href="#codesyntax_4" onClick="javascript:wpsh_code(4)" title="Show code only"><img border="0" style="border: 0 none" src="http://www.kevinblake.co.uk/wp-content/plugins/wp-synhighlight/themes/default/images/code.png" /></a>&nbsp;<a href="#codesyntax_4" onClick="javascript:wpsh_print(4)" title="Print code"><img border="0" style="border: 0 none" src="http://www.kevinblake.co.uk/wp-content/plugins/wp-synhighlight/themes/default/images/printer.png" /></a>&nbsp;<a href="http://www.kevinblake.co.uk/wp-content/plugins/wp-synhighlight/About.html" target="_blank" title="Show plugin information"><img border="0" style="border: 0 none" src="http://www.kevinblake.co.uk/wp-content/plugins/wp-synhighlight/themes/default/images/info.gif" /></a>&nbsp;</td></tr></table></div><div id="wpshdi_4" class="wp-synhighlighter-inner" style="display: block;"><pre class="php" style="font-family:monospace;"><span class="kw2">function</span> <span class="sy0">&amp;</span>_setUrl<span class="br0">&#40;</span><span class="br0">&#41;</span> <span class="br0">&#123;</span>
	<span class="co1">//Build URL from base URL and other required parameters</span>
	<span class="kw1">switch</span> <span class="br0">&#40;</span><span class="re0">$this</span><span class="sy0">-&gt;</span>_locale<span class="br0">&#41;</span> <span class="br0">&#123;</span>				
		<span class="kw1">case</span> <span class="st_h">'uk'</span><span class="sy0">:</span>
			<span class="re0">$region</span> <span class="sy0">=</span> <span class="st_h">'co.uk'</span><span class="sy0">;</span>
			<span class="kw1">break</span><span class="sy0">;</span>
		<span class="kw1">case</span> <span class="st_h">'de'</span><span class="sy0">:</span>
			<span class="re0">$region</span> <span class="sy0">.=</span> <span class="st_h">'de'</span><span class="sy0">;</span>
			<span class="kw1">break</span><span class="sy0">;</span>
		<span class="kw1">case</span> <span class="st_h">'jp'</span><span class="sy0">:</span>
			<span class="re0">$region</span> <span class="sy0">.=</span> <span class="st_h">'co.jp'</span><span class="sy0">;</span>
			<span class="kw1">break</span><span class="sy0">;</span>
		<span class="kw1">case</span> <span class="st_h">'fr'</span><span class="sy0">:</span>
			<span class="re0">$region</span> <span class="sy0">.=</span> <span class="st_h">'fr'</span><span class="sy0">;</span>
			<span class="kw1">break</span><span class="sy0">;</span>
		<span class="kw1">case</span> <span class="st_h">'ca'</span><span class="sy0">:</span>
			<span class="re0">$region</span> <span class="sy0">.=</span> <span class="st_h">'ca'</span><span class="sy0">;</span>
			<span class="kw1">break</span><span class="sy0">;</span>
		<span class="kw1">case</span> <span class="st_h">'us'</span><span class="sy0">:</span>
		<span class="kw1">default</span><span class="sy0">:</span>
			<span class="re0">$region</span> <span class="sy0">=</span> <span class="st_h">'com'</span><span class="sy0">;</span>
			<span class="kw1">break</span><span class="sy0">;</span>
	<span class="br0">&#125;</span>
	<span class="re0">$public_key</span> <span class="sy0">=</span> <span class="st0">&quot;&lt; &lt; Your Access Key ID &gt;&gt;&quot;</span><span class="sy0">;</span>
	<span class="re0">$private_key</span> <span class="sy0">=</span> <span class="st0">&quot;&lt; &lt; Your Secret Access Key &gt;&gt;&quot;</span><span class="sy0">;</span>
	<span class="re0">$url</span> <span class="sy0">=</span> aws_signed_request<span class="br0">&#40;</span><span class="re0">$region</span><span class="sy0">,</span> <a href="http://www.php.net/array"><span class="kw3">array</span></a><span class="br0">&#40;</span>
			<span class="st0">&quot;Operation&quot;</span><span class="sy0">=&gt;</span> <span class="st0">&quot;ItemSearch&quot;</span><span class="sy0">,</span>
			<span class="st0">&quot;Keywords&quot;</span> <span class="sy0">=&gt;</span> <span class="re0">$this</span><span class="sy0">-&gt;</span>_parameters<span class="br0">&#91;</span>Keywords<span class="br0">&#93;</span><span class="sy0">,</span>
			<span class="st0">&quot;ResponseGroup&quot;</span><span class="sy0">=&gt;</span><span class="re0">$this</span><span class="sy0">-&gt;</span>_parameters<span class="br0">&#91;</span>ResponseGroup<span class="br0">&#93;</span><span class="sy0">,</span>
			<span class="st0">&quot;SearchIndex&quot;</span> <span class="sy0">=&gt;</span> <span class="re0">$this</span><span class="sy0">-&gt;</span>_parameters<span class="br0">&#91;</span>SearchIndex<span class="br0">&#93;</span><span class="sy0">,</span>
			<span class="st0">&quot;AssociateTag&quot;</span> <span class="sy0">=&gt;</span> <a href="http://www.php.net/urlencode"><span class="kw3">urlencode</span></a><span class="br0">&#40;</span><span class="re0">$this</span><span class="sy0">-&gt;</span>_associate_tag<span class="br0">&#41;</span><span class="br0">&#41;</span><span class="sy0">,</span>
			<span class="re0">$public_key</span><span class="sy0">,</span> <span class="re0">$private_key</span><span class="br0">&#41;</span><span class="sy0">;</span>
	<span class="kw1">return</span> <span class="re0">$url</span><span class="sy0">;</span>
<span class="br0">&#125;</span></pre></div></div>
<p>3.  Oddly enough, this new method requires a private secret key which Amazon recommends to not give to anyone.  So I&#8217;m not going to post mine here, even though it&#8217;s required for the plugin to work.  So before I ponder that particular nugget of madness, you&#8217;ll need to <a href="https://aws-portal.amazon.com/gp/aws/developer/account/index.html" target="_blank">sign up for an AWS developer account</a>, and find your own keys via the <a href="https://aws-portal.amazon.com/gp/aws/developer/account/index.html?ie=UTF8&#038;action=access-key" target="_blank">Access Identifiers</a> page.  These need to be added into the function above.</p>
<p>That should be enough to get you back up and running again, although selfishly I&#8217;ve only really tested it for my needs alone.  So please let me know if it works, or fails miserably.</p>
<p>For all the legal bits, I&#8217;m not at all affiliated with Amazon or Sozu &#8211; so please use at your own risk <img src='http://www.kevinblake.co.uk/wp-includes/images/smilies/icon_smile.gif' alt=':)' class='wp-smiley' /> </p>
]]></content:encoded>
			<wfw:commentRss>http://www.kevinblake.co.uk/rescuscitating-amm-with-amazon-web-service-signed-requests/656/feed/</wfw:commentRss>
		<slash:comments>0</slash:comments>
		</item>
		<item>
		<title>C# Joins with Linq and Lambdas</title>
		<link>http://www.kevinblake.co.uk/csharp-lamba-joins-in-linq/647/</link>
		<comments>http://www.kevinblake.co.uk/csharp-lamba-joins-in-linq/647/#comments</comments>
		<pubDate>Sat, 08 Aug 2009 12:16:14 +0000</pubDate>
		<dc:creator>Kevin</dc:creator>
				<category><![CDATA[Uncategorized]]></category>
		<category><![CDATA[.net]]></category>
		<category><![CDATA[c#]]></category>
		<category><![CDATA[csharp]]></category>
		<category><![CDATA[lambda]]></category>
		<category><![CDATA[linq]]></category>
		<category><![CDATA[programming]]></category>
		<category><![CDATA[technology]]></category>

		<guid isPermaLink="false">http://www.kevinblake.co.uk/?p=647</guid>
		<description><![CDATA[I&#8217;m always forgetting the syntax for lambda joins in C#, because I never use them enough and get bored looking for reminders enough that I just revert back my old ways and use the query expression instead. So rather than find a good tutorial and bookmark it, I&#8217;ll post it here instead. By the time [...]]]></description>
			<content:encoded><![CDATA[<p>I&#8217;m always forgetting the syntax for lambda joins in C#, because I never use them enough and get bored looking for reminders enough that I just revert back my old ways and use the query expression instead.  So rather than find a good tutorial and bookmark it, I&#8217;ll post it here instead.  By the time it falls off the front page, I&#8217;ll just about have remembered how to do it without needing this anyway <img src='http://www.kevinblake.co.uk/wp-includes/images/smilies/icon_smile.gif' alt=':)' class='wp-smiley' /> </p>
<p><strong>Query Syntax</strong></p>
<div id="wpshdo_5" class="wp-synhighlighter-outer"><div id="wpshdt_5" class="wp-synhighlighter-expanded"><table border="0" width="100%"><tr><td align="left" width="80%"><a name="#codesyntax_5"></a><a id="wpshat_5" class="wp-synhighlighter-title" href="#codesyntax_5"  onClick="javascript:wpsh_toggleBlock(5)" title="Click to show/hide code block">Code block</a></td><td align="right"><a href="#codesyntax_5" onClick="javascript:wpsh_code(5)" title="Show code only"><img border="0" style="border: 0 none" src="http://www.kevinblake.co.uk/wp-content/plugins/wp-synhighlight/themes/default/images/code.png" /></a>&nbsp;<a href="#codesyntax_5" onClick="javascript:wpsh_print(5)" title="Print code"><img border="0" style="border: 0 none" src="http://www.kevinblake.co.uk/wp-content/plugins/wp-synhighlight/themes/default/images/printer.png" /></a>&nbsp;<a href="http://www.kevinblake.co.uk/wp-content/plugins/wp-synhighlight/About.html" target="_blank" title="Show plugin information"><img border="0" style="border: 0 none" src="http://www.kevinblake.co.uk/wp-content/plugins/wp-synhighlight/themes/default/images/info.gif" /></a>&nbsp;</td></tr></table></div><div id="wpshdi_5" class="wp-synhighlighter-inner" style="display: block;"><pre class="csharp" style="font-family:monospace;">var products <span class="sy0">=</span> from audio <span class="kw1">in</span> DbContext.<span class="me1">DataContext</span>.<span class="me1">ProductAudios</span>
join product <span class="kw1">in</span> DbContext.<span class="me1">DataContext</span>.<span class="me1">ProductAudios</span> on audio.<span class="me1">ProductId</span> equals product.<span class="me1">ProductId</span>
select <a href="http://www.google.com/search?q=new+msdn.microsoft.com"><span class="kw3">new</span></a> <span class="br0">&#123;</span> Product <span class="sy0">=</span> product, Audio <span class="sy0">=</span> audio <span class="br0">&#125;</span><span class="sy0">;</span></pre></div></div>
<p><strong>Lambda Syntax</strong></p>
<div id="wpshdo_6" class="wp-synhighlighter-outer"><div id="wpshdt_6" class="wp-synhighlighter-expanded"><table border="0" width="100%"><tr><td align="left" width="80%"><a name="#codesyntax_6"></a><a id="wpshat_6" class="wp-synhighlighter-title" href="#codesyntax_6"  onClick="javascript:wpsh_toggleBlock(6)" title="Click to show/hide code block">Code block</a></td><td align="right"><a href="#codesyntax_6" onClick="javascript:wpsh_code(6)" title="Show code only"><img border="0" style="border: 0 none" src="http://www.kevinblake.co.uk/wp-content/plugins/wp-synhighlight/themes/default/images/code.png" /></a>&nbsp;<a href="#codesyntax_6" onClick="javascript:wpsh_print(6)" title="Print code"><img border="0" style="border: 0 none" src="http://www.kevinblake.co.uk/wp-content/plugins/wp-synhighlight/themes/default/images/printer.png" /></a>&nbsp;<a href="http://www.kevinblake.co.uk/wp-content/plugins/wp-synhighlight/About.html" target="_blank" title="Show plugin information"><img border="0" style="border: 0 none" src="http://www.kevinblake.co.uk/wp-content/plugins/wp-synhighlight/themes/default/images/info.gif" /></a>&nbsp;</td></tr></table></div><div id="wpshdi_6" class="wp-synhighlighter-inner" style="display: block;"><pre class="csharp" style="font-family:monospace;">var products <span class="sy0">=</span> DbContext.<span class="me1">DataContext</span>.<span class="me1">ProductAudios</span>.<span class="me1">Join</span><span class="br0">&#40;</span>
                DbContext.<span class="me1">DataContext</span>.<span class="me1">Products</span>,
                audio <span class="sy0">=&gt;</span> audio.<span class="me1">ProductId</span>,
                product <span class="sy0">=&gt;</span> product.<span class="me1">ProductId</span>,
                <span class="br0">&#40;</span>audio, product<span class="br0">&#41;</span> <span class="sy0">=&gt;</span> <a href="http://www.google.com/search?q=new+msdn.microsoft.com"><span class="kw3">new</span></a> <span class="br0">&#123;</span> Product <span class="sy0">=</span> product, Audio <span class="sy0">=</span> audio <span class="br0">&#125;</span><span class="br0">&#41;</span><span class="sy0">;</span></pre></div></div>
<p>It might look like more code because of my formatting, but I find the lambda syntax much convenient when chaining queries together with other where&#8217;s and groupby&#8217;s, especially when that might be split across different methods.  It also isolates your join nicely, whereas I find the query syntax will start to get particularly unreadable with more complex queries.</p>
<p>Last but not least, another piece of linq-join-related syntax I&#8217;m finding myself always having to look up a lot is for left outer joins.  Fortunately I always end up at MSDN for that one, so I&#8217;ll just link to it here:<br />
<a href="http://msdn.microsoft.com/en-us/library/bb397895.aspx">How to: Perform Left Outer Joins</a></p>
]]></content:encoded>
			<wfw:commentRss>http://www.kevinblake.co.uk/csharp-lamba-joins-in-linq/647/feed/</wfw:commentRss>
		<slash:comments>1</slash:comments>
		</item>
		<item>
		<title>Running Ruby methods within C# / .NET</title>
		<link>http://www.kevinblake.co.uk/running-ruby-methods-within-c-net/631/</link>
		<comments>http://www.kevinblake.co.uk/running-ruby-methods-within-c-net/631/#comments</comments>
		<pubDate>Thu, 23 Jul 2009 21:16:04 +0000</pubDate>
		<dc:creator>Kevin</dc:creator>
				<category><![CDATA[Uncategorized]]></category>
		<category><![CDATA[.net]]></category>
		<category><![CDATA[c#]]></category>
		<category><![CDATA[csharp]]></category>
		<category><![CDATA[dotnet]]></category>
		<category><![CDATA[ironruby]]></category>
		<category><![CDATA[programming]]></category>
		<category><![CDATA[ruby]]></category>
		<category><![CDATA[technology]]></category>

		<guid isPermaLink="false">http://www.kevinblake.co.uk/?p=631</guid>
		<description><![CDATA[The last example might have been a little too trivial, even by my standards. Even I struggled to imagine a scenario where I might ever need to use it. So hopefully this one will be a little bit more interesting and demonstrate something more useful. Useful, but still just as simple as the previous examples, [...]]]></description>
			<content:encoded><![CDATA[<p>The last example might have been a little too trivial, even by my standards.  Even I struggled to imagine a scenario where I might ever need to use it.  So hopefully this one will be a little bit more interesting and demonstrate something more useful.</p>
<p>Useful, but still just as simple as the previous examples, that is.  Again &#8211; you&#8217;ll need your references from the downloaded IronRuby bin/ folder.  And as you&#8217;ve come to expect, a very simple ruby script defining a lambda function.</p>
<div id="wpshdo_7" class="wp-synhighlighter-outer"><div id="wpshdt_7" class="wp-synhighlighter-expanded"><table border="0" width="100%"><tr><td align="left" width="80%"><a name="#codesyntax_7"></a><a id="wpshat_7" class="wp-synhighlighter-title" href="#codesyntax_7"  onClick="javascript:wpsh_toggleBlock(7)" title="Click to show/hide code block">Code block</a></td><td align="right"><a href="#codesyntax_7" onClick="javascript:wpsh_code(7)" title="Show code only"><img border="0" style="border: 0 none" src="http://www.kevinblake.co.uk/wp-content/plugins/wp-synhighlight/themes/default/images/code.png" /></a>&nbsp;<a href="#codesyntax_7" onClick="javascript:wpsh_print(7)" title="Print code"><img border="0" style="border: 0 none" src="http://www.kevinblake.co.uk/wp-content/plugins/wp-synhighlight/themes/default/images/printer.png" /></a>&nbsp;<a href="http://www.kevinblake.co.uk/wp-content/plugins/wp-synhighlight/About.html" target="_blank" title="Show plugin information"><img border="0" style="border: 0 none" src="http://www.kevinblake.co.uk/wp-content/plugins/wp-synhighlight/themes/default/images/info.gif" /></a>&nbsp;</td></tr></table></div><div id="wpshdi_7" class="wp-synhighlighter-inner" style="display: block;"><pre class="ruby" style="font-family:monospace;"><span class="re0">$m</span> = <span class="kw3">lambda</span> <span class="br0">&#123;</span>
            a = <span class="kw3">Array</span>.<span class="me1">new</span>
            a.<span class="me1">push</span><span class="br0">&#40;</span>2, 3<span class="br0">&#41;</span>
            <span class="br0">&#40;</span>4..50<span class="br0">&#41;</span>.<span class="me1">each</span> <span class="kw1">do</span>
               <span class="sy0">|</span>i<span class="sy0">|</span>
               <span class="br0">&#40;</span>2..<span class="br0">&#40;</span><span class="kw4">Math</span>.<span class="me1">sqrt</span><span class="br0">&#40;</span>i<span class="br0">&#41;</span>.<span class="me1">ceil</span><span class="br0">&#41;</span><span class="br0">&#41;</span>.<span class="me1">each</span> <span class="kw1">do</span>
                  <span class="sy0">|</span>thing<span class="sy0">|</span>
                  <span class="kw1">if</span> <span class="br0">&#40;</span>i.<span class="me1">divmod</span><span class="br0">&#40;</span>thing<span class="br0">&#41;</span><span class="br0">&#91;</span>1<span class="br0">&#93;</span> == 0<span class="br0">&#41;</span>
                     a.<span class="me1">push</span> i
                     <span class="kw1">break</span>
                  <span class="kw1">end</span>
               <span class="kw1">end</span>
            <span class="kw1">end</span>
            <span class="kw2">return</span> a
         <span class="br0">&#125;</span></pre></div></div>
<p>From this, we&#8217;ll get an array of the prime numbers.  The function can then be executed rather nicely from within your .NET code like this:</p>
<div id="wpshdo_8" class="wp-synhighlighter-outer"><div id="wpshdt_8" class="wp-synhighlighter-expanded"><table border="0" width="100%"><tr><td align="left" width="80%"><a name="#codesyntax_8"></a><a id="wpshat_8" class="wp-synhighlighter-title" href="#codesyntax_8"  onClick="javascript:wpsh_toggleBlock(8)" title="Click to show/hide code block">Code block</a></td><td align="right"><a href="#codesyntax_8" onClick="javascript:wpsh_code(8)" title="Show code only"><img border="0" style="border: 0 none" src="http://www.kevinblake.co.uk/wp-content/plugins/wp-synhighlight/themes/default/images/code.png" /></a>&nbsp;<a href="#codesyntax_8" onClick="javascript:wpsh_print(8)" title="Print code"><img border="0" style="border: 0 none" src="http://www.kevinblake.co.uk/wp-content/plugins/wp-synhighlight/themes/default/images/printer.png" /></a>&nbsp;<a href="http://www.kevinblake.co.uk/wp-content/plugins/wp-synhighlight/About.html" target="_blank" title="Show plugin information"><img border="0" style="border: 0 none" src="http://www.kevinblake.co.uk/wp-content/plugins/wp-synhighlight/themes/default/images/info.gif" /></a>&nbsp;</td></tr></table></div><div id="wpshdi_8" class="wp-synhighlighter-inner" style="display: block;"><pre class="pascal" style="font-family:monospace;"><span class="kw1">var</span> ruby <span class="sy0">=</span> Ruby.<span class="me1">GetEngine</span><span class="br0">&#40;</span>Ruby.<span class="me1">CreateRuntime</span><span class="br0">&#40;</span><span class="br0">&#41;</span><span class="br0">&#41;</span>;
ruby.<span class="me1">Execute</span><span class="br0">&#40;</span>@<span class="st0">&quot;
    $m = lambda {
//.. snip..
            return a
         }
&quot;</span><span class="br0">&#41;</span>;
<span class="kw1">var</span> rubyContext <span class="sy0">=</span> Ruby.<span class="me1">GetExecutionContext</span><span class="br0">&#40;</span>ruby<span class="br0">&#41;</span>;
<span class="kw1">var</span> m <span class="sy0">=</span> <span class="br0">&#40;</span>Proc<span class="br0">&#41;</span>rubyContext.<span class="me1">GetGlobalVariable</span><span class="br0">&#40;</span><span class="st0">&quot;m&quot;</span><span class="br0">&#41;</span>;
<span class="kw1">var</span> rubyArray <span class="sy0">=</span> <span class="br0">&#40;</span>RubyArray<span class="br0">&#41;</span> m.<span class="me1">Call</span><span class="br0">&#40;</span><span class="br0">&#41;</span>;
foreach <span class="br0">&#40;</span><span class="kw1">var</span> o <span class="kw1">in</span> rubyArray<span class="br0">&#41;</span>
<span class="coMULTI">{
    Console.Write(string.Format(&quot;{0}</span><span class="sy0">,</span><span class="st0">&quot;, o));
}</span></pre></div></div>
<p>Now we&#8217;re really starting to leverage that syntactical beauty of ruby within .NET and jumping (almost) seamlessly between the two.  Now, I really should do some demos on something more useful than prime numbers, and perhaps get into one of the big areas of interest of Ruby &#8211; testing frameworks.  Not tonight though <img src='http://www.kevinblake.co.uk/wp-includes/images/smilies/icon_smile.gif' alt=':)' class='wp-smiley' /> </p>
<p>Demo project available as usual:</p>
<ul>
<li><a href="http://www.kevinblake.co.uk/wp-content/uploads/2009/07/csharp-execute-ironruby-methods.zip">Download C# IronRuby Method Wrapper</a></li>
</ul>
]]></content:encoded>
			<wfw:commentRss>http://www.kevinblake.co.uk/running-ruby-methods-within-c-net/631/feed/</wfw:commentRss>
		<slash:comments>0</slash:comments>
		</item>
		<item>
		<title>Executing complete (Iron)Ruby scripts from within native C# / .NET</title>
		<link>http://www.kevinblake.co.uk/executing-complete-ironruby-scripts-from-within-native-c-net/624/</link>
		<comments>http://www.kevinblake.co.uk/executing-complete-ironruby-scripts-from-within-native-c-net/624/#comments</comments>
		<pubDate>Wed, 22 Jul 2009 20:26:15 +0000</pubDate>
		<dc:creator>Kevin</dc:creator>
				<category><![CDATA[Uncategorized]]></category>
		<category><![CDATA[.net]]></category>
		<category><![CDATA[c#]]></category>
		<category><![CDATA[csharp]]></category>
		<category><![CDATA[dotnet]]></category>
		<category><![CDATA[ironruby]]></category>
		<category><![CDATA[programming]]></category>
		<category><![CDATA[ruby]]></category>
		<category><![CDATA[technology]]></category>

		<guid isPermaLink="false">http://www.kevinblake.co.uk/?p=624</guid>
		<description><![CDATA[Running Ruby code as-is within .NET is almost too simple to even write home about. In fact I almost didn&#8217;t, but after I wrote it the solution stared up at me with its big brown eyes, and I couldn&#8217;t resist. I&#8217;m not totally sure when I&#8217;d ever need to use this, but perhaps taking some [...]]]></description>
			<content:encoded><![CDATA[<p>Running Ruby code as-is within .NET is almost too simple to even write home about.  In fact I almost didn&#8217;t, but after I wrote it the solution stared up at me with its big brown eyes, and I couldn&#8217;t resist.  I&#8217;m not totally sure when I&#8217;d ever need to use this, but perhaps taking some legacy Ruby scripts where I don&#8217;t really care about the results, and still want to run them amongst some other .NET tasks.  It might come up in some obscure unit testing one day.  You never know.</p>
<p>So, this still serves as an example of how simple it can be to run ruby scripts within .NET.  We&#8217;ll get to making use of some return values, and running individual methods in the next post.</p>
<p>Following on from the last example, the following ruby script prints all the prime numbers between 1 and 50.</p>
<div id="wpshdo_9" class="wp-synhighlighter-outer"><div id="wpshdt_9" class="wp-synhighlighter-expanded"><table border="0" width="100%"><tr><td align="left" width="80%"><a name="#codesyntax_9"></a><a id="wpshat_9" class="wp-synhighlighter-title" href="#codesyntax_9"  onClick="javascript:wpsh_toggleBlock(9)" title="Click to show/hide code block">Code block</a></td><td align="right"><a href="#codesyntax_9" onClick="javascript:wpsh_code(9)" title="Show code only"><img border="0" style="border: 0 none" src="http://www.kevinblake.co.uk/wp-content/plugins/wp-synhighlight/themes/default/images/code.png" /></a>&nbsp;<a href="#codesyntax_9" onClick="javascript:wpsh_print(9)" title="Print code"><img border="0" style="border: 0 none" src="http://www.kevinblake.co.uk/wp-content/plugins/wp-synhighlight/themes/default/images/printer.png" /></a>&nbsp;<a href="http://www.kevinblake.co.uk/wp-content/plugins/wp-synhighlight/About.html" target="_blank" title="Show plugin information"><img border="0" style="border: 0 none" src="http://www.kevinblake.co.uk/wp-content/plugins/wp-synhighlight/themes/default/images/info.gif" /></a>&nbsp;</td></tr></table></div><div id="wpshdi_9" class="wp-synhighlighter-inner" style="display: block;"><pre class="ruby" style="font-family:monospace;">state = <span class="kw4">Numeric</span>.<span class="me1">new</span>
<span class="kw3">print</span> <span class="st0">&quot;2,3,&quot;</span>
<span class="br0">&#40;</span>4..50<span class="br0">&#41;</span>.<span class="me1">each</span> <span class="kw1">do</span>
   <span class="sy0">|</span>i<span class="sy0">|</span>
   <span class="br0">&#40;</span>2..<span class="br0">&#40;</span><span class="kw4">Math</span>.<span class="me1">sqrt</span><span class="br0">&#40;</span>i<span class="br0">&#41;</span>.<span class="me1">ceil</span><span class="br0">&#41;</span><span class="br0">&#41;</span>.<span class="me1">each</span> <span class="kw1">do</span>
      <span class="sy0">|</span>thing<span class="sy0">|</span>
      state = 1
      <span class="kw1">if</span> <span class="br0">&#40;</span>i.<span class="me1">divmod</span><span class="br0">&#40;</span>thing<span class="br0">&#41;</span><span class="br0">&#91;</span>1<span class="br0">&#93;</span> == 0<span class="br0">&#41;</span>
         state = 0
         <span class="kw1">break</span>
      <span class="kw1">end</span>
   <span class="kw1">end</span>
   <span class="kw3">print</span> <span class="st0">&quot;#{i}<span class="es0">\,</span>&quot;</span> <span class="kw1">unless</span> <span class="br0">&#40;</span>state == 0<span class="br0">&#41;</span>
<span class="kw1">end</span></pre></div></div>
<p>With the ruby script complete (you can also run this with the ir.exe that ships with IronRuby if you like)&#8230; Next start up a new project within Visual Studio, and add some references from your downloaded IronRuby bin folder (IronRuby.dll, IronRuby.Libraries.dll etc&#8230;).</p>
<p>You only need a few lines of code to execute your ruby script.</p>
<div id="wpshdo_10" class="wp-synhighlighter-outer"><div id="wpshdt_10" class="wp-synhighlighter-expanded"><table border="0" width="100%"><tr><td align="left" width="80%"><a name="#codesyntax_10"></a><a id="wpshat_10" class="wp-synhighlighter-title" href="#codesyntax_10"  onClick="javascript:wpsh_toggleBlock(10)" title="Click to show/hide code block">Code block</a></td><td align="right"><a href="#codesyntax_10" onClick="javascript:wpsh_code(10)" title="Show code only"><img border="0" style="border: 0 none" src="http://www.kevinblake.co.uk/wp-content/plugins/wp-synhighlight/themes/default/images/code.png" /></a>&nbsp;<a href="#codesyntax_10" onClick="javascript:wpsh_print(10)" title="Print code"><img border="0" style="border: 0 none" src="http://www.kevinblake.co.uk/wp-content/plugins/wp-synhighlight/themes/default/images/printer.png" /></a>&nbsp;<a href="http://www.kevinblake.co.uk/wp-content/plugins/wp-synhighlight/About.html" target="_blank" title="Show plugin information"><img border="0" style="border: 0 none" src="http://www.kevinblake.co.uk/wp-content/plugins/wp-synhighlight/themes/default/images/info.gif" /></a>&nbsp;</td></tr></table></div><div id="wpshdi_10" class="wp-synhighlighter-inner" style="display: block;"><pre class="csharp" style="font-family:monospace;"><span class="kw1">using</span> <span class="co3">IronRuby</span><span class="sy0">;</span>
<span class="co1">// ..</span>
var runtime <span class="sy0">=</span> Ruby.<span class="me1">CreateRuntime</span><span class="br0">&#40;</span><span class="br0">&#41;</span><span class="sy0">;</span>
runtime.<span class="me1">ExecuteFile</span><span class="br0">&#40;</span><span class="st_h">@&quot;ruby/run.rb&quot;</span><span class="br0">&#41;</span><span class="sy0">;</span></pre></div></div>
<p>As before, you can download the full example to check it and run for yourself.  And also as before, you will also need <a href="http://www.ironruby.net/Download" target="_blank">IronRuby.<br />
</a></p>
<ul>
<li><a href='http://www.kevinblake.co.uk/wp-content/uploads/2009/07/ruby-execute-full-script-within-csharp-demo.zip'>Download C# IronRuby Wrapper</a></li>
</ul>
]]></content:encoded>
			<wfw:commentRss>http://www.kevinblake.co.uk/executing-complete-ironruby-scripts-from-within-native-c-net/624/feed/</wfw:commentRss>
		<slash:comments>0</slash:comments>
		</item>
		<item>
		<title>Using C# / .NET libraries within IronRuby</title>
		<link>http://www.kevinblake.co.uk/using-c-net-libraries-within-ironruby/602/</link>
		<comments>http://www.kevinblake.co.uk/using-c-net-libraries-within-ironruby/602/#comments</comments>
		<pubDate>Sat, 18 Jul 2009 09:34:10 +0000</pubDate>
		<dc:creator>Kevin</dc:creator>
				<category><![CDATA[Uncategorized]]></category>
		<category><![CDATA[.net]]></category>
		<category><![CDATA[c#]]></category>
		<category><![CDATA[csharp]]></category>
		<category><![CDATA[dotnet]]></category>
		<category><![CDATA[ironruby]]></category>
		<category><![CDATA[programming]]></category>
		<category><![CDATA[ruby]]></category>
		<category><![CDATA[technology]]></category>
		<category><![CDATA[vistasquad]]></category>

		<guid isPermaLink="false">http://www.kevinblake.co.uk/?p=602</guid>
		<description><![CDATA[I attended my first VistaSquad meeting on Wednesday. Part of the evening was a very interesting talk from @ben_hall on IronRuby, which among many other things included how to use any .NET CLR libraries direct from your IronRuby script (running via the .NET DLR). Whilst my example below is extremely trivial, it shows how you [...]]]></description>
			<content:encoded><![CDATA[<p>I attended my first <a href="http://vistasquad.co.uk/" target="_blank">VistaSquad</a> meeting on Wednesday.  Part of the evening was a very interesting talk from <a href="http://www.twitter.com/ben_hall">@ben_hall</a> on IronRuby, which among many other things included how to use any .NET CLR libraries direct from your IronRuby script (running via the .NET DLR).</p>
<p>Whilst my example below is extremely trivial, it shows how you might make use of any existing libraries within your Ruby scripts.  This same technique applies to any .NET libraries, whether they&#8217;re custom, part of the framework, or created by your gran.  I don&#8217;t think I really need to sell it in &#8211; but I love the flexibility that this provides.</p>
<p>So to get to the example, this simple piece of C# displays all the prime numbers between 0 and maxNumber:</p>
<div id="wpshdo_11" class="wp-synhighlighter-outer"><div id="wpshdt_11" class="wp-synhighlighter-expanded"><table border="0" width="100%"><tr><td align="left" width="80%"><a name="#codesyntax_11"></a><a id="wpshat_11" class="wp-synhighlighter-title" href="#codesyntax_11"  onClick="javascript:wpsh_toggleBlock(11)" title="Click to show/hide code block">Code block</a></td><td align="right"><a href="#codesyntax_11" onClick="javascript:wpsh_code(11)" title="Show code only"><img border="0" style="border: 0 none" src="http://www.kevinblake.co.uk/wp-content/plugins/wp-synhighlight/themes/default/images/code.png" /></a>&nbsp;<a href="#codesyntax_11" onClick="javascript:wpsh_print(11)" title="Print code"><img border="0" style="border: 0 none" src="http://www.kevinblake.co.uk/wp-content/plugins/wp-synhighlight/themes/default/images/printer.png" /></a>&nbsp;<a href="http://www.kevinblake.co.uk/wp-content/plugins/wp-synhighlight/About.html" target="_blank" title="Show plugin information"><img border="0" style="border: 0 none" src="http://www.kevinblake.co.uk/wp-content/plugins/wp-synhighlight/themes/default/images/info.gif" /></a>&nbsp;</td></tr></table></div><div id="wpshdi_11" class="wp-synhighlighter-inner" style="display: block;"><pre class="csharp" style="font-family:monospace;"><span class="kw1">public</span> <span class="kw4">int</span><span class="br0">&#91;</span><span class="br0">&#93;</span> DisplayPrimeNumbers<span class="br0">&#40;</span><span class="kw4">int</span> maxNumber<span class="br0">&#41;</span>
<span class="br0">&#123;</span>
    <span class="kw4">int</span> max <span class="sy0">=</span> maxNumber<span class="sy0">;</span>
    List previousPrimes <span class="sy0">=</span> <a href="http://www.google.com/search?q=new+msdn.microsoft.com"><span class="kw3">new</span></a> List<span class="br0">&#40;</span><span class="br0">&#41;</span><span class="sy0">;</span>
    previousPrimes.<span class="me1">Add</span><span class="br0">&#40;</span>2<span class="br0">&#41;</span><span class="sy0">;</span>
    <span class="kw1">if</span> <span class="br0">&#40;</span>max <span class="sy0">&lt;</span> 2<span class="br0">&#41;</span> <span class="kw1">return</span> null<span class="sy0">;</span> <span class="co1">// none</span>
    <span class="kw1">for</span> <span class="br0">&#40;</span><span class="kw4">int</span> i <span class="sy0">=</span> <span class="nu0">3</span><span class="sy0">;</span> i  maxDivisor<span class="br0">&#41;</span> break<span class="sy0">;</span>
            <span class="kw1">if</span> <span class="br0">&#40;</span><span class="br0">&#40;</span>i <span class="sy0">%</span> previousPrimes<span class="br0">&#91;</span>j<span class="br0">&#93;</span><span class="br0">&#41;</span> <span class="sy0">==</span> 0<span class="br0">&#41;</span>
            <span class="br0">&#123;</span>
                foundDivisor <span class="sy0">=</span> true<span class="sy0">;</span>
            <span class="br0">&#125;</span>
        <span class="br0">&#125;</span>
        <span class="kw1">if</span> <span class="br0">&#40;</span><span class="sy0">!</span>foundDivisor<span class="br0">&#41;</span>
        <span class="br0">&#123;</span>
            previousPrimes.<span class="me1">Add</span><span class="br0">&#40;</span>i<span class="br0">&#41;</span><span class="sy0">;</span>
        <span class="br0">&#125;</span>
    <span class="br0">&#125;</span>
    <span class="kw1">return</span> previousPrimes.<span class="me1">ToArray</span><span class="br0">&#40;</span><span class="br0">&#41;</span><span class="sy0">;</span>
<span class="br0">&#125;</span></pre></div></div>
<p>We can build that up into a class library and using IronRuby, manipulate the return of the method the same as though we had been running native ruby.</p>
<div id="wpshdo_12" class="wp-synhighlighter-outer"><div id="wpshdt_12" class="wp-synhighlighter-expanded"><table border="0" width="100%"><tr><td align="left" width="80%"><a name="#codesyntax_12"></a><a id="wpshat_12" class="wp-synhighlighter-title" href="#codesyntax_12"  onClick="javascript:wpsh_toggleBlock(12)" title="Click to show/hide code block">Code block</a></td><td align="right"><a href="#codesyntax_12" onClick="javascript:wpsh_code(12)" title="Show code only"><img border="0" style="border: 0 none" src="http://www.kevinblake.co.uk/wp-content/plugins/wp-synhighlight/themes/default/images/code.png" /></a>&nbsp;<a href="#codesyntax_12" onClick="javascript:wpsh_print(12)" title="Print code"><img border="0" style="border: 0 none" src="http://www.kevinblake.co.uk/wp-content/plugins/wp-synhighlight/themes/default/images/printer.png" /></a>&nbsp;<a href="http://www.kevinblake.co.uk/wp-content/plugins/wp-synhighlight/About.html" target="_blank" title="Show plugin information"><img border="0" style="border: 0 none" src="http://www.kevinblake.co.uk/wp-content/plugins/wp-synhighlight/themes/default/images/info.gif" /></a>&nbsp;</td></tr></table></div><div id="wpshdi_12" class="wp-synhighlighter-inner" style="display: block;"><pre class="ruby" style="font-family:monospace;"><span class="kw3">require</span> <span class="st0">'mscorlib'</span>
<span class="kw3">require</span> <span class="st0">'CSharpLib, Version=1.0.0.0, Culture=neutral, PublicKeyToken=null'</span>;
prime_numbers = <span class="re2">CSharpLib::PrimeNumbers</span>.<span class="me1">new</span>
<span class="br0">&#40;</span>prime_numbers.<span class="me1">DisplayPrimeNumbers</span> 20<span class="br0">&#41;</span>.<span class="me1">each</span> <span class="kw1">do</span> <span class="sy0">|</span>num<span class="sy0">|</span>
	<span class="kw3">puts</span> num
<span class="kw1">end</span></pre></div></div>
<p>You can download the full sample below, a C# console app is also included for completeness (although isn&#8217;t a part of the IronRuby process).  You will of course, need to <a href="http://www.ironruby.net/Download">download IronRuby</a> first, and add the installed bin/ folder to your path.  Then just change to the <em>&lt;sample&gt;</em>/ruby/ directory, and run it with:</p>
<p><code>ir run.rb</code></p>
<ul>
<li><a href='http://www.kevinblake.co.uk/wp-content/uploads/2009/07/primenumber-ruby-csharp.zip'>Download IronRuby / C# prime number sample</a></li>
</ul>
<p>It&#8217;s probably worth noting that IronRuby is still a way off from a 1.0 release, but it&#8217;s already very usable and looking rather cool.  Since it&#8217;s on <a href="http://www.kevinblake.co.uk/todo/594/">my recent //TODO list</a>, I&#8217;ll be doing a few more examples here &#8211; next time turning this one its head and executing your ruby scripts from within C#.  In the meantime, you can check out <a href="http://www.slideshare.net/BenHalluk/ironruby" target="_blank">Ben&#8217;s set of slides</a> from Wednesday on Slideshare.</int></p>
]]></content:encoded>
			<wfw:commentRss>http://www.kevinblake.co.uk/using-c-net-libraries-within-ironruby/602/feed/</wfw:commentRss>
		<slash:comments>0</slash:comments>
		</item>
		<item>
		<title>//TODO: Learn, play, discuss.</title>
		<link>http://www.kevinblake.co.uk/todo/594/</link>
		<comments>http://www.kevinblake.co.uk/todo/594/#comments</comments>
		<pubDate>Sat, 11 Jul 2009 14:24:34 +0000</pubDate>
		<dc:creator>Kevin</dc:creator>
				<category><![CDATA[Uncategorized]]></category>
		<category><![CDATA[.net]]></category>
		<category><![CDATA[dotnet]]></category>
		<category><![CDATA[gallery3]]></category>
		<category><![CDATA[geotagging]]></category>
		<category><![CDATA[gps]]></category>
		<category><![CDATA[programming]]></category>
		<category><![CDATA[technology]]></category>

		<guid isPermaLink="false">http://www.kevinblake.co.uk/?p=594</guid>
		<description><![CDATA[Somewhat inspired by Mike Taulty&#8217;s blog, I&#8217;ve decided I should throw my Tech TODO list at the world, because it might encourage / guilt me into doing some of them, as well as provide a preview on what this blog might be including over the next few months. So all of these are technologies, packages, [...]]]></description>
			<content:encoded><![CDATA[<p>Somewhat inspired by <a href="http://mtaulty.com/CommunityServer/blogs/mike_taultys_blog/archive/2009/07/02/todo-list.aspx" target="_blank">Mike Taulty&#8217;s blog</a>, I&#8217;ve decided I should throw my Tech TODO list at the world, because it might encourage / guilt me into doing some of them, as well as provide a preview on what this blog might be including over the next few months.</p>
<p>So all of these are technologies, packages, or platforms I want to be checking out in the not-to-distant future.  In no particular order, they&#8217;re bound to be added to as I go and quite possibly ignored as well.</p>
<ul>
<li>.NET
<ul>
<li>ASP.NET MVC</li>
<li>ADO.NET Data Services</li>
<li>F#</li>
<li>IronRuby</li>
<li>Open-sourcing a simple XML resource provider (CodePlex)</li>
<li>.NET 4
<ul>
<li>Windows Communication Foundation</li>
<li>Entity Framework</li>
<li>Parallel Extensions</li>
</ul>
</li>
</ul>
</li>
<li>Gallery3
<ul>
<li>Module development
<ul>
<li>Migrate Twitter module</li>
<li>Migrate auto-GPS-tagging module</li>
</ul>
</li>
<li>Theme development</li>
</ul>
</li>
<li>Google Wave</li>
</ul>
]]></content:encoded>
			<wfw:commentRss>http://www.kevinblake.co.uk/todo/594/feed/</wfw:commentRss>
		<slash:comments>0</slash:comments>
		</item>
		<item>
		<title>Gallery2 remote API C# wrapper</title>
		<link>http://www.kevinblake.co.uk/gallery2-remote-api-c-wrapper/586/</link>
		<comments>http://www.kevinblake.co.uk/gallery2-remote-api-c-wrapper/586/#comments</comments>
		<pubDate>Mon, 29 Jun 2009 17:59:22 +0000</pubDate>
		<dc:creator>Kevin</dc:creator>
				<category><![CDATA[Uncategorized]]></category>
		<category><![CDATA[.net]]></category>
		<category><![CDATA[api]]></category>
		<category><![CDATA[c#]]></category>
		<category><![CDATA[csharp]]></category>
		<category><![CDATA[gallery2]]></category>
		<category><![CDATA[programming]]></category>
		<category><![CDATA[technology]]></category>
		<category><![CDATA[twitter]]></category>

		<guid isPermaLink="false">http://www.kevinblake.co.uk/?p=586</guid>
		<description><![CDATA[I stumbled across the Gallery.NET Toolkit on Twitter, while I should have been doing something more useful; some great work from @rmaclean (thanks for sharing / codeplexing  it). The API wraps up a lot of the Gallery2 remote services into some easy to use C# functions. Hopefully I&#8217;ll find an excuse to use this one day.]]></description>
			<content:encoded><![CDATA[<p>I stumbled across the <a href="http://gallery2.codeplex.com/Release/ProjectReleases.aspx?ReleaseId=29252" target="_blank">Gallery.NET Toolkit</a> on Twitter, while I should have been doing something more useful; some great work from <a href="http://www.twitter.com/rmaclean" target="_blank">@rmaclean</a> (thanks for sharing / codeplexing  it).</p>
<p>The API wraps up a lot of the Gallery2 remote services into some easy to use C# functions.</p>
<div id="wpshdo_13" class="wp-synhighlighter-outer"><div id="wpshdt_13" class="wp-synhighlighter-expanded"><table border="0" width="100%"><tr><td align="left" width="80%"><a name="#codesyntax_13"></a><a id="wpshat_13" class="wp-synhighlighter-title" href="#codesyntax_13"  onClick="javascript:wpsh_toggleBlock(13)" title="Click to show/hide code block">Code block</a></td><td align="right"><a href="#codesyntax_13" onClick="javascript:wpsh_code(13)" title="Show code only"><img border="0" style="border: 0 none" src="http://www.kevinblake.co.uk/wp-content/plugins/wp-synhighlight/themes/default/images/code.png" /></a>&nbsp;<a href="#codesyntax_13" onClick="javascript:wpsh_print(13)" title="Print code"><img border="0" style="border: 0 none" src="http://www.kevinblake.co.uk/wp-content/plugins/wp-synhighlight/themes/default/images/printer.png" /></a>&nbsp;<a href="http://www.kevinblake.co.uk/wp-content/plugins/wp-synhighlight/About.html" target="_blank" title="Show plugin information"><img border="0" style="border: 0 none" src="http://www.kevinblake.co.uk/wp-content/plugins/wp-synhighlight/themes/default/images/info.gif" /></a>&nbsp;</td></tr></table></div><div id="wpshdi_13" class="wp-synhighlighter-inner" style="display: block;"><pre class="csharp" style="font-family:monospace;">Actions a <span class="sy0">=</span> <a href="http://www.google.com/search?q=new+msdn.microsoft.com"><span class="kw3">new</span></a> SADev.<span class="me1">Gallery2</span>.<span class="me1">Protocol</span>.<span class="me1">Actions</span><span class="br0">&#40;</span><span class="st0">&quot;http://www.blakepics.com&quot;</span><span class="br0">&#41;</span><span class="sy0">;</span>
<span class="kw4">string</span> authToken <span class="sy0">=</span> a.<span class="me1">Login</span><span class="br0">&#40;</span><span class="st0">&quot;*************&quot;</span>, <span class="st0">&quot;*************&quot;</span><span class="br0">&#41;</span>.<span class="me1">AuthToken</span><span class="sy0">;</span>
a.<span class="me1">FetchAlbums</span><span class="br0">&#40;</span>authToken<span class="br0">&#41;</span>.<span class="me1">Albums</span>.<span class="kw1">ForEach</span><span class="br0">&#40;</span>
    album <span class="sy0">=&gt;</span>
    <span class="br0">&#123;</span>
        Console.<span class="me1">WriteLine</span><span class="br0">&#40;</span>album.<span class="me1">Title</span><span class="br0">&#41;</span><span class="sy0">;</span>
        a.<span class="me1">FetchImages</span><span class="br0">&#40;</span>authToken, album.<span class="me1">Name</span><span class="br0">&#41;</span>.<span class="me1">Images</span>.<span class="kw1">ForEach</span><span class="br0">&#40;</span>image <span class="sy0">=&gt;</span>
            Console.<span class="me1">WriteLine</span><span class="br0">&#40;</span><span class="st0">&quot;<span class="es0">\t</span>&quot;</span> <span class="sy0">+</span> image.<span class="me1">Url</span><span class="br0">&#41;</span>
        <span class="br0">&#41;</span><span class="sy0">;</span>
    <span class="br0">&#125;</span>
    <span class="br0">&#41;</span><span class="sy0">;</span>
Console.<span class="me1">ReadKey</span><span class="br0">&#40;</span><span class="br0">&#41;</span><span class="sy0">;</span></pre></div></div>
<p>Hopefully I&#8217;ll find an excuse to use this one day.</p>
]]></content:encoded>
			<wfw:commentRss>http://www.kevinblake.co.uk/gallery2-remote-api-c-wrapper/586/feed/</wfw:commentRss>
		<slash:comments>1</slash:comments>
		</item>
		<item>
		<title>Getting document reports from Amazon Seller Central SOAP services (C#)</title>
		<link>http://www.kevinblake.co.uk/getting-document-reports-from-amazon-seller-central-soap-services-c/457/</link>
		<comments>http://www.kevinblake.co.uk/getting-document-reports-from-amazon-seller-central-soap-services-c/457/#comments</comments>
		<pubDate>Sun, 22 Mar 2009 10:29:50 +0000</pubDate>
		<dc:creator>Kevin</dc:creator>
				<category><![CDATA[Uncategorized]]></category>
		<category><![CDATA[.net]]></category>
		<category><![CDATA[amazon]]></category>
		<category><![CDATA[amazon seller central]]></category>
		<category><![CDATA[c#]]></category>
		<category><![CDATA[programming]]></category>
		<category><![CDATA[soap]]></category>
		<category><![CDATA[technology]]></category>
		<category><![CDATA[web services]]></category>

		<guid isPermaLink="false">http://www.kevinblake.co.uk/?p=457</guid>
		<description><![CDATA[Developing against the Amazon API becomes a lot more straightforward with being able to get at the errors with your XML documents. Validating against the XSDs is only part of the solution, but even downloading reports can be tricky. Trouble is, the documentation from Amazon is a very closed &#038; private sort of affair &#8211; [...]]]></description>
			<content:encoded><![CDATA[<p>Developing against the Amazon API becomes a lot more straightforward with being able to get at the errors with your XML documents.  Validating against the XSDs is only part of the solution, but even downloading reports can be tricky.  Trouble is, the documentation from Amazon is a very closed &#038; private sort of affair &#8211; sometimes out of date and sometimes very sparse.  Perhaps they should think about a wiki <img src='http://www.kevinblake.co.uk/wp-includes/images/smilies/icon_smile.gif' alt=':)' class='wp-smiley' /> </p>
<p>Getting at your reports consists of two parts, firstly &#8211; use the Document ID (long) you got from posting the XML in the first place.</p>
<div id="wpshdo_14" class="wp-synhighlighter-outer"><div id="wpshdt_14" class="wp-synhighlighter-expanded"><table border="0" width="100%"><tr><td align="left" width="80%"><a name="#codesyntax_14"></a><a id="wpshat_14" class="wp-synhighlighter-title" href="#codesyntax_14"  onClick="javascript:wpsh_toggleBlock(14)" title="Click to show/hide code block">Code block</a></td><td align="right"><a href="#codesyntax_14" onClick="javascript:wpsh_code(14)" title="Show code only"><img border="0" style="border: 0 none" src="http://www.kevinblake.co.uk/wp-content/plugins/wp-synhighlight/themes/default/images/code.png" /></a>&nbsp;<a href="#codesyntax_14" onClick="javascript:wpsh_print(14)" title="Print code"><img border="0" style="border: 0 none" src="http://www.kevinblake.co.uk/wp-content/plugins/wp-synhighlight/themes/default/images/printer.png" /></a>&nbsp;<a href="http://www.kevinblake.co.uk/wp-content/plugins/wp-synhighlight/About.html" target="_blank" title="Show plugin information"><img border="0" style="border: 0 none" src="http://www.kevinblake.co.uk/wp-content/plugins/wp-synhighlight/themes/default/images/info.gif" /></a>&nbsp;</td></tr></table></div><div id="wpshdi_14" class="wp-synhighlighter-inner" style="display: block;"><pre class="csharp" style="font-family:monospace;"><span class="kw1">public</span> DocumentProcessingInfo DocumentStatus<span class="br0">&#40;</span><span class="kw4">long</span> DocumentID<span class="br0">&#41;</span>
    <span class="br0">&#123;</span>
        <span class="co1">//Setup the service interface, set the URL of the service</span>
        <span class="co1">//and add our credentials.</span>
        merchantinterfacedime myAmazon <span class="sy0">=</span>
            <a href="http://www.google.com/search?q=new+msdn.microsoft.com"><span class="kw3">new</span></a> merchantinterfacedime<span class="br0">&#40;</span><span class="br0">&#41;</span><span class="sy0">;</span>
        myAmazon.<span class="me1">Url</span> <span class="sy0">=</span> ConfigurationManager.<span class="me1">AppSettings</span><span class="br0">&#91;</span><span class="st0">&quot;URL&quot;</span><span class="br0">&#93;</span><span class="sy0">;</span>
        myAmazon.<span class="me1">Credentials</span> <span class="sy0">=</span>
            <a href="http://www.google.com/search?q=new+msdn.microsoft.com"><span class="kw3">new</span></a> NetworkCredential<span class="br0">&#40;</span>
                ConfigurationManager.<span class="me1">AppSettings</span><span class="br0">&#91;</span><span class="st0">&quot;UserName&quot;</span><span class="br0">&#93;</span>,
                ConfigurationManager.<span class="me1">AppSettings</span><span class="br0">&#91;</span><span class="st0">&quot;Password&quot;</span><span class="br0">&#93;</span><span class="br0">&#41;</span><span class="sy0">;</span>
        <span class="co1">//Setup our merchant details.</span>
        Merchant myMerchant <span class="sy0">=</span> <a href="http://www.google.com/search?q=new+msdn.microsoft.com"><span class="kw3">new</span></a> Merchant<span class="br0">&#40;</span><span class="br0">&#41;</span><span class="sy0">;</span>
        myMerchant.<span class="me1">merchantIdentifier</span> <span class="sy0">=</span>
            ConfigurationManager.<span class="me1">AppSettings</span><span class="br0">&#91;</span><span class="st0">&quot;MerchantIdentifier&quot;</span><span class="br0">&#93;</span><span class="sy0">;</span>
        myMerchant.<span class="me1">merchantName</span> <span class="sy0">=</span>
            ConfigurationManager.<span class="me1">AppSettings</span><span class="br0">&#91;</span><span class="st0">&quot;MerchantName&quot;</span><span class="br0">&#93;</span><span class="sy0">;</span>
        <span class="co1">//Send it all off to Amazon.</span>
        DocumentProcessingInfo myStatus <span class="sy0">=</span>
            myAmazon.<span class="me1">getDocumentProcessingStatus</span><span class="br0">&#40;</span>
            myMerchant, DocumentID<span class="br0">&#41;</span><span class="sy0">;</span>
        <span class="co1">//Return the status of the document.</span>
        <span class="kw1">return</span> myStatus<span class="sy0">;</span>
    <span class="br0">&#125;</span></pre></div></div>
<p>This will give you the status of your upload, as well as whether it&#8217;s complete or not.  It also gives you another document ID, which you can use to get at your much-needed reports.</p>
<div id="wpshdo_15" class="wp-synhighlighter-outer"><div id="wpshdt_15" class="wp-synhighlighter-expanded"><table border="0" width="100%"><tr><td align="left" width="80%"><a name="#codesyntax_15"></a><a id="wpshat_15" class="wp-synhighlighter-title" href="#codesyntax_15"  onClick="javascript:wpsh_toggleBlock(15)" title="Click to show/hide code block">Code block</a></td><td align="right"><a href="#codesyntax_15" onClick="javascript:wpsh_code(15)" title="Show code only"><img border="0" style="border: 0 none" src="http://www.kevinblake.co.uk/wp-content/plugins/wp-synhighlight/themes/default/images/code.png" /></a>&nbsp;<a href="#codesyntax_15" onClick="javascript:wpsh_print(15)" title="Print code"><img border="0" style="border: 0 none" src="http://www.kevinblake.co.uk/wp-content/plugins/wp-synhighlight/themes/default/images/printer.png" /></a>&nbsp;<a href="http://www.kevinblake.co.uk/wp-content/plugins/wp-synhighlight/About.html" target="_blank" title="Show plugin information"><img border="0" style="border: 0 none" src="http://www.kevinblake.co.uk/wp-content/plugins/wp-synhighlight/themes/default/images/info.gif" /></a>&nbsp;</td></tr></table></div><div id="wpshdi_15" class="wp-synhighlighter-inner" style="display: block;"><pre class="csharp" style="font-family:monospace;"><span class="kw1">public</span> <span class="kw4">string</span> GetDocument<span class="br0">&#40;</span><span class="kw4">string</span> id<span class="br0">&#41;</span> <span class="br0">&#123;</span>
        StringBuilder report <span class="sy0">=</span> <a href="http://www.google.com/search?q=new+msdn.microsoft.com"><span class="kw3">new</span></a> StringBuilder<span class="br0">&#40;</span><span class="br0">&#41;</span><span class="sy0">;</span>
        merchantinterfacedime myAmazon <span class="sy0">=</span>
            <a href="http://www.google.com/search?q=new+msdn.microsoft.com"><span class="kw3">new</span></a> merchantinterfacedime<span class="br0">&#40;</span><span class="br0">&#41;</span><span class="sy0">;</span>
        myAmazon.<span class="me1">Url</span> <span class="sy0">=</span> ConfigurationManager.<span class="me1">AppSettings</span><span class="br0">&#91;</span><span class="st0">&quot;URL&quot;</span><span class="br0">&#93;</span><span class="sy0">;</span>
        myAmazon.<span class="me1">Credentials</span> <span class="sy0">=</span>
            <a href="http://www.google.com/search?q=new+msdn.microsoft.com"><span class="kw3">new</span></a> NetworkCredential<span class="br0">&#40;</span>
                ConfigurationManager.<span class="me1">AppSettings</span><span class="br0">&#91;</span><span class="st0">&quot;UserName&quot;</span><span class="br0">&#93;</span>,
                ConfigurationManager.<span class="me1">AppSettings</span><span class="br0">&#91;</span><span class="st0">&quot;Password&quot;</span><span class="br0">&#93;</span><span class="br0">&#41;</span><span class="sy0">;</span>
        <span class="co1">//Setup our merchant details.</span>
        Merchant myMerchant <span class="sy0">=</span> <a href="http://www.google.com/search?q=new+msdn.microsoft.com"><span class="kw3">new</span></a> Merchant<span class="br0">&#40;</span><span class="br0">&#41;</span><span class="sy0">;</span>
        myMerchant.<span class="me1">merchantIdentifier</span> <span class="sy0">=</span>
            ConfigurationManager.<span class="me1">AppSettings</span><span class="br0">&#91;</span><span class="st0">&quot;MerchantIdentifier&quot;</span><span class="br0">&#93;</span><span class="sy0">;</span>
        myMerchant.<span class="me1">merchantName</span> <span class="sy0">=</span>
            ConfigurationManager.<span class="me1">AppSettings</span><span class="br0">&#91;</span><span class="st0">&quot;MerchantName&quot;</span><span class="br0">&#93;</span><span class="sy0">;</span>
        ReferencedBinary incomingDoc <span class="sy0">=</span> <a href="http://www.google.com/search?q=new+msdn.microsoft.com"><span class="kw3">new</span></a> ReferencedBinary<span class="br0">&#40;</span><span class="br0">&#41;</span><span class="sy0">;</span>
        <span class="co1">// the seven-digit string is the document ID number</span>
        myAmazon.<span class="me1">getDocument</span><span class="br0">&#40;</span>myMerchant, id, <span class="kw1">out</span> incomingDoc<span class="br0">&#41;</span><span class="sy0">;</span>
        IEnumerator enumer <span class="sy0">=</span> myAmazon.<span class="me1">ResponseSoapContext</span>.<span class="me1">Attachments</span>.<span class="me1">GetEnumerator</span><span class="br0">&#40;</span><span class="br0">&#41;</span><span class="sy0">;</span>
        <span class="kw1">while</span> <span class="br0">&#40;</span>enumer.<span class="me1">MoveNext</span><span class="br0">&#40;</span><span class="br0">&#41;</span><span class="br0">&#41;</span>
        <span class="br0">&#123;</span>
            <span class="co1">// Print the document to standard out</span>
            Attachment downloadedDoc <span class="sy0">=</span> enumer.<span class="me1">Current</span> <span class="kw1">as</span> Attachment<span class="sy0">;</span>
            StreamReader r <span class="sy0">=</span> <a href="http://www.google.com/search?q=new+msdn.microsoft.com"><span class="kw3">new</span></a> StreamReader<span class="br0">&#40;</span>downloadedDoc.<span class="me1">Stream</span><span class="br0">&#41;</span><span class="sy0">;</span>
            report.<span class="me1">Append</span><span class="br0">&#40;</span>r.<span class="me1">ReadToEnd</span><span class="br0">&#40;</span><span class="br0">&#41;</span><span class="br0">&#41;</span><span class="sy0">;</span>
        <span class="br0">&#125;</span>
        <span class="kw1">return</span> report.<span class="me1">ToString</span><span class="br0">&#40;</span><span class="br0">&#41;</span><span class="sy0">;</span>
<span class="br0">&#125;</span></pre></div></div>
<p>And tying it all together:</p>
<div id="wpshdo_16" class="wp-synhighlighter-outer"><div id="wpshdt_16" class="wp-synhighlighter-expanded"><table border="0" width="100%"><tr><td align="left" width="80%"><a name="#codesyntax_16"></a><a id="wpshat_16" class="wp-synhighlighter-title" href="#codesyntax_16"  onClick="javascript:wpsh_toggleBlock(16)" title="Click to show/hide code block">Code block</a></td><td align="right"><a href="#codesyntax_16" onClick="javascript:wpsh_code(16)" title="Show code only"><img border="0" style="border: 0 none" src="http://www.kevinblake.co.uk/wp-content/plugins/wp-synhighlight/themes/default/images/code.png" /></a>&nbsp;<a href="#codesyntax_16" onClick="javascript:wpsh_print(16)" title="Print code"><img border="0" style="border: 0 none" src="http://www.kevinblake.co.uk/wp-content/plugins/wp-synhighlight/themes/default/images/printer.png" /></a>&nbsp;<a href="http://www.kevinblake.co.uk/wp-content/plugins/wp-synhighlight/About.html" target="_blank" title="Show plugin information"><img border="0" style="border: 0 none" src="http://www.kevinblake.co.uk/wp-content/plugins/wp-synhighlight/themes/default/images/info.gif" /></a>&nbsp;</td></tr></table></div><div id="wpshdi_16" class="wp-synhighlighter-inner" style="display: block;"><pre class="csharp" style="font-family:monospace;"><span class="kw4">long</span> amazonId <span class="sy0">=</span> <span class="co2">#######</span>
<span class="kw4">string</span> report <span class="sy0">=</span> GetDocument<span class="br0">&#40;</span>DocumentStatus<span class="br0">&#40;</span>amazonId<span class="br0">&#41;</span>.<span class="me1">processingReport</span>.<span class="me1">documentID</span><span class="br0">&#41;</span><span class="sy0">;</span></pre></div></div>
<p>Your report will be in XML, and give you any validation errors that might be preventing your feed from working properly, as well as some very helpful status on the number of items processed.  How did you ever live without it?</p>
]]></content:encoded>
			<wfw:commentRss>http://www.kevinblake.co.uk/getting-document-reports-from-amazon-seller-central-soap-services-c/457/feed/</wfw:commentRss>
		<slash:comments>6</slash:comments>
		</item>
		<item>
		<title>Twitter &#8211; Conversation in the Machine</title>
		<link>http://www.kevinblake.co.uk/twitter-conversation-in-the-machine/184/</link>
		<comments>http://www.kevinblake.co.uk/twitter-conversation-in-the-machine/184/#comments</comments>
		<pubDate>Thu, 31 Jul 2008 18:49:29 +0000</pubDate>
		<dc:creator>Kevin</dc:creator>
				<category><![CDATA[Uncategorized]]></category>
		<category><![CDATA[linux]]></category>
		<category><![CDATA[mashup]]></category>
		<category><![CDATA[perl]]></category>
		<category><![CDATA[programming]]></category>
		<category><![CDATA[technology]]></category>
		<category><![CDATA[twitter]]></category>

		<guid isPermaLink="false">http://www.kevinblake.co.uk/?p=184</guid>
		<description><![CDATA[It&#8217;s another of those life-changing technologies which will not only improve the way you interact your fellow humans across the planet, but also shape and change the web as we know it for a brighter future beyond our current limited borders. No it&#8217;s not. It&#8217;s a micro-blogging tool which performs about the same function as [...]]]></description>
			<content:encoded><![CDATA[<p>It&#8217;s another of those life-changing technologies which will not only improve the way you interact your fellow humans across the planet, but also shape and change the web as we know it for a brighter future beyond our current limited borders.</p>
<p>No it&#8217;s not.</p>
<p>It&#8217;s a micro-blogging tool which performs about the same function as your Facebook status, with a bit more history and more conversation potential than real speaking.  It also falls into the category of &#8220;shiny web things&#8221; that the magpie&#8217;s of the Internet world run bounding towards with wings flapping, declaring their undying allegiance and overwhelming excitement about the grand new era of technology, society and communication.</p>
<p>I am said magpie.  I just haven&#8217;t had much use for it, so whilst most people are bounding towards <a href="http://pownce.com/" target="_blank">Pownce</a> with their wings wide open, I&#8217;m still trying to find an excuse.</p>
<p>My <a href="http://twitter.com/puzzlebox" target="_blank">Twitter feed</a> is decidedly empty, having originally opened it as a way only of updating my Facebook status before I realised that was syndication for the sake of it (See integrations with <a href="http://blog.brightkite.com/" target="_blank">BrightKite</a>, <a href="http://www.loopt.com/" target="_blank">Loopt</a>, and <a href="http://flickr.twittergram.com/" target="_blank">Flickr </a>integration for reference).  But I do get a kick out of things like the <a href="http://infovore.org/archives/2008/02/28/making-bridges-talk/" target="_blank">Tower Bridge Tweets</a>.  The wonderful thing about this Web 2.0 stuff is that you don&#8217;t have to use any of it for what it was intended for (which is usually so vague and fluffy, it only really starts to take shape after the rules have been broken).</p>
<p>So I grabbed a copy of the <a href="http://search.cpan.org/~cthom/Net-Twitter-1.14/lib/Net/Twitter.pm" target="_blank">Net::Twitter module</a> for Perl and before you know it, my script that monitors if the Wifi connection on the <a href="http://www.blakepics.com" target="_blank">Blakepics </a>server had gone down was <a href="http://www.twitter.com/puzzleboxneco" target="_blank">happily tweeting away</a> with only three more lines of (my) code.</p>
<p><code>use Net::Twitter;<br />
my $twit = Net::Twitter-&gt;new(username=&gt;"<em>username</em>", password=&gt;"<em>password</em>",  source =&gt; "DowntimeMonitor" );<br />
$twit-&gt;update("Internet connection ".($state ? "is now up" : "has been restarted"));</code></p>
]]></content:encoded>
			<wfw:commentRss>http://www.kevinblake.co.uk/twitter-conversation-in-the-machine/184/feed/</wfw:commentRss>
		<slash:comments>4</slash:comments>
		</item>
	</channel>
</rss>
