<?xml version="1.0" encoding="UTF-8"?>
<?xml-stylesheet href="http://feeds.feedburner.com/~d/styles/rss1full.xsl" type="text/xsl" media="screen"?><?xml-stylesheet href="http://feeds.feedburner.com/~d/styles/itemcontent.css" type="text/css" media="screen"?><rdf:RDF xmlns:rdf="http://www.w3.org/1999/02/22-rdf-syntax-ns#" xmlns:dc="http://purl.org/dc/elements/1.1/" xmlns="http://purl.org/rss/1.0/" xmlns:feedburner="http://rssnamespace.org/feedburner/ext/1.0"><channel rdf:about="http://www.semergence.com"><title>Semergence</title><link>http://www.semergence.com</link><description>Semantic Web, Ruby on Rails, and Massive Data</description><dc:language>en</dc:language><items><rdf:Seq><rdf:li rdf:resource="http://www.semergence.com/2008/11/17/rails-backwards-incompatible-change-coming-to-23-application-is-now-applicationcontroller/" /><rdf:li rdf:resource="http://www.semergence.com/2008/11/03/displaying-deployment-date-and-time-and-git-revision-number-in-rails-views/" /><rdf:li rdf:resource="http://www.semergence.com/2008/11/02/dear-mysql-please-include-a-rest-interface-in-your-next-version/" /><rdf:li rdf:resource="http://www.semergence.com/2008/10/29/a-count-view-for-couchdb/" /><rdf:li rdf:resource="http://www.semergence.com/2008/10/21/calculating-combinations-using-java-and-lots-of-bits/" /><rdf:li rdf:resource="http://www.semergence.com/2008/10/17/easy-way-to-configure-rails-activerecord-and-sql-server-on-mac-os-x/" /><rdf:li rdf:resource="http://www.semergence.com/2008/07/25/ironically-the-open-web-foundation-requires-registration/" /><rdf:li rdf:resource="http://www.semergence.com/2008/07/22/qotd-twitter-learning-scala/" /><rdf:li rdf:resource="http://www.semergence.com/2008/06/28/issues-with-active-scaffold-and-rails-21-solved/" /><rdf:li rdf:resource="http://www.semergence.com/2008/06/28/scalable-counters-for-web-applications/" /></rdf:Seq></items><atom10:link xmlns:atom10="http://www.w3.org/2005/Atom" rel="self" href="http://feeds.feedburner.com/Semergence" type="application/rss+xml" /><feedburner:browserFriendly>This is an XML content feed. It is intended to be viewed in a newsreader or syndicated to another site, subject to copyright and fair use.</feedburner:browserFriendly></channel><item rdf:about="http://www.semergence.com/2008/11/17/rails-backwards-incompatible-change-coming-to-23-application-is-now-applicationcontroller/"><title>Rails Backwards Incompatible Change Coming to 2.3, Application is Now ApplicationController</title><link>http://www.semergence.com/2008/11/17/rails-backwards-incompatible-change-coming-to-23-application-is-now-applicationcontroller/</link><dc:subject>rubyonrails</dc:subject><dc:subject>rails</dc:subject><dc:creator>admin</dc:creator><dc:date>2008-11-17T16:57:48-06:00</dc:date><content:encoded xmlns:content="http://purl.org/rss/1.0/modules/content/"><![CDATA[<p>Just a head&#8217;s up to <a href="http://www.rubyonrails.org">Ruby on Rails</a> fans out there.  <a href="http://en.wikipedia.org/wiki/David_Heinemeier_Hansson">DHH</a> just checked in a very <a href="http://github.com/rails/rails/commit/fcce1f17eaf9993b0210fe8e2a8117b61a1f0f69">backwards incompatible change</a> for the 2.3 branch.  The root class for your controllers is now <code>ApplicationController</code> and not <code>Application</code>.</p>
<p>I&#8217;m hoping this <a href="http://github.com/rails/rails/commit/fcce1f17eaf9993b0210fe8e2a8117b61a1f0f69">patch</a> is reverted and instead rolled out for 3.0.</p>

