<?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"?><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:atom="http://www.w3.org/2005/Atom" xmlns:feedburner="http://rssnamespace.org/feedburner/ext/1.0" version="2.0">

<channel>
	<title>Mandarin Soda</title>
	
	<link>http://mandarinsoda.com</link>
	<description>Random Musings, Sometimes Programming.</description>
	<pubDate>Wed, 29 Oct 2008 01:07:48 +0000</pubDate>
	<generator>http://wordpress.org/?v=2.6.3</generator>
	<language>en</language>
			<atom10:link xmlns:atom10="http://www.w3.org/2005/Atom" rel="self" href="http://feeds.feedburner.com/MandarinSoda" type="application/rss+xml" /><item>
		<title>Rails MailChimp Plugin Updates</title>
		<link>http://feeds.feedburner.com/~r/MandarinSoda/~3/435292813/</link>
		<comments>http://mandarinsoda.com/2008/10/28/rails-mailchimp-plugin-updates/#comments</comments>
		<pubDate>Wed, 29 Oct 2008 01:04:32 +0000</pubDate>
		<dc:creator>Matt Carlson</dc:creator>
		
		<category><![CDATA[Uncategorized]]></category>

		<guid isPermaLink="false">http://mandarinsoda.com/?p=216</guid>
		<description><![CDATA[While I&#8217;ve been tinkering with fleshing out my custom DataMapper adapter for MailChimp, I decided to start adding more functionality to my Rails/ActiveRecord plugin.  I&#8217;ve upgraded to the most recent MailChimp APIs and am in the process of adding campaign management functionality. Drop me a line if you want to fork and patch what [...]]]></description>
			<content:encoded><![CDATA[<p>While I&#8217;ve been tinkering with fleshing out my custom DataMapper adapter for MailChimp, I decided to start adding more functionality to my <a href="http://github.com/mandarinsoda/acts_as_chimp/tree/master">Rails/ActiveRecord plugin</a>.  I&#8217;ve upgraded to the most recent MailChimp APIs and am in the process of adding campaign management functionality. Drop me a line if you want to fork and patch what I have, as a few redundant plugins have started popping up and it seems like some consolidation would make sense.</p>

<span class="slashdigglicious">
<a href="http://slashdot.org/bookmark.pl?url=http%3A%2F%2Fmandarinsoda.com%2F2008%2F10%2F28%2Frails-mailchimp-plugin-updates%2F&amp;title=Rails+MailChimp+Plugin+Updates" title="Slashdot It!"><img src="http://slashdot.org/favicon.ico" height="16" width="16" alt="[Slashdot]" /></a>
<a href="http://digg.com/submit?phase=2&amp;url=http%3A%2F%2Fmandarinsoda.com%2F2008%2F10%2F28%2Frails-mailchimp-plugin-updates%2F&amp;title=Rails+MailChimp+Plugin+Updates" title="Digg This Story"><img src="http://digg.com/favicon.ico" width="16" height="16" alt="[Digg]" /></a>
<a href="http://reddit.com/submit?url=http%3A%2F%2Fmandarinsoda.com%2F2008%2F10%2F28%2Frails-mailchimp-plugin-updates%2F&amp;title=Rails+MailChimp+Plugin+Updates" title="Reddit"><img src="http://reddit.com/favicon.ico" width="16" height="16" alt="[Reddit]" /></a>
<a href="http://del.icio.us/post?url=http%3A%2F%2Fmandarinsoda.com%2F2008%2F10%2F28%2Frails-mailchimp-plugin-updates%2F&amp;title=Rails+MailChimp+Plugin+Updates" title="Save to del.icio.us" onclick="window.open('http://del.icio.us/post?v=4&amp;noui&amp;jump=close&amp;url=http%3A%2F%2Fmandarinsoda.com%2F2008%2F10%2F28%2Frails-mailchimp-plugin-updates%2F&amp;title=Rails+MailChimp+Plugin+Updates', 'delicious', 'toolbar=no,width=700,height=400'); return false;"><img src="http://images.del.icio.us/static/img/delicious.small.gif" width="16" height="16" alt="[del.icio.us]" /></a>
<a href="http://www.facebook.com/share.php?u=http%3A%2F%2Fmandarinsoda.com%2F2008%2F10%2F28%2Frails-mailchimp-plugin-updates%2F" title="Share on Facebook"><img src="http://www.facebook.com/favicon.ico" width="16" height="16" alt="[Facebook]" /></a>
<a href="http://technorati.com/faves?add=http%3A%2F%2Fmandarinsoda.com%2F2008%2F10%2F28%2Frails-mailchimp-plugin-updates%2F" title="Add to my Technorati Favorites"><img src="http://technorati.com/favicon.ico" width="16" height="16" alt="[Technorati]" /></a>
<a href="http://www.google.com/bookmarks/mark?op=edit&amp;output=popup&amp;bkmk=http%3A%2F%2Fmandarinsoda.com%2F2008%2F10%2F28%2Frails-mailchimp-plugin-updates%2F&amp;title=Rails+MailChimp+Plugin+Updates" title="Save to Google Bookmarks"><img src="http://www.google.com/favicon.ico" width="16" height="16" alt="[Google]" /></a>
<a href="http://www.stumbleupon.com/submit?url=http%3A%2F%2Fmandarinsoda.com%2F2008%2F10%2F28%2Frails-mailchimp-plugin-updates%2F&amp;title=Rails+MailChimp+Plugin+Updates" title="Stumble it!"><img src="http://www.stumbleupon.com/favicon.ico" width="16" height="16" alt="[StumbleUpon]" /></a>
</span>]]></content:encoded>
			<wfw:commentRss>http://mandarinsoda.com/2008/10/28/rails-mailchimp-plugin-updates/feed/</wfw:commentRss>
		<feedburner:origLink>http://mandarinsoda.com/2008/10/28/rails-mailchimp-plugin-updates/</feedburner:origLink></item>
		<item>
		<title>David Sedaris on the Undecided</title>
		<link>http://feeds.feedburner.com/~r/MandarinSoda/~3/432849772/</link>
		<comments>http://mandarinsoda.com/2008/10/26/david-sedaris-on-the-undecided/#comments</comments>
		<pubDate>Sun, 26 Oct 2008 19:43:21 +0000</pubDate>
		<dc:creator>Matt Carlson</dc:creator>
		
		<category><![CDATA[Uncategorized]]></category>

		<guid isPermaLink="false">http://mandarinsoda.com/?p=214</guid>
		<description><![CDATA[David Sedaris has a great new piece in the latest New Yorker on undecided voters for this year&#8217;s election.  My favorite quote:

To put them in perspective, I think of being on an airplane. The flight attendant comes down the aisle with her food cart and, eventually, parks it beside my seat. “Can I interest [...]]]></description>
			<content:encoded><![CDATA[<p>David Sedaris has a great new piece in the latest <a href="http://www.newyorker.com/humor/2008/10/27/081027sh_shouts_sedaris">New Yorker</a> on undecided voters for this year&#8217;s election.  My favorite quote:</p>
<blockquote><p>
To put them in perspective, I think of being on an airplane. The flight attendant comes down the aisle with her food cart and, eventually, parks it beside my seat. “Can I interest you in the chicken?” she asks. “Or would you prefer the platter of shit with bits of broken glass in it?”</p>
<p>To be undecided in this election is to pause for a moment and then ask how the chicken is cooked.</p>
<p>I mean, really, what’s to be confused about?</p></blockquote>

<span class="slashdigglicious">
<a href="http://slashdot.org/bookmark.pl?url=http%3A%2F%2Fmandarinsoda.com%2F2008%2F10%2F26%2Fdavid-sedaris-on-the-undecided%2F&amp;title=David+Sedaris+on+the+Undecided" title="Slashdot It!"><img src="http://slashdot.org/favicon.ico" height="16" width="16" alt="[Slashdot]" /></a>
<a href="http://digg.com/submit?phase=2&amp;url=http%3A%2F%2Fmandarinsoda.com%2F2008%2F10%2F26%2Fdavid-sedaris-on-the-undecided%2F&amp;title=David+Sedaris+on+the+Undecided" title="Digg This Story"><img src="http://digg.com/favicon.ico" width="16" height="16" alt="[Digg]" /></a>
<a href="http://reddit.com/submit?url=http%3A%2F%2Fmandarinsoda.com%2F2008%2F10%2F26%2Fdavid-sedaris-on-the-undecided%2F&amp;title=David+Sedaris+on+the+Undecided" title="Reddit"><img src="http://reddit.com/favicon.ico" width="16" height="16" alt="[Reddit]" /></a>
<a href="http://del.icio.us/post?url=http%3A%2F%2Fmandarinsoda.com%2F2008%2F10%2F26%2Fdavid-sedaris-on-the-undecided%2F&amp;title=David+Sedaris+on+the+Undecided" title="Save to del.icio.us" onclick="window.open('http://del.icio.us/post?v=4&amp;noui&amp;jump=close&amp;url=http%3A%2F%2Fmandarinsoda.com%2F2008%2F10%2F26%2Fdavid-sedaris-on-the-undecided%2F&amp;title=David+Sedaris+on+the+Undecided', 'delicious', 'toolbar=no,width=700,height=400'); return false;"><img src="http://images.del.icio.us/static/img/delicious.small.gif" width="16" height="16" alt="[del.icio.us]" /></a>
<a href="http://www.facebook.com/share.php?u=http%3A%2F%2Fmandarinsoda.com%2F2008%2F10%2F26%2Fdavid-sedaris-on-the-undecided%2F" title="Share on Facebook"><img src="http://www.facebook.com/favicon.ico" width="16" height="16" alt="[Facebook]" /></a>
<a href="http://technorati.com/faves?add=http%3A%2F%2Fmandarinsoda.com%2F2008%2F10%2F26%2Fdavid-sedaris-on-the-undecided%2F" title="Add to my Technorati Favorites"><img src="http://technorati.com/favicon.ico" width="16" height="16" alt="[Technorati]" /></a>
<a href="http://www.google.com/bookmarks/mark?op=edit&amp;output=popup&amp;bkmk=http%3A%2F%2Fmandarinsoda.com%2F2008%2F10%2F26%2Fdavid-sedaris-on-the-undecided%2F&amp;title=David+Sedaris+on+the+Undecided" title="Save to Google Bookmarks"><img src="http://www.google.com/favicon.ico" width="16" height="16" alt="[Google]" /></a>
<a href="http://www.stumbleupon.com/submit?url=http%3A%2F%2Fmandarinsoda.com%2F2008%2F10%2F26%2Fdavid-sedaris-on-the-undecided%2F&amp;title=David+Sedaris+on+the+Undecided" title="Stumble it!"><img src="http://www.stumbleupon.com/favicon.ico" width="16" height="16" alt="[StumbleUpon]" /></a>
</span>]]></content:encoded>
			<wfw:commentRss>http://mandarinsoda.com/2008/10/26/david-sedaris-on-the-undecided/feed/</wfw:commentRss>
		<feedburner:origLink>http://mandarinsoda.com/2008/10/26/david-sedaris-on-the-undecided/</feedburner:origLink></item>
		<item>
		<title>Netflix API Authentication with the Ruby Oauth Gem</title>
		<link>http://feeds.feedburner.com/~r/MandarinSoda/~3/425899533/</link>
		<comments>http://mandarinsoda.com/2008/10/19/netflix-authentication-with-ruby-oauth/#comments</comments>
		<pubDate>Mon, 20 Oct 2008 00:24:16 +0000</pubDate>
		<dc:creator>Matt Carlson</dc:creator>
		
		<category><![CDATA[Programming]]></category>

		<category><![CDATA[Uncategorized]]></category>

		<category><![CDATA[Web Development]]></category>

		<category><![CDATA[ruby]]></category>

		<guid isPermaLink="false">http://mandarinsoda.com/?p=204</guid>
		<description><![CDATA[For any folks out there struggling to get the Ruby OAuth gem working with Netflix authentication, here&#8217;s a quick run down on how to get started.
The 0.2.7 version of Ruby OAuth isn&#8217;t totally compatible with the Netflix authentication APIs.  However, thanks to the grooviness that it is GitHub, Rob Ares graciously forked the OAuth [...]]]></description>
			<content:encoded><![CDATA[<p>For any folks out there struggling to get the Ruby OAuth gem working with Netflix authentication, here&#8217;s a quick run down on how to get started.</p>
<p>The 0.2.7 version of Ruby OAuth isn&#8217;t totally compatible with the Netflix authentication APIs.  However, thanks to the grooviness that it is <a href="http://github.com/">GitHub</a>, <a href="http://github.com/rares/oauth/tree/master">Rob Ares</a> graciously forked the OAuth gem in order to get it working.  So clone his repository and get cracking!  </p>
<p>Here&#8217;s a start:</p>
<pre>
<code>
require "oauth/consumer"
consumer = OAuth::Consumer.new(
      "developer api key",
      "developer api secret",
      {
        :site => "http://api.netflix.com",
        :request_token_url => "https://api-user.netflix.com/oauth/request_token",
        :access_token_url => "http://api.netflix.com/oauth/access_token",
        :authorize_url => "https://api-user.netflix.com/oauth/login"
      })

    request_token = consumer.get_request_token  

 request_token.authorize_url({
      :oauth_consumer_key => "you developer api key",
      :application_name => "application name",
      :oauth_callback => "optional"
    })

    access_token = request_token.get_access_token

    response = consumer.request(
      :get,
      "/users/#{access_token.response[:user_id]}",
      access_token,
      {:scheme => :query_string})
</pre>
<p></code></p>

<span class="slashdigglicious">
<a href="http://slashdot.org/bookmark.pl?url=http%3A%2F%2Fmandarinsoda.com%2F2008%2F10%2F19%2Fnetflix-authentication-with-ruby-oauth%2F&amp;title=Netflix+API+Authentication+with+the+Ruby+Oauth+Gem" title="Slashdot It!"><img src="http://slashdot.org/favicon.ico" height="16" width="16" alt="[Slashdot]" /></a>
<a href="http://digg.com/submit?phase=2&amp;url=http%3A%2F%2Fmandarinsoda.com%2F2008%2F10%2F19%2Fnetflix-authentication-with-ruby-oauth%2F&amp;title=Netflix+API+Authentication+with+the+Ruby+Oauth+Gem" title="Digg This Story"><img src="http://digg.com/favicon.ico" width="16" height="16" alt="[Digg]" /></a>
<a href="http://reddit.com/submit?url=http%3A%2F%2Fmandarinsoda.com%2F2008%2F10%2F19%2Fnetflix-authentication-with-ruby-oauth%2F&amp;title=Netflix+API+Authentication+with+the+Ruby+Oauth+Gem" title="Reddit"><img src="http://reddit.com/favicon.ico" width="16" height="16" alt="[Reddit]" /></a>
<a href="http://del.icio.us/post?url=http%3A%2F%2Fmandarinsoda.com%2F2008%2F10%2F19%2Fnetflix-authentication-with-ruby-oauth%2F&amp;title=Netflix+API+Authentication+with+the+Ruby+Oauth+Gem" title="Save to del.icio.us" onclick="window.open('http://del.icio.us/post?v=4&amp;noui&amp;jump=close&amp;url=http%3A%2F%2Fmandarinsoda.com%2F2008%2F10%2F19%2Fnetflix-authentication-with-ruby-oauth%2F&amp;title=Netflix+API+Authentication+with+the+Ruby+Oauth+Gem', 'delicious', 'toolbar=no,width=700,height=400'); return false;"><img src="http://images.del.icio.us/static/img/delicious.small.gif" width="16" height="16" alt="[del.icio.us]" /></a>
<a href="http://www.facebook.com/share.php?u=http%3A%2F%2Fmandarinsoda.com%2F2008%2F10%2F19%2Fnetflix-authentication-with-ruby-oauth%2F" title="Share on Facebook"><img src="http://www.facebook.com/favicon.ico" width="16" height="16" alt="[Facebook]" /></a>
<a href="http://technorati.com/faves?add=http%3A%2F%2Fmandarinsoda.com%2F2008%2F10%2F19%2Fnetflix-authentication-with-ruby-oauth%2F" title="Add to my Technorati Favorites"><img src="http://technorati.com/favicon.ico" width="16" height="16" alt="[Technorati]" /></a>
<a href="http://www.google.com/bookmarks/mark?op=edit&amp;output=popup&amp;bkmk=http%3A%2F%2Fmandarinsoda.com%2F2008%2F10%2F19%2Fnetflix-authentication-with-ruby-oauth%2F&amp;title=Netflix+API+Authentication+with+the+Ruby+Oauth+Gem" title="Save to Google Bookmarks"><img src="http://www.google.com/favicon.ico" width="16" height="16" alt="[Google]" /></a>
<a href="http://www.stumbleupon.com/submit?url=http%3A%2F%2Fmandarinsoda.com%2F2008%2F10%2F19%2Fnetflix-authentication-with-ruby-oauth%2F&amp;title=Netflix+API+Authentication+with+the+Ruby+Oauth+Gem" title="Stumble it!"><img src="http://www.stumbleupon.com/favicon.ico" width="16" height="16" alt="[StumbleUpon]" /></a>
</span>]]></content:encoded>
			<wfw:commentRss>http://mandarinsoda.com/2008/10/19/netflix-authentication-with-ruby-oauth/feed/</wfw:commentRss>
		<feedburner:origLink>http://mandarinsoda.com/2008/10/19/netflix-authentication-with-ruby-oauth/</feedburner:origLink></item>
		<item>
		<title>DataMapper Adapter for Netflix</title>
		<link>http://feeds.feedburner.com/~r/MandarinSoda/~3/416038001/</link>
		<comments>http://mandarinsoda.com/2008/10/09/datamapper-adapter-for-netflix/#comments</comments>
		<pubDate>Thu, 09 Oct 2008 19:03:28 +0000</pubDate>
		<dc:creator>Matt Carlson</dc:creator>
		
		<category><![CDATA[Programming]]></category>

		<category><![CDATA[Web Development]]></category>

		<category><![CDATA[datamapper]]></category>

		<category><![CDATA[ruby]]></category>

		<guid isPermaLink="false">http://mandarinsoda.com/?p=202</guid>
		<description><![CDATA[I&#8217;ve apparently caught the DM Adapter bug, as I&#8217;ve decided to write one to access Netflix while I finish up my MailChimp adapter. 
I&#8217;ll be posting as I go along, as I&#8217;ve been learning quite a bit about the inner workings of DataMapper while going through this process.  
Cheers.










]]></description>
			<content:encoded><![CDATA[<p>I&#8217;ve apparently caught the <a href="http://datamapper.rubyforge.org/DataMapper/Adapters/">DM Adapter</a> bug, as I&#8217;ve decided to write <a href="http://github.com/mandarinsoda/datamapper-netflix-adapter/tree/master">one to access Netflix</a> while I finish up my MailChimp adapter. </p>
<p>I&#8217;ll be posting as I go along, as I&#8217;ve been learning quite a bit about the inner workings of DataMapper while going through this process.  </p>
<p>Cheers.</p>

<span class="slashdigglicious">
<a href="http://slashdot.org/bookmark.pl?url=http%3A%2F%2Fmandarinsoda.com%2F2008%2F10%2F09%2Fdatamapper-adapter-for-netflix%2F&amp;title=DataMapper+Adapter+for+Netflix" title="Slashdot It!"><img src="http://slashdot.org/favicon.ico" height="16" width="16" alt="[Slashdot]" /></a>
<a href="http://digg.com/submit?phase=2&amp;url=http%3A%2F%2Fmandarinsoda.com%2F2008%2F10%2F09%2Fdatamapper-adapter-for-netflix%2F&amp;title=DataMapper+Adapter+for+Netflix" title="Digg This Story"><img src="http://digg.com/favicon.ico" width="16" height="16" alt="[Digg]" /></a>
<a href="http://reddit.com/submit?url=http%3A%2F%2Fmandarinsoda.com%2F2008%2F10%2F09%2Fdatamapper-adapter-for-netflix%2F&amp;title=DataMapper+Adapter+for+Netflix" title="Reddit"><img src="http://reddit.com/favicon.ico" width="16" height="16" alt="[Reddit]" /></a>
<a href="http://del.icio.us/post?url=http%3A%2F%2Fmandarinsoda.com%2F2008%2F10%2F09%2Fdatamapper-adapter-for-netflix%2F&amp;title=DataMapper+Adapter+for+Netflix" title="Save to del.icio.us" onclick="window.open('http://del.icio.us/post?v=4&amp;noui&amp;jump=close&amp;url=http%3A%2F%2Fmandarinsoda.com%2F2008%2F10%2F09%2Fdatamapper-adapter-for-netflix%2F&amp;title=DataMapper+Adapter+for+Netflix', 'delicious', 'toolbar=no,width=700,height=400'); return false;"><img src="http://images.del.icio.us/static/img/delicious.small.gif" width="16" height="16" alt="[del.icio.us]" /></a>
<a href="http://www.facebook.com/share.php?u=http%3A%2F%2Fmandarinsoda.com%2F2008%2F10%2F09%2Fdatamapper-adapter-for-netflix%2F" title="Share on Facebook"><img src="http://www.facebook.com/favicon.ico" width="16" height="16" alt="[Facebook]" /></a>
<a href="http://technorati.com/faves?add=http%3A%2F%2Fmandarinsoda.com%2F2008%2F10%2F09%2Fdatamapper-adapter-for-netflix%2F" title="Add to my Technorati Favorites"><img src="http://technorati.com/favicon.ico" width="16" height="16" alt="[Technorati]" /></a>
<a href="http://www.google.com/bookmarks/mark?op=edit&amp;output=popup&amp;bkmk=http%3A%2F%2Fmandarinsoda.com%2F2008%2F10%2F09%2Fdatamapper-adapter-for-netflix%2F&amp;title=DataMapper+Adapter+for+Netflix" title="Save to Google Bookmarks"><img src="http://www.google.com/favicon.ico" width="16" height="16" alt="[Google]" /></a>
<a href="http://www.stumbleupon.com/submit?url=http%3A%2F%2Fmandarinsoda.com%2F2008%2F10%2F09%2Fdatamapper-adapter-for-netflix%2F&amp;title=DataMapper+Adapter+for+Netflix" title="Stumble it!"><img src="http://www.stumbleupon.com/favicon.ico" width="16" height="16" alt="[StumbleUpon]" /></a>
</span>]]></content:encoded>
			<wfw:commentRss>http://mandarinsoda.com/2008/10/09/datamapper-adapter-for-netflix/feed/</wfw:commentRss>
		<feedburner:origLink>http://mandarinsoda.com/2008/10/09/datamapper-adapter-for-netflix/</feedburner:origLink></item>
		<item>
		<title>Writing a DataMapper Adapter to Access MailChimp Web Services From Merb</title>
		<link>http://feeds.feedburner.com/~r/MandarinSoda/~3/410582654/</link>
		<comments>http://mandarinsoda.com/2008/10/03/writing-a-datamapper-adapter-to-access-mailchimp-web-services/#comments</comments>
		<pubDate>Fri, 03 Oct 2008 20:52:31 +0000</pubDate>
		<dc:creator>Matt Carlson</dc:creator>
		
		<category><![CDATA[Programming]]></category>

		<category><![CDATA[Web Development]]></category>

		<category><![CDATA[datamapper]]></category>

		<category><![CDATA[merb]]></category>

		<category><![CDATA[ruby]]></category>

		<category><![CDATA[MailChimp]]></category>

		<guid isPermaLink="false">http://mandarinsoda.com/?p=186</guid>
		<description><![CDATA[As I mentioned in my last post, I&#8217;ve started looking into writing DataMapper Adapters, using my MailChimp wrapper as an example.  Thus far, I&#8217;ve been pretty impressed with the Adapter layer built into DataMapper and the possibilities this abstraction layer provides.  A quick search over at GitHub will show you all the interesting [...]]]></description>
			<content:encoded><![CDATA[<p>As I mentioned in my last post, I&#8217;ve started looking into writing DataMapper Adapters, using my <a href="http://github.com/mandarinsoda/datamapper-mailchimp-adapter/tree/master">MailChimp wrapper as an example</a>.  Thus far, I&#8217;ve been pretty impressed with the Adapter layer built into DataMapper and the possibilities this abstraction layer provides.  A <a href="http://github.com/search?q=datamapper+adapter">quick search over at GitHub</a> will show you all the interesting things folks are doing with adapters.   </p>
<p>Anyway, here&#8217;s a synopsis of what I&#8217;ve come across thus far.  As pointed out <a href="http://merbist.com/2008/09/29/write-your-own-custom-datamapper-adapter/">in this post</a> by The Merbist, a custom adapter simply inherits from <a href="http://github.com/sam/dm-core/tree/master/lib/dm-core/adapters/abstract_adapter.rb">Abstract Adapter</a> and as such, can define a number of default Adapter methods such as create, update, delete, read_one and read_many.  You also have access to an initialization method that supplies a hash with important environment information, including any parameters relevant to your adapter that a user may have setup in a database.yml file.  This allowed me to create a MailChimp client and login <a href="http://github.com/mandarinsoda/datamapper-mailchimp-adapter/tree/master/lib/dm-mailchimp-adapter.rb#L15-20">once during class initialization</a> rather than at every request, so I got that going for me.</p>
<p>Once I had a MailChimp client setup with login information, I started getting create working in my adapter.  The create method takes a collection of resources as an option which I simply loop through and call the MailChimp listSubscribe API.  So far, so good.  I now wanted to test whether any of this would work with Merb.</p>
<p>I created a merb app:</p>
<pre>
<code>
 merb-gen app campaign
 cd campaign
</code>
</pre>
<p>and set the :use_orm parameter to datamapper in the Merb init.rb.</p>
<p>Next, I ran <code>rake dm:db:database_yaml</code> in order to generate a database.yml file to specify relevant properties for my adapter.  In my case, I needed to create an entry for my mailchimp adapter:</p>
<pre>
<code>
  adapter:  mailchimp
  database:
  username: user
  password: password
  mailing_list_id: list_id
  host: localhost
</code>
</pre>
<p>.</p>
<p>I next created a resource to test the adapter with by running <code>merb-gen resource mailings</code>.  My thinking was that one could have a User stored in a relational (or other) datastore, and that User can have many mailings or some such thing, bad naming aside.  Anyway, a cool feature of DataMapper is that you can specify any number of repositories in a database.yml with different adapters, and then specify on a resource by resource basis which repository a resource belongs to like so:</p>
<pre>
<code>
 def self.default_repository_name
      :mysql
 end
</code>
</pre>
<p>After generating my resource, I went in to add the properties MailChimp would require for the create method.  </p>
<pre>
<code>
class Mailings
  include DataMapper::Resource

  property :id, String, :serial => true, :key => true, :field => :_id
  property :first_name, String
  property :last_name, String
  property :email, String
  property :mailing_list_id, String

   def build_mail_merge()
      {"EMAIL" => self.email, "FNAME" => self.first_name, "LNAME" => self.last_name }
   end
end
</code>
</pre>
<p>.</p>
<p>I also added a callback method that is used by the adapter in order to pass mail merge arguments to MailChimp.  This seemed like a sane approach given that the MailChimp mail_merge arguments are quite dynamic.</p>
<p>With a resource firmly in place, I fired up the merb console and tested to see whether I could connect to MailChimp with it.</p>
<pre>
<code>
 m = Mailing.new
 m.first_name = 'mandarin'
 m.last_name = 'soda'
 m.email = 'msoda@disney.com'
 m.mailing_list_id = '9'
 m.create
</code>
</pre>
<p>I checked my disney email, and sure enough, I had an opt-in response from MailChimp. Victory Adapter!  I could sign users up to MailChimp via the DataMapper APIs quite quickly&#8230;.not too shabby.</p>
<p>That&#8217;s where I&#8217;m at for now&#8230;still have some things to iron out, one being that DataMapper is returning false after a successful create.  Others, of course being that I need to figure out the rest of the default Adapter methods.  Feel free to follow on GitHub if you feel so inclined.</p>

<span class="slashdigglicious">
<a href="http://slashdot.org/bookmark.pl?url=http%3A%2F%2Fmandarinsoda.com%2F2008%2F10%2F03%2Fwriting-a-datamapper-adapter-to-access-mailchimp-web-services%2F&amp;title=Writing+a+DataMapper+Adapter+to+Access+MailChimp+Web+Services+From+Merb" title="Slashdot It!"><img src="http://slashdot.org/favicon.ico" height="16" width="16" alt="[Slashdot]" /></a>
<a href="http://digg.com/submit?phase=2&amp;url=http%3A%2F%2Fmandarinsoda.com%2F2008%2F10%2F03%2Fwriting-a-datamapper-adapter-to-access-mailchimp-web-services%2F&amp;title=Writing+a+DataMapper+Adapter+to+Access+MailChimp+Web+Services+From+Merb" title="Digg This Story"><img src="http://digg.com/favicon.ico" width="16" height="16" alt="[Digg]" /></a>
<a href="http://reddit.com/submit?url=http%3A%2F%2Fmandarinsoda.com%2F2008%2F10%2F03%2Fwriting-a-datamapper-adapter-to-access-mailchimp-web-services%2F&amp;title=Writing+a+DataMapper+Adapter+to+Access+MailChimp+Web+Services+From+Merb" title="Reddit"><img src="http://reddit.com/favicon.ico" width="16" height="16" alt="[Reddit]" /></a>
<a href="http://del.icio.us/post?url=http%3A%2F%2Fmandarinsoda.com%2F2008%2F10%2F03%2Fwriting-a-datamapper-adapter-to-access-mailchimp-web-services%2F&amp;title=Writing+a+DataMapper+Adapter+to+Access+MailChimp+Web+Services+From+Merb" title="Save to del.icio.us" onclick="window.open('http://del.icio.us/post?v=4&amp;noui&amp;jump=close&amp;url=http%3A%2F%2Fmandarinsoda.com%2F2008%2F10%2F03%2Fwriting-a-datamapper-adapter-to-access-mailchimp-web-services%2F&amp;title=Writing+a+DataMapper+Adapter+to+Access+MailChimp+Web+Services+From+Merb', 'delicious', 'toolbar=no,width=700,height=400'); return false;"><img src="http://images.del.icio.us/static/img/delicious.small.gif" width="16" height="16" alt="[del.icio.us]" /></a>
<a href="http://www.facebook.com/share.php?u=http%3A%2F%2Fmandarinsoda.com%2F2008%2F10%2F03%2Fwriting-a-datamapper-adapter-to-access-mailchimp-web-services%2F" title="Share on Facebook"><img src="http://www.facebook.com/favicon.ico" width="16" height="16" alt="[Facebook]" /></a>
<a href="http://technorati.com/faves?add=http%3A%2F%2Fmandarinsoda.com%2F2008%2F10%2F03%2Fwriting-a-datamapper-adapter-to-access-mailchimp-web-services%2F" title="Add to my Technorati Favorites"><img src="http://technorati.com/favicon.ico" width="16" height="16" alt="[Technorati]" /></a>
<a href="http://www.google.com/bookmarks/mark?op=edit&amp;output=popup&amp;bkmk=http%3A%2F%2Fmandarinsoda.com%2F2008%2F10%2F03%2Fwriting-a-datamapper-adapter-to-access-mailchimp-web-services%2F&amp;title=Writing+a+DataMapper+Adapter+to+Access+MailChimp+Web+Services+From+Merb" title="Save to Google Bookmarks"><img src="http://www.google.com/favicon.ico" width="16" height="16" alt="[Google]" /></a>
<a href="http://www.stumbleupon.com/submit?url=http%3A%2F%2Fmandarinsoda.com%2F2008%2F10%2F03%2Fwriting-a-datamapper-adapter-to-access-mailchimp-web-services%2F&amp;title=Writing+a+DataMapper+Adapter+to+Access+MailChimp+Web+Services+From+Merb" title="Stumble it!"><img src="http://www.stumbleupon.com/favicon.ico" width="16" height="16" alt="[StumbleUpon]" /></a>
</span>]]></content:encoded>
			<wfw:commentRss>http://mandarinsoda.com/2008/10/03/writing-a-datamapper-adapter-to-access-mailchimp-web-services/feed/</wfw:commentRss>
		<feedburner:origLink>http://mandarinsoda.com/2008/10/03/writing-a-datamapper-adapter-to-access-mailchimp-web-services/</feedburner:origLink></item>
		<item>
		<title>DataMapper Adapter for MailChimp</title>
		<link>http://feeds.feedburner.com/~r/MandarinSoda/~3/406786245/</link>
		<comments>http://mandarinsoda.com/2008/09/29/datamapper-adapter-for-mailchimp/#comments</comments>
		<pubDate>Tue, 30 Sep 2008 00:53:38 +0000</pubDate>
		<dc:creator>Matt Carlson</dc:creator>
		
		<category><![CDATA[Programming]]></category>

		<category><![CDATA[merb]]></category>

		<category><![CDATA[ruby]]></category>

		<category><![CDATA[datamapper]]></category>

		<category><![CDATA[MailChimp]]></category>

		<guid isPermaLink="false">http://mandarinsoda.com/?p=181</guid>
		<description><![CDATA[Inspired by this post by The Merbist, I&#8217;ve decided to begin writing a Datamapper Adapter for MailChimp as a follow up to my post about creating a Merb web service.  Look here for updates.  Just an empty shell at the moment, but I&#8217;ll remedy that shortly.










]]></description>
			<content:encoded><![CDATA[<p>Inspired by <a href="http://merbist.com/2008/09/29/write-your-own-custom-datamapper-adapter/">this post</a> by <a href="http://merbist.com/">The Merbist</a>, I&#8217;ve decided to begin writing a Datamapper Adapter for MailChimp as a follow up to my post about creating a Merb web service.  Look <a href="http://github.com/mandarinsoda/datamapper-mailchimp-adapter/tree/master">here</a> for updates.  Just an empty shell at the moment, but I&#8217;ll remedy that shortly.</p>

<span class="slashdigglicious">
<a href="http://slashdot.org/bookmark.pl?url=http%3A%2F%2Fmandarinsoda.com%2F2008%2F09%2F29%2Fdatamapper-adapter-for-mailchimp%2F&amp;title=DataMapper+Adapter+for+MailChimp" title="Slashdot It!"><img src="http://slashdot.org/favicon.ico" height="16" width="16" alt="[Slashdot]" /></a>
<a href="http://digg.com/submit?phase=2&amp;url=http%3A%2F%2Fmandarinsoda.com%2F2008%2F09%2F29%2Fdatamapper-adapter-for-mailchimp%2F&amp;title=DataMapper+Adapter+for+MailChimp" title="Digg This Story"><img src="http://digg.com/favicon.ico" width="16" height="16" alt="[Digg]" /></a>
<a href="http://reddit.com/submit?url=http%3A%2F%2Fmandarinsoda.com%2F2008%2F09%2F29%2Fdatamapper-adapter-for-mailchimp%2F&amp;title=DataMapper+Adapter+for+MailChimp" title="Reddit"><img src="http://reddit.com/favicon.ico" width="16" height="16" alt="[Reddit]" /></a>
<a href="http://del.icio.us/post?url=http%3A%2F%2Fmandarinsoda.com%2F2008%2F09%2F29%2Fdatamapper-adapter-for-mailchimp%2F&amp;title=DataMapper+Adapter+for+MailChimp" title="Save to del.icio.us" onclick="window.open('http://del.icio.us/post?v=4&amp;noui&amp;jump=close&amp;url=http%3A%2F%2Fmandarinsoda.com%2F2008%2F09%2F29%2Fdatamapper-adapter-for-mailchimp%2F&amp;title=DataMapper+Adapter+for+MailChimp', 'delicious', 'toolbar=no,width=700,height=400'); return false;"><img src="http://images.del.icio.us/static/img/delicious.small.gif" width="16" height="16" alt="[del.icio.us]" /></a>
<a href="http://www.facebook.com/share.php?u=http%3A%2F%2Fmandarinsoda.com%2F2008%2F09%2F29%2Fdatamapper-adapter-for-mailchimp%2F" title="Share on Facebook"><img src="http://www.facebook.com/favicon.ico" width="16" height="16" alt="[Facebook]" /></a>
<a href="http://technorati.com/faves?add=http%3A%2F%2Fmandarinsoda.com%2F2008%2F09%2F29%2Fdatamapper-adapter-for-mailchimp%2F" title="Add to my Technorati Favorites"><img src="http://technorati.com/favicon.ico" width="16" height="16" alt="[Technorati]" /></a>
<a href="http://www.google.com/bookmarks/mark?op=edit&amp;output=popup&amp;bkmk=http%3A%2F%2Fmandarinsoda.com%2F2008%2F09%2F29%2Fdatamapper-adapter-for-mailchimp%2F&amp;title=DataMapper+Adapter+for+MailChimp" title="Save to Google Bookmarks"><img src="http://www.google.com/favicon.ico" width="16" height="16" alt="[Google]" /></a>
<a href="http://www.stumbleupon.com/submit?url=http%3A%2F%2Fmandarinsoda.com%2F2008%2F09%2F29%2Fdatamapper-adapter-for-mailchimp%2F&amp;title=DataMapper+Adapter+for+MailChimp" title="Stumble it!"><img src="http://www.stumbleupon.com/favicon.ico" width="16" height="16" alt="[StumbleUpon]" /></a>
</span>]]></content:encoded>
			<wfw:commentRss>http://mandarinsoda.com/2008/09/29/datamapper-adapter-for-mailchimp/feed/</wfw:commentRss>
		<feedburner:origLink>http://mandarinsoda.com/2008/09/29/datamapper-adapter-for-mailchimp/</feedburner:origLink></item>
		<item>
		<title>Zeep SMS Gem Configuration for Rails</title>
		<link>http://feeds.feedburner.com/~r/MandarinSoda/~3/398221953/</link>
		<comments>http://mandarinsoda.com/2008/09/20/zeep-sms-gem-configuration-for-rails/#comments</comments>
		<pubDate>Sat, 20 Sep 2008 16:31:07 +0000</pubDate>
		<dc:creator>Matt Carlson</dc:creator>
		
		<category><![CDATA[Programming]]></category>

		<category><![CDATA[Rails]]></category>

		<category><![CDATA[sms]]></category>

		<guid isPermaLink="false">http://mandarinsoda.com/?p=167</guid>
		<description><![CDATA[For whatever reason, I can rarely remember the myriad syntax for managing gem dependencies in Rails.  I&#8217;ve visited this page quite a bit during various projects.  
When trying to install the zeep messaging gem recently, sure enough I struggled a bit with getting the syntax correct.  
Anyway, without further ado, here is [...]]]></description>
			<content:encoded><![CDATA[<p>For whatever reason, I can rarely remember the myriad syntax for managing gem dependencies in Rails.  I&#8217;ve visited <a href="http://ryandaigle.com/articles/2008/4/1/what-s-new-in-edge-rails-gem-dependencies">this page</a> quite a bit during various projects.  </p>
<p>When trying to install the <a href="http://code.google.com/p/zeep-messaging/downloads/detail?name=zeep-messaging-0.1.5.gem&#038;can=2&#038;q=">zeep messaging gem</a> recently, sure enough I struggled a bit with getting the syntax correct.  </p>
<p>Anyway, without further ado, here is what worked:<br />
<code>config.gem "zeep-messaging", :lib => "zeep/messaging", :version => "0.1.5"</code></p>
<p>Kinda nice sending SMS messages from the console, I have to admit.</p>

<span class="slashdigglicious">
<a href="http://slashdot.org/bookmark.pl?url=http%3A%2F%2Fmandarinsoda.com%2F2008%2F09%2F20%2Fzeep-sms-gem-configuration-for-rails%2F&amp;title=Zeep+SMS+Gem+Configuration+for+Rails" title="Slashdot It!"><img src="http://slashdot.org/favicon.ico" height="16" width="16" alt="[Slashdot]" /></a>
<a href="http://digg.com/submit?phase=2&amp;url=http%3A%2F%2Fmandarinsoda.com%2F2008%2F09%2F20%2Fzeep-sms-gem-configuration-for-rails%2F&amp;title=Zeep+SMS+Gem+Configuration+for+Rails" title="Digg This Story"><img src="http://digg.com/favicon.ico" width="16" height="16" alt="[Digg]" /></a>
<a href="http://reddit.com/submit?url=http%3A%2F%2Fmandarinsoda.com%2F2008%2F09%2F20%2Fzeep-sms-gem-configuration-for-rails%2F&amp;title=Zeep+SMS+Gem+Configuration+for+Rails" title="Reddit"><img src="http://reddit.com/favicon.ico" width="16" height="16" alt="[Reddit]" /></a>
<a href="http://del.icio.us/post?url=http%3A%2F%2Fmandarinsoda.com%2F2008%2F09%2F20%2Fzeep-sms-gem-configuration-for-rails%2F&amp;title=Zeep+SMS+Gem+Configuration+for+Rails" title="Save to del.icio.us" onclick="window.open('http://del.icio.us/post?v=4&amp;noui&amp;jump=close&amp;url=http%3A%2F%2Fmandarinsoda.com%2F2008%2F09%2F20%2Fzeep-sms-gem-configuration-for-rails%2F&amp;title=Zeep+SMS+Gem+Configuration+for+Rails', 'delicious', 'toolbar=no,width=700,height=400'); return false;"><img src="http://images.del.icio.us/static/img/delicious.small.gif" width="16" height="16" alt="[del.icio.us]" /></a>
<a href="http://www.facebook.com/share.php?u=http%3A%2F%2Fmandarinsoda.com%2F2008%2F09%2F20%2Fzeep-sms-gem-configuration-for-rails%2F" title="Share on Facebook"><img src="http://www.facebook.com/favicon.ico" width="16" height="16" alt="[Facebook]" /></a>
<a href="http://technorati.com/faves?add=http%3A%2F%2Fmandarinsoda.com%2F2008%2F09%2F20%2Fzeep-sms-gem-configuration-for-rails%2F" title="Add to my Technorati Favorites"><img src="http://technorati.com/favicon.ico" width="16" height="16" alt="[Technorati]" /></a>
<a href="http://www.google.com/bookmarks/mark?op=edit&amp;output=popup&amp;bkmk=http%3A%2F%2Fmandarinsoda.com%2F2008%2F09%2F20%2Fzeep-sms-gem-configuration-for-rails%2F&amp;title=Zeep+SMS+Gem+Configuration+for+Rails" title="Save to Google Bookmarks"><img src="http://www.google.com/favicon.ico" width="16" height="16" alt="[Google]" /></a>
<a href="http://www.stumbleupon.com/submit?url=http%3A%2F%2Fmandarinsoda.com%2F2008%2F09%2F20%2Fzeep-sms-gem-configuration-for-rails%2F&amp;title=Zeep+SMS+Gem+Configuration+for+Rails" title="Stumble it!"><img src="http://www.stumbleupon.com/favicon.ico" width="16" height="16" alt="[StumbleUpon]" /></a>
</span>]]></content:encoded>
			<wfw:commentRss>http://mandarinsoda.com/2008/09/20/zeep-sms-gem-configuration-for-rails/feed/</wfw:commentRss>
		<feedburner:origLink>http://mandarinsoda.com/2008/09/20/zeep-sms-gem-configuration-for-rails/</feedburner:origLink></item>
		<item>
		<title>Monitoring Radiant CMS and Phusion Passenger on Slicehost</title>
		<link>http://feeds.feedburner.com/~r/MandarinSoda/~3/388023104/</link>
		<comments>http://mandarinsoda.com/2008/09/09/monitoring-radiant-cms-and-phusion-passenger-on-slicehost/#comments</comments>
		<pubDate>Tue, 09 Sep 2008 21:21:10 +0000</pubDate>
		<dc:creator>Matt Carlson</dc:creator>
		
		<category><![CDATA[Rails]]></category>

		<category><![CDATA[Slicehost]]></category>

		<category><![CDATA[miscellaneous]]></category>

		<category><![CDATA[Radiant]]></category>

		<guid isPermaLink="false">http://mandarinsoda.com/?p=160</guid>
		<description><![CDATA[In my previous post, I wrote about quickly setting an Ubuntu Hardy slice up with Radiant and the latest Phusion tools (mod_rails and Ruby Enterprise) and alluded to some setting up logging and monitoring as next steps.  As monitoring and logging are fascinating subjects, I figured I&#8217;d follow up with a few sentences about [...]]]></description>
			<content:encoded><![CDATA[<p>In my previous post, I wrote about quickly setting an Ubuntu Hardy slice up with Radiant and the latest Phusion tools (mod_rails and Ruby Enterprise) and alluded to some setting up logging and monitoring as next steps.  As monitoring and logging are fascinating subjects, I figured I&#8217;d follow up with a few sentences about what I configured.</p>
<p>Apache will log to its own log files, as well as <a href="http://httpd.apache.org/docs/1.3/logs.html#rotation">handle log rotation</a>, so nothing much to write about there.  However, as a good practice, you&#8217;ll likely want to rotate your Radiant logs.  And for that, you&#8217;ll want logrotate.  </p>
<p>Logrotate gets its configuration information from /etc/logrotate.conf, so one just needs to open it up and tell it to look at the Radiant logs and rotate them like so:</p>
<pre><code>
# Rotate Rails application logs
/path/to/radiant/shared/log/*.log {
daily
missingok
rotate 7
compress
delaycompress
notifempty
copytruncate
}
</pre>
<p></code></p>
<p>This will rotate 7 days worth of logs, compress older logs and start a new log file.   And it will do it daily. Simple.  </p>
<p>Monitoring is a bit more involved, but God makes it fairly easy, and its all in Ruby.  According to <a href="https://boxpanel.blueboxgrp.com/public/the_vault/index.php/Mod_Rails_Tips">this helpful site</a> mod_rails monitors its own processes, which leaves us to Monitor Apache, MySQL and any other processes running around.  The <a href="http://god.rubyforge.org/">God site</a> has very good documentation, so I suggest you head over there if you want detailed descriptions of everything it can do.  For the sake of this post, I&#8217;ll just lead folks to simple Apache and MySQL configurations.</p>
<p>After installing God <code>sudo gem install god --no-ri --no-rdoc</code>, setup a conf.god somewhere sensible and take a look at the posts below, as it probably doesn&#8217;t make sense for me to reiterate what others have already admirably accomplished:<br />
<a href="http://rubypond.com/articles/2007/12/28/touched-by-god-process-monitoring/">Monitoring MySQL and setting up notifications</a>.<br />
<a href="http://blog.blenderbox.com/2008/03/11/monitoring-apache-with-god/">Monitoring Apache</a>.</p>
<p>Now I just need to figure out what will monitor God.</p>

<span class="slashdigglicious">
<a href="http://slashdot.org/bookmark.pl?url=http%3A%2F%2Fmandarinsoda.com%2F2008%2F09%2F09%2Fmonitoring-radiant-cms-and-phusion-passenger-on-slicehost%2F&amp;title=Monitoring+Radiant+CMS+and+Phusion+Passenger+on+Slicehost" title="Slashdot It!"><img src="http://slashdot.org/favicon.ico" height="16" width="16" alt="[Slashdot]" /></a>
<a href="http://digg.com/submit?phase=2&amp;url=http%3A%2F%2Fmandarinsoda.com%2F2008%2F09%2F09%2Fmonitoring-radiant-cms-and-phusion-passenger-on-slicehost%2F&amp;title=Monitoring+Radiant+CMS+and+Phusion+Passenger+on+Slicehost" title="Digg This Story"><img src="http://digg.com/favicon.ico" width="16" height="16" alt="[Digg]" /></a>
<a href="http://reddit.com/submit?url=http%3A%2F%2Fmandarinsoda.com%2F2008%2F09%2F09%2Fmonitoring-radiant-cms-and-phusion-passenger-on-slicehost%2F&amp;title=Monitoring+Radiant+CMS+and+Phusion+Passenger+on+Slicehost" title="Reddit"><img src="http://reddit.com/favicon.ico" width="16" height="16" alt="[Reddit]" /></a>
<a href="http://del.icio.us/post?url=http%3A%2F%2Fmandarinsoda.com%2F2008%2F09%2F09%2Fmonitoring-radiant-cms-and-phusion-passenger-on-slicehost%2F&amp;title=Monitoring+Radiant+CMS+and+Phusion+Passenger+on+Slicehost" title="Save to del.icio.us" onclick="window.open('http://del.icio.us/post?v=4&amp;noui&amp;jump=close&amp;url=http%3A%2F%2Fmandarinsoda.com%2F2008%2F09%2F09%2Fmonitoring-radiant-cms-and-phusion-passenger-on-slicehost%2F&amp;title=Monitoring+Radiant+CMS+and+Phusion+Passenger+on+Slicehost', 'delicious', 'toolbar=no,width=700,height=400'); return false;"><img src="http://images.del.icio.us/static/img/delicious.small.gif" width="16" height="16" alt="[del.icio.us]" /></a>
<a href="http://www.facebook.com/share.php?u=http%3A%2F%2Fmandarinsoda.com%2F2008%2F09%2F09%2Fmonitoring-radiant-cms-and-phusion-passenger-on-slicehost%2F" title="Share on Facebook"><img src="http://www.facebook.com/favicon.ico" width="16" height="16" alt="[Facebook]" /></a>
<a href="http://technorati.com/faves?add=http%3A%2F%2Fmandarinsoda.com%2F2008%2F09%2F09%2Fmonitoring-radiant-cms-and-phusion-passenger-on-slicehost%2F" title="Add to my Technorati Favorites"><img src="http://technorati.com/favicon.ico" width="16" height="16" alt="[Technorati]" /></a>
<a href="http://www.google.com/bookmarks/mark?op=edit&amp;output=popup&amp;bkmk=http%3A%2F%2Fmandarinsoda.com%2F2008%2F09%2F09%2Fmonitoring-radiant-cms-and-phusion-passenger-on-slicehost%2F&amp;title=Monitoring+Radiant+CMS+and+Phusion+Passenger+on+Slicehost" title="Save to Google Bookmarks"><img src="http://www.google.com/favicon.ico" width="16" height="16" alt="[Google]" /></a>
<a href="http://www.stumbleupon.com/submit?url=http%3A%2F%2Fmandarinsoda.com%2F2008%2F09%2F09%2Fmonitoring-radiant-cms-and-phusion-passenger-on-slicehost%2F&amp;title=Monitoring+Radiant+CMS+and+Phusion+Passenger+on+Slicehost" title="Stumble it!"><img src="http://www.stumbleupon.com/favicon.ico" width="16" height="16" alt="[StumbleUpon]" /></a>
</span>]]></content:encoded>
			<wfw:commentRss>http://mandarinsoda.com/2008/09/09/monitoring-radiant-cms-and-phusion-passenger-on-slicehost/feed/</wfw:commentRss>
		<feedburner:origLink>http://mandarinsoda.com/2008/09/09/monitoring-radiant-cms-and-phusion-passenger-on-slicehost/</feedburner:origLink></item>
		<item>
		<title>Writing a Simple MailChimp Web Service Using Merb</title>
		<link>http://feeds.feedburner.com/~r/MandarinSoda/~3/387100615/</link>
		<comments>http://mandarinsoda.com/2008/09/08/writing-a-simple-mailchimp-web-service-using-merb/#comments</comments>
		<pubDate>Mon, 08 Sep 2008 23:17:55 +0000</pubDate>
		<dc:creator>Matt Carlson</dc:creator>
		
		<category><![CDATA[Programming]]></category>

		<category><![CDATA[Software Design]]></category>

		<category><![CDATA[Web Design]]></category>

		<category><![CDATA[Web Development]]></category>

		<category><![CDATA[MailChimp]]></category>

		<category><![CDATA[merb]]></category>

		<guid isPermaLink="false">http://mandarinsoda.com/?p=129</guid>
		<description><![CDATA[A while back, I was asked to build some code to help keep a businesses mailing list synchronized between SalesForce.com and their campaign management tool, which I suggested should be MailChimp and not the tool they were currently using, but I digress.  The project never materialized, but I figured I would build it anyway [...]]]></description>
			<content:encoded><![CDATA[<p>A while back, I was asked to build some code to help keep a businesses mailing list synchronized between SalesForce.com and their campaign management tool, which I suggested should be <a href="http://www.mailchimp.com/index.phtml">MailChimp</a> and not the tool they were currently using, but I digress.  The project never materialized, but I figured I would build it anyway and use it as a chance to explore <a href="http://merbivore.com/">Merb</a> a bit.</p>
<p>My thinking at the time was that a standalone &#8220;wrapper&#8221; web service made sense.  While it would have complicated application administration a bit, encapsulating the mailing list functionality in a simple service that could be called synchronously or asynchronously, as well as modified and deployed independent of core site logic, sounded reasonable.</p>
<p>So, let&#8217;s start with building a minimal Merb application to serve as a foundation:<br />
<code>merb-gen app mail_chimp_service --flat</code></p>
<p>This generates one controller, a few templates (if we want to build in some templated monitoring and for xml responses) and just enough configuration to get the Merb service started.</p>
<p>To test it out, just fire up Merb with the following command: <code>merb</code> and head to <code>http://localhost:4000</code>.</p>
<p>With a foundation in place, I started looking into my MailChimp plugin to see if I should turn it into a gem or do something simpler.  I turned to <a href="http://seattlerb.rubyforge.org/hoe/">hoe</a>, thinking that making a gem would be interesting, but then decided otherwise, as I basically didn&#8217;t feel like writing that much.    So instead, I wrote a simple chimp class to do the MailChimp API work:</p>
<pre><code>require 'xmlrpc/client'
class Chimp
  cattr_accessor :client, :auth
  def add(subscriber)
    chimp_subscribe(auth, Merb::Config[:chimp_settings]['mail_chimp']['mailing_list_id'],
                            subscriber.email, subscriber.mail_merge)
  end
  private
  def chimp_subscribe(auth, mailing_list_id, email, merge_vars,
                                email_content_type="html", double_optin=true)
    begin
      client.call("listSubscribe", auth, mailing_list_id, email,
                     merge_vars, email_content_type, double_optin)
    rescue XMLRPC::FaultException =&gt; e
      Merb.logger e.faultCode
      Merb.logger e.faultString
    end
  end
end</code></pre>
<p>This class adds users to a specific MailChimp mailing list using the MailChimp APIs.  The client and auth attributes are set in the Merb init.rb class, as they really only need to be loaded once and not initialized per each request:</p>
<pre><code>
Merb::BootLoader.after_app_loads do
    Chimp.client = XMLRPC::Client.new2('http://api.mailchimp.com/1.0/')
    Chimp.auth = XMLRPC::Client.new2('http://api.mailchimp.com/1.0/').call("login",
                         Merb::Config[:chimp_settings]['mail_chimp']['username'],
                         Merb::Config[:chimp_settings]['mail_chimp']['password'])
end
</code></pre>
<p>I&#8217;m loading the MailChimp configuration parameters in the init.rb file in the config block. I&#8217;m just loading in a yaml file with the relevant information one would presumably want externalized from the application code:</p>
<pre><code>
Merb::Config.use { |c|
 .....
 c[:chimp_settings]      = YAML.load_file(Merb.root/'mailing.yml')
}
</code></pre>
<p>I then created a simple subscriber.rb class to encapsulate user elements and wired the relevant classes together in my single controller like so:</p>
<pre><code>
require 'chimp'
require 'subscriber'
class Foo &lt; Merb::Controller
  provides :xml

  def _template_location(action, type = nil, controller = controller_name)
    controller == "layout" ? "layout.#{action}.#{type}" : "#{action}.#{type}"
  end

  def index
    subscriber = Subscriber.new(params)
    chimp = Chimp.new
    chimp.add(subscriber)
    render false
  end
end
</code></pre>
<p>I subsquently added an index.xml.erb class to my views directory in order to render successful responses, fired up my app with the merb command and then ran a test in a separate console to ensure everything was working:</p>
<pre><code>
curl -H "Accept: text/xml" -L -d
"email=matt@mandarinsoda.com&amp;first_name=swanky&amp;last_name=mango" http://localhost:4000</code></pre>
<p>It worked - the very first time!  (joking, but it did work after a bit of tinkering).  I saw the content of my index.xml.erb and received a MailChimp opt-in email. Not too shabby for a few hours of tinkering.  I&#8217;m sure there are interesting Merb features missing as well that could make this all the more compact.  More to explore later.</p>

<span class="slashdigglicious">
<a href="http://slashdot.org/bookmark.pl?url=http%3A%2F%2Fmandarinsoda.com%2F2008%2F09%2F08%2Fwriting-a-simple-mailchimp-web-service-using-merb%2F&amp;title=Writing+a+Simple+MailChimp+Web+Service+Using+Merb" title="Slashdot It!"><img src="http://slashdot.org/favicon.ico" height="16" width="16" alt="[Slashdot]" /></a>
<a href="http://digg.com/submit?phase=2&amp;url=http%3A%2F%2Fmandarinsoda.com%2F2008%2F09%2F08%2Fwriting-a-simple-mailchimp-web-service-using-merb%2F&amp;title=Writing+a+Simple+MailChimp+Web+Service+Using+Merb" title="Digg This Story"><img src="http://digg.com/favicon.ico" width="16" height="16" alt="[Digg]" /></a>
<a href="http://reddit.com/submit?url=http%3A%2F%2Fmandarinsoda.com%2F2008%2F09%2F08%2Fwriting-a-simple-mailchimp-web-service-using-merb%2F&amp;title=Writing+a+Simple+MailChimp+Web+Service+Using+Merb" title="Reddit"><img src="http://reddit.com/favicon.ico" width="16" height="16" alt="[Reddit]" /></a>
<a href="http://del.icio.us/post?url=http%3A%2F%2Fmandarinsoda.com%2F2008%2F09%2F08%2Fwriting-a-simple-mailchimp-web-service-using-merb%2F&amp;title=Writing+a+Simple+MailChimp+Web+Service+Using+Merb" title="Save to del.icio.us" onclick="window.open('http://del.icio.us/post?v=4&amp;noui&amp;jump=close&amp;url=http%3A%2F%2Fmandarinsoda.com%2F2008%2F09%2F08%2Fwriting-a-simple-mailchimp-web-service-using-merb%2F&amp;title=Writing+a+Simple+MailChimp+Web+Service+Using+Merb', 'delicious', 'toolbar=no,width=700,height=400'); return false;"><img src="http://images.del.icio.us/static/img/delicious.small.gif" width="16" height="16" alt="[del.icio.us]" /></a>
<a href="http://www.facebook.com/share.php?u=http%3A%2F%2Fmandarinsoda.com%2F2008%2F09%2F08%2Fwriting-a-simple-mailchimp-web-service-using-merb%2F" title="Share on Facebook"><img src="http://www.facebook.com/favicon.ico" width="16" height="16" alt="[Facebook]" /></a>
<a href="http://technorati.com/faves?add=http%3A%2F%2Fmandarinsoda.com%2F2008%2F09%2F08%2Fwriting-a-simple-mailchimp-web-service-using-merb%2F" title="Add to my Technorati Favorites"><img src="http://technorati.com/favicon.ico" width="16" height="16" alt="[Technorati]" /></a>
<a href="http://www.google.com/bookmarks/mark?op=edit&amp;output=popup&amp;bkmk=http%3A%2F%2Fmandarinsoda.com%2F2008%2F09%2F08%2Fwriting-a-simple-mailchimp-web-service-using-merb%2F&amp;title=Writing+a+Simple+MailChimp+Web+Service+Using+Merb" title="Save to Google Bookmarks"><img src="http://www.google.com/favicon.ico" width="16" height="16" alt="[Google]" /></a>
<a href="http://www.stumbleupon.com/submit?url=http%3A%2F%2Fmandarinsoda.com%2F2008%2F09%2F08%2Fwriting-a-simple-mailchimp-web-service-using-merb%2F&amp;title=Writing+a+Simple+MailChimp+Web+Service+Using+Merb" title="Stumble it!"><img src="http://www.stumbleupon.com/favicon.ico" width="16" height="16" alt="[StumbleUpon]" /></a>
</span>]]></content:encoded>
			<wfw:commentRss>http://mandarinsoda.com/2008/09/08/writing-a-simple-mailchimp-web-service-using-merb/feed/</wfw:commentRss>
		<feedburner:origLink>http://mandarinsoda.com/2008/09/08/writing-a-simple-mailchimp-web-service-using-merb/</feedburner:origLink></item>
		<item>
		<title>Where is Triumph These Days?</title>
		<link>http://feeds.feedburner.com/~r/MandarinSoda/~3/385335603/</link>
		<comments>http://mandarinsoda.com/2008/09/06/where-is-triumph-these-days/#comments</comments>
		<pubDate>Sat, 06 Sep 2008 22:32:26 +0000</pubDate>
		<dc:creator>Matt Carlson</dc:creator>
		
		<category><![CDATA[Uncategorized]]></category>

		<guid isPermaLink="false">http://mandarinsoda.com/?p=140</guid>
		<description><![CDATA[Triumph at a Star Wars opening.  Funny stuff.










]]></description>
			<content:encoded><![CDATA[<p><a href="http://www.youtube.com/watch?v=bZ5HUmunDbk">Triumph at a Star Wars opening</a>.  Funny stuff.</p>

<span class="slashdigglicious">
<a href="http://slashdot.org/bookmark.pl?url=http%3A%2F%2Fmandarinsoda.com%2F2008%2F09%2F06%2Fwhere-is-triumph-these-days%2F&amp;title=Where+is+Triumph+These+Days%3F" title="Slashdot It!"><img src="http://slashdot.org/favicon.ico" height="16" width="16" alt="[Slashdot]" /></a>
<a href="http://digg.com/submit?phase=2&amp;url=http%3A%2F%2Fmandarinsoda.com%2F2008%2F09%2F06%2Fwhere-is-triumph-these-days%2F&amp;title=Where+is+Triumph+These+Days%3F" title="Digg This Story"><img src="http://digg.com/favicon.ico" width="16" height="16" alt="[Digg]" /></a>
<a href="http://reddit.com/submit?url=http%3A%2F%2Fmandarinsoda.com%2F2008%2F09%2F06%2Fwhere-is-triumph-these-days%2F&amp;title=Where+is+Triumph+These+Days%3F" title="Reddit"><img src="http://reddit.com/favicon.ico" width="16" height="16" alt="[Reddit]" /></a>
<a href="http://del.icio.us/post?url=http%3A%2F%2Fmandarinsoda.com%2F2008%2F09%2F06%2Fwhere-is-triumph-these-days%2F&amp;title=Where+is+Triumph+These+Days%3F" title="Save to del.icio.us" onclick="window.open('http://del.icio.us/post?v=4&amp;noui&amp;jump=close&amp;url=http%3A%2F%2Fmandarinsoda.com%2F2008%2F09%2F06%2Fwhere-is-triumph-these-days%2F&amp;title=Where+is+Triumph+These+Days%3F', 'delicious', 'toolbar=no,width=700,height=400'); return false;"><img src="http://images.del.icio.us/static/img/delicious.small.gif" width="16" height="16" alt="[del.icio.us]" /></a>
<a href="http://www.facebook.com/share.php?u=http%3A%2F%2Fmandarinsoda.com%2F2008%2F09%2F06%2Fwhere-is-triumph-these-days%2F" title="Share on Facebook"><img src="http://www.facebook.com/favicon.ico" width="16" height="16" alt="[Facebook]" /></a>
<a href="http://technorati.com/faves?add=http%3A%2F%2Fmandarinsoda.com%2F2008%2F09%2F06%2Fwhere-is-triumph-these-days%2F" title="Add to my Technorati Favorites"><img src="http://technorati.com/favicon.ico" width="16" height="16" alt="[Technorati]" /></a>
<a href="http://www.google.com/bookmarks/mark?op=edit&amp;output=popup&amp;bkmk=http%3A%2F%2Fmandarinsoda.com%2F2008%2F09%2F06%2Fwhere-is-triumph-these-days%2F&amp;title=Where+is+Triumph+These+Days%3F" title="Save to Google Bookmarks"><img src="http://www.google.com/favicon.ico" width="16" height="16" alt="[Google]" /></a>
<a href="http://www.stumbleupon.com/submit?url=http%3A%2F%2Fmandarinsoda.com%2F2008%2F09%2F06%2Fwhere-is-triumph-these-days%2F&amp;title=Where+is+Triumph+These+Days%3F" title="Stumble it!"><img src="http://www.stumbleupon.com/favicon.ico" width="16" height="16" alt="[StumbleUpon]" /></a>
</span>]]></content:encoded>
			<wfw:commentRss>http://mandarinsoda.com/2008/09/06/where-is-triumph-these-days/feed/</wfw:commentRss>
		<feedburner:origLink>http://mandarinsoda.com/2008/09/06/where-is-triumph-these-days/</feedburner:origLink></item>
	</channel>
</rss>
