<?xml version="1.0" encoding="UTF-8"?>
<!--Generated by Squarespace Site Server v5.11.5 (http://www.squarespace.com/) on Fri, 03 Sep 2010 03:02:05 GMT--><rss xmlns:content="http://purl.org/rss/1.0/modules/content/" xmlns:wfw="http://wellformedweb.org/CommentAPI/" xmlns:itunes="http://www.itunes.com/dtds/podcast-1.0.dtd" xmlns:dc="http://purl.org/dc/elements/1.1/" version="2.0"><channel><title>Collective Noodle</title><link>http://www.collectivenoodle.com/blog-articles/</link><description></description><lastBuildDate>Wed, 23 Jun 2010 16:10:39 +0000</lastBuildDate><copyright></copyright><language>en-US</language><generator>Squarespace Site Server v5.11.5 (http://www.squarespace.com/)</generator><item><title>Problem installing git using homebrew</title><category>Programming</category><category>Ruby</category><category>git</category><category>homebrew</category><category>install</category><category>problem</category><category>programming</category><dc:creator>Brian Chamberlain</dc:creator><pubDate>Fri, 30 Apr 2010 19:29:57 +0000</pubDate><link>http://www.collectivenoodle.com/blog-articles/2010/4/30/problem-installing-git-using-homebrew.html</link><guid isPermaLink="false">322227:3378849:7498402</guid><description><![CDATA[<p>In file included from /usr/local/include/curl/curl.h:36,
                     from http.h:6,
                     from remote-curl.c:5:
    /usr/local/include/curl/curlrules.h:134: error: size of array ‘<strong>curl<em>rule</em>01</strong>’ is negative
    make: <em>*</em> [remote-curl.o] Error 1</p>
]]></description><wfw:commentRss>http://www.collectivenoodle.com/blog-articles/rss-comments-entry-7498402.xml</wfw:commentRss></item><item><title>CouchDB makes a great data cache (with help from Ruby)</title><category>CouchDB</category><category>CouchRest</category><category>Ruby</category><category>Ruby code example</category><category>bulk_docs</category><category>bulk_save</category><category>trick</category><dc:creator>Brian Chamberlain</dc:creator><pubDate>Tue, 12 Jan 2010 22:02:40 +0000</pubDate><link>http://www.collectivenoodle.com/blog-articles/2010/1/12/couchdb-makes-a-great-data-cache-with-help-from-ruby.html</link><guid isPermaLink="false">322227:3378849:6305521</guid><description><![CDATA[<p>I was working on pulling in some data from this nasty web service (slow, complex, unreliable) where the data is not structured the way I want it to be (oh yeah, and there&#8217;s that too&#8230;). To get all the data I need there&#8217;s about seven or so queries I have to make. Not wanting to have my main app deal with all these queries and storing the data in its relational (and rigid) structure I thought this seemed like a good use case for CouchDB. The semi-structured data format in CouchDB allows me to layer data on top of existing documents as need. Each query adding more data to the existing data and in the end giving me the full picture of the end objects I am after. &#8220;Progressive data enhancement&#8221; if you will. Once I&#8217;ve got this full picture of the data I can sit my CouchDB database between my main app and this ugly, awful web service. My main app will hit CouchDBs nice, clean RESTful!!!, interface for the data I want. A small Ruby script (on a chron perhaps) deals with all the aforementioned nastiness, grabs data from the web service and loads it into CouchDB. This setup encapsulates the idiosyncrasies of the outside world in one place and allows my main app to operate in reality distortion field of my own design. Sweet!</p>

<p>Ultimately, this data will end up (at least part of it) in a relational DB but setting up the needed tables, columns, etc&#8230; require a lot upfront to build out the all that good relational-ness. At this point, it&#8217;s pretty exploratory. As I add more webservice calls I&#8217;d like to immediately see that data and use it in my app. Not have to write a migration that I may or may not have to roll back if the additional data element is wrong or not needed. I&#8217;m trying to keep it agile over here!</p>