<p><a href="http://feeds.feedburner.com/~a/Semergence?a=JnMZTX"><img src="http://feeds.feedburner.com/~a/Semergence?i=JnMZTX" border="0"></img></a></p><div class="feedflare">
<a href="http://feeds.feedburner.com/~f/Semergence?a=hnnZN"><img src="http://feeds.feedburner.com/~f/Semergence?i=hnnZN" border="0"></img></a>
</div><img src="http://feeds.feedburner.com/~r/Semergence/~4/456504288" height="1" width="1"/>]]></content:encoded><description>Just a head&amp;#8217;s up to Ruby on Rails fans out there.  DHH just checked in a very backwards incompatible change for the 2.3 branch.  The root class for your controllers is now ApplicationController and not Application.
I&amp;#8217;m hoping this patch is reverted and instead rolled out for 3.0.</description><wfw:commentRss xmlns:wfw="http://wellformedweb.org/CommentAPI/">http://www.semergence.com/2008/11/17/rails-backwards-incompatible-change-coming-to-23-application-is-now-applicationcontroller/feed/</wfw:commentRss></item><item rdf:about="http://www.semergence.com/2008/11/03/displaying-deployment-date-and-time-and-git-revision-number-in-rails-views/"><title>Displaying Deployment Date and Time and Git Revision Number in Rails Views</title><link>http://www.semergence.com/2008/11/03/displaying-deployment-date-and-time-and-git-revision-number-in-rails-views/</link><dc:subject>git</dc:subject><dc:subject>capistrano</dc:subject><dc:subject>rubyonrails</dc:subject><dc:creator>admin</dc:creator><dc:date>2008-11-03T15:09:15-06:00</dc:date><content:encoded xmlns:content="http://purl.org/rss/1.0/modules/content/"><![CDATA[<p>I had a need to display the deployment date and time (timestamp) and the current revision/version number in the footer of all our pages in our <a href="http://www.rubyonrails.org">Rails</a> application.  Our users always were asking &#8220;Did you update the web site?&#8221;</p>
<p>Thanks to <a href="http://www.capify.org">capistrano</a>, the deployment tool, this turned out to be fairly easy.  Capistrano already collects the deployed version and places it into a file named <code>REVISION</code> in the deployment directory.  The contents hold whatever is reported by your version control software.  For <a href="http://git.or.cz/">git</a>, this is a SHA1 hash.</p>
<p>For the deployment timestamp, thankfully capistrano uses a timestamp for the deployment directory name.  So we can just parse the path, looking for the timestamp.</p>
<p>Below is the helper code, please let me know if there&#8217;s a better way.</p>
<p><code>
<pre>
  # pulls from the capistrano directory structure
  def deploy_timestamp
    if Rails.env.production?
      RAILS_ROOT.split('/').last
    else
      &quot;Undeployed&quot;
    end
  end

  def deploy_version
    if Rails.env.production?
      File.read(&quot;#{RAILS_ROOT}/REVISION&quot;)
    else
      &quot;DEV - &quot; + `git rev-parse HEAD`
    end
  end
</pre>
<p></code></p>

<p><a href="http://feeds.feedburner.com/~a/Semergence?a=YEd8AK"><img src="http://feeds.feedburner.com/~a/Semergence?i=YEd8AK" border="0"></img></a></p><div class="feedflare">
<a href="http://feeds.feedburner.com/~f/Semergence?a=2wQqN"><img src="http://feeds.feedburner.com/~f/Semergence?i=2wQqN" border="0"></img></a>
</div><img src="http://feeds.feedburner.com/~r/Semergence/~4/441390254" height="1" width="1"/>]]></content:encoded><description>I had a need to display the deployment date and time (timestamp) and the current revision/version number in the footer of all our pages in our Rails application.  Our users always were asking &amp;#8220;Did you update the web site?&amp;#8221;
Thanks to capistrano, the deployment tool, this turned out to be fairly easy.  Capistrano already [...]</description><wfw:commentRss xmlns:wfw="http://wellformedweb.org/CommentAPI/">http://www.semergence.com/2008/11/03/displaying-deployment-date-and-time-and-git-revision-number-in-rails-views/feed/</wfw:commentRss></item><item rdf:about="http://www.semergence.com/2008/11/02/dear-mysql-please-include-a-rest-interface-in-your-next-version/"><title>Dear MySQL, Please Include a REST Interface In Your Next Version</title><link>http://www.semergence.com/2008/11/02/dear-mysql-please-include-a-rest-interface-in-your-next-version/</link><dc:subject>rest</dc:subject><dc:subject>mysql</dc:subject><dc:subject>web</dc:subject><dc:creator>admin</dc:creator><dc:date>2008-11-02T13:02:30-06:00</dc:date><content:encoded xmlns:content="http://purl.org/rss/1.0/modules/content/"><![CDATA[<p>Dear <a href="http://www.mysql.com/">MySQL</a>,</p>
<p>I know you just got bought by Sun, and are now swimming in money and possibilities.  Please continue this momentum by formalizing your connection to the Web by including a RESTful end point in your next version.  The Web is where you grew up and matured, and it&#8217;s time to give back.</p>
<p>The architecture wars are nearly over, and REST has proven time and again to be the dominant architectural style for Web applications.  You, MySQL, need to expose your data via REST to promote interoperability across clients and further cement your place as one of the top databases for the Web.</p>
<p>This is low hanging fruit.</p>
<p>Your URL space is well defined, as you have databases, tables and views, rows, and columns.  The HTTP methods (GET, PUT, POST, DELETE) map very well to your SQL DML methods of SELECT, INSERT, UPDATE, and DELETE.</p>
<p>I&#8217;d imagine your URL space to be something like:</p>
<ul>
<li>/databases</li>
<li>/databases/NAME/tables</li>
<li>/databases/NAME/tables/NAME/rows</li>
<li>/databases/NAME/tables/NAME/rows/PK</li>
</ul>
<p>Use Content Negotiation to return either XML or JSON.  Use hypermedia to encapsulate the connections between rows.  Use HTTP Basic Auth and plug in to your existing user management (use SSL for security.)  Take advantage of your fondness for <a href="http://www.danga.com/memcached/">Memcached</a>.</p>
<p>With <a href="http://incubator.apache.org/couchdb/">CouchDB</a> promoting a REST interface, any language that can speak JSON and HTTP can build a trivial client.</p>
<p>MySQL, the Web is where you flurished.  Time to join the Web.</p>
<p>Sincerely,</p>
<p>Seth</p>

