<?xml version="1.0" encoding="UTF-8"?>
<rss version="2.0"
	xmlns:content="http://purl.org/rss/1.0/modules/content/"
	xmlns:wfw="http://wellformedweb.org/CommentAPI/"
	xmlns:dc="http://purl.org/dc/elements/1.1/"
	xmlns:atom="http://www.w3.org/2005/Atom"
	xmlns:sy="http://purl.org/rss/1.0/modules/syndication/"
	xmlns:slash="http://purl.org/rss/1.0/modules/slash/"
	>

<channel>
	<title>Virtuous Code &#187; rails</title>
	<atom:link href="http://devblog.avdi.org/tag/rails/feed/" rel="self" type="application/rss+xml" />
	<link>http://devblog.avdi.org</link>
	<description>&#34;The three virtues of a programmer: laziness, impatience, and hubris&#34; -- Larry Wall</description>
	<lastBuildDate>Thu, 23 May 2013 18:31:20 +0000</lastBuildDate>
	<language>en-US</language>
	<sy:updatePeriod>hourly</sy:updatePeriod>
	<sy:updateFrequency>1</sy:updateFrequency>
	<generator>http://wordpress.org/?v=</generator>
		<item>
		<title>Configuring database_cleaner with Rails, RSpec, Capybara, and Selenium</title>
		<link>http://devblog.avdi.org/2012/08/31/configuring-database_cleaner-with-rails-rspec-capybara-and-selenium/</link>
		<comments>http://devblog.avdi.org/2012/08/31/configuring-database_cleaner-with-rails-rspec-capybara-and-selenium/#comments</comments>
		<pubDate>Fri, 31 Aug 2012 04:00:00 +0000</pubDate>
		<dc:creator>Avdi Grimm</dc:creator>
				<category><![CDATA[Rails]]></category>
		<category><![CDATA[Ruby]]></category>
		<category><![CDATA[capybara]]></category>
		<category><![CDATA[database]]></category>
		<category><![CDATA[rails]]></category>
		<category><![CDATA[rspec]]></category>
		<category><![CDATA[selenium]]></category>
		<category><![CDATA[testing]]></category>

		<guid isPermaLink="false">http://devblog.avdi.org/?p=2620</guid>
		<description><![CDATA[How I avoid finding myself in database bizarro world while testing Rails apps. <a href="http://devblog.avdi.org/2012/08/31/configuring-database_cleaner-with-rails-rspec-capybara-and-selenium/">Continue reading <span class="meta-nav">&#8594;</span></a>]]></description>
				<content:encoded><![CDATA[<p>If you write Rails code, or any Ruby code that interacts with a database, and you also write automated tests, chances are you have heard of or used the <a href="https://github.com/bmabey/database_cleaner">database_cleaner</a> gem. It&#8217;s a terrific gem that abstracts away the various ORM APIs for getting the DB into a &#8220;blank slate&#8221; state. </p>
<p> Periodically I start a new project using Rails, with RSpec, Capybara, and Selenium for acceptance testing, and a short way into it I find myself banging my head against bizarre inconsistencies with the test database. I&#8217;ll set up some records in the test DB, only to have the Selenium-driven browser-based tests act like those records never existed. Eventually, I&#8217;ll realize what I did wrong and curse my feeble brain for not remembering the last time I solved the same problem. </p>
<p> The problem is always the same: the tests are being wrapped in database transactions, so any code running outside the actual test process (like, say, a server process servicing a Selenium-driven browser request) <em>does not see</em> the database fixture I&#8217;ve so carefully assembled. </p>
<p> I just walked a <a href="http://devblog.avdi.org/pair-programming-services/">pairing</a> client through the same fix, so in the interests of remembering the steps, and hopefully preventing some other folks from tearing their hair out, here are the steps needed. </p>
<p> First of all, and this is very important, go into <code>spec/spec_helper.rb</code> and change this line: </p>
<pre class="src src-ruby">config.use_transactional_fixtures = <span class="org-variable-name">true</span>
</pre>
<p> To: </p>
<pre class="src src-ruby">config.use_transactional_fixtures = <span class="org-variable-name">false</span>
</pre>
<p> This will disable rspec-rails&#8217; implicit wrapping of tests in a database transaction. Without disabling this, none of the following configuration will matter. </p>
<p> Now configure <code>database_cleaner</code>. I usually create a separate file called <code>spec/support/database_cleaner.rb</code> for this. Inside, I put something like this: </p>
<pre class="src src-ruby"><span class="org-type">RSpec</span>.configure <span class="org-keyword">do</span> |config|

  config.before(<span class="org-constant">:suite</span>) <span class="org-keyword">do</span>
    <span class="org-type">DatabaseCleaner</span>.clean_with(<span class="org-constant">:truncation</span>)
  <span class="org-keyword">end</span>

  config.before(<span class="org-constant">:each</span>) <span class="org-keyword">do</span>
    <span class="org-type">DatabaseCleaner</span>.strategy = <span class="org-constant">:transaction</span>
  <span class="org-keyword">end</span>

  config.before(<span class="org-constant">:each</span>, <span class="org-constant">:js</span> =&gt; <span class="org-variable-name">true</span>) <span class="org-keyword">do</span>
    <span class="org-type">DatabaseCleaner</span>.strategy = <span class="org-constant">:truncation</span>
  <span class="org-keyword">end</span>

  config.before(<span class="org-constant">:each</span>) <span class="org-keyword">do</span>
    <span class="org-type">DatabaseCleaner</span>.start
  <span class="org-keyword">end</span>

  config.after(<span class="org-constant">:each</span>) <span class="org-keyword">do</span>
    <span class="org-type">DatabaseCleaner</span>.clean
  <span class="org-keyword">end</span>

<span class="org-keyword">end</span>
</pre>
<p> Let&#8217;s take that step by step. </p>
<pre class="src src-ruby">config.before(<span class="org-constant">:suite</span>) <span class="org-keyword">do</span>
  <span class="org-type">DatabaseCleaner</span>.clean_with(<span class="org-constant">:truncation</span>)
<span class="org-keyword">end</span>
</pre>
<p> This says that before the entire test suite runs, clear the test database out completely. This gets rid of any garbage left over from interrupted or poorly-written tests&mdash;a common source of surprising test behavior. </p>
<pre class="src src-ruby">config.before(<span class="org-constant">:each</span>) <span class="org-keyword">do</span>
  <span class="org-type">DatabaseCleaner</span>.strategy = <span class="org-constant">:transaction</span>
<span class="org-keyword">end</span>
</pre>
<p> This part sets the default database cleaning strategy to be transactions. Transactions are very fast, and for all the tests where they <em>do</em> work&mdash;that is, any test where the entire test runs in the RSpec process&mdash;they are preferable. </p>
<pre class="src src-ruby">config.before(<span class="org-constant">:each</span>, <span class="org-constant">:js</span> =&gt; <span class="org-variable-name">true</span>) <span class="org-keyword">do</span>
  <span class="org-type">DatabaseCleaner</span>.strategy = <span class="org-constant">:truncation</span>
<span class="org-keyword">end</span>
</pre>
<p> This line <em>only</em> runs before examples which have been flagged <code>:js =&gt; true</code>. By default, these are the only tests for which Capybara fires up a test server process and drives an actual browser window via the Selenium backend. For these types of tests, transactions won&#8217;t work, so this code overrides the setting and chooses the &#8220;truncation&#8221; strategy instead. </p>
<pre class="src src-ruby">config.before(<span class="org-constant">:each</span>) <span class="org-keyword">do</span>
  <span class="org-type">DatabaseCleaner</span>.start
<span class="org-keyword">end</span>

config.after(<span class="org-constant">:each</span>) <span class="org-keyword">do</span>
  <span class="org-type">DatabaseCleaner</span>.clean
<span class="org-keyword">end</span>
</pre>
<p> These lines hook up <code>database_cleaner</code> around the beginning and end of each test, telling it to execute whatever cleanup strategy we selected beforehand. </p>
<p> And that&#8217;s it! </p>
<p> Note that this is all for RSpec, and does not cover Cucumber configuration. </p>
<p> Hopefully this will help someone else out there avoid the frustrations I&#8217;ve run into! </p>
<p> EDIT: A few people have asked me why I don&#8217;t just force all threads to share the same ActiveRecord connection, as demonstrated <a href="https://gist.github.com/470808">in this Gist</a>. A few reasons: </p>
<ul>
<li>Using <code>database_cleaner</code> implies that I want ORM   neutrality. <code>database_cleaner</code> supports ActiveRecord, DataMapper,   MongoMapper, and others. The solution linked above only works for   ActiveRecord.  </li>
<li>It&#8217;s a monkey-patched kludge which will only work so long as AR   refrains from changing its connection-sharing internals. And frankly   I&#8217;m not sure I trust it to work across all Ruby VM and database   combinations (UPDATE: And indeed, I&#8217;ve now seen two different people   say there are race conditions with the current Postgres   adapter). I&#8217;d be more inclined to use it if ActiveRecord had a   published configuration option which was known to work in all   contexts.  </li>
<li>As I stressed above, I&#8217;m careful to set things up so that only the   tests that need them fall back to truncation. Since <code>:js =&gt; true</code>   tests generally don&#8217;t form the bulk of my suite (and since they are   unavoidably slow anyway, due to the overhead of driving a browser),   I&#8217;m not overly concerned about the added overhead. Perhaps if all of   my acceptance tests drove a live browser I&#8217;d be more worried about   it.  </li>
<li>In cases where database truncation <em>is</em> taking up a significant   amount of test time, you can usually speed things up with some   judicious control of which subset of tables get truncated for a   given test. This is something <code>database_cleaner</code> makes pretty   easy. Maybe that would make a good topic for a followup post.  </li>
<li>UPDATE: Oh yeah, and as <a href="https://twitter.com/donaldball/status/241548932415635456">@donaldball points out</a>, sharing a   transaction between test and test server means acceptance tests   don&#8217;t run quite the same as they would in production. Specifically,   they&#8217;ll never trigger <code>after_commit</code> hooks. </li>
</ul>
]]></content:encoded>
			<wfw:commentRss>http://devblog.avdi.org/2012/08/31/configuring-database_cleaner-with-rails-rspec-capybara-and-selenium/feed/</wfw:commentRss>
		<slash:comments>18</slash:comments>
		</item>
		<item>
		<title>Creating Cowsays.com Part 2: Unit Tests and Cow Files</title>
		<link>http://devblog.avdi.org/2012/05/16/creating-cowsays-com-part-2-unit-tests-and-cow-files/</link>
		<comments>http://devblog.avdi.org/2012/05/16/creating-cowsays-com-part-2-unit-tests-and-cow-files/#comments</comments>
		<pubDate>Wed, 16 May 2012 13:00:42 +0000</pubDate>
		<dc:creator>Avdi Grimm</dc:creator>
				<category><![CDATA[Announcements]]></category>
		<category><![CDATA[Screencasts]]></category>
		<category><![CDATA[bdd]]></category>
		<category><![CDATA[heroku]]></category>
		<category><![CDATA[rails]]></category>
		<category><![CDATA[ruby]]></category>
		<category><![CDATA[screencasts]]></category>
		<category><![CDATA[sinatra]]></category>
		<category><![CDATA[tdd]]></category>

		<guid isPermaLink="false">http://devblog.avdi.org/?p=2312</guid>
		<description><![CDATA[Part two in my &#8220;live&#8221;-style screencast series is now available! Watch me code up a small web app from scratch using test-driven development. In this hour-long episode, I switch from integration testing to unit testing in order to drive out &#8230; <a href="http://devblog.avdi.org/2012/05/16/creating-cowsays-com-part-2-unit-tests-and-cow-files/">Continue reading <span class="meta-nav">&#8594;</span></a>]]></description>
				<content:encoded><![CDATA[<p><a href="http://devblog.avdi.org/2012/05/16/creating-cowsays-com-part-2-unit-tests-and-cow-files/creating-cowsays-3d-2/" rel="attachment wp-att-2318"><img class="alignright  wp-image-2318 product" title="creating-cowsays-3d" src="http://devblog.avdi.org/wp-content/uploads/2012/05/creating-cowsays-3d-150x150.png" alt="" width="150" height="150" /></a>Part two in my &#8220;live&#8221;-style screencast series is <a href="https://shiprise.dpdcart.com/cart/add?product_id=38354&amp;method_id=38512">now available</a>! Watch me code up a small web app from scratch using test-driven development.</p>
<p>In this hour-long episode, I switch from integration testing to unit testing in order to drive out some more features for the Sinatra-based web service I&#8217;ve been building. You&#8217;ll see me:</p>
<ul>
<li>Use the &#8220;hub&#8221; gem to interact with GitHub.</li>
<li>Talk about the decision point to drop from integration to unit testing.</li>
<li>Use <code>IO.popen</code> to pipe text through an external process.</li>
<li>Isolate tests for filesystem interaction using simple dependency injection.</li>
<li>Use <code>Enumerable#each_cons</code> and enumerators to identify a sub-sequence in an Array.</li>
<li>Use the <code>Pathname</code> standard library.</li>
<li>&#8230;and more!</li>
</ul>
<div>
<p>Here&#8217;s a five-minute preview:</p>
<p><script type='text/javascript' src='http://content.bitsontherun.com/players/Sq4RhUqK-uGtfOrbJ.js'></script></p>
<p>If that has piqued your interest, the whole episode is available for immediate purchase.</p>
</div>
<div class="cta "><p class="medium"><a href="https://shiprise.dpdcart.com/cart/add?product_id=38354&amp;method_id=38512">Buy Screencast for $5</a></p></div>
<p>Did you miss part 1? Get it now:</p>
<div class="cta "><p class="small"><a href="https://shiprise.dpdcart.com/cart/add?product_id=36134&amp;method_id=36189">Buy Part 1: Zero to Heroku for $5</a></p></div>
]]></content:encoded>
			<wfw:commentRss>http://devblog.avdi.org/2012/05/16/creating-cowsays-com-part-2-unit-tests-and-cow-files/feed/</wfw:commentRss>
		<slash:comments>0</slash:comments>
		</item>
		<item>
		<title>New maintainer needed for NullDB</title>
		<link>http://devblog.avdi.org/2012/04/13/new-maintainer-needed-for-nulldb/</link>
		<comments>http://devblog.avdi.org/2012/04/13/new-maintainer-needed-for-nulldb/#comments</comments>
		<pubDate>Fri, 13 Apr 2012 17:45:18 +0000</pubDate>
		<dc:creator>Avdi Grimm</dc:creator>
				<category><![CDATA[Announcements]]></category>
		<category><![CDATA[activerecord]]></category>
		<category><![CDATA[database]]></category>
		<category><![CDATA[nulldb]]></category>
		<category><![CDATA[rails]]></category>
		<category><![CDATA[testing]]></category>

		<guid isPermaLink="false">http://devblog.avdi.org/?p=2237</guid>
		<description><![CDATA[NullDB, for those who don&#8217;t know, is a null backend for ActiveRecord. Unlike RSpec&#8217;s stub_object, rather than raise an exception on DB access, will NullDB DB interactions simply become no-ops. This is handy for things like testing after_save hooks in &#8230; <a href="http://devblog.avdi.org/2012/04/13/new-maintainer-needed-for-nulldb/">Continue reading <span class="meta-nav">&#8594;</span></a>]]></description>
				<content:encoded><![CDATA[<p><a href="https://github.com/nulldb/nulldb">NullDB</a>, for those who don&#8217;t know, is a null backend for ActiveRecord. Unlike RSpec&#8217;s stub_object, rather than raise an exception on DB access, will NullDB DB interactions simply become no-ops. This is handy for things like testing after_save hooks in isolation.</p>
<p>Myron Marston has done a stellar job shepherding it through the Rails 3 transition, but he&#8217;s busy with <a href="https://github.com/myronmarston/vcr">other awesome projects</a> now and has asked me to look for a new maintainer. So: If you&#8217;re interested in helping keep NullDB up to date with the latest changes to ActiveRecord, please get in touch!</p>
<p>&nbsp;</p>
]]></content:encoded>
			<wfw:commentRss>http://devblog.avdi.org/2012/04/13/new-maintainer-needed-for-nulldb/feed/</wfw:commentRss>
		<slash:comments>0</slash:comments>
		</item>
		<item>
		<title>Early access beta of &#8220;Objects on Rails&#8221; Now Available</title>
		<link>http://devblog.avdi.org/2011/11/15/early-access-beta-of-objects-on-rails-now-available-2/</link>
		<comments>http://devblog.avdi.org/2011/11/15/early-access-beta-of-objects-on-rails-now-available-2/#comments</comments>
		<pubDate>Tue, 15 Nov 2011 19:38:03 +0000</pubDate>
		<dc:creator>Avdi Grimm</dc:creator>
				<category><![CDATA[Announcements]]></category>
		<category><![CDATA[Books]]></category>
		<category><![CDATA[books]]></category>
		<category><![CDATA[oo]]></category>
		<category><![CDATA[oop]]></category>
		<category><![CDATA[rails]]></category>
		<category><![CDATA[tdd]]></category>

		<guid isPermaLink="false">http://avdi.org/devblog/?p=1916</guid>
		<description><![CDATA[UPDATE: Objects on Rails is now complete and freely available online. Often, at conferences and users group meetings, I find myself discussing the intersection of Ruby on Rails, Object-Oriented development, and Test-Driven Development, and I&#8217;ll mention something like &#8220;I prefer to develop my &#8230; <a href="http://devblog.avdi.org/2011/11/15/early-access-beta-of-objects-on-rails-now-available-2/">Continue reading <span class="meta-nav">&#8594;</span></a>]]></description>
				<content:encoded><![CDATA[<p>UPDATE: Objects on Rails is now complete and <a href="http://objectsonrails.com/">freely available online</a>.</p>
<p>Often, at conferences and users group meetings, I find myself discussing the intersection of Ruby on Rails, Object-Oriented development, and Test-Driven Development, and I&#8217;ll mention something like &#8220;I prefer to develop my business objects first, and add ActiveRecord in later&#8221;. This usually leads to questions about how I structure my projects, how I isolate the business logic from ActiveRecord for testing, and so on. These discussions usually wind up with me saying &#8220;I&#8217;ll write a blog post about it&#8230;&#8221;.</p>
<p>A couple months ago I set out to start that blog post. I looked up from my keyboard a few hours later and realized that I had something rather larger than a blog post on my hands. Since then I&#8217;ve been pecking away at from time to time, in between work and conference travel. Now it&#8217;s reached the point where I&#8217;ve got a rough draft and it&#8217;s time to get some reader input.</p>
<p>When the book is complete I plan on releasing it <strong>for free</strong> for online reading in it&#8217;s entirety. It&#8217;s not quite ready for that stage yet. But today, <strong>I&#8217;m making an early-access (very) beta draft available for $5</strong>.</p>
<p>Wait a second&#8230; I&#8217;m selling you a book which I&#8217;ll eventually put online for free? How is that a good deal?</p>
<p>Here&#8217;s what you get for your money:</p>
<ul>
<li>Early access!</li>
<li>Input into the final product.</li>
<li>When they are ready, you&#8217;ll get <strong>PDF, Mobi, and Epub versions</strong> for your offline reading pleasure. These versions will not be made available for free.</li>
<li>Once it is ready, <strong>a copy of the full source code including revision history</strong> of the working demo project the book is based on. Again, this will not be made available for free.</li>
<li>A warm, fuzzy feeling because you&#8217;re supporting me in writing this and future books, like my upcoming &#8220;Confident Ruby&#8221;.</li>
</ul>
<div><span style="font-size: small;"><span class="Apple-style-span" style="line-height: 24px;">Curious about what&#8217;s in the book? Here are some of the topics covered:</span></span></div>
<div><span style="font-size: x-small;"><span class="Apple-style-span" style="line-height: 24px;"><br />
</span></span></div>
<ul>
<li>Starting with business models, adding persistence later.</li>
<li>Blazing-fast isolated tests using minitest without Rails loaded.</li>
<li>Using the language of the domain, not the language of the framework.</li>
<li>Stubbing out whole classes and modules in tests.</li>
<li>Stop worrying and learn to love Dependency Injection</li>
<li>Using the Presenter pattern to iron out convoluted view logic.</li>
<li>Exposing rich hypermedia RESTful resources with presenters.</li>
<li>Treating ActiveRecord as an implementation detail.</li>
<li>Separating fast unit tests from slower integration tests.</li>
<li>When to throw away your tests.</li>
<li>Using object composition to separate concerns.</li>
<li>Extracting object Roles into their own objects.</li>
</ul>
<p>Sound interesting? Click here to buy it now:</p>
<p style="text-align: center;"><a class="dpdcart iframe" href="https://getdpd.com/v2/cart/add/6855/27062/26612"><img class="aligncenter" style="border-style: initial; border-color: initial; border-width: 0px;" src="https://getdpd.com/images/buy_buttons/atc/solid3/buy-now_1-6_red.png" alt="Add to Cart" width="150" height="57" border="0" /></a></p>
<p style="text-align: left;">UPDATE: Want to submit feedback or discuss the book? I&#8217;ve created a Google Group for that purpose: <a href="https://groups.google.com/group/objects-on-rails">https://groups.google.com/group/objects-on-rails</a></p>
]]></content:encoded>
			<wfw:commentRss>http://devblog.avdi.org/2011/11/15/early-access-beta-of-objects-on-rails-now-available-2/feed/</wfw:commentRss>
		<slash:comments>27</slash:comments>
		</item>
		<item>
		<title>DRYing up your validations using DB reflection</title>
		<link>http://devblog.avdi.org/2011/10/20/drying-up-your-validations-using-db-reflection/</link>
		<comments>http://devblog.avdi.org/2011/10/20/drying-up-your-validations-using-db-reflection/#comments</comments>
		<pubDate>Thu, 20 Oct 2011 13:00:00 +0000</pubDate>
		<dc:creator>Avdi Grimm</dc:creator>
				<category><![CDATA[Rails]]></category>
		<category><![CDATA[activerecord]]></category>
		<category><![CDATA[rails]]></category>
		<category><![CDATA[ruby]]></category>
		<category><![CDATA[validations]]></category>

		<guid isPermaLink="false">http://avdi.org/devblog/?p=1884</guid>
		<description><![CDATA[Avoiding silent truncation of your model fields requires putting length validations on them. But this can introduce duplication of knowledge. In this post I demonstrate how to pull limit information directly from the DB into your model validations. <a href="http://devblog.avdi.org/2011/10/20/drying-up-your-validations-using-db-reflection/">Continue reading <span class="meta-nav">&#8594;</span></a>]]></description>
				<content:encoded><![CDATA[<p>Out of the box, ActiveRecord will silently truncate attribute values which exceed their column width. </p>
<pre class="src src-ruby">require <span class="org-string">'active_record'</span>

<span class="org-keyword">class</span> <span class="org-type">Greeting</span> &lt; <span class="org-type">ActiveRecord</span>::<span class="org-type">Base</span>
  establish_connection(adapter:  <span class="org-string">'mysql'</span>, 
                       database: <span class="org-string">'scratch'</span>, 
                       password: <span class="org-type">ENV</span>[<span class="org-string">'MYSQL_PASSWORD'</span>])

  connection.create_table(<span class="org-constant">:greetings</span>) <span class="org-keyword">do</span> |t|
    t.string <span class="org-constant">:text</span>, limit: 10
  <span class="org-keyword">end</span>
<span class="org-keyword">end</span>

g = <span class="org-type">Greeting</span>.create(text: <span class="org-string">"Greetings and salutations, esteemed world!"</span>)
g.reload
puts g.text <span class="org-comment-delimiter"># </span><span class="org-comment">=&gt; "Greetings "</span>
</pre>
<p> This is potentially surprising to users. To improve usability, we can set a validation: </p>
<pre class="src src-ruby">require <span class="org-string">'active_record'</span>

<span class="org-keyword">class</span> <span class="org-type">Greeting</span> &lt; <span class="org-type">ActiveRecord</span>::<span class="org-type">Base</span>
  validates <span class="org-constant">:text</span>, length: { maximum: 10 }
<span class="org-keyword">end</span>

g = <span class="org-type">Greeting</span>.create(text: <span class="org-string">"Greetings and salutations, esteemed world!"</span>)
g.valid? <span class="org-comment-delimiter"># </span><span class="org-comment">=&gt; false</span>
g.errors.full_messages <span class="org-comment-delimiter"># </span><span class="org-comment">=&gt; ["Text is too long (maximum is 10 characters)"]</span>
</pre>
<p> Now we have a new problem: duplication of the length cap. The number &#8220;10&#8243; now appears in both the database migrations, and the model validations. </p>
<p> We could extract it out into a constant, although referencing models can be problematic in migrations. But that still doesn&#8217;t account for the (many) cases where we don&#8217;t specify an explicit field limit in the migration, and instead rely on the built-in ActiveRecord defaults for field limits. </p>
<p> Here&#8217;s a solution that uses database reflection to validate a field is within its DB column size limit: </p>
<pre class="src src-ruby">validates <span class="org-constant">:text</span>,
          <span class="org-constant">:length</span> =&gt; {
              <span class="org-constant">:maximum</span> =&gt; columns_hash[<span class="org-string">'text'</span>].limit
          },
</pre>
<p> ActiveRecord provides the <code>columns_hash</code> to get at column metadata gathered from the database backend. In the code above we query it for the <code>limit</code> attribute, and use that as the max field length. By pulling the limit from the DB, we avoid duplication of knowledge. </p>
]]></content:encoded>
			<wfw:commentRss>http://devblog.avdi.org/2011/10/20/drying-up-your-validations-using-db-reflection/feed/</wfw:commentRss>
		<slash:comments>26</slash:comments>
		</item>
		<item>
		<title>View Sandboxes for Rails</title>
		<link>http://devblog.avdi.org/2011/08/16/view-sandboxes-for-rails/</link>
		<comments>http://devblog.avdi.org/2011/08/16/view-sandboxes-for-rails/#comments</comments>
		<pubDate>Tue, 16 Aug 2011 21:45:30 +0000</pubDate>
		<dc:creator>Avdi Grimm</dc:creator>
				<category><![CDATA[Howto]]></category>
		<category><![CDATA[Rails]]></category>
		<category><![CDATA[rails]]></category>
		<category><![CDATA[views]]></category>

		<guid isPermaLink="false">http://avdi.org/devblog/?p=1557</guid>
		<description><![CDATA[Designing HTML views is an iterative, interactive process by nature. And anything that slows down the iterations, slows down development. I was working on a form recently where the steps to show it went something like this: Go to the &#8230; <a href="http://devblog.avdi.org/2011/08/16/view-sandboxes-for-rails/">Continue reading <span class="meta-nav">&#8594;</span></a>]]></description>
				<content:encoded><![CDATA[<p>Designing HTML views is an iterative, interactive process by nature. And anything that slows down the iterations, slows down development.</p>
<p>I was working on a form recently where the steps to show it went something like this:</p>
<ol>
<li>Go to the home page</li>
<li>Log in</li>
<li>Click &#8220;New Thingit&#8221; (domain terms have been changed to protect the innocent)</li>
<li>Click &#8220;Edit&#8221; on the Thingit</li>
<li>Click &#8220;Settings&#8221;</li>
<li>Click &#8220;Enable Facebook integration&#8221;</li>
<li>Click &#8220;Save&#8221;</li>
<li>Click &#8220;New Wodget&#8221;</li>
<li>Fill in the &#8220;New Wodget&#8221; form</li>
<li>Click &#8220;Save&#8221;</li>
<li>Click &#8220;Edit&#8221; on the saved wodget</li>
</ol>
<p>All this just to get to the &#8220;Edit&#8221; view of a Wodget. Once you got this far the iterations were a little tighter, but because the forms were presented via AJAX, you couldn&#8217;t just hit F5 to refresh the form after making a view change. You still had to take a few steps:</p>
<ol>
<li>Click &#8220;Cancel&#8221;</li>
<li>Click &#8220;Edit&#8221;</li>
</ol>
<p>All this rigmarole got in the way of quickly seeing the results of view tweaks.</p>
<p>The way I finally decided to address the issue was to create a &#8220;view sandbox&#8221; inside the app where I could easily fiddle with arbitrary views.</p>
<p>I created a routing section for the sandbox which would only be enabled in the &#8220;development&#8221; environment:</p>
<pre name="code" class="ruby">
if Rails.env.development? 
  match 'sandbox/:action' =&gt; 'sandbox' 
end
</pre>
<p>Then I created a very basic SandboxController, with an action dedicated to the view I wanted to play with:</p>
<pre name="code" class="ruby">class SandboxController &lt; ApplicationController
  helper 'thingit'
  helper 'wodget'
  
  layout 'application'

  def edit_wodget
    @thingit = Thingit.find_or_create_by_name("SANDBOX_THINGIT") do |thingit|
      thingit.wodgets.create(...)
    end
    @wodget = @thingit.wodgets.first
  end
end</pre>
<p>The controller action created just enough example model data to keep the view happy.</p>
<p>Finally, I created a <tt>views/sandbox/edit_wodget.html.haml</tt> view corresponding to the action, which simply included the Wodget form partial.</p>
<p>With this in place, I was able to simply navigate to http://localhost:3000/sandbox/edit_wodget to experiment with changes to the view, hitting reload when I wanted to see the effect.</p>
<p>Maybe there&#8217;s a better way to do this, and if there is I hope you&#8217;ll clue me in. I present this in case anyone else has run into a situation where the change-&gt;preview-&gt;change roundtrip is just too darn slow.</p>
]]></content:encoded>
			<wfw:commentRss>http://devblog.avdi.org/2011/08/16/view-sandboxes-for-rails/feed/</wfw:commentRss>
		<slash:comments>14</slash:comments>
		</item>
		<item>
		<title>RailsConf, BohConf, DCRUG Video</title>
		<link>http://devblog.avdi.org/2011/05/13/railsconf-bohconf-dcrug-video/</link>
		<comments>http://devblog.avdi.org/2011/05/13/railsconf-bohconf-dcrug-video/#comments</comments>
		<pubDate>Fri, 13 May 2011 17:46:35 +0000</pubDate>
		<dc:creator>Avdi Grimm</dc:creator>
				<category><![CDATA[Conferences]]></category>
		<category><![CDATA[baltimore]]></category>
		<category><![CDATA[rails]]></category>
		<category><![CDATA[railsconf]]></category>
		<category><![CDATA[ruby]]></category>

		<guid isPermaLink="false">http://avdi.org/devblog/?p=1234</guid>
		<description><![CDATA[DCRUG First off, I had a great time at DCRUG last night. I enjoyed getting a peek at Jeff Casimir&#8216;s &#8220;pre-alpha&#8221; presentation on Rails views. And Joel Strait&#8216;s live demo of BEATS was very cool. I did something a little &#8230; <a href="http://devblog.avdi.org/2011/05/13/railsconf-bohconf-dcrug-video/">Continue reading <span class="meta-nav">&#8594;</span></a>]]></description>
				<content:encoded><![CDATA[<h3>DCRUG</h3>
<p>First off, I had a great time at <a href="http://www.meetup.com/dcruby/">DCRUG</a> last night. I enjoyed getting a peek at <a href="http://twitter.com/j3">Jeff Casimir</a>&#8216;s &#8220;pre-alpha&#8221; presentation on Rails views. And <a href="http://twitter.com/joelstrait">Joel Strait</a>&#8216;s live demo of <a href="http://beatsdrummachine.com/">BEATS</a> was very cool.</p>
<p>I did something a little different from my previous &#8220;Exceptional Ruby&#8221; talks. Since the time slot was limited to half an hour, I just picked five things most people don&#8217;t know about Ruby exceptions and went through them one by one. I think I enjoyed this talk more than any other I&#8217;ve given; with the pressure off to get through a ton of material in a short time, I was able to relax and just enjoy showing off some fun tricks. There&#8217;s <a href="http://youtu.be/p5BdCR-fcTI#t=17m48s">video up already</a>, thanks to <a href="https://twitter.com/#!/verticalgambit">JP Arnold</a>.</p>
<h3>RailsConf / BohConf</h3>
<p>I will be presenting my talk <a href="http://en.oreilly.com/rails2011/public/schedule/detail/18418">&#8220;<strong>Confident Code</strong>&#8220;</a>, on how to write Ruby code in a straightforward, narrative style, at <a href="http://en.oreilly.com/rails2011/public/schedule/detail/18418">RailsConf this Tuesday at 2:50PM, in Ballroom II</a>. No, this is not the exceptions talk. However, if you want to hear me blab about failure handling, I&#8217;ll be hosting a <strong>guided exploration on Ruby exceptions</strong> on Tuesday evening at 5:30PM in the <a href="http://bohconf.com/">BohConf</a> room. I&#8217;m thinking of doing a variation on the DCRUG talk, and just leading folks through some code examples that demonstrate little-known aspects of Ruby exceptions. It should be a lot of fun, I hope to see you there!</p>
<div class="zemanta-pixie" style="margin-top: 10px; height: 15px;"><a class="zemanta-pixie-a" title="Enhanced by Zemanta" href="http://www.zemanta.com/"><img class="zemanta-pixie-img" style="border: none; float: right;" src="http://img.zemanta.com/zemified_a.png?x-id=8fd679af-97db-41c6-856e-ece139c1d94b" alt="Enhanced by Zemanta" /></a></div>
]]></content:encoded>
			<wfw:commentRss>http://devblog.avdi.org/2011/05/13/railsconf-bohconf-dcrug-video/feed/</wfw:commentRss>
		<slash:comments>0</slash:comments>
		</item>
		<item>
		<title>Linkdump #7</title>
		<link>http://devblog.avdi.org/2011/04/10/linkdump-7/</link>
		<comments>http://devblog.avdi.org/2011/04/10/linkdump-7/#comments</comments>
		<pubDate>Sun, 10 Apr 2011 15:21:35 +0000</pubDate>
		<dc:creator>Avdi Grimm</dc:creator>
				<category><![CDATA[Links]]></category>
		<category><![CDATA[architecture]]></category>
		<category><![CDATA[bdd]]></category>
		<category><![CDATA[java]]></category>
		<category><![CDATA[javascript]]></category>
		<category><![CDATA[literate programming]]></category>
		<category><![CDATA[logging]]></category>
		<category><![CDATA[nodejs]]></category>
		<category><![CDATA[rails]]></category>
		<category><![CDATA[rspec]]></category>
		<category><![CDATA[ruby]]></category>
		<category><![CDATA[tdd]]></category>
		<category><![CDATA[testing]]></category>

		<guid isPermaLink="false">http://avdi.org/devblog/?p=1191</guid>
		<description><![CDATA[Hacker Chat: Pinboard Creator Maciej Ceglowski Talks About Why Boring Architecture is Good, and More Wise words. tags: development I think many developers (myself included) are easily seduced by new technology and are willing to burn a lot of time &#8230; <a href="http://devblog.avdi.org/2011/04/10/linkdump-7/">Continue reading <span class="meta-nav">&#8594;</span></a>]]></description>
				<content:encoded><![CDATA[<ul class="diigo-linkroll">
<li>
<p class="diigo-link"><a href="http://www.readwriteweb.com/hack/2011/02/pinboard-creator-maciej-ceglow.php">Hacker Chat: Pinboard Creator Maciej Ceglowski Talks About Why Boring Architecture is Good, and More</a></p>
<p class="diigo-description">Wise words.</p>
<p class="diigo-tags"><span>tags:</span>                        <a href="http://www.diigo.com/user/avdigrimm/development">development</a></p>
<ul class="diigo-annotations">
<li>
<div class="diigoContent">
<div class="diigoContentInner">I think many developers (myself included) are easily seduced by new technology and are willing to burn a lot of time rigging it together just for the joy of tinkering.  So nowadays we see a lot of fairly uninteresting web apps with very technically sweet implementations.   In designing Pinboard, I tried to steer clear of this temptation by picking very familiar, vanilla tools wherever possible so I would have no excuse for architectural wank.</div>
</p></div>
</li>
</ul>
</li>
<li>
<p class="diigo-link"><a href="http://www.heartmindcode.com/blog/2011/04/creating-ruby-hashes">Creating Ruby Hashes | Heart, Mind and Code</a></p>
<p class="diigo-description">Detailed coverage of Ruby features, just the sort of thing I love :-)</p>
<p class="diigo-tags"><span>tags:</span>                        <a href="http://www.diigo.com/user/avdigrimm/development">development</a>             <a href="http://www.diigo.com/user/avdigrimm/ruby">ruby</a></p>
<ul class="diigo-annotations">
<li>
<div class="diigoContent">
<div class="diigoContentInner">I just created a quick Ruby screencast on creating hashes. I don&rsquo;t cover all of the possibilities, but I do show 5 ways&mdash;including one you should never use.</div>
</p></div>
</li>
</ul>
</li>
<li>
<p class="diigo-link"><a href="http://www.readwriteweb.com/hack/2011/04/6-free-e-books-on-nodejs.php?utm_source=feedburner&amp;utm_medium=feed&amp;utm_campaign=Feed%3A+readwriteweb+%28ReadWriteWeb%29">6 Free E-Books and Tutorials for Learning and Mastering Node.js</a></p>
<p class="diigo-tags"><span>tags:</span>                        <a href="http://www.diigo.com/user/avdigrimm/development">development</a>             <a href="http://www.diigo.com/user/avdigrimm/javascript">javascript</a>             <a href="http://www.diigo.com/user/avdigrimm/nodejs">nodejs</a></p>
</li>
<li>
<p class="diigo-link"><a href="http://marxsoftware.blogspot.com/2011/03/jdk-7-new-interfaces-classes-enums-and.html">JDK 7: New Interfaces, Classes, Enums, and Methods</a></p>
<p class="diigo-description">A rundown of some of the lesser-known additions to Java 7.</p>
<p class="diigo-tags"><span>tags:</span>                        <a href="http://www.diigo.com/user/avdigrimm/development">development</a>             <a href="http://www.diigo.com/user/avdigrimm/java">java</a></p>
<ul class="diigo-annotations">
<li>
<div class="diigoContent">
<div class="diigoContentInner">There are numerous new classes, enums, methods, and interfaces being added to <a rel="nofollow" href="http://jdk7.java.net/">JDK 7</a> that may not get significant coverage in the blogs and articles on Java 7</div>
</p></div>
</li>
</ul>
</li>
<li>
<p class="diigo-link"><a href="http://adam.heroku.com/past/2011/4/1/logs_are_streams_not_files">Logs Are Streams, Not Files</a></p>
<p class="diigo-tags"><span>tags:</span>                        <a href="http://www.diigo.com/user/avdigrimm/development">development</a>             <a href="http://www.diigo.com/user/avdigrimm/ruby">ruby</a>             <a href="http://www.diigo.com/user/avdigrimm/rails">rails</a>             <a href="http://www.diigo.com/user/avdigrimm/logging">logging</a></p>
<ul class="diigo-annotations">
<li>
<div class="diigoContent">
<div class="diigoContentInner">Unfortunately, Rails stands out as a major exception to this simple principle. It creates its own log directory and writes various files into it; some plugins even take it upon themselves to write their own, separate logfiles. This hurts the local development experience: what you see in your terminal isn&rsquo;t complete, so you have to open a separate window with <code>tail -f log/*.log</code> to get the information you want. But it hurts the deployment experience even more, because you end up having to tinker around with a bunch of Rails logger configuration options to get your logs from all your web machines to merge into a single stream.</div>
</p></div>
</li>
</ul>
</li>
<li>
<p class="diigo-link"><a href="http://www.loggly.com">Loggly&nbsp;|&nbsp;Logging as a Service</a></p>
<p class="diigo-description">Cloud-based logging service.</p>
<p class="diigo-tags"><span>tags:</span>                        <a href="http://www.diigo.com/user/avdigrimm/development">development</a>             <a href="http://www.diigo.com/user/avdigrimm/logging">logging</a>             <a href="http://www.diigo.com/user/avdigrimm/monitoring">monitoring</a></p>
</li>
<li>
<p class="diigo-link"><a href="https://papertrailapp.com">Papertrail &#8211; hosted log management. Aggregate, tail, search &#8211; instantly.</a></p>
<p class="diigo-description">A different cloud-based logging service</p>
<p class="diigo-tags"><span>tags:</span>                        <a href="http://www.diigo.com/user/avdigrimm/development">development</a>             <a href="http://www.diigo.com/user/avdigrimm/logging">logging</a>             <a href="http://www.diigo.com/user/avdigrimm/monitoring">monitoring</a></p>
</li>
<li>
<p class="diigo-link"><a href="https://github.com/ddollar/rails_log_stdout">ddollar/rails_log_stdout &#8211; GitHub</a></p>
<p class="diigo-description">Configure a Rails 2 or 3 app to log to STDOUT by default</p>
<p class="diigo-tags"><span>tags:</span>                        <a href="http://www.diigo.com/user/avdigrimm/development">development</a>             <a href="http://www.diigo.com/user/avdigrimm/ruby">ruby</a>             <a href="http://www.diigo.com/user/avdigrimm/rails">rails</a>             <a href="http://www.diigo.com/user/avdigrimm/logging">logging</a></p>
</li>
<li>
<p class="diigo-link"><a href="https://github.com/facebook/scribe/wiki">Scribe &#8211; GitHub</a></p>
<p class="diigo-description">Interesting distributed logging project.</p>
<p class="diigo-tags"><span>tags:</span>                        <a href="http://www.diigo.com/user/avdigrimm/development">development</a>             <a href="http://www.diigo.com/user/avdigrimm/logging">logging</a>             <a href="http://www.diigo.com/user/avdigrimm/monitoring">monitoring</a></p>
</li>
<li>
<p class="diigo-link"><a href="http://christophercliff.github.com/sausage">sausage.js</a></p>
<p class="diigo-description">A jQuery plugin foor pagination.</p>
<p class="diigo-tags"><span>tags:</span>                        <a href="http://www.diigo.com/user/avdigrimm/jquery">jquery</a>             <a href="http://www.diigo.com/user/avdigrimm/pagination">pagination</a>             <a href="http://www.diigo.com/user/avdigrimm/development">development</a>             <a href="http://www.diigo.com/user/avdigrimm/javascript">javascript</a>             <a href="http://www.diigo.com/user/avdigrimm/ui">ui</a></p>
<ul class="diigo-annotations">
<li>
<div class="diigoContent">
<div class="diigoContentInner">Sausage is a jQuery UI widget for contextual pagination. It complements long or infinite-scrolling pages by keeping the user informed of her location within the document</div>
</p></div>
</li>
</ul>
</li>
<li>
<p class="diigo-link"><a href="http://research.microsoft.com/en-us/um/people/simonpj/papers/parallel/remote.pdf">Cloud Haskell</a></p>
<p class="diigo-description">(PDF) A Haskell DSL for Erlang-style distributed computing.</p>
<p class="diigo-tags"><span>tags:</span>                        <a href="http://www.diigo.com/user/avdigrimm/haskell">haskell</a>             <a href="http://www.diigo.com/user/avdigrimm/erlang">erlang</a>             <a href="http://www.diigo.com/user/avdigrimm/distributed">distributed</a>             <a href="http://www.diigo.com/user/avdigrimm/csp">csp</a>             <a href="http://www.diigo.com/user/avdigrimm/development">development</a></p>
</li>
<li>
<p class="diigo-link"><a href="http://timelessrepo.com/literate-programming.html">literate-programming.rb</a></p>
<p class="diigo-description">A lovely strange loop of a post: a literate program about literate programming. Thanks to Larry Marburger for pointing it out to me.</p>
<p class="diigo-tags"><span>tags:</span>                        <a href="http://www.diigo.com/user/avdigrimm/programming">programming</a>             <a href="http://www.diigo.com/user/avdigrimm/development">development</a>             <a href="http://www.diigo.com/user/avdigrimm/literate">literate</a>             <a href="http://www.diigo.com/user/avdigrimm/ruby">ruby</a></p>
</li>
<li>
<p class="diigo-link"><a href="https://github.com/sconover/wrong">sconover/wrong &#8211; GitHub</a></p>
<p class="diigo-description">Very cool alternative for writing assertions in Ruby tests.</p>
<p class="diigo-tags"><span>tags:</span>                        <a href="http://www.diigo.com/user/avdigrimm/testing">testing</a>             <a href="http://www.diigo.com/user/avdigrimm/tdd">tdd</a>             <a href="http://www.diigo.com/user/avdigrimm/bdd">bdd</a>             <a href="http://www.diigo.com/user/avdigrimm/rspec">rspec</a>             <a href="http://www.diigo.com/user/avdigrimm/ruby">ruby</a>             <a href="http://www.diigo.com/user/avdigrimm/development">development</a>             <a href="http://www.diigo.com/user/avdigrimm/assertions">assertions</a></p>
<ul class="diigo-annotations">
<li>
<div class="diigoContent">
<div class="diigoContentInner">if you can write it in Ruby, Wrong can make a sensible failure message out of it</div>
</p></div>
</li>
</ul>
</li>
</ul>
<p class="diigo-ps">Posted from <a href="http://www.diigo.com">Diigo</a>. The rest of my favorite links are <a href="http://www.diigo.com/user/avdigrimm">here</a>.</p>
]]></content:encoded>
			<wfw:commentRss>http://devblog.avdi.org/2011/04/10/linkdump-7/feed/</wfw:commentRss>
		<slash:comments>0</slash:comments>
		</item>
		<item>
		<title>Getting Started with Erector in Rails 3</title>
		<link>http://devblog.avdi.org/2011/04/04/getting-started-with-erector-in-rails-3/</link>
		<comments>http://devblog.avdi.org/2011/04/04/getting-started-with-erector-in-rails-3/#comments</comments>
		<pubDate>Mon, 04 Apr 2011 05:20:06 +0000</pubDate>
		<dc:creator>Avdi Grimm</dc:creator>
				<category><![CDATA[Screencasts]]></category>
		<category><![CDATA[erector]]></category>
		<category><![CDATA[html]]></category>
		<category><![CDATA[markaby]]></category>
		<category><![CDATA[rails]]></category>
		<category><![CDATA[ruby]]></category>
		<category><![CDATA[views]]></category>

		<guid isPermaLink="false">http://virtuouscode.com/?p=1167</guid>
		<description><![CDATA[A quick guide to getting up and running with the Erector templating library. EDIT: Here&#8217;s the fork and branch I used to get it working.]]></description>
				<content:encoded><![CDATA[<p><script type='text/javascript' src='http://content.bitsontherun.com/players/4jCHJYMY-uGtfOrbJ.js'></script></p>
<div class="blip_description">A quick guide to getting up and running with the <a href="http://erector.rubyforge.org/" rel="nofollow">Erector</a> templating library.</div>
<div class="blip_description"></div>
<div class="blip_description">EDIT: Here&#8217;s the <a href="https://github.com/bigfix/erector/tree/rails3">fork and branch I used to get it working</a>.</div>
]]></content:encoded>
			<wfw:commentRss>http://devblog.avdi.org/2011/04/04/getting-started-with-erector-in-rails-3/feed/</wfw:commentRss>
		<slash:comments>1</slash:comments>
		</item>
		<item>
		<title>Linkdump #6</title>
		<link>http://devblog.avdi.org/2011/03/18/linkdump-6/</link>
		<comments>http://devblog.avdi.org/2011/03/18/linkdump-6/#comments</comments>
		<pubDate>Fri, 18 Mar 2011 16:22:44 +0000</pubDate>
		<dc:creator>Avdi Grimm</dc:creator>
				<category><![CDATA[Links]]></category>
		<category><![CDATA[c++]]></category>
		<category><![CDATA[c++0x]]></category>
		<category><![CDATA[clojure]]></category>
		<category><![CDATA[data structures]]></category>
		<category><![CDATA[datamapper]]></category>
		<category><![CDATA[javascript]]></category>
		<category><![CDATA[links]]></category>
		<category><![CDATA[memoization]]></category>
		<category><![CDATA[parsing]]></category>
		<category><![CDATA[rails]]></category>
		<category><![CDATA[ruby]]></category>
		<category><![CDATA[Ruby on Rails]]></category>

		<guid isPermaLink="false">http://avdi.org/devblog/?p=1149</guid>
		<description><![CDATA[agile/db_branch &#8211; GitHub I&#8217;d been looking for a way to manage databases for multiple branches of an app, and this is one of the (many) suggestions. tags: development database ruby rails git Rails plugin to play nice with git branching &#8230; <a href="http://devblog.avdi.org/2011/03/18/linkdump-6/">Continue reading <span class="meta-nav">&#8594;</span></a>]]></description>
				<content:encoded><![CDATA[<ul class="diigo-linkroll">
<li>
<p class="diigo-link"><a href="https://github.com/agile/db_branch#readme">agile/db_branch &#8211; GitHub</a></p>
<p class="diigo-description">I&#8217;d been looking for a way to manage databases for multiple branches of an app, and this is one of the (many) suggestions.</p>
<p class="diigo-tags"><span>tags:</span> <a href="http://www.diigo.com/user/avdigrimm/development">development</a> <a href="http://www.diigo.com/user/avdigrimm/database">database</a> <a href="http://www.diigo.com/user/avdigrimm/ruby">ruby</a> <a href="http://www.diigo.com/user/avdigrimm/rails">rails</a> <a href="http://www.diigo.com/user/avdigrimm/git">git</a></p>
<ul class="diigo-annotations">
<li>
<div class="diigoContent">
<div class="diigoContentInner">Rails plugin to play nice with git branching and databases. Loads abranch-specific database YAML file allowing you to migrate in branches withoutaffecting the database of other branches.</div>
</div>
</li>
</ul>
</li>
<li>
<p class="diigo-link"><a href="http://www.webappers.com/2011/03/17/documentation-about-the-most-quirky-parts-of-javascript/?utm_source=feedburner&amp;utm_medium=feed&amp;utm_campaign=Feed%3A+Webappers+%28WebAppers%29">Documentation About the Most Quirky Parts of Javascript</a></p>
<p class="diigo-tags"><span>tags:</span> <a href="http://www.diigo.com/user/avdigrimm/development">development</a> <a href="http://www.diigo.com/user/avdigrimm/javascript">javascript</a></p>
<ul class="diigo-annotations">
<li>
<div class="diigoContent">
<div class="diigoContentInner"><a title="Javascript Garden" rel="nofollow" href="http://bonsaiden.github.com/JavaScript-Garden/" target="_blank">JavaScript Garden</a> is a growing collection of documentation about the most quirky parts of the JavaScript programming language. It gives advice to avoid common mistakes, subtle bugs, as well as performance issues and bad practices that non-expert JavaScript programmers may encounter on their endeavours into the depths of the language.</div>
</div>
</li>
</ul>
</li>
<li>
<p class="diigo-link"><a href="http://slackito.com/2011/03/17/automatic-memoization-in-cplusplus0x">Automatic memoization in C++0x « slackito.com</a></p>
<p class="diigo-description">Really cool to see a practical example of some of the  new C++ features.</p>
<p class="diigo-tags"><span>tags:</span> <a href="http://www.diigo.com/user/avdigrimm/development">development</a> <a href="http://www.diigo.com/user/avdigrimm/c++">c++</a> <a href="http://www.diigo.com/user/avdigrimm/c++0x">c++0x</a></p>
<ul class="diigo-annotations">
<li>
<div class="diigoContent">
<div class="diigoContentInner">I still like the Python version better, as it looks cleaner to me, but I’m glad the new features can help us reduce the amount of boilerplate where switching to newer languages is not possible (sometimes you just NEED the extra speed). Kudos to the C++ standards committee for the improvements and the gcc team for keeping up with them</div>
</div>
</li>
</ul>
</li>
<li>
<p class="diigo-link"><a href="http://akka.io">Akka Project</a></p>
<p class="diigo-tags"><span>tags:</span> <a href="http://www.diigo.com/user/avdigrimm/scala">scala</a> <a href="http://www.diigo.com/user/avdigrimm/java">java</a> <a href="http://www.diigo.com/user/avdigrimm/concurrency">concurrency</a> <a href="http://www.diigo.com/user/avdigrimm/development">development</a></p>
<ul class="diigo-annotations">
<li>
<div class="diigoContent">
<div class="diigoContentInner">We believe that writing correct concurrent, fault-tolerant and scalable applications is too hard. Most of the time it&#8217;s because we are using the wrong tools and the wrong level of abstraction.</div>
</div>
</li>
</ul>
</li>
<li>
<p class="diigo-link"><a href="https://github.com/manalang/bdoc">manalang/bdoc &#8211; GitHub</a></p>
<p class="diigo-tags"><span>tags:</span> <a href="http://www.diigo.com/user/avdigrimm/ruby">ruby</a> <a href="http://www.diigo.com/user/avdigrimm/rubygems">rubygems</a> <a href="http://www.diigo.com/user/avdigrimm/docuementation">docuementation</a></p>
<ul class="diigo-annotations">
<li>
<div class="diigoContent">
<div class="diigoContentInner">Bdoc is a simple replacement for the gem or yard server. All it does islook at all of the Gems you have installed locally and creates a niceiframe based browser that makes it easy to navigate between gem docs. ITDOES NOT REQUIRE A SERVER FOR VIEWING… not like gem server does!</div>
</div>
</li>
</ul>
</li>
<li>
<p class="diigo-link"><a href="http://kschiess.github.com/parslet/index.html">parslet</a></p>
<p class="diigo-description">I really need to give Parslet a shot; I&#8217;ve been badly disappointed by the nonexistent error reporting in other Ruby parser generators.</p>
<p class="diigo-tags"><span>tags:</span> <a href="http://www.diigo.com/user/avdigrimm/development">development</a> <a href="http://www.diigo.com/user/avdigrimm/ruby">ruby</a> <a href="http://www.diigo.com/user/avdigrimm/parser">parser</a></p>
<ul class="diigo-annotations">
<li>
<div class="diigoContent">
<div class="diigoContentInner">
<ul>parslet makes developing complex parsers easy. It does so by</ul>
<ul>
<li>providing the best <strong>error reporting</strong> possible</li>
<li><strong>not generating</strong> reams of code for you to debug</li>
</ul>
</div>
</div>
</li>
</ul>
</li>
<li>
<p class="diigo-link"><a href="http://pastie.org/1647636">example spec_helper.rb showing Spork w/DataMapper usage</a></p>
<p class="diigo-description">How to use DataMapper with Spork and Rails 3</p>
<p class="diigo-tags"><span>tags:</span> <a href="http://www.diigo.com/user/avdigrimm/development">development</a> <a href="http://www.diigo.com/user/avdigrimm/ruby">ruby</a> <a href="http://www.diigo.com/user/avdigrimm/rails">rails</a> <a href="http://www.diigo.com/user/avdigrimm/datamapper">datamapper</a></p>
</li>
<li>
<p class="diigo-link"><a href="https://github.com/harukizaemon/hamster#readme">harukizaemon/hamster &#8211; GitHub</a></p>
<p class="diigo-description">A library of efficient immutable collection classes (a la Clojure) for Ruby.</p>
<p class="diigo-tags"><span>tags:</span> <a href="http://www.diigo.com/user/avdigrimm/development">development</a> <a href="http://www.diigo.com/user/avdigrimm/ruby">ruby</a> <a href="http://www.diigo.com/user/avdigrimm/data">data</a></p>
<ul class="diigo-annotations">
<li>
<div class="diigoContent">
<div class="diigoContentInner">Hamster collections are immutable. Whenever you modify a Hamstercollection, the original is preserved and a modified copy is returned. Thismakes them inherently thread-safe and sharable.</div>
</div>
</li>
</ul>
</li>
<li>
<p class="diigo-link"><a href="http://talklikeaduck.denhaven2.com/2011/03/13/algorithm-choice-trumps-programming-language-choice-for">Algorithm Choice Trumps Programming Language Choice For Performance</a></p>
<p class="diigo-description">My guess is that the same algorithm implemented in Haskell would once again run faster than Ruby. But this is a good reminder that the language is never the first place to look for performance improvements.</p>
<p class="diigo-tags"><span>tags:</span> <a href="http://www.diigo.com/user/avdigrimm/development">development</a> <a href="http://www.diigo.com/user/avdigrimm/ruby">ruby</a> <a href="http://www.diigo.com/user/avdigrimm/haskell">haskell</a> <a href="http://www.diigo.com/user/avdigrimm/performance">performance</a></p>
<ul class="diigo-annotations">
<li>
<div class="diigoContent">
<div class="diigoContentInner">
<p>Brian&#8217;s approach is to generate all of the substrings in the input string, then filter that list of substrings to those which are palindromes, and then output the longest one which passes through that filter.  A cursory analysis indicates that this is O(n^2) which is in-line with his data.</p>
<p>I couldn&#8217;t resist, so I sat down with my MacBook and my Sunday morning coffee and wrote my version of the program, in about 30-45 minutes.</p>
</div>
</div>
</li>
</ul>
</li>
<p class="diigo-ps">Posted from <a href="http://www.diigo.com">Diigo</a>. The rest of my favorite links are <a href="http://www.diigo.com/user/avdigrimm">here</a>.</p>
<div class="zemanta-pixie" style="margin-top: 10px; height: 15px;"><a class="zemanta-pixie-a" title="Enhanced by Zemanta" href="http://www.zemanta.com/"><img class="zemanta-pixie-img" style="border: none; float: right;" src="http://img.zemanta.com/zemified_a.png?x-id=2a4ebd8d-e36b-4498-92bf-183ed2b1edce" alt="Enhanced by Zemanta" /></a></div>
</ul>
]]></content:encoded>
			<wfw:commentRss>http://devblog.avdi.org/2011/03/18/linkdump-6/feed/</wfw:commentRss>
		<slash:comments>0</slash:comments>
		</item>
	</channel>
</rss>