<p>So, I have my code query the remote web service and I get back a hash for each object I want to put in my CouchDB database (conveniently I designed this code to turn ugly SOAP mapping objects into plain old arrays of hashes). The initial web service query returned over 12,000 objects so iterating over each one to stuff into the CouchDB seemed silly. Luckily CouchDB can handle bulk document creation (using the CouchRest gen this is exposed as &#8216;bulk_save&#8217;). The first time I did this it worked fine and returned all the new id&#8217;s it created. After some thought about how to get the rest of my data in there I decided to use custom document IDs instead of the autogenerated UUIDs in couch assigns. Using the default id would mean I&#8217;d have to hit Couch to look up the id on each web service returned object just to get the document. This is an extra lookup in CouchDB which is fine because Couch is very fast but there&#8217;s no need for this.</p>

<p>CouchDB bulk create allows you to specify your own unique id to use instead of the auto assigned/generated one. In my situation this would allow me to just blindly post to Couch with my own ID in the URL and have the new data from my other queries go directly to the document. The progressive data enhancement I was after without the redundant lookup to get the right document first.</p>

<p>What I needed to do was wipe out my database that held the CouchDB created document with the CouchIDs, modify the hashes I get back from the web services to have &#8220;<em>id&#8221;=>&#8221;</em>my<em>unique</em>id<em>&#8221; in there so when I did my bulk</em>save CouchDB would not create IDs for me but just use the ones given to it.</p>

<p>Here&#8217;s (finally) where Ruby comes in.</p>

<p>Let&#8217;s say that here is the array of hashes I get back from the webservice:</p>

<pre><code>vals =[{:a =&gt; "1"},{:a =&gt; "2"},{:a =&gt; "3"}]
</code></pre>

<p>(where :a is the key for the web service unique id value)</p>

<p>I need to modify each hash in this array to add {&#8220;<em>id&#8221; => &#8220;</em>value<em>of</em>&#8216;a&#8217;_&#8221;} so we want the first element to look like:</p>

<pre><code>{"_id" =&gt; "1",:a =&gt; "1"}
</code></pre>

<p>for example&#8230;</p>

<p>Ruby #map to the rescue!</p>

<pre><code>vals.map{|v| v["_id"]=v[:a]}
</code></pre>

<p>Gives us:</p>

<pre><code>vals.inspect
=&gt; "[{"_id"=&gt;"1", :a=&gt;"1"}, {"_id"=&gt;"2", :a=&gt;"2"}, {"_id"=&gt;"3", :a=&gt;"3"}]"
</code></pre>

<p>With our hash formatted the right way to use our web service given ID as the CouchDB ID bulk_save will create all the documents we need so that we can access them (using this sample data) like:</p>

<pre><code>curl -X GET 'http://127.0.0.1:5984/test_db/1'
</code></pre>

<p>Should give you:</p>

<pre><code>{"_id":"1","_rev":"1-10085f96b70ddbb6155710a391194304","a"=&gt;"1"}
</code></pre>

<p>(your rev id will be different of course)</p>

<p>That&#8217;s all there is to it!</p>
]]></description><wfw:commentRss>http://www.collectivenoodle.com/blog-articles/rss-comments-entry-6305521.xml</wfw:commentRss></item><item><title>PGError: ERROR: permission denied: "RI_ConstraintTrigger_xxxxxxx" is a system trigger</title><category>Postgres</category><category>Programming</category><category>Rails</category><category>errors</category><category>programming</category><category>rails</category><dc:creator>Brian Chamberlain</dc:creator><pubDate>Tue, 08 Dec 2009 16:25:19 +0000</pubDate><link>http://www.collectivenoodle.com/blog-articles/2009/12/8/pgerror-error-permission-denied-ri_constrainttrigger_xxxxxxx.html</link><guid isPermaLink="false">322227:3378849:6019797</guid><description><![CDATA[<p>This was a fun one.</p>

<p>Today I set out to get one of my apps setup on the CI server we have use at work when I ran into this problem. It occurred only for a few of the remaining specs in the test suite that still use fixtures. The error looked something like this:</p>