<p><a href="http://feeds.feedburner.com/~a/Semergence?a=jxzH5n"><img src="http://feeds.feedburner.com/~a/Semergence?i=jxzH5n" border="0"></img></a></p><div class="feedflare">
<a href="http://feeds.feedburner.com/~f/Semergence?a=wCYjN"><img src="http://feeds.feedburner.com/~f/Semergence?i=wCYjN" border="0"></img></a>
</div><img src="http://feeds.feedburner.com/~r/Semergence/~4/440194785" height="1" width="1"/>]]></content:encoded><description>Dear MySQL,
I know you just got bought by Sun, and are now swimming in money and possibilities.  Please continue this momentum by formalizing your connection to the Web by including a RESTful end point in your next version.  The Web is where you grew up and matured, and it&amp;#8217;s time to give back.
The [...]</description><wfw:commentRss xmlns:wfw="http://wellformedweb.org/CommentAPI/">http://www.semergence.com/2008/11/02/dear-mysql-please-include-a-rest-interface-in-your-next-version/feed/</wfw:commentRss></item><item rdf:about="http://www.semergence.com/2008/10/29/a-count-view-for-couchdb/"><title>A Count(*) View for CouchDB</title><link>http://www.semergence.com/2008/10/29/a-count-view-for-couchdb/</link><dc:subject>couchdb</dc:subject><dc:creator>admin</dc:creator><dc:date>2008-10-29T15:59:43-05:00</dc:date><content:encoded xmlns:content="http://purl.org/rss/1.0/modules/content/"><![CDATA[<p>I&#8217;ve been working with <a href="http://incubator.apache.org/couchdb/">CouchDB</a> a lot lately.  The first thing I tried to do, after I loaded 1,000,000 records, is to do the equivalent of <code>count(*)</code>.  Below is the view I used to implement a &#8220;count how many records I have in this database&#8221; or &#8220;count all&#8221;:</p>
<pre><code>
{ "_id": "_design/counts",
  "language": "javascript",
  "views": {
    "all": {
      "map": "function(doc) { emit(null, 1); }",
      "reduce": "function(keys, values, combine) { return sum(values); }"
    }
  }
}
</pre>
<p></code></p>

