<?xml version="1.0" encoding="UTF-8"?>
<?xml-stylesheet href="http://feeds.feedburner.com/~d/styles/rss2full.xsl" type="text/xsl" media="screen"?><?xml-stylesheet href="http://feeds.feedburner.com/~d/styles/itemcontent.css" type="text/css" media="screen"?><!-- generator="wordpress/2.2" --><rss 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:feedburner="http://rssnamespace.org/feedburner/ext/1.0" version="2.0">

<channel>
	<title>Eribium</title>
	<link>http://www.eribium.org/blog</link>
	<description>18yr old hacking away at Ruby on Rails and Flex</description>
	<pubDate>Thu, 12 Jun 2008 19:53:33 +0000</pubDate>
	<generator>http://wordpress.org/?v=2.2</generator>
	<language>en</language>
			<atom10:link xmlns:atom10="http://www.w3.org/2005/Atom" rel="self" href="http://feeds.feedburner.com/Eribium" type="application/rss+xml" /><feedburner:emailServiceId>277241</feedburner:emailServiceId><feedburner:feedburnerHostname>http://www.feedburner.com</feedburner:feedburnerHostname><item>
		<title>CSRF &amp; Working With Rails</title>
		<link>http://feeds.feedburner.com/~r/Eribium/~3/310512045/</link>
		<comments>http://www.eribium.org/blog/?p=189#comments</comments>
		<pubDate>Thu, 12 Jun 2008 16:32:22 +0000</pubDate>
		<dc:creator>maccman</dc:creator>
		
		<category><![CDATA[Rails]]></category>

		<guid isPermaLink="false">http://www.eribium.org/blog/?p=189</guid>
		<description><![CDATA[About a week ago Mislav Marohnic wrote about a simple CSRF attack on Working with Rails.
What Mislav exploited was the fact that Working With Rails didn&#8217;t require a POST request to create recommendations, so just by visiting his blog you&#8217;d inadvertadly recommend him (if you were logged into WWR).
In less than 24 hours Mislav got [...]]]></description>
			<content:encoded><![CDATA[<p>About a week ago <a href="http://mislav.caboo.se">Mislav Marohnic</a> <a href="http://mislav.caboo.se/rails/excercise-in-csrf/">wrote</a> about a simple CSRF attack on <a href="http://workingwithrails.com/person/13081-alex-maccaw">Working with Rails</a>.</p>
<p>What Mislav exploited was the fact that Working With Rails didn&#8217;t require a POST request to create recommendations, so just by visiting his blog you&#8217;d inadvertadly recommend him (if you were logged into WWR).<br />
In less than 24 hours Mislav got enough recommendations to boost his raking by 10 places.</p>
<p>WWR fixed that particular hack, they disallowed GET requests to the create action, only allowing POST ones.</p>
<p>However, <strong>they certainly haven&#8217;t solved the problem</strong>. It&#8217;s possible to make cross site POST requests without the user actively submitting a form. <a href="http://pastie.org/213772">This script</a> I made creates an iframe with a form inside, and submits the form. So, without a user realizing it, they&#8217;ve recommended me on WWR (I haven&#8217;t used it in this site btw).</p>
<p>It just shows that it&#8217;s fundamentally important to use a form authentication token (which Rails 2 now does by default) to prevent CSRF.</p>
<p>And, it&#8217;s worth bearing in mind that an open <a href="http://jeremiahgrossman.blogspot.com/2008/05/crossdomainxml-invites-cross-site.html">crossdomain.xml file </a> would make any CSRF protections absolutely worthless, since you could go and grab that form authentication token with Flash.</p>
<img src="http://feeds.feedburner.com/~r/Eribium/~4/310512045" height="1" width="1"/>]]></content:encoded>
			<wfw:commentRss>http://www.eribium.org/blog/?feed=rss2&amp;p=189</wfw:commentRss>
		<feedburner:awareness>http://api.feedburner.com/awareness/1.0/GetItemData?uri=Eribium&amp;itemurl=http%3A%2F%2Fwww.eribium.org%2Fblog%2F%3Fp%3D189</feedburner:awareness><feedburner:origLink>http://www.eribium.org/blog/?p=189</feedburner:origLink></item>
		<item>
		<title>Airdoc - Google Doc Uploader</title>
		<link>http://feeds.feedburner.com/~r/Eribium/~3/270745443/</link>
		<comments>http://www.eribium.org/blog/?p=187#comments</comments>
		<pubDate>Tue, 15 Apr 2008 14:36:26 +0000</pubDate>
		<dc:creator>maccman</dc:creator>
		
		<category><![CDATA[Air (Apollo)]]></category>

		<guid isPermaLink="false">http://www.eribium.org/blog/?p=187</guid>
		<description><![CDATA[If you die a little inside when someone sends you a Word/Excel/Powerpoint document to read then Airdoc is for you!
The other day someone sent me a Powerpoint file containing some screenshots, wrong on so many levels, but perhaps some good will come out of it since it motivated  me to write this simple Air [...]]]></description>
			<content:encoded><![CDATA[<p>If you die a little inside when someone sends you a Word/Excel/Powerpoint document to read then Airdoc is for you!</p>
<p>The other day someone sent me a Powerpoint file containing some screenshots, wrong on so many levels, but perhaps some good will come out of it since it motivated  me to write this simple Air app.</p>
<p>Airdoc is a very simple Air application that registers itself to open those Office documents. It&#8217;ll then proceed to upload them to Google Docs - and open them right in your browser.</p>
<p>You&#8217;ll need to install <a href="http://get.adobe.com/air/">Adobe Air</a> first.</p>
<p><a href="http://maccman.s3.amazonaws.com/airdoc.air">Download Airdoc</a>.</p>
<img src="http://feeds.feedburner.com/~r/Eribium/~4/270745443" height="1" width="1"/>]]></content:encoded>
			<wfw:commentRss>http://www.eribium.org/blog/?feed=rss2&amp;p=187</wfw:commentRss>
		<feedburner:awareness>http://api.feedburner.com/awareness/1.0/GetItemData?uri=Eribium&amp;itemurl=http%3A%2F%2Fwww.eribium.org%2Fblog%2F%3Fp%3D187</feedburner:awareness><feedburner:origLink>http://www.eribium.org/blog/?p=187</feedburner:origLink></item>
		<item>
		<title>We don’t need mod_rails - we need mod_rack</title>
		<link>http://feeds.feedburner.com/~r/Eribium/~3/270610962/</link>
		<comments>http://www.eribium.org/blog/?p=188#comments</comments>
		<pubDate>Tue, 15 Apr 2008 10:14:42 +0000</pubDate>
		<dc:creator>maccman</dc:creator>
		
		<category><![CDATA[Ruby]]></category>

		<category><![CDATA[Rails]]></category>

		<guid isPermaLink="false">http://www.eribium.org/blog/?p=188</guid>
		<description><![CDATA[Mod rails is certainly a step in the right direction - but I think a much better idea would be to implement support for Rack. 
Rack is an abstraction between Webservers and Ruby web frameworks. Thin, for example, uses this to great effect - by using Rack, Thin automatically supports tons of Ruby web frameworks [...]]]></description>
			<content:encoded><![CDATA[<p><a href="http://www.modrails.com">Mod rails</a> is certainly a step in the right direction - but I think a much better idea would be to implement support for <a href="http://rack.rubyforge.org">Rack</a>. </p>
<p>Rack is an abstraction between Webservers and Ruby web frameworks. <a href="http://code.macournoyer.com/thin/">Thin</a>, for example, uses this to great effect - by using Rack, Thin automatically supports tons of Ruby web frameworks out of the box:</p>
<ul>
<li>Camping</li>
<li>Coset</li>
<li>Halcyon</li>
<li>Maveric</li>
<li>Merb</li>
<li>Ramaze</li>
<li>Sinatra</li>
<li>Vintage</li>
</ul>
<p>There is also a Rails adapter to Rack (in the Thin repo)</p>
<p>So, wouldn&#8217;t it make more sense for the mod_rails team to work on mod_rack? Then you could upload a simple Ruby script like this to your webserver, and it would just work:</p>
<p>rack_app = Proc.new do |env|<br />
  [200, {&#8221;Content-Type&#8221;=>&#8221;text/html&#8221;}, &#8220;hello world!&#8221;]<br />
end<br />
run rack_app</p>
<img src="http://feeds.feedburner.com/~r/Eribium/~4/270610962" height="1" width="1"/>]]></content:encoded>
			<wfw:commentRss>http://www.eribium.org/blog/?feed=rss2&amp;p=188</wfw:commentRss>
		<feedburner:awareness>http://api.feedburner.com/awareness/1.0/GetItemData?uri=Eribium&amp;itemurl=http%3A%2F%2Fwww.eribium.org%2Fblog%2F%3Fp%3D188</feedburner:awareness><feedburner:origLink>http://www.eribium.org/blog/?p=188</feedburner:origLink></item>
		<item>
		<title>IPlayer RSS Feed</title>
		<link>http://feeds.feedburner.com/~r/Eribium/~3/250732496/</link>
		<comments>http://www.eribium.org/blog/?p=186#comments</comments>
		<pubDate>Thu, 13 Mar 2008 12:28:34 +0000</pubDate>
		<dc:creator>maccman</dc:creator>
		
		<category><![CDATA[Uncategorized]]></category>

		<guid isPermaLink="false">http://www.eribium.org/blog/?p=186</guid>
		<description><![CDATA[Update: download has been cracked again.
After Paul&#8217;s neat hack to allow downloading of IPlayer programs, I thought I&#8217;d also improve the IPlayer&#8217;s pink experience by providing an RSS feed. 
The Big British Castle, in their infinite wisdom, don&#8217;t provide a feed to the IPlayer, but instead email you updates - how antiquated is that!
So, I&#8217;ve [...]]]></description>
			<content:encoded><![CDATA[<p><strong>Update:</strong> download has been cracked <a href="http://po-ru.com/diary/bbc-iplayer-fix-hacked-again/">again</a>.</p>
<p>After <a href="http://po-ru.com/diary/cracking-open-the-iplayer/">Paul&#8217;s neat hack</a> to allow downloading of <a href="http://www.bbc.co.uk/iplayer">IPlayer</a> programs, I thought I&#8217;d also improve the IPlayer&#8217;s pink experience by providing an RSS feed. </p>
<p>The <a href="http://www.bbc.co.uk">Big British Castle</a>, in their infinite wisdom, don&#8217;t provide a feed to the IPlayer, but instead email you updates - how antiquated is that!</p>
<p>So, I&#8217;ve made a simple script that scrapes their website (with Hpricot), and constructs a RSS feed. And I have a cron job that runs it daily.<br />
For example:<br />
./iplayer-feed /path/to/apache/public/dir/iplayer-feed.rss<br />
Or in the crontab:<br />
20 4 * * * /path/to/iplayer-feed /path/to/apache/public/dir/iplayer-feed.rss  >/dev/null</p>
<p>Originally I subscribed to the daily updates (as you can see from the code). However - I underestimated how much unwatchable content they make, so I had to cut back to a few categories. Since everyone&#8217;s taste is different, I&#8217;d thought I&#8217;d post the code, rather than host the feed, so people can customise it to suit themselves. </p>
<p>So, just browse the IPlayer site, choose a few categories, and paste the urls into the code. Or, take the full plunge, and subscribe to the daily updates (don&#8217;t say I didn&#8217;t warn you).</p>
<p>Anyway, here&#8217;s the <a href="http://www.eribium.org/blog/wp-content/uploads/iplayer-feed">code</a>.</p>
<img src="http://feeds.feedburner.com/~r/Eribium/~4/250732496" height="1" width="1"/>]]></content:encoded>
			<wfw:commentRss>http://www.eribium.org/blog/?feed=rss2&amp;p=186</wfw:commentRss>
		<feedburner:awareness>http://api.feedburner.com/awareness/1.0/GetItemData?uri=Eribium&amp;itemurl=http%3A%2F%2Fwww.eribium.org%2Fblog%2F%3Fp%3D186</feedburner:awareness><feedburner:origLink>http://www.eribium.org/blog/?p=186</feedburner:origLink></item>
		<item>
		<title>EventMachine VS Twisted</title>
		<link>http://feeds.feedburner.com/~r/Eribium/~3/241600771/</link>
		<comments>http://www.eribium.org/blog/?p=184#comments</comments>
		<pubDate>Tue, 26 Feb 2008 17:18:30 +0000</pubDate>
		<dc:creator>maccman</dc:creator>
		
		<category><![CDATA[Uncategorized]]></category>

		<guid isPermaLink="false">http://www.eribium.org/blog/?p=184</guid>
		<description><![CDATA[I was interested in the performance differences between Twisted and EventMachine for an application I&#8217;ve developing which is going to have to handle a lot of load as clients will be regularly polling it.
Disclaimer: I&#8217;m fairly new to Python and Twisted  - so there may be a way of speeding them up which I&#8217;m [...]]]></description>
			<content:encoded><![CDATA[<p>I was interested in the performance differences between <a class="ext-link" href="http://twistedmatrix.com/"><span class="icon">Twisted</span></a> and <a class="wiki" href="http://www.rubyeventmachine.com">EventMachine</a> for an application I&#8217;ve developing which is going to have to handle a lot of load as clients will be regularly polling it.</p>
<p><strong>Disclaimer:</strong> I&#8217;m fairly new to Python and Twisted  - so there may be a way of speeding them up which I&#8217;m not aware of - perhaps by compiling to byte code or using a stackless interpreter. </p>
<p>Rather than test performance at a TCP level, I thought I&#8217;d do more of a real world example - and test HTTP servers. <a class="ext-link" href="http://code.macournoyer.com/thin/"><span class="icon">Thin</span></a> (combined with <a class="ext-link" href="http://rack.rubyforge.org"><span class="icon">Rack</span></a>) is a HTTP layer to <a class="wiki" href="http://www.rubyeventmachine.com">EventMachine</a>. Twisted has its own HTTP parser built in. </p>
<h2>Results (recorded with ab)</h2>
<p>Concurrency: 20<br />
Requests: 2000</p>
<p><strong>EventMachine:</strong> Requests per second:    3327.79/sec (mean)<br />
<strong>Twisted:</strong>      Requests per second:    3194.76/sec (mean)</p>
<p>Concurrency: 200<br />
Requests: 20000</p>
<p><strong>EventMachine:</strong> Requests per second:    4401.80/sec (mean)<br />
<strong>Twisted:</strong>      Requests per second:    4761.90/sec (mean)</p>
<h2>Conclusion</h2>
<p>Take these tests with a pinch of salt, as the old saying goes something along the lines of &#8216;There are lies, damned lies, and then there are statistics&#8217;.</p>
<p>The results are remarkably similar - with EM beating Twisted at some concurrency levels, and vica versa. There doesn&#8217;t seem to be an obvious difference in requests per second - even with an extremely large volume of requests.</p>
<p>To be honest, I&#8217;m a bit surprised. Ruby isn&#8217;t know for it&#8217;s speed, and we&#8217;re already using 2 more gems, Thin and Rack which, although they are as light as possible, still add overhead.</p>
<p>When it comes down to virtual memory Ruby uses a hefty 47 mb, but Python isn&#8217;t much better at 39 mb. I don&#8217;t suppose that would be a deal breaker for most people though.</p>
<p>I call it a draw ;)</p>
<p>You can see the code I used <a href="http://rubyeventmachine.com/wiki/EMvsTwisted">here</a>.</p>
<img src="http://feeds.feedburner.com/~r/Eribium/~4/241600771" height="1" width="1"/>]]></content:encoded>
			<wfw:commentRss>http://www.eribium.org/blog/?feed=rss2&amp;p=184</wfw:commentRss>
		<feedburner:awareness>http://api.feedburner.com/awareness/1.0/GetItemData?uri=Eribium&amp;itemurl=http%3A%2F%2Fwww.eribium.org%2Fblog%2F%3Fp%3D184</feedburner:awareness><feedburner:origLink>http://www.eribium.org/blog/?p=184</feedburner:origLink></item>
		<item>
		<title>Aireo Beta</title>
		<link>http://feeds.feedburner.com/~r/Eribium/~3/236581306/</link>
		<comments>http://www.eribium.org/blog/?p=183#comments</comments>
		<pubDate>Sun, 17 Feb 2008 18:30:27 +0000</pubDate>
		<dc:creator>maccman</dc:creator>
		
		<category><![CDATA[Aireo]]></category>

		<guid isPermaLink="false">http://www.eribium.org/blog/?p=183</guid>
		<description><![CDATA[Well, it&#8217;s been a while but the private beta of Aireo has been released. You can signup for the beta here. I can&#8217;t promise invites for everyone, but I&#8217;ll do my best.
Aireo is an digital asset solution, letting you simply upload your files to the internet, keeping them backed up safety, and providing a intuitive [...]]]></description>
			<content:encoded><![CDATA[<p>Well, it&#8217;s been a while but the private beta of <a href="http://aireohq.com">Aireo</a> has been released. You can signup for the beta <a href="http://signup.aireohq.com/">here</a>. I can&#8217;t promise invites for everyone, but I&#8217;ll do my best.</p>
<p>Aireo is an digital asset solution, letting you simply upload your files to the internet, keeping them backed up safety, and providing a intuitive interface to access them anywhere.<br />
On top of this, Aireo&#8217;s sharing capabilities allow you to email files and create links to them (shown in the last screenshot).</p>
<p><a href="http://www.flickr.com/photos/maccman/2266491765/" title="Aireo by maccman, on Flickr"><img src="http://farm3.static.flickr.com/2173/2266491765_604a077e4a.jpg" width="500" height="241" alt="Aireo" /></a></p>
<p><a href="http://www.flickr.com/photos/maccman/2152607635/" title="Aireo Link by maccman, on Flickr"><img src="http://farm3.static.flickr.com/2013/2152607635_42ed28b3f5.jpg" width="500" height="179" alt="Aireo Link" /></a></p>
<p>I&#8217;m also working on a client side part of Aireo which will be released next.</p>
<img src="http://feeds.feedburner.com/~r/Eribium/~4/236581306" height="1" width="1"/>]]></content:encoded>
			<wfw:commentRss>http://www.eribium.org/blog/?feed=rss2&amp;p=183</wfw:commentRss>
		<feedburner:awareness>http://api.feedburner.com/awareness/1.0/GetItemData?uri=Eribium&amp;itemurl=http%3A%2F%2Fwww.eribium.org%2Fblog%2F%3Fp%3D183</feedburner:awareness><feedburner:origLink>http://www.eribium.org/blog/?p=183</feedburner:origLink></item>
		<item>
		<title>Sparrow - speedy queue that speaks memcached</title>
		<link>http://feeds.feedburner.com/~r/Eribium/~3/175866282/</link>
		<comments>http://www.eribium.org/blog/?p=180#comments</comments>
		<pubDate>Sat, 27 Oct 2007 15:56:24 +0000</pubDate>
		<dc:creator>maccman</dc:creator>
		
		<category><![CDATA[Queue]]></category>

		<category><![CDATA[Ruby]]></category>

		<guid isPermaLink="false">http://www.eribium.org/blog/?p=180</guid>
		<description><![CDATA[I&#8217;ve recently been researching alternate queues to ActiveMq and it struck me how few there were. Others have commented on the different options; suffice to say I was disappointed. 
My experience with queues in general suggests that most of the time you don&#8217;t need anything complicated at all and the biggest concern is performance and [...]]]></description>
			<content:encoded><![CDATA[<p>I&#8217;ve recently been researching alternate queues to <a href="http://activemq.apache.org/">ActiveMq</a> and it struck me how few there were. Others have commented on the different <a href="http://blog.nbwd.co.uk/2007/9/5/didn-t-you-get-the-memo">options</a>; suffice to say I was disappointed. </p>
<p>My experience with queues in general suggests that most of the time you don&#8217;t need anything complicated at all and the biggest concern is performance and stability.</p>
<p><a href="http://www.eribium.org/blog/?p=174">I&#8217;ve used</a> <a href="http://www.amazon.com/Simple-Queue-Service-home-page/b?ie=UTF8&#038;node=13584001">SQS</a>, but I think even that goes too far with message ids and explicit message deletion.</p>
<p>All you really need is &#8217;set&#8217; and &#8216;get&#8217;, basically just the memcached protocol.<br />
Twitter seem to have produced their own messaging queue, called Starling, that works on this principle; but, as far as know, it hasn&#8217;t been open sourced. </p>
<p>So, last night, I wrote my own, called Sparrow. It&#8217;s in early stages at the moment, but you can <a href="http://sparrow.googlecode.com/svn/trunk/">grab the code</a> from the <a href="http://code.google.com/p/sparrow/">Google project</a>. </p>
<p>The advantage of using a simple protocol like memcached is that there are lots of other client libraries out there that will support it already.</p>
<p>Sparrow comes with built in support for daemonization and clustering. Also included are example libraries and clients. For example:</p>
<pre class="prettyprint">require 'memcached'
m = MemCache.new('127.0.0.1:11211', '127.0.0.1:11212', '127.0.0.1:11213')
m['queue_name'] = '1' # Publish to queue
m['queue_name']       #=&gt; 1 Pull next msg from queue
m['queue_name']       #=&gt; nil
m.delete('queue_name) # Delete queue

# or using the included client:

class MyQueue &lt; MemCacheQueue
  def on_message
    logger.info "Received msg with args: #{args.inspect}"
  end
end

MemCacheQueue.connect('127.0.0.1:11211')
MyQueue.publish('test msg')
MyQueue.run(true)</pre>
<p>I&#8217;ve yet to run any proper tests, but early indications suggest that Sparrow processes messages at a rate of 850-900 per second (per client) which obviously depends on any clustering you&#8217;re doing. You can even open up several streams to Sparrow, since it uses eventmachine and has a non-blocking io, so it may not be necessary to have more daemons running. In a cluster of three, I can get message processing up to the 3000 per second mark.</p>
<p>Ideally Sparrow would be ported to a faster language (perhaps just pure C) than Ruby.</p>
<p>Anyways, It would be good to have some feedback - especially on code optimizations. For example, I don&#8217;t think the way I find messages after they&#8217;ve been saved is particularly fast.</p>
<img src="http://feeds.feedburner.com/~r/Eribium/~4/175866282" height="1" width="1"/>]]></content:encoded>
			<wfw:commentRss>http://www.eribium.org/blog/?feed=rss2&amp;p=180</wfw:commentRss>
		<feedburner:awareness>http://api.feedburner.com/awareness/1.0/GetItemData?uri=Eribium&amp;itemurl=http%3A%2F%2Fwww.eribium.org%2Fblog%2F%3Fp%3D180</feedburner:awareness><feedburner:origLink>http://www.eribium.org/blog/?p=180</feedburner:origLink></item>
		<item>
		<title>Active Resource and Serialised columns</title>
		<link>http://feeds.feedburner.com/~r/Eribium/~3/172074816/</link>
		<comments>http://www.eribium.org/blog/?p=179#comments</comments>
		<pubDate>Fri, 19 Oct 2007 13:46:00 +0000</pubDate>
		<dc:creator>maccman</dc:creator>
		
		<category><![CDATA[Active Resource (REST)]]></category>

		<guid isPermaLink="false">http://www.eribium.org/blog/?p=179</guid>
		<description><![CDATA[Currently using serialised columns with Active Resource is broken. To serialize xml, Active Resource uses Active Support&#8217;s to_xml method which seems to have a few problems.
&#62;&#62; {:ruby_symbol =&#62; :sym}.to_xml
=&#62; &#60;?xml version=&#34;1.0&#34; encoding=&#34;UTF-8&#34;?&#62;&#60;hash&#62;&#60;ruby-symbol:sym/&#62;&#60;/hash&#62;
What is ruby-symbol:sym I ask you! Rails obviously chokes on this xml and your post/put fails. However, serializing Active Record objects works fine:
&#62;&#62; User.find(:first).to_xml
=&#62; [...]]]></description>
			<content:encoded><![CDATA[<p>Currently using serialised columns with Active Resource is broken. To serialize xml, Active Resource uses Active Support&#8217;s to_xml method which seems to have a few problems.</p>
<p>&gt;&gt; {:ruby_symbol =&gt; :sym}.to_xml<br />
=&gt; &lt;?xml version=&quot;1.0&quot; encoding=&quot;UTF-8&quot;?&gt;&lt;hash&gt;&lt;ruby-symbol:sym/&gt;&lt;/hash&gt;</p>
<p>What is ruby-symbol:sym I ask you! Rails obviously chokes on this xml and your post/put fails. However, serializing Active Record objects works fine:</p>
<p>&gt;&gt; User.find(:first).to_xml<br />
=&gt; &lt;?xml version=&quot;1.0&quot; encoding=&quot;UTF-8&quot;?&gt;&lt;user&gt;&lt;ruby-symbol type=&quot;yaml&quot;&gt;&#8212; :sym\n&lt;/ruby-symbol&gt;&lt;/user&gt;</p>
<p>So the problem is that Active Support&#8217;s serialization has got a bit of catchup to do with Active Record&#8217;s.<br />
The next two lines are a quick and dirty way of fixing it for symbols (which is the only serialization I use) for the meantime, but I hope this will be fixed by the time Rails 2 comes. You can obviously add copies for Arrays etc.</p>
<p>ActiveSupport::CoreExtensions::Hash::Conversions::XML_TYPE_NAMES[&#8217;Symbol&#8217;] = &#8216;yaml&#8217;<br />
ActiveSupport::CoreExtensions::Hash::Conversions::XML_FORMATTING[&#8217;symbol&#8217;] = Proc.new {|symbol| symbol.to_yaml }</p>
<p><strong>Update</strong><br />
That was quick. I&#8217;ve been keeping an eye on the Rails edge changesets and it&#8217;s <a href="http://dev.rubyonrails.org/ticket/9954#comment:1">been fixed</a>. Thanks Assaf.</p>
<img src="http://feeds.feedburner.com/~r/Eribium/~4/172074816" height="1" width="1"/>]]></content:encoded>
			<wfw:commentRss>http://www.eribium.org/blog/?feed=rss2&amp;p=179</wfw:commentRss>
		<feedburner:awareness>http://api.feedburner.com/awareness/1.0/GetItemData?uri=Eribium&amp;itemurl=http%3A%2F%2Fwww.eribium.org%2Fblog%2F%3Fp%3D179</feedburner:awareness><feedburner:origLink>http://www.eribium.org/blog/?p=179</feedburner:origLink></item>
		<item>
		<title>Ruby SQS Plugin V 0.2</title>
		<link>http://feeds.feedburner.com/~r/Eribium/~3/164645010/</link>
		<comments>http://www.eribium.org/blog/?p=177#comments</comments>
		<pubDate>Wed, 03 Oct 2007 11:04:32 +0000</pubDate>
		<dc:creator>maccman</dc:creator>
		
		<category><![CDATA[Ruby]]></category>

		<category><![CDATA[SQS]]></category>

		<category><![CDATA[Rails]]></category>

		<guid isPermaLink="false">http://www.eribium.org/blog/?p=177</guid>
		<description><![CDATA[I&#8217;ve updated Mq.
There was a major bug, where messages were picked up more than once which is now sorted.
Also, you can automatically create more pollers per queue, like so:

  Mq.run_all(5) # which would run 5 pollers per queue forked with Daemonize

Get it here
]]></description>
			<content:encoded><![CDATA[<p>I&#8217;ve updated Mq.<br />
There was a major bug, where messages were picked up more than once which is now sorted.<br />
Also, you can automatically create more pollers per queue, like so:</p>
<pre>
  Mq.run_all(5) # which would run 5 pollers per queue forked with Daemonize
</pre>
<p><a href='http://www.eribium.org/blog/wp-content/uploads/2007/10/mq.txt' title='Mq - SQS Rails Plugin'>Get it here</a></p>
<img src="http://feeds.feedburner.com/~r/Eribium/~4/164645010" height="1" width="1"/>]]></content:encoded>
			<wfw:commentRss>http://www.eribium.org/blog/?feed=rss2&amp;p=177</wfw:commentRss>
		<feedburner:awareness>http://api.feedburner.com/awareness/1.0/GetItemData?uri=Eribium&amp;itemurl=http%3A%2F%2Fwww.eribium.org%2Fblog%2F%3Fp%3D177</feedburner:awareness><feedburner:origLink>http://www.eribium.org/blog/?p=177</feedburner:origLink></item>
		<item>
		<title>Ruby/Rails SQS Plugin</title>
		<link>http://feeds.feedburner.com/~r/Eribium/~3/164349528/</link>
		<comments>http://www.eribium.org/blog/?p=174#comments</comments>
		<pubDate>Tue, 02 Oct 2007 19:56:07 +0000</pubDate>
		<dc:creator>maccman</dc:creator>
		
		<category><![CDATA[Ruby]]></category>

		<category><![CDATA[SQS]]></category>

		<category><![CDATA[AWS]]></category>

		<category><![CDATA[Rails]]></category>

		<guid isPermaLink="false">http://www.eribium.org/blog/?p=174</guid>
		<description><![CDATA[SQS, in case you&#8217;ve been living under a digital rock, is a ultra useful simple queue service from Amazon.
As far as I know, Ruby/Rails has only two major libs for interfacing with SQS. ActiveMessaging and SQS. 
I wasn&#8217;t satisfied with either since using ActiveMessaging with SQS seems rather overkill (chain saw to a bunny rabbit) [...]]]></description>
			<content:encoded><![CDATA[<p><a href="http://aws.amazon.com/sqs">SQS</a>, in case you&#8217;ve been living under a digital rock, is a ultra useful simple queue service from Amazon.</p>
<p>As far as I know, Ruby/Rails has only two major libs for interfacing with SQS. <a href="http://code.google.com/p/activemessaging/wiki/ActiveMessaging">ActiveMessaging</a> and <a href="http://sqs.rubyforge.org">SQS</a>. </p>
<p>I wasn&#8217;t satisfied with either since using ActiveMessaging with SQS seems rather overkill (<a href="http://blog.nbwd.co.uk/2007/9/5/didn-t-you-get-the-memo">chain saw to a bunny rabbit</a>) and the SQS lib is too simple for my needs. </p>
<p>So, naturally, <a href='http://www.eribium.org/blog/wp-content/uploads/2007/10/mq.txt' title='Mq - SQS Rails Plugin'>I wrote my own</a> (on top of <a href="http://sqs.rubyforge.org">SQS</a>) and here it is. It&#8217;s targeted towards a Rails environment, but should work in just plain Ruby too.</p>
<p>I&#8217;m debating whether to move this into a plugin, or just a single file in the lib directory. I&#8217;m going with the latter, at the moment, as it doesn&#8217;t really seem big enough. Likewise, I&#8217;m thinking of creating a google code project - let me know if you want to contribute.</p>
<p>So, the main concept, is similar to ActiveMessaging. You define Queues (or Processors) which inherit from one central class. If you&#8217;re using Rails, it&#8217;s best to add another folder containing these to the load path in environment. Each processor has its own queue on SQS. The log naming defaults to the lowercase class name. You can define delays and retries in your processor, which will overwrite the defaults.<br />
Like so:</p>
<pre>
class AnotherQueue &lt; Mq
  def on_message
   logger.info('Log from Another Queue')
   logger.info(args)
  end

  def retry_attempts
    1
  end

  def delay
  end
end
</pre>
<p>You can then add messages to the queue with a simple YourQueue.publish(*args), and pull them off with a YourQueue.run, accessing all arguments passed to the publish method in a &#8216;args&#8217; variable.</p>
<pre>
  Mq.connect({:access_key_id =&gt; 'foo', :secret_access_key =&gt; 'foo'}) # in environment.rb
  Mq.run_all # in script/console or you can do individual queues: AnotherQueue.run(true)
  AnotherQueue.publish('a message') # somewhere in your app...
</pre>
<p>Methods on queues inheriting from Mq</p>
<pre>
  AnotherQueue.count
  AnotherQueue.empty?
  AnotherQueue.queue # raw SQS queue object
  AnotherQueue.destroy # returns false if queue isn't empty
  AnotherQueue.destroy! # forces destroy
  AnotherQueue.queue_name # the name of the queue on SQS
  AnotherQueue.run # eternal loop that pick up messages for this queue. Pass 'true' to daemonize
  AnotherQueue.publish(*args) # publish message to queue (needs at least one arg)
</pre>
<p>And the ones you&#8217;ll need from Mq:</p>
<pre>
  Mq.count_all # counts every message in every queue
  Mq.run_all # runs every queue (daemonizes by default)
</pre>
<p>I&#8217;ve also added some neat daemonization (you&#8217;ll need Daemonize btw), so pollers have the option of working in the background.</p>
<p>There&#8217;s still a bit of testing to be done, especially with the multiple poller for the same queue scenario, but I just wanted to get it out there, so to speak.</p>
<p>So, to sum up, you&#8217;ll need the <a href="http://sqs.rubyforge.org">SQS gem</a>, the <a href="http://grub.ath.cx/daemonize/">Daemonize lib</a> and, of course, a SQS account with Amazon.</p>
<p><a href='http://www.eribium.org/blog/wp-content/uploads/2007/10/mq.txt' title='Mq - SQS Rails Plugin' title='Mq - SQS Rails Plugin'>Get it here.</a></p>
<p>I&#8217;m not sure what the next step will be. I suppose it depends on feedback. I may release another lib I&#8217;ve written, using the same interface and methods, but using the db to queue messages.</p>
<img src="http://feeds.feedburner.com/~r/Eribium/~4/164349528" height="1" width="1"/>]]></content:encoded>
			<wfw:commentRss>http://www.eribium.org/blog/?feed=rss2&amp;p=174</wfw:commentRss>
		<feedburner:awareness>http://api.feedburner.com/awareness/1.0/GetItemData?uri=Eribium&amp;itemurl=http%3A%2F%2Fwww.eribium.org%2Fblog%2F%3Fp%3D174</feedburner:awareness><feedburner:origLink>http://www.eribium.org/blog/?p=174</feedburner:origLink></item>
	<feedburner:awareness>http://api.feedburner.com/awareness/1.0/GetFeedData?uri=Eribium</feedburner:awareness></channel>
</rss>