<pre><code>ActiveRecord::StatementInvalid in 'RegistryController should show the current registry for the current user - no params sent'
PGError: ERROR:  permission denied: "RI_ConstraintTrigger_2681229" is a system trigger: ALTER TABLE "schema_migrations" ENABLE TRIGGER ALL;ALTER TABLE "users" ENABLE TRIGGER ALL;ALTER
......
ALL;ALTER TABLE "master_answers" ENABLE TRIGGER ALL;ALTER TABLE "questions" ENABLE TRIGGER ALL;ALTER TABLE "answers" ENABLE TRIGGER ALL;ALTER TABLE "people" ENABLE TRIGGER ALL
</code></pre>

<p>Turns out this is a permission issue with the how Postgres handles triggers. Triggers belong to the superuser and if you&#8217;ve set up your DB permissions properly your test user on your DB should NOT be a super user. </p>

<p><a href="http://blogs.law.harvard.edu/djcp/2009/01/rails-22-postgres-and-testing/">This author</a> correctly identifies the problem but suggests the solution is to change the permissions on your test user: </p>

<p><a href="http://kopongo.com/2008/7/25/postgres-ri_constrainttrigger-error">Here is a better approach</a> to addressing the actual problem (and thorough explanation):</p>

<p>I deviated from this approach slightly in that I only added the &#8216;require&#8217; statement to pull in the hack in my CI environment (not for all the environments as the author suggests). I thoughts are that this change only needs to solve a problem in the CI env, so that is where it should live. This <em>could</em> bite me in the butt because it introduces an inconsistency in the adapter behavior across envs. To be honest, I&#8217;m not sure which is worse. We&#8217;ll see how it plays out.</p>
]]></description><wfw:commentRss>http://www.collectivenoodle.com/blog-articles/rss-comments-entry-6019797.xml</wfw:commentRss></item><item><title>Trouble with the Postgres Ruby gem on OSX 10.6 (pg gem on Snow Leopard)</title><category>10.6</category><category>Postgres</category><category>Ruby</category><category>Ruby</category><category>gems</category><category>pg</category><category>rails</category><dc:creator>Brian Chamberlain</dc:creator><pubDate>Thu, 08 Oct 2009 01:09:31 +0000</pubDate><link>http://www.collectivenoodle.com/blog-articles/2009/10/7/trouble-with-the-postgres-ruby-gem-on-osx-106-pg-gem-on-snow.html</link><guid isPermaLink="false">322227:3378849:5427281</guid><description><![CDATA[<p>I recently (i.e. earlier today) decided to stop cheating and using the Postgres pure Ruby (postgres-pr) adapter and switch to the real-deal compiled version (formerly known as &#8216;postgres&#8217; now known as just &#8216;pg&#8217;). I had been putting this off because all prior attempts to <code>sudo gem install postgres</code> had failed with esoteric messages which I will likely never understand.</p>

<p>It also happens that I just upgraded to OS X 10.6 (AKA Snow Leopard). What better time to try again?</p>

<h2>Step 1 - Out with the old</h2>

<p><code>gem uninstall postgres-pr</code></p>

<p><code>Select gem to uninstall: <br />
 1. postgres-pr-0.4.0 <br />
 2. postgres-pr-0.5.1 <br />
 3. postgres-pr-0.6.1 <br />
 4. postgres-pr-0.6.1 <br />
 5. All versions
</code></p>

<p>I chose option 5</p>

<p><code>
Successfully uninstalled postgres-pr-0.4.0 <br />
Successfully uninstalled postgres-pr-0.5.1 <br />
Successfully uninstalled postgres-pr-0.6.1 <br />
Successfully uninstalled postgres-pr-0.6.1
</code></p>

<p>I don&#8217;t know why there were two postgres-pr-0.6.1 perhaps one had been installed in my local .gem directory and the other in the system gem dir.</p>

<h2>Step 2 - Installing the newness</h2>

<p><code>sudo gem install pg</code></p>

<p>Wait for it&#8230;</p>

<p>FAIL!
`ERROR:  Error installing pg: <br />
    ERROR: Failed to build gem native extension.  </p>

<p>/System/Library/Frameworks/Ruby.framework/Versions/1.8/usr/bin/ruby extconf.rb <br />
extconf.rb:1: command not found: pg<em>config &#8212;version <br />
ERROR: can&#8217;t find pg</em>config. <br />
HINT: Make sure pg_config is in your PATH  `</p>