<p><a href="http://feeds.feedburner.com/~a/Semergence?a=oyciVU"><img src="http://feeds.feedburner.com/~a/Semergence?i=oyciVU" border="0"></img></a></p><div class="feedflare">
<a href="http://feeds.feedburner.com/~f/Semergence?a=6SA0M"><img src="http://feeds.feedburner.com/~f/Semergence?i=6SA0M" border="0"></img></a>
</div><img src="http://feeds.feedburner.com/~r/Semergence/~4/436238601" height="1" width="1"/>]]></content:encoded><description>I&amp;#8217;ve been working with CouchDB a lot lately.  The first thing I tried to do, after I loaded 1,000,000 records, is to do the equivalent of count(*).  Below is the view I used to implement a &amp;#8220;count how many records I have in this database&amp;#8221; or &amp;#8220;count all&amp;#8221;:

{ "_id": "_design/counts",
  "language": "javascript",
 [...]</description><wfw:commentRss xmlns:wfw="http://wellformedweb.org/CommentAPI/">http://www.semergence.com/2008/10/29/a-count-view-for-couchdb/feed/</wfw:commentRss></item><item rdf:about="http://www.semergence.com/2008/10/21/calculating-combinations-using-java-and-lots-of-bits/"><title>Calculating Combinations Using Java and Lots of Bits</title><link>http://www.semergence.com/2008/10/21/calculating-combinations-using-java-and-lots-of-bits/</link><dc:subject>algorithms</dc:subject><dc:subject>combinations</dc:subject><dc:subject>Java</dc:subject><dc:creator>admin</dc:creator><dc:date>2008-10-21T21:32:56-05:00</dc:date><content:encoded xmlns:content="http://purl.org/rss/1.0/modules/content/"><![CDATA[<p>I was feeling nostalgic and went back to see how I calculated <a href="http://www.semergence.com/2007/08/01/calculating-combinations-the-erlang-way/">combinations in Erlang</a> and <a href="http://www.semergence.com/2007/08/04/calculating-combinations-in-ruby-from-erlang/">combinations in Ruby</a>.  I wanted to see if there was a fun way to do it without resorting to recursion.</p>
<p>I started with my crazy hack to use <a href="http://www.semergence.com/2007/07/23/calculating-combinations-the-cool-way/">bit strings to calculate combinations</a>.  I didn&#8217;t want to resort to creating bit strings, as I wanted to minimize the amount of work I needed to do.  Therefore, I thought about simply using bitwise operators.</p>
<p>Below is my Java algorithm for creating calculations using iteration and bitwise operators to create all combinations from an array.</p>
<p>Thoughts?</p>
<p><code>
<pre>
public static void generate(String[] list) {
	int max = (int) Math.pow(list.length, 2)-1;
	System.out.println(max + " combinations");
	for (long i = 0; i < max; i++) {
		String[] combo = new String[Long.bitCount(i)];
		int comboPos = 0;
		for (int j = 0; j < list.length; j++) {
			if ((i &#038; (1L<<j)) > 0) {
				combo[comboPos++] = list[j];
			}
		}
		//System.out.println(Arrays.toString(combo));
	}
}
</pre>
<p></code></p>
<p>Update: handle up to 64 slots.  Will need to move to something like BigInteger to handle greater than 64 bits I suppose.  Wonder how that will affect performance?</p>

<p><a href="http://feeds.feedburner.com/~a/Semergence?a=Hmwmai"><img src="http://feeds.feedburner.com/~a/Semergence?i=Hmwmai" border="0"></img></a></p><div class="feedflare">
<a href="http://feeds.feedburner.com/~f/Semergence?a=VjaLM"><img src="http://feeds.feedburner.com/~f/Semergence?i=VjaLM" border="0"></img></a>
</div><img src="http://feeds.feedburner.com/~r/Semergence/~4/428102589" height="1" width="1"/>]]></content:encoded><description>I was feeling nostalgic and went back to see how I calculated combinations in Erlang and combinations in Ruby.  I wanted to see if there was a fun way to do it without resorting to recursion.
I started with my crazy hack to use bit strings to calculate combinations.  I didn&amp;#8217;t want to resort [...]</description><wfw:commentRss xmlns:wfw="http://wellformedweb.org/CommentAPI/">http://www.semergence.com/2008/10/21/calculating-combinations-using-java-and-lots-of-bits/feed/</wfw:commentRss></item><item rdf:about="http://www.semergence.com/2008/10/17/easy-way-to-configure-rails-activerecord-and-sql-server-on-mac-os-x/"><title>Easy Way to Configure Rails ActiveRecord and SQL Server on Mac OS X</title><link>http://www.semergence.com/2008/10/17/easy-way-to-configure-rails-activerecord-and-sql-server-on-mac-os-x/</link><dc:subject>sqlserver</dc:subject><dc:subject>rubyonrails</dc:subject><dc:creator>admin</dc:creator><dc:date>2008-10-17T14:09:17-05:00</dc:date><content:encoded xmlns:content="http://purl.org/rss/1.0/modules/content/"><![CDATA[<p>Thanks to <a href="http://wiki.rubyonrails.org/rails/pages/HowtoConnectToMicrosoftSQLServerFromRailsOnOSX">How to Connect To Microsoft SQL Server From Rails On OSX</a>, I found out a very easy way to configure the database connection.</p>
<p>Assuming you have FreeTDS installed (easily through <a href="http://www.macports.org/">macports</a>) and iODBC (comes out of the box with Mac OS X) then this is all you need in your database.yml file:</p>
<pre><code>
development:
  adapter: sqlserver
  mode: odbc
  dsn: DRIVER=/opt/local/lib/libtdsodbc.so;TDS_Version=8.0;SERVER=10.0.6.20;DATABASE=awesome_development;Port=1433;uid=sa;pwd=password;