<p>Crap, that sucks. But there is a glimmer of hope. Note the &#8220;HINT&#8221;&#8230;hmm&#8230; thanks fellas!</p>

<h2>Step 3? - Where is that pg_config?!</h2>

<p>Through the magic of the command line we can search for it.
Drop this on the command line.</p>

<p><code>mdfind pg_config|grep bin|uniq</code></p>

<p>Your results will probably be different but mine are:
<code>
/Library/PostgreSQL/8.3/bin/pg_config <br />
/usr/local (from old Mac)/bin/pg_config <br />
/usr/local (from old Mac)/pgsql/bin/pg_config <br />
/usr/local (from old Mac)/src/postgresql-8.2.5/src/bin/pg_config <br />
/usr/local (from old Mac)/src/postgresql-8.2.5/src/bin/pg_config/pg_config <br />
/usr/local (from old Mac)/src/postgresql-8.2.5/src/bin/pg_config/pg_config.c <br />
/usr/local (from old Mac)/src/postgresql-8.2.5/src/bin/pg_config/pg_config.o
</code>  </p>

<p>Pay attention to the first line that&#8217;s where the elusive &#8216;pg_config&#8217; is hiding. (For the record, I have no idea why this file is needed or what it does. Perhaps some sort of pg config?) <em>See the comments below for an explanation by my friend Rhett.</em></p>

<p><em>Note to reader:
At this point I got distracted and tried to delete that <code>local (from old mac)</code> folder and almost ran an rf with recursive force on my usr/local directory (by almost&#8230; I mean I did run it but thankfully a sudo is required for this operation. For all my complaining about having to use Sudo it totally saved my ass. I will henceforth never complain about having to type it in all the time.)</em></p>

<h2>Step&#8230; to hell with the steps because we have derailed.</h2>

<p>Time to try the install again.
Drop the path on the command as part of the install like so.</p>

<p><code>PATH=/Library/PostgreSQL/8.3/bin:$PATH sudo gem install pg</code></p>

<p>This yields a new, somewhat more confusing and more verbose error. The meat of it is: <br />
<code>In file included from compat.c:16: <br />
compat.h:38:2: error: #error PostgreSQL client version too old, requires 7.3 or later.
</code></p>

<p>I have even less of an idea what to do with this&#8230; thankfully, after some googling it turns out this is a common issue compiling the pg gem on Snow Leopard and the fix is easy.</p>

<p>So, combining the first fix with this new one we get: <br />
<code>PATH=/Library/PostgreSQL/8.3/bin:$PATH sudo env ARCHFLAGS='-arch i386' gem install pg</code></p>

<p>Running this we get:  </p>

<p><code>Building native extensions.  This could take a while... <br />
Successfully installed pg-0.8.0 <br />
1 gem installed
</code></p>

<p>Sweet!!! No more postgres-pr. We are now on the very fast pg gem for Postgres on Ruby.</p>
]]></description><wfw:commentRss>http://www.collectivenoodle.com/blog-articles/rss-comments-entry-5427281.xml</wfw:commentRss></item><item><title>Vimperator 2.0 crashing Firefox 3.0+</title><category>VIM</category><category>Web</category><category>firefox</category><category>fix</category><category>vimperator</category><dc:creator>Brian Chamberlain</dc:creator><pubDate>Fri, 08 May 2009 16:34:52 +0000</pubDate><link>http://www.collectivenoodle.com/blog-articles/2009/5/8/vimperator-20-crashing-firefox-30.html</link><guid isPermaLink="false">322227:3378849:3924092</guid><description><![CDATA[<p>I really like using the <a href="http://vimperator.org/trac/wiki/Vimperator">Vimperator</a> plugin for FireFox. It&#8217;s helped me learn the Vim commands and obviated the mouse for browsing web pages (except for heavy javascript or Flash laden websites).</p>

<p>Unfortunately, the latest version of the <a href="http://vimperator.org/trac/wiki/Vimperator">Vimperator</a> plugin (version 2.0) causes my install of Firefox to crash like, 80% of the time. Since Firefox is my primary browser having to force quit it all the time became a serious annoyance. </p>

<p>After doing some digging on the web it seemed that this problem was not that common (although a co-worker of mine was having the same problem but with less frequency). There was some hint in a email post that it might have something to do with an old bookmark service bug. I&#8217;m not really sure what that means, or if that is the actual problem. However, there is solution that seems to be holding up well, at least for me anyway.</p>

<p>To fix this problem here&#8217;s what you need to do:</p>

<p>1) Create a .vimperatorrc file in your home directory (/Users/brian &#8230;for example)</p>

<p>2) In this file add the following line</p>

<pre>
:set nopreload
</pre>

<p>3) Save the file and restart Firefox.</p>

<p><em>Note: I&#8217;m not entirely sure what the &#8216;nopreload&#8217; command does. I found out about this setting from <a href="http://www.mozdev.org/pipermail/vimperator/2009-April/004183.html">this mailing list email</a>.</em></p>
]]></description><wfw:commentRss>http://www.collectivenoodle.com/blog-articles/rss-comments-entry-3924092.xml</wfw:commentRss></item><item><title>Rails environment sanity</title><dc:creator>Brian Chamberlain</dc:creator><pubDate>Wed, 08 Apr 2009 15:04:41 +0000</pubDate><link>http://www.collectivenoodle.com/blog-articles/2009/4/8/rails-environment-sanity.html</link><guid isPermaLink="false">322227:3378849:3591290</guid><description><![CDATA[<p>Media temple&#8217;s hosting support has a neat little pearl script to check the gems on your system.
http://kb.mediatemple.net/questions/784/(gs)+How+do+I+check+my+Ruby+gems+for+proper+versions%3F</p>
]]></description><wfw:commentRss>http://www.collectivenoodle.com/blog-articles/rss-comments-entry-3591290.xml</wfw:commentRss></item><item><title>Jumping ship. Moving from Textmate to Vim for Rails development</title><category>Programming</category><category>Textmate</category><category>VIM</category><category>development</category><category>programming</category><category>rails</category><dc:creator>Brian Chamberlain</dc:creator><pubDate>Fri, 27 Mar 2009 01:39:18 +0000</pubDate><link>http://www.collectivenoodle.com/blog-articles/2009/3/27/jumping-ship-moving-from-textmate-to-vim-for-rails-developme.html</link><guid isPermaLink="false">322227:3378849:3470476</guid><description><![CDATA[<h1>Background</h1>

<p>For the last two years or so I&#8217;ve been using <a href="http://macromates.com/">Texmate</a> for almost all of my Rails development. When I first started with Rails it was the <a href="http://www.loudthinking.com/arc/000270.html">recommended editor to use</a> and much cheaper than the alternative (BBEdit). I purchased my copy and started hacking away. Even though Textmate met most of my needs I experimented with <a href="http://www.aptana.com/rails">RadRails</a> (now Aptana), <a href="http://www.activestate.com/komodo/">Komodo</a>, and <a href="http://www.textpad.com/">Textpad</a> (on Windows) and none of them had the simplicity, flexibility, or ease of use as Textmate. Recently I&#8217;ve noticed that there has been a fall off in Textmate development (<a href="http://www.versiontracker.com/dyn/moreinfo/macosx/24928&amp;mode=feedback&amp;vid=All">version 1.5.8</a> was release sometime in February, prior to that <a href="http://www.versiontracker.com/dyn/moreinfo/macosx/24928&amp;vid=463931&amp;mode=info">version 1.5.7</a> was released in October of 2007!). Not that this is a huge problem, but with the textmate <a href="http://wiki.macromates.com/Suggestions/GUI">feature request as long as it is</a> I would hope that the developer would be more on top of things.</p>

<h1>Why the switch?</h1>