</code></pre>
<p>No configuration of a DSN required, and no mucking about with freetds.conf!</p>
<p>Now, if I could just use database.yml to get rid of SQL Server all together, I&#8217;d be a happy developer.</p>

<p><a href="http://feeds.feedburner.com/~a/Semergence?a=fpOTZ6"><img src="http://feeds.feedburner.com/~a/Semergence?i=fpOTZ6" border="0"></img></a></p><div class="feedflare">
<a href="http://feeds.feedburner.com/~f/Semergence?a=cfM1M"><img src="http://feeds.feedburner.com/~f/Semergence?i=cfM1M" border="0"></img></a>
</div><img src="http://feeds.feedburner.com/~r/Semergence/~4/423975347" height="1" width="1"/>]]></content:encoded><description>Thanks to How to Connect To Microsoft SQL Server From Rails On OSX, I found out a very easy way to configure the database connection.
Assuming you have FreeTDS installed (easily through macports) and iODBC (comes out of the box with Mac OS X) then this is all you need in your database.yml file:

development:
  adapter: [...]</description><wfw:commentRss xmlns:wfw="http://wellformedweb.org/CommentAPI/">http://www.semergence.com/2008/10/17/easy-way-to-configure-rails-activerecord-and-sql-server-on-mac-os-x/feed/</wfw:commentRss></item><item rdf:about="http://www.semergence.com/2008/07/25/ironically-the-open-web-foundation-requires-registration/"><title>Ironically, The Open Web Foundation Requires Registration</title><link>http://www.semergence.com/2008/07/25/ironically-the-open-web-foundation-requires-registration/</link><dc:subject>web</dc:subject><dc:creator>admin</dc:creator><dc:date>2008-07-25T19:16:36-05:00</dc:date><content:encoded xmlns:content="http://purl.org/rss/1.0/modules/content/"><![CDATA[<p>So the irony is that the <a href="http://openwebfoundation.org/">Open Web Foundation</a> requires <a href="http://groups.google.com/group/open-web-discuss/subscribe?note=1">registration</a> and justification for joining.</p>

<p><a href="http://feeds.feedburner.com/~a/Semergence?a=Pb8u9I"><img src="http://feeds.feedburner.com/~a/Semergence?i=Pb8u9I" border="0"></img></a></p><div class="feedflare">
<a href="http://feeds.feedburner.com/~f/Semergence?a=dRA7FJ"><img src="http://feeds.feedburner.com/~f/Semergence?i=dRA7FJ" border="0"></img></a>
</div><img src="http://feeds.feedburner.com/~r/Semergence/~4/346150740" height="1" width="1"/>]]></content:encoded><description>So the irony is that the Open Web Foundation requires registration and justification for joining.</description><wfw:commentRss xmlns:wfw="http://wellformedweb.org/CommentAPI/">http://www.semergence.com/2008/07/25/ironically-the-open-web-foundation-requires-registration/feed/</wfw:commentRss></item><item rdf:about="http://www.semergence.com/2008/07/22/qotd-twitter-learning-scala/"><title>QOTD - Twitter Learning Scala</title><link>http://www.semergence.com/2008/07/22/qotd-twitter-learning-scala/</link><dc:subject>scala</dc:subject><dc:creator>admin</dc:creator><dc:date>2008-07-23T02:03:02-05:00</dc:date><content:encoded xmlns:content="http://purl.org/rss/1.0/modules/content/"><![CDATA[<blockquote><p>
Several of us engineers at Twitter, Inc. are learning Scala as the language in which to develop new components for our system.
</p></blockquote>
<p>From <a href="http://www.gracelessfailures.com/2008/06/test-post.html">Graceless Failures: Hello World</a></p>