<p>After much consideration, I decided to give Vim a try. Part of my reason for a switch in text editors was because I was looking for what would be the the &#8220;samurai sword&#8221; for software development (if there is such a thing). The other part of the reason why I started looking for other text editors was the ability to open two files at once. While this may not seem like a big deal to most people, I am tired of cmd-T&#8217;ing between my models and my spec files, my css and my views, my models and my migrations, etc&#8230; Perhaps it&#8217;s my development style or lack of short term memory but having to toggle between two files was beginning to wear on me and my productivity.</p>

<h1>Why Vim?</h1>

<p>Well, it helps that a developer I work with is a Vim guru. Also, (on his recommendation) I started using a Firefox plugin called <a href="http://vimperator.org/trac/wiki/Vimperator">Vimperator</a>. This is a cool tool that is like a Vim gateway drug. It removes almost all interface elements in your browser and allows you to interact with web pages like they were files in Vim. It&#8217;s totally sweet. Being able to browse the web without your mouse is more awesome than you can imagine! </p>

<p>After using Vimperator for a while I started to become comfortable with how to use Vim. I had learned some of the commands to navigate. I was ready to make the plunge into Rails development in Vim. </p>

<h1>How to do it</h1>

<p>I&#8217;m not going to get into how to use Vim. There are <a href="http://www.google.com/search?hl=en&amp;q=vim+tutorial&amp;btnG=Search&amp;cts=1238123302554">far better sites</a> out there for that purpose. Here are some of the add-ons for Vim I recommend to make the transition from Textmate to Vim easier.</p>

<ol>
<li><p>First, I use a Mac so MacVim is a must. <a href="http://code.google.com/p/macvim/">You can get MacVim here</a>. </p></li>
<li><p>Once you&#8217;ve got that installed <a href="http://www.vim.org/scripts/script.php?script_id=1567">get the Rails script utility</a> to make your Vim Rails aware. It will make it easy to switch between related files, run rake tasks, etc&#8230; </p></li>
<li><p>To get the nice tree project gutter that Textmate has there is <a href="http://www.vim.org/scripts/script.php?script_id=1658">NERDTree</a>. Using the same commands for navigating vim you can navigate your project files with ease.</p></li>
</ol>

<p>One last tip&#8230; Vim (and other advanced text editors) have a lot of sharp edges. One which cut me was the caps lock key. Caps lock is a pretty <a href="http://www.engadget.com/2006/08/17/the-war-against-the-caps-lock-key-is-on/3">useless key</a>. I&#8217;m not sure how it ended up on modern computers. Perhaps so people can <a href="http://www.flickr.com/photos/cosford/2056310717/">unleash the fury</a>?! Anyway, there is this neat program called <a href="http://www.pqrs.org/tekezo/macosx/keyremap4macbook/extra.html">PCKeyboardHack</a> that will allow you to remap your caps lock key to esc which is great for Vim because the esc key is vital to Vim usage. </p>

<h1>The old (and busted)</h1>

<p><span class="full-image-block ssNonEditable"><span><img src="http://www.collectivenoodle.com/storage/textmate.jpg?__SQUARESPACE_CACHEVERSION=1238176607825" alt=""/></span></span></p>

<h1>The new (with teh hotness)</h1>

<p><span class="full-image-block ssNonEditable"><span><img src="http://www.collectivenoodle.com/storage/vim.jpg?__SQUARESPACE_CACHEVERSION=1238176585982" alt=""/></span></span></p>

<p>Hope this post helps with your Textmate to Vim conversion. It takes sometime to make the transition but it&#8217;s worth it. I&#8217;ll post more tips when I have them.</p>
]]></description><wfw:commentRss>http://www.collectivenoodle.com/blog-articles/rss-comments-entry-3470476.xml</wfw:commentRss></item><item><title>First Post</title><dc:creator>Brian Chamberlain</dc:creator><pubDate>Fri, 27 Mar 2009 01:35:24 +0000</pubDate><link>http://www.collectivenoodle.com/blog-articles/2009/3/27/first-post.html</link><guid isPermaLink="false">322227:3378849:3470202</guid><description><![CDATA[<p>This is my first post on the new squarespace site. They provide pretty great service!</p>
]]></description><wfw:commentRss>http://www.collectivenoodle.com/blog-articles/rss-comments-entry-3470202.xml</wfw:commentRss></item></channel></rss>