<p><a href="http://feeds.feedburner.com/~a/Semergence?a=lZ3Cwd"><img src="http://feeds.feedburner.com/~a/Semergence?i=lZ3Cwd" border="0"></img></a></p><div class="feedflare">
<a href="http://feeds.feedburner.com/~f/Semergence?a=ux9mSJ"><img src="http://feeds.feedburner.com/~f/Semergence?i=ux9mSJ" border="0"></img></a>
</div><img src="http://feeds.feedburner.com/~r/Semergence/~4/343289988" height="1" width="1"/>]]></content:encoded><description>Several of us engineers at Twitter, Inc. are learning Scala as the language in which to develop new components for our system.

From Graceless Failures: Hello World</description><wfw:commentRss xmlns:wfw="http://wellformedweb.org/CommentAPI/">http://www.semergence.com/2008/07/22/qotd-twitter-learning-scala/feed/</wfw:commentRss></item><item rdf:about="http://www.semergence.com/2008/06/28/issues-with-active-scaffold-and-rails-21-solved/"><title>Issues with Active Scaffold and Rails 2.1, Solved</title><link>http://www.semergence.com/2008/06/28/issues-with-active-scaffold-and-rails-21-solved/</link><dc:subject>rubyonrails</dc:subject><dc:subject>rails</dc:subject><dc:creator>admin</dc:creator><dc:date>2008-06-28T18:07:51-05:00</dc:date><content:encoded xmlns:content="http://purl.org/rss/1.0/modules/content/"><![CDATA[<p>If you are looking to upgrade to Rails 2.1 and you are using <a href="http://activescaffold.com/">Active Scaffold</a>, be aware it still has a few rough edges.</p>
<p>Make sure you install the Rails 2.1 branch of Active Scaffold:</p>
<pre><code>
git clone git://github.com/activescaffold/active_scaffold
cd active_scaffold
git branch -r (just lists the branches)
git checkout origin/rails-2.1
</code></pre>
<p>(Check out the full thread for <a href="http://code.google.com/p/activescaffold/issues/detail?id=515#c26">Rails 2.1 and Active Scaffold compatibility</a>)</p>
<p>Second, I had to patch <code>vendor/plugins/active_scaffold/lib/extensions/generic_view_path.rb</code>.  On line 53, make it look like this:</p>
<p><code><br />
if !@template.controller.is_a?(ActionMailer::Base) &#038;&#038; @template.controller.class.uses_active_scaffold?<br />
</code></p>
<p>I had to add <code>!@template.controller.is_a?(ActionMailer::Base) &#038;&#038; </code></p>
<p>All my tests are now passing!</p>
<p>I still love Active Scaffold, even though it&#8217;s a bit behind the times.</p>

<p><a href="http://feeds.feedburner.com/~a/Semergence?a=a5hAM8"><img src="http://feeds.feedburner.com/~a/Semergence?i=a5hAM8" border="0"></img></a></p><div class="feedflare">
<a href="http://feeds.feedburner.com/~f/Semergence?a=eHRO9I"><img src="http://feeds.feedburner.com/~f/Semergence?i=eHRO9I" border="0"></img></a>
</div><img src="http://feeds.feedburner.com/~r/Semergence/~4/322270158" height="1" width="1"/>]]></content:encoded><description>If you are looking to upgrade to Rails 2.1 and you are using Active Scaffold, be aware it still has a few rough edges.
Make sure you install the Rails 2.1 branch of Active Scaffold:

git clone git://github.com/activescaffold/active_scaffold
cd active_scaffold
git branch -r (just lists the branches)
git checkout origin/rails-2.1

(Check out the full thread for Rails 2.1 and Active Scaffold [...]</description><wfw:commentRss xmlns:wfw="http://wellformedweb.org/CommentAPI/">http://www.semergence.com/2008/06/28/issues-with-active-scaffold-and-rails-21-solved/feed/</wfw:commentRss></item><item rdf:about="http://www.semergence.com/2008/06/28/scalable-counters-for-web-applications/"><title>Scalable Counters for Web Applications</title><link>http://www.semergence.com/2008/06/28/scalable-counters-for-web-applications/</link><dc:subject>scaling</dc:subject><dc:subject>web</dc:subject><dc:creator>admin</dc:creator><dc:date>2008-06-28T16:23:33-05:00</dc:date><content:encoded xmlns:content="http://purl.org/rss/1.0/modules/content/"><![CDATA[<p>So you need to provide a count or counter for your web application, but you want it to scale.  The naive approach would be to simply <code>select count(*) from table</code>.  That will fail under load because it requires scanning your entire collection.</p>
<p>The first question you need to ask is, Do you need exact counts or will approximate counts be good enough?  I bet in many situations, an approximate count will be perfectly reasonable.  Think about the use case of tracking web hits.  When you&#8217;re talking about millions of hits, what is the difference between 1,000,000 and 1,000,001?  Of course, only your business expert will know if approximate or exact answers are required.  The decision, though, is crucial because it&#8217;s the difference between an easy implementation and a hard (costly) implementation.</p>
<p>Let&#8217;s say, for the purposes of this article, that you&#8217;ll need very close to accurate counts, plus you need to scale <strong>a lot</strong>.  The first step is to pre-calculate the count, and cache the results.  When a new web hit occurs, grab the current count, add one, and put it back.  This approach will scale for a while, but the chance of missing a count goes up as load goes up.  Because we&#8217;re not explicitly locking on the row (which can be expensive), the last person to write the record back to the database wins.</p>
<p>The next option is to wrap the &#8220;grab record, increment, put record back&#8221; inside a locking transaction.  This will ensure that only one writer can access the counter at a time.  This ensures an accurate count, but will greatly slow down the site as contention around the single counter increases.</p>
<p>The third option, and the best option, is to split the counter up into smaller counters.  When it&#8217;s time to get the full, single count, simply grab all the counter partitions and add them up.  For very high loads, increase the number of partitions.  The theory is it&#8217;s quick to add up 100 partitions, while you&#8217;re providing 100 different counters to lock around.</p>
<p>How do you pick which partition to increment?  One easy way is to create a hash of the timestamp (or some other part of the request that changes frequently) of the request, and mod it on the number of partitions in the system.  The theory here is you&#8217;ll be spreading the load across the partitions as the number of concurrent requests increases.</p>
<p>In any scalable web system, reads should be by key and writes are expensive.  Do whatever you can to read a single object by a key, and minimize your writes.  Minimize the contention around objects in the data store, too.  Realize that ad hoc queries can almost always be implemented by pre-calculating the answers, so that an ad hoc query is simply retrieving a record by a key (instead of scanning through all rows, computing the answer as you go.)</p>
<p>For more on this technique, I recommend the excellent video <a href="http://sites.google.com/site/io/building-scalable-web-applications-with-google-app-engine">Builing Scalable Web Applications with Google App Engine</a>.</p>

<p><a href="http://feeds.feedburner.com/~a/Semergence?a=qhtHbS"><img src="http://feeds.feedburner.com/~a/Semergence?i=qhtHbS" border="0"></img></a></p><div class="feedflare">
<a href="http://feeds.feedburner.com/~f/Semergence?a=qJigrI"><img src="http://feeds.feedburner.com/~f/Semergence?i=qJigrI" border="0"></img></a>
</div><img src="http://feeds.feedburner.com/~r/Semergence/~4/322229459" height="1" width="1"/>]]></content:encoded><description>So you need to provide a count or counter for your web application, but you want it to scale.  The naive approach would be to simply select count(*) from table.  That will fail under load because it requires scanning your entire collection.
The first question you need to ask is, Do you need exact [...]</description><wfw:commentRss xmlns:wfw="http://wellformedweb.org/CommentAPI/">http://www.semergence.com/2008/06/28/scalable-counters-for-web-applications/feed/</wfw:commentRss></item></rdf:RDF>
