<?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:media="http://search.yahoo.com/mrss/"
	>

<channel>
	<title>Spongecell Tech Blog</title>
	<atom:link href="http://spongetech.wordpress.com/feed/" rel="self" type="application/rss+xml" />
	<link>http://spongetech.wordpress.com</link>
	<description>Sponges are good for polishing</description>
	<pubDate>Sun, 08 Jun 2008 02:35:21 +0000</pubDate>
	<generator>http://wordpress.org/?v=MU</generator>
	<language>en</language>
			<item>
		<title>Embedded Calendars and Github Trolling</title>
		<link>http://spongetech.wordpress.com/2008/06/07/embedded-calendars-and-github-trolling/</link>
		<comments>http://spongetech.wordpress.com/2008/06/07/embedded-calendars-and-github-trolling/#comments</comments>
		<pubDate>Sun, 08 Jun 2008 02:35:21 +0000</pubDate>
		<dc:creator>Chris Hobbs</dc:creator>
		
		<category><![CDATA[Technology]]></category>

		<guid isPermaLink="false">http://spongetech.wordpress.com/?p=47</guid>
		<description><![CDATA[I was trolling github to see what kind of calendar projects were out there and found calendar_helper. It looks decent. I would probably use it if I needed to display a simple calendar.

For displaying a rich calendar in html the best solution is of course to use Spongecell&#8217;s Monthly Online Calendar:

These calendars can easily be [...]]]></description>
			<content:encoded><![CDATA[<div class='snap_preview'><br /><p>I was trolling <a href="http://github.com" target="_blank">github</a> to see what kind of calendar projects were out there and found <a href="http://github.com/redinger/calendar_helper/tree/master" target="_blank">calendar_helper</a>. It looks decent. I would probably use it if I needed to display a simple calendar.</p>
<p><img class="alignnone size-full wp-image-45" src="http://spongetech.files.wordpress.com/2008/06/calendar_helper.png?w=362&h=254" alt="" width="362" height="254" /></p>
<p>For displaying a rich calendar in html the best solution is of course to use <a href="http://spongecell.com/online_calendar_for_website" target="_blank">Spongecell&#8217;s Monthly Online Calendar</a>:</p>
<p><a href="http://spongecell.com/online_calendar_for_website"><img class="alignnone size-full wp-image-46" src="http://spongetech.files.wordpress.com/2008/06/boxed_cal.png?w=450&h=437" alt="" width="450" height="437" /></a></p>
<p>These calendars can easily be created at <a href="http://spongecell.com">Spongecell</a> by creating some events and then getting code for your site. For a dynamic calendar built into your web application these calendars can be modified and created using the <a href="http://spongecell.com/api/help" target="_blank">Spongecell API</a>. A good <a href="http://github.com/ckhsponge/spongewolf/tree/master" target="_blank">open source</a> example of this can be found at <a href="http://spongewolf.com">Spongewolf</a>.</p>
<p>Github is my new favorite social network. My friends are defined by people watching my projects and the projects I am watching. There&#8217;s a lot less trashiness and nudity than on other social networks I try to avoid such as MySpace and LinkedIn.</p>
<img alt="" border="0" src="http://feeds.wordpress.com/1.0/categories/spongetech.wordpress.com/47/" /> <img alt="" border="0" src="http://feeds.wordpress.com/1.0/tags/spongetech.wordpress.com/47/" /> <a rel="nofollow" href="http://feeds.wordpress.com/1.0/gocomments/spongetech.wordpress.com/47/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/comments/spongetech.wordpress.com/47/" /></a> <a rel="nofollow" href="http://feeds.wordpress.com/1.0/godelicious/spongetech.wordpress.com/47/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/delicious/spongetech.wordpress.com/47/" /></a> <a rel="nofollow" href="http://feeds.wordpress.com/1.0/gostumble/spongetech.wordpress.com/47/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/stumble/spongetech.wordpress.com/47/" /></a> <a rel="nofollow" href="http://feeds.wordpress.com/1.0/godigg/spongetech.wordpress.com/47/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/digg/spongetech.wordpress.com/47/" /></a> <a rel="nofollow" href="http://feeds.wordpress.com/1.0/goreddit/spongetech.wordpress.com/47/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/reddit/spongetech.wordpress.com/47/" /></a> <img alt="" border="0" src="http://stats.wordpress.com/b.gif?host=spongetech.wordpress.com&blog=535142&post=47&subd=spongetech&ref=&feed=1" /></div>]]></content:encoded>
			<wfw:commentRss>http://spongetech.wordpress.com/2008/06/07/embedded-calendars-and-github-trolling/feed/</wfw:commentRss>
	
		<media:content url="http://a.wordpress.com/avatar/ckhsponge-128.jpg" medium="image">
			<media:title type="html">ckhsponge</media:title>
		</media:content>

		<media:content url="http://spongetech.files.wordpress.com/2008/06/calendar_helper.png" medium="image" />

		<media:content url="http://spongetech.files.wordpress.com/2008/06/boxed_cal.png" medium="image" />
	</item>
		<item>
		<title>installing git is not fun but it is more fun than a fork in your eye</title>
		<link>http://spongetech.wordpress.com/2008/04/29/installing-git-is-not-fun-but-it-is-more-fun-than-a-fork-in-your-eye/</link>
		<comments>http://spongetech.wordpress.com/2008/04/29/installing-git-is-not-fun-but-it-is-more-fun-than-a-fork-in-your-eye/#comments</comments>
		<pubDate>Wed, 30 Apr 2008 00:56:45 +0000</pubDate>
		<dc:creator>Chris Hobbs</dc:creator>
		
		<category><![CDATA[Uncategorized]]></category>

		<guid isPermaLink="false">http://spongetech.wordpress.com/?p=43</guid>
		<description><![CDATA[Here is more or less what I did to install git on OS X and on Media Temple. Newer versions of the below files will exist by the time you are reading this i.e. now.
I got the below mostly from http://dysinger.net/2007/12/30/installing-git-on-mac-os-x-105-leopard/
# GPG (if you didn&#8217;t have it already)
curl ftp://ftp.gnupg.org/gcrypt/gnupg/gnupg-1.4.7.tar.bz2 &#124; tar xj
cd gnupg-1.4.7
./configure
make
sudo make install
cd [...]]]></description>
			<content:encoded><![CDATA[<div class='snap_preview'><br /><p>Here is more or less what I did to install git on OS X and on Media Temple. Newer versions of the below files will exist by the time you are reading this i.e. now.</p>
<p>I got the below mostly from <a title="http://dysinger.net/2007/12/30/installing-git-on-mac-os-x-105-leopard/" href="http://dysinger.net/2007/12/30/installing-git-on-mac-os-x-105-leopard/">http://dysinger.net/2007/12/30/installing-git-on-mac-os-x-105-leopard/</a></p>
<p># GPG (if you didn&#8217;t have it already)<br />
curl ftp://ftp.gnupg.org/gcrypt/gnupg/gnupg-1.4.7.tar.bz2 | tar xj<br />
cd gnupg-1.4.7<br />
./configure<br />
make<br />
sudo make install<br />
cd ..</p>
<p># GetText<br />
curl http://mirrors.usc.edu/pub/gnu/gettext/gettext-0.17.tar.gz | tar xz<br />
cd gettext-0.17<br />
./configure<br />
make<br />
sudo make install<br />
cd ..</p>
<p># GIT<br />
curl http://kernel.org/pub/software/scm/git/git-1.5.4.4.tar.bz2 | tar xj<br />
cd git-1.5.4.4<br />
./configure<br />
make<br />
sudo make install<br />
cd ..<br />
curl  http://www.kernel.org/pub/software/scm/git/git-manpages-1.5.4.4.tar.bz2 |<br />
sudo tar xj -C /usr/local/share/man</p>
<p># Setup GIT<br />
git config &#8211;global user.name &#8216;My Name&#8217;<br />
git config &#8211;global user.email me@mydomain.net</p>
<p>#can you see two dashes before &#8220;global&#8221;?</p>
<img alt="" border="0" src="http://feeds.wordpress.com/1.0/categories/spongetech.wordpress.com/43/" /> <img alt="" border="0" src="http://feeds.wordpress.com/1.0/tags/spongetech.wordpress.com/43/" /> <a rel="nofollow" href="http://feeds.wordpress.com/1.0/gocomments/spongetech.wordpress.com/43/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/comments/spongetech.wordpress.com/43/" /></a> <a rel="nofollow" href="http://feeds.wordpress.com/1.0/godelicious/spongetech.wordpress.com/43/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/delicious/spongetech.wordpress.com/43/" /></a> <a rel="nofollow" href="http://feeds.wordpress.com/1.0/gostumble/spongetech.wordpress.com/43/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/stumble/spongetech.wordpress.com/43/" /></a> <a rel="nofollow" href="http://feeds.wordpress.com/1.0/godigg/spongetech.wordpress.com/43/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/digg/spongetech.wordpress.com/43/" /></a> <a rel="nofollow" href="http://feeds.wordpress.com/1.0/goreddit/spongetech.wordpress.com/43/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/reddit/spongetech.wordpress.com/43/" /></a> <img alt="" border="0" src="http://stats.wordpress.com/b.gif?host=spongetech.wordpress.com&blog=535142&post=43&subd=spongetech&ref=&feed=1" /></div>]]></content:encoded>
			<wfw:commentRss>http://spongetech.wordpress.com/2008/04/29/installing-git-is-not-fun-but-it-is-more-fun-than-a-fork-in-your-eye/feed/</wfw:commentRss>
	
		<media:content url="http://a.wordpress.com/avatar/ckhsponge-128.jpg" medium="image">
			<media:title type="html">ckhsponge</media:title>
		</media:content>
	</item>
		<item>
		<title>deployment on mediatemple with capistrano and git is not fun but it is more fun than doing your taxes</title>
		<link>http://spongetech.wordpress.com/2008/04/15/deployment-on-mediatemple-with-capistrano-and-git-is-no-walk-in-the-park/</link>
		<comments>http://spongetech.wordpress.com/2008/04/15/deployment-on-mediatemple-with-capistrano-and-git-is-no-walk-in-the-park/#comments</comments>
		<pubDate>Wed, 16 Apr 2008 01:11:56 +0000</pubDate>
		<dc:creator>Chris Hobbs</dc:creator>
		
		<category><![CDATA[Technology]]></category>

		<guid isPermaLink="false">http://spongetech.wordpress.com/?p=42</guid>
		<description><![CDATA[HAPPY TAX DAY!
Deploying to Media Temple isn&#8217;t easy. You have to add a domain, make an alternate domain and configure a lot of things through something called &#8220;mtr&#8221;. In order to deploy there with capistrano and git I first compiled git on my server to the following location:
/home/####/users/.home/usr/bin/git
Then I capify my project and copy in [...]]]></description>
			<content:encoded><![CDATA[<div class='snap_preview'><br /><p>HAPPY TAX DAY!</p>
<p>Deploying to Media Temple isn&#8217;t easy. You have to add a domain, make an alternate domain and configure a lot of things through something called &#8220;mtr&#8221;. In order to deploy there with capistrano and git I first compiled git on my server to the following location:</p>
<p>/home/####/users/.home/usr/bin/git</p>
<p>Then I <strong>capify </strong>my project and copy in the below deploy.rb with my custom settings and passwords. There are some tasks included such as mtr_init, mtr_generate_htaccess and mtr_create_link that help with media temple commands.</p>
<p> </p>
<p>deploy.rb:</p>
<pre>require 'mt-capistrano'

#gem install mt-capistrano --source=http://gems.mediatemple.net/

 

set :site,         "SITE_NUMBER (4 digits probably)"

set :application,  "APPLICATION"

set :webpath,      "APPLICATION.com"

set :domain,       "MEDIA TEMPLE DOMAIN"

set :user,         "MEDIA TEMPLE USER"

set :password,     "MEDIA TEMPLE PASSWORD"

 

set :scm, :git

set :scm_command, "/home/####/users/.home/usr/bin/git"

set :repository, "git://github.com/ckhsponge/remindblast.git"

set :deploy_to,  "/home/#{site}/containers/rails/#{application}"

set :current_deploy_dir, "#{deploy_to}/current"

set :tmp_dir, "#{deploy_to}/tmp"

 

set :checkout, "export"

 

role :web, "#{domain}"

role :app, "#{domain}"

role :db,  "#{domain}", :primary =&gt; true

 

task :after_update_code, :roles =&gt; :app do

  put(File.read('config/database.yml'), "#{release_path}/config/database.yml", :mode =&gt; 0444)

end

 

task :mtr_init, :roles =&gt; :app do

  run "cd $HOME/../../containers &amp;&amp; mkdir -p rails &amp;&amp; cd rails &amp;&amp; mkdir -p #{application} &amp;&amp; cd #{application} &amp;&amp; mkdir -p current &amp;&amp; cd current &amp;&amp; mtr add #{application} $PWD #{webpath}"

  run "mkdir -p $HOME/../../containers/rails/#{application}/shared"

  run "mkdir -p $HOME/../../containers/rails/#{application}/shared/log"

end

 

task :mtr_create_link, :roles =&gt; :app do

  run "mtr create_link #{application}"

end

 

namespace :deploy do

task :restart, :roles =&gt; :app do

  #run "mtr restart #{application} -u #{user} -p #{password}"

  #run "mtr generate_htaccess #{application} -u #{user} -p #{password}"

  run "mtr restart #{application} -u #{user} -p #{password}"

  run "mtr generate_htaccess #{application} -u #{user} -p #{password}"

  #migrate

end

end</pre>
<img alt="" border="0" src="http://feeds.wordpress.com/1.0/categories/spongetech.wordpress.com/42/" /> <img alt="" border="0" src="http://feeds.wordpress.com/1.0/tags/spongetech.wordpress.com/42/" /> <a rel="nofollow" href="http://feeds.wordpress.com/1.0/gocomments/spongetech.wordpress.com/42/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/comments/spongetech.wordpress.com/42/" /></a> <a rel="nofollow" href="http://feeds.wordpress.com/1.0/godelicious/spongetech.wordpress.com/42/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/delicious/spongetech.wordpress.com/42/" /></a> <a rel="nofollow" href="http://feeds.wordpress.com/1.0/gostumble/spongetech.wordpress.com/42/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/stumble/spongetech.wordpress.com/42/" /></a> <a rel="nofollow" href="http://feeds.wordpress.com/1.0/godigg/spongetech.wordpress.com/42/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/digg/spongetech.wordpress.com/42/" /></a> <a rel="nofollow" href="http://feeds.wordpress.com/1.0/goreddit/spongetech.wordpress.com/42/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/reddit/spongetech.wordpress.com/42/" /></a> <img alt="" border="0" src="http://stats.wordpress.com/b.gif?host=spongetech.wordpress.com&blog=535142&post=42&subd=spongetech&ref=&feed=1" /></div>]]></content:encoded>
			<wfw:commentRss>http://spongetech.wordpress.com/2008/04/15/deployment-on-mediatemple-with-capistrano-and-git-is-no-walk-in-the-park/feed/</wfw:commentRss>
	
		<media:content url="http://a.wordpress.com/avatar/ckhsponge-128.jpg" medium="image">
			<media:title type="html">ckhsponge</media:title>
		</media:content>
	</item>
		<item>
		<title>Capistrano Remote Cache Easter Party &#8216;08</title>
		<link>http://spongetech.wordpress.com/2008/03/25/capistrano-remote-cache-easter-party-08/</link>
		<comments>http://spongetech.wordpress.com/2008/03/25/capistrano-remote-cache-easter-party-08/#comments</comments>
		<pubDate>Tue, 25 Mar 2008 00:53:13 +0000</pubDate>
		<dc:creator>Chris Hobbs</dc:creator>
		
		<category><![CDATA[Uncategorized]]></category>

		<guid isPermaLink="false">http://spongetech.wordpress.com/?p=40</guid>
		<description><![CDATA[Thankfully we all survived Easter this year. To celebrate the resurrection of our savior we resurrected our servers into a new cluster at Engine Yard. The new cluster has plenty of room for us to grow as we need more resources. We didn&#8217;t kill our servers on Good Friday but we did have two hours [...]]]></description>
			<content:encoded><![CDATA[<div class='snap_preview'><br /><p>Thankfully we all survived Easter this year. To celebrate the resurrection of our savior we resurrected our servers into a new cluster at <a href="http://engineyard.com" target="_blank">Engine Yard</a>. The new cluster has plenty of room for us to grow as we need more resources. We didn&#8217;t kill our servers on Good Friday but we did have two hours of easter downtime right before midnight as we copied the database.
<p> We discovered some new deployment recipes in the process.
<p>  Engine Yard has a gem <span style="font-weight:bold;" class="Apple-style-span">eycap</span> that allows remote caching and dramatically speeds up deployment for our plugin laden application. It works by checking out our code on the remote system. For every deploy the code is updated and then copied minus the .svn directories. <b>That means an entire svn checkout is not needed!</b>
<p>First install the gem:
<p><span style="color:#3f7f5f;font-family:Monaco;font-size:11px;line-height:normal;" class="Apple-style-span">gem install eycap &#8211;source http://gems.engineyard.com</span><span style="color:#3f7f5f;font-family:Monaco;font-size:11px;line-height:normal;" class="Apple-style-span"></span><span style="color:#3f7f5f;font-family:Monaco;font-size:11px;line-height:normal;" class="Apple-style-span"></span>
<p>Then add this to your deploy.rb:
<p style="font:normal normal normal 11px/normal Monaco;color:#2a00ff;margin:0;"><span style="color:#000000;">require</span> &#8216;eycap/recipes&#8217;</p>
<p style="font:normal normal normal 11px/normal Monaco;color:#ff4040;margin:0;"><span style="color:#000000;">set</span> :deploy_via<span style="color:#000000;">,</span>    :filtered_remote_cache</p>
<p style="font:normal normal normal 11px/normal Monaco;color:#ff4040;margin:0;"><span style="color:#000000;font-family:Georgia;font-size:16px;line-height:20px;" class="Apple-style-span"><span style="color:#2a00ff;font-family:Monaco;font-size:11px;line-height:normal;" class="Apple-style-span"><span style="color:#000000;">set</span><span style="color:#ff4040;"> :repository_cache</span><span style="color:#000000;">,</span>    &#8220;/var/cache/somewhere&#8221;</span> </span></p>
<p style="font:normal normal normal 11px/normal Monaco;color:#ff4040;margin:0;">
<p style="font:normal normal normal 11px/normal Monaco;color:#ff4040;margin:0;"> <span style="color:#000000;font-family:Georgia;font-size:16px;line-height:20px;" class="Apple-style-span">
<p>The license included says anyone who has the software can use it so I think I&#8217;m allowed talk about it. Enjoy.</span></p>
<p>
<img src="http://spongetech.files.wordpress.com/2008/03/images.jpeg" alt="images.jpeg" /></p>
<img alt="" border="0" src="http://feeds.wordpress.com/1.0/categories/spongetech.wordpress.com/40/" /> <img alt="" border="0" src="http://feeds.wordpress.com/1.0/tags/spongetech.wordpress.com/40/" /> <a rel="nofollow" href="http://feeds.wordpress.com/1.0/gocomments/spongetech.wordpress.com/40/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/comments/spongetech.wordpress.com/40/" /></a> <a rel="nofollow" href="http://feeds.wordpress.com/1.0/godelicious/spongetech.wordpress.com/40/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/delicious/spongetech.wordpress.com/40/" /></a> <a rel="nofollow" href="http://feeds.wordpress.com/1.0/gostumble/spongetech.wordpress.com/40/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/stumble/spongetech.wordpress.com/40/" /></a> <a rel="nofollow" href="http://feeds.wordpress.com/1.0/godigg/spongetech.wordpress.com/40/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/digg/spongetech.wordpress.com/40/" /></a> <a rel="nofollow" href="http://feeds.wordpress.com/1.0/goreddit/spongetech.wordpress.com/40/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/reddit/spongetech.wordpress.com/40/" /></a> <img alt="" border="0" src="http://stats.wordpress.com/b.gif?host=spongetech.wordpress.com&blog=535142&post=40&subd=spongetech&ref=&feed=1" /></div>]]></content:encoded>
			<wfw:commentRss>http://spongetech.wordpress.com/2008/03/25/capistrano-remote-cache-easter-party-08/feed/</wfw:commentRss>
	
		<media:content url="http://a.wordpress.com/avatar/ckhsponge-128.jpg" medium="image">
			<media:title type="html">ckhsponge</media:title>
		</media:content>

		<media:content url="http://spongetech.files.wordpress.com/2008/03/images.jpeg" medium="image">
			<media:title type="html">images.jpeg</media:title>
		</media:content>
	</item>
		<item>
		<title>A Lazy Javascript, a Ruby Load and a Sponge plugin to a bar</title>
		<link>http://spongetech.wordpress.com/2008/03/21/a-lazy-javascript-a-ruby-load-and-a-sponge-plugin-to-a-bar/</link>
		<comments>http://spongetech.wordpress.com/2008/03/21/a-lazy-javascript-a-ruby-load-and-a-sponge-plugin-to-a-bar/#comments</comments>
		<pubDate>Fri, 21 Mar 2008 06:10:35 +0000</pubDate>
		<dc:creator>blythedunham</dc:creator>
		
		<category><![CDATA[Uncategorized]]></category>

		<category><![CDATA[ajax]]></category>

		<category><![CDATA[cache]]></category>

		<category><![CDATA[eagle]]></category>

		<category><![CDATA[fragment cache]]></category>

		<category><![CDATA[javascript]]></category>

		<category><![CDATA[late load]]></category>

		<category><![CDATA[lazy load]]></category>

		<category><![CDATA[performance]]></category>

		<category><![CDATA[plugin]]></category>

		<category><![CDATA[remote_function]]></category>

		<category><![CDATA[ruby]]></category>

		<category><![CDATA[ruby on rails]]></category>

		<category><![CDATA[sloth]]></category>

		<guid isPermaLink="false">http://spongetech.wordpress.com/?p=39</guid>
		<description><![CDATA[Lazy Load Content

Sometimes a portion of your page takes a really long time to generate and render. Instead of allowing the user to spin his thumbs, you can display the bulk of content to user and send off a separate ajax request to gather the &#8220;slow&#8221; data. Lazy Load Content makes late loading a portion [...]]]></description>
			<content:encoded><![CDATA[<div class='snap_preview'><br /><h1>Lazy Load Content</h1>
<p><img src="http://farm1.static.flickr.com/16/89276890_2754a551c6.jpg?v=0" align="middle" height="263" width="350" /></p>
<p>Sometimes a portion of your page takes a really long time to generate and render. Instead of allowing the user to spin his thumbs, you can display the bulk of content to user and send off a separate ajax request to gather the &#8220;slow&#8221; data. Lazy Load Content makes late loading a portion of your page through ajax as easy as setting up a <i>remote_function</i> call. With options to render fragment cached if they exist, and perform the late load if not, your app will fly like the sloth eating eagle.</p>
<pre></pre>
<h2>Install</h2>
<pre><font color="#003300">ruby script/plugin install </font> <font color="#003300">http://arperftoolkit.rubyforge.org/svn/trunk/lazy_load_content/</font></pre>
<p>Copy the file <a href="http://arperftoolkit.rubyforge.org/svn/trunk/lazy_load_content/javascripts/lazyLoadContent.js">javascripts/lazyLoadContent.js </a>into your public/javascripts folder and include it with prototype.js in your views.</p>
<pre></pre>
<h2>The Basics:</h2>
<p>In your <a href="http://arperftoolkit.rubyforge.org/svn/trunk/lazy_load_content/test/views/lazy_load_test/lazy_load_test.haml">rhtml or haml file</a>:</p>
<pre>&lt;h1&gt; I love giraffes.. basically &lt;/h1&gt;
&lt;% lazy_load(:remote =&gt; {:update =&gt; 'lazyLoadContent', :url =&gt; {:action =&gt; 'lazy_load_action'}})do -%&gt;
  &lt;div id = "lazyLoadContent"&gt; We wait while the giraffes are smelling themselves. &lt;/div&gt;
&lt;% end -%&gt;</pre>
<p>In your <a href="http://arperftoolkit.rubyforge.org/svn/trunk/lazy_load_content/test/controllers/lazy_load_test_controller.rb">controller </a>define the specified function</p>
<pre>def lazy_load_action
  render :text =&gt; 'The giraffes are ready!'
end</pre>
<p>When the page loads, the loading text is displayed: <font color="#ff0000">We wait while the giraffes are smelling themselves.</font><br />
Then after the ajax call we see: <font color="#008000">The giraffes are ready!</font></p>
<p>&#8230;&#8230;.. and more&#8230;&#8230;&#8230;.<span id="more-39"></span></p>
<h2>Fragment cache integration</h2>
<p>Specify the fragment cache parameters in :cache. If the fragment cache exists, the content is inserted<br />
into the file and an ajax call is not performed. If the fragment does not exist, the loading content appears and the ajax call is performed to retrieve the data:</p>
<p>haml file  <a href="http://arperftoolkit.rubyforge.org/svn/trunk/lazy_load_content/test/views/lazy_load_test/lazy_load_test.haml">lazy_load_test.haml</a>:</p>
<pre>- lazy_load(:remote =&gt; {:update =&gt; 'lazyLoadContent', :url =&gt; {:action =&gt; 'lazy_load_cache_action'}}, | :cache =&gt; {:id =&gt; params[:id],  :action =&gt; &#8216;cached_action&#8217;}) ) do |
   #lazyLoadContent While we are waiting for the giraffes to smell each other&#8230;.</pre>
<p>in your controller <a href="http://http://arperftoolkit.rubyforge.org/svn/trunk/lazy_load_content/test/controllers/lazy_load_test_controller.rb">lazy_load_controller.rb</a>:</p>
<pre>def lazy_load_cache_action
  render :partial =&gt; 'cached_action'
end</pre>
<p>in the partial _cached_action.haml:<br />
Note that the cache parameters here are exactly the same as the parameters given to cache in the lazy_load function</p>
<pre>- cache(:id =&gt; params[:id], :action =&gt; &#8216;cached_action&#8217;)
  #cachedData
    love cache!</pre>
<p>This is compatible with the <a href="http://svn.livsey.org/plugins/timed_fragment_cache/">timed_fragment_cache  </a>plugin, by specifying a second parameter with the expiry in both the cache call AND the lazy_load call.</p>
<pre>:cache =&gt; {:id =&gt; params[:id], :action =&gt; &#8216;cached_action&#8217;, :expiry =&gt; 15.minutes.from_now}</pre>
<h2>Combining multiple requests</h2>
<p>By using the <i>:bulk </i>option instead of the <i>:remote</i> option, you can combine multiple lazy load calls with the same url into one ajax call. This is convenient if you need to load multiple data during one call and wish to avoid multiple round trips. This option is only available when <i>:dom_type =&gt;  :dom_element </i>as discussed below. Unique parameters for each lazy load can be specified in the <i>:params </i>option as shown below.</p>
<p>In the controller, individual parameters will be available as an array of hash maps in <i>params[:lazy_load]. </i></p>
<pre>Parameters: {"action"=&gt;"lazy_load_bulk_action", "controller"=&gt;"lazy_load_test",  "lazy_load"=&gt;[{"id"=&gt;"1", "update"=&gt;"lazyLoadContentOne"}, {"id"=&gt;"2", "update"=&gt;"lazyLoadContentTwo"}]}</pre>
<p>Would be produced from the following:</p>
<pre>- lazy_load(:dom_type =&gt; :dom_element, |
 :bulk =&gt; {:update =&gt; 'lazyLoadContentOne', |
 :params =&gt; {:id =&gt; 1}, |
 :url =&gt; {:action =&gt; 'lazy_load_bulk_action'}}) do |
   #lazyLoadContentOne
       Loading ONE... - lazy_load(:dom_type =&gt; :dom_element, |
 :bulk =&gt; {:update =&gt; 'lazyLoadContentTwo', |
 :params =&gt; {:id =&gt; 2}, |
 :url =&gt; {:action =&gt; 'lazy_load_bulk_action'}}) do |
   #lazyLoadContentTwo
       Loading TWO...<!--more--></pre>
<h2>Types of lazy load</h2>
<ol>
<li><b> javascript:</b> (default) inline javascript that responds the the document onLoad event</li>
<li><b>dom_element:</b> insert hidden divs with request information</li>
<li><b>store: </b>Stores all options for later use by integrator</li>
</ol>
<h3>:javascript</h3>
<p>inline javascript responds to the document onLoad event to submit the Ajax request</p>
<pre>&lt;![CDATA[
document.observe("dom:loaded", function() {new Ajax.Updater('lazyLoadContent', '/lazy_load_test/lazy_load_action', {asynchronous:true, evalScripts:true})});
//]]&gt;</pre>
<h3>:dom_element</h3>
<p>Insert hidden divs into the DOM with <i>class=&#8221;lazyLoadContent&#8221;</i> and information for the ajax request. The javascript executed at the end then searches for classes on initialization and executes the ajax request based on their content. This is the preferred method used by Spongecell as it allows us to execute static javascript, and defers most of the javascript execution at the end of the page. Sponge Tom and Sponge Andrey gave me some sweet suggestions with this technique and the javascript development and by moving most of the javascript to the bottom of the page our app ate sloths like a super falcon.</p>
<p>This technique requires inclusion of <a href="http://arperftoolkit.rubyforge.org/svn/trunk/lazy_load_content/javascripts/lazyLoadContent.js">lazyLoadContent.js</a> in the document. Please copy the file into your public/javascripts and include it with prototype.js in your view</p>
<pre>= javascript_include_tag "vendor/prototype"

= javascript_include_tag "vendor/lazyLoadContent/lazyLoadContent"</pre>
<pre>&lt;div class="lazyLoadContent" lazyloadeval="new Ajax.Updater('lazyLoadContent', '/lazy_load_test/lazy_load_action', {asynchronous:true, evalScripts:true})" style="display:none"&gt;&lt;/div&gt;</pre>
<p>Tags generated using the :bulk option are slightly different.</p>
<pre>&lt;div class="lazyLoadContent" params="{"update": "lazyLoadContentOne", "id": 1}" style="display:none" url="/lazy_load_test/lazy_load_bulk_action"&gt;&lt;/div&gt;</pre>
<h3>:store</h3>
<p>This method renders nothing, but stores the options for later retrieval.</p>
<h2><img src="http://www.dkimages.com/discover/previews/1453/11180937.JPG" align="absmiddle" height="299" width="267" />Bottom Line</h2>
<p>Use this easy trick make your app snappy and fun. This is version 0.00001 so  yer complaints suggestions and comments.</p>
<img alt="" border="0" src="http://feeds.wordpress.com/1.0/categories/spongetech.wordpress.com/39/" /> <img alt="" border="0" src="http://feeds.wordpress.com/1.0/tags/spongetech.wordpress.com/39/" /> <a rel="nofollow" href="http://feeds.wordpress.com/1.0/gocomments/spongetech.wordpress.com/39/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/comments/spongetech.wordpress.com/39/" /></a> <a rel="nofollow" href="http://feeds.wordpress.com/1.0/godelicious/spongetech.wordpress.com/39/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/delicious/spongetech.wordpress.com/39/" /></a> <a rel="nofollow" href="http://feeds.wordpress.com/1.0/gostumble/spongetech.wordpress.com/39/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/stumble/spongetech.wordpress.com/39/" /></a> <a rel="nofollow" href="http://feeds.wordpress.com/1.0/godigg/spongetech.wordpress.com/39/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/digg/spongetech.wordpress.com/39/" /></a> <a rel="nofollow" href="http://feeds.wordpress.com/1.0/goreddit/spongetech.wordpress.com/39/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/reddit/spongetech.wordpress.com/39/" /></a> <img alt="" border="0" src="http://stats.wordpress.com/b.gif?host=spongetech.wordpress.com&blog=535142&post=39&subd=spongetech&ref=&feed=1" /></div>]]></content:encoded>
			<wfw:commentRss>http://spongetech.wordpress.com/2008/03/21/a-lazy-javascript-a-ruby-load-and-a-sponge-plugin-to-a-bar/feed/</wfw:commentRss>
	
		<media:content url="http://farm1.static.flickr.com/16/89276890_2754a551c6.jpg?v=0" medium="image" />

		<media:content url="http://www.dkimages.com/discover/previews/1453/11180937.JPG" medium="image" />
	</item>
		<item>
		<title>ruby-xslt for windows</title>
		<link>http://spongetech.wordpress.com/2008/03/14/ruby-xslt-for-windows/</link>
		<comments>http://spongetech.wordpress.com/2008/03/14/ruby-xslt-for-windows/#comments</comments>
		<pubDate>Fri, 14 Mar 2008 23:32:12 +0000</pubDate>
		<dc:creator>Tom Bagby</dc:creator>
		
		<category><![CDATA[Technology]]></category>

		<guid isPermaLink="false">http://spongetech.wordpress.com/?p=38</guid>
		<description><![CDATA[Porting native ruby gems to Win32 is a bitch.  I have been using ruby-xslt for our XSLT needs on OS X for a while now and finally had to port it to Windows to support our minority of Windows developers.
Here is my advice for if you have to do this sort of thing:
Download the [...]]]></description>
			<content:encoded><![CDATA[<div class='snap_preview'><br /><p>Porting native ruby gems to Win32 is a bitch.  I have been using <a href="http://http://raa.ruby-lang.org/project/ruby-xslt/">ruby-xslt</a> for our XSLT needs on OS X for a while now and finally had to port it to Windows to support our minority of Windows developers.</p>
<p>Here is my advice for if you have to do this sort of thing:</p>
<p><a href="http://www.microsoft.com/downloads/details.aspx?FamilyId=E6E1C3DF-A74F-4207-8586-711EBE331CDC&amp;displaylang=en">Download the Windows SDK</a> - turns out you can download the Windows development tools for free now.  The web install wasted many hours of my time getting clogged and refusing to install and it would have been faster to just download the ISO in the first place.  You don&#8217;t need all the .Net stuff.</p>
<p>Try to get rid of any shell scripts in the gem build process.  There was a little shell to build the arguments to the linker to include the xslt libraries for example.  I wasted a bunch of time trying to get it to run in the build process somehow when the real best answer was to look at the output in cygwin and put the equivalent flags straight into my Makefile.</p>
<p>There is a magic thing you have to do with manifests that I don&#8217;t even pretend to understand:</p>
<p><i>mt.exe -manifest my_lib_name.so.manifest -outputresource:my_lib_name.so;2</i></p>
<p>These <a href="http://blogs.law.harvard.edu/hoanga/2006/12/14/getting-a-ruby-c-extension-to-compile-on-windows/">blog posts</a> by Al Hoang explain a lot.</p>
<p>You probably have to include msvcr80.dll with your thing which is installed and used by the SDK.</p>
<p>Replace non-portable library calls with portable calls back into Ruby, not with Windows native calls.  There were a bunch of POSIX file calls in the ruby-xslt library for opening and reading libraries.  Those kinds of things are really easy to replace by just calling methods on File from C.</p>
<p>I&#8217;d like to get this all cleaned up and made available with ruby-xslt so it can be used straight from the gem by Windows users.  But it is extra work and gem install stuff is confusing and weird.  Email me if ruby-xslt for Windows is something you are looking for though and maybe I will try to put some effort into it.</p>
<p>Oh, and <a href="http://www.zlatkovic.com/libxml.en.html">these are the libxml2 and libxslt binaries precompiled for Win32</a>.</p>
<img alt="" border="0" src="http://feeds.wordpress.com/1.0/categories/spongetech.wordpress.com/38/" /> <img alt="" border="0" src="http://feeds.wordpress.com/1.0/tags/spongetech.wordpress.com/38/" /> <a rel="nofollow" href="http://feeds.wordpress.com/1.0/gocomments/spongetech.wordpress.com/38/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/comments/spongetech.wordpress.com/38/" /></a> <a rel="nofollow" href="http://feeds.wordpress.com/1.0/godelicious/spongetech.wordpress.com/38/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/delicious/spongetech.wordpress.com/38/" /></a> <a rel="nofollow" href="http://feeds.wordpress.com/1.0/gostumble/spongetech.wordpress.com/38/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/stumble/spongetech.wordpress.com/38/" /></a> <a rel="nofollow" href="http://feeds.wordpress.com/1.0/godigg/spongetech.wordpress.com/38/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/digg/spongetech.wordpress.com/38/" /></a> <a rel="nofollow" href="http://feeds.wordpress.com/1.0/goreddit/spongetech.wordpress.com/38/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/reddit/spongetech.wordpress.com/38/" /></a> <img alt="" border="0" src="http://stats.wordpress.com/b.gif?host=spongetech.wordpress.com&blog=535142&post=38&subd=spongetech&ref=&feed=1" /></div>]]></content:encoded>
			<wfw:commentRss>http://spongetech.wordpress.com/2008/03/14/ruby-xslt-for-windows/feed/</wfw:commentRss>
		</item>
		<item>
		<title>Rails is spewing sql in my soup (better sql logging for optimizing)</title>
		<link>http://spongetech.wordpress.com/2008/02/12/rails-is-spewing-sql-in-my-soup/</link>
		<comments>http://spongetech.wordpress.com/2008/02/12/rails-is-spewing-sql-in-my-soup/#comments</comments>
		<pubDate>Tue, 12 Feb 2008 07:08:01 +0000</pubDate>
		<dc:creator>blythedunham</dc:creator>
		
		<category><![CDATA[Technology]]></category>

		<category><![CDATA[active record]]></category>

		<category><![CDATA[activerecord]]></category>

		<category><![CDATA[connection]]></category>

		<category><![CDATA[execute]]></category>

		<category><![CDATA[giraffe]]></category>

		<category><![CDATA[logging]]></category>

		<category><![CDATA[mysql]]></category>

		<category><![CDATA[optimization]]></category>

		<category><![CDATA[optimize]]></category>

		<category><![CDATA[Rails]]></category>

		<category><![CDATA[ruby]]></category>

		<category><![CDATA[soup]]></category>

		<category><![CDATA[sql]]></category>

		<guid isPermaLink="false">http://spongetech.wordpress.com/?p=37</guid>
		<description><![CDATA[Im all pissy today because Rails is spewing all these sql statements out and I have no idea where they are coming from so I can add my little optimizations or what have you. As if I wasn&#8217;t already crying in my soup.
 log_sql_caller(:include =&#62; 'SELECT count(*) from giraffes', :log_level =&#62; :error) { ... }

So [...]]]></description>
			<content:encoded><![CDATA[<div class='snap_preview'><br /><p><img src="http://www.jesus-is-savior.com/Evils%20in%20America/Rock-n-Roll/goats_head_soup.jpg" align="right" height="264" width="266" />Im all pissy today because Rails is spewing all these sql statements out and I have no idea where they are coming from so I can add my little optimizations or what have you. As if I wasn&#8217;t already <a href="http://images.jupiterimages.com/common/detail/40/56/23515640.jpg" target="_blank">crying in my soup</a>.</p>
<p><code> log_sql_caller(:include =&gt; 'SELECT count(*) from giraffes', :log_level =&gt; :error) { ... }<br />
</code></p>
<p>So I wrote a little <a href="http://arperftoolkit.rubyforge.org/svn/trunk/log_sql_caller/README">plugin </a>to print the callstack in the log so I don&#8217;t have to read eleventy billion lines of code! Or enable some debugger of pain.</p>
<p><code> ruby script/plugin install http://arperftoolkit.rubyforge.org/svn/trunk/log_sql_caller/ </code></p>
<p>Que bueno! Now our soup is thick and moist like goat stew. Yum.</p>
<img alt="" border="0" src="http://feeds.wordpress.com/1.0/categories/spongetech.wordpress.com/37/" /> <img alt="" border="0" src="http://feeds.wordpress.com/1.0/tags/spongetech.wordpress.com/37/" /> <a rel="nofollow" href="http://feeds.wordpress.com/1.0/gocomments/spongetech.wordpress.com/37/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/comments/spongetech.wordpress.com/37/" /></a> <a rel="nofollow" href="http://feeds.wordpress.com/1.0/godelicious/spongetech.wordpress.com/37/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/delicious/spongetech.wordpress.com/37/" /></a> <a rel="nofollow" href="http://feeds.wordpress.com/1.0/gostumble/spongetech.wordpress.com/37/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/stumble/spongetech.wordpress.com/37/" /></a> <a rel="nofollow" href="http://feeds.wordpress.com/1.0/godigg/spongetech.wordpress.com/37/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/digg/spongetech.wordpress.com/37/" /></a> <a rel="nofollow" href="http://feeds.wordpress.com/1.0/goreddit/spongetech.wordpress.com/37/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/reddit/spongetech.wordpress.com/37/" /></a> <img alt="" border="0" src="http://stats.wordpress.com/b.gif?host=spongetech.wordpress.com&blog=535142&post=37&subd=spongetech&ref=&feed=1" /></div>]]></content:encoded>
			<wfw:commentRss>http://spongetech.wordpress.com/2008/02/12/rails-is-spewing-sql-in-my-soup/feed/</wfw:commentRss>
	
		<media:content url="http://www.jesus-is-savior.com/Evils%20in%20America/Rock-n-Roll/goats_head_soup.jpg" medium="image" />
	</item>
		<item>
		<title>Delegate to the Giraffe</title>
		<link>http://spongetech.wordpress.com/2008/02/12/delegate-to-the-giraffe/</link>
		<comments>http://spongetech.wordpress.com/2008/02/12/delegate-to-the-giraffe/#comments</comments>
		<pubDate>Tue, 12 Feb 2008 06:50:56 +0000</pubDate>
		<dc:creator>blythedunham</dc:creator>
		
		<category><![CDATA[Uncategorized]]></category>

		<category><![CDATA[active record]]></category>

		<category><![CDATA[delegate]]></category>

		<category><![CDATA[Rails]]></category>

		<category><![CDATA[ruby]]></category>

		<guid isPermaLink="false">http://spongetech.wordpress.com/?p=24</guid>
		<description><![CDATA[I have gotten very tired of writing the same code over and over. And apparently I was so tired I forgot to publish this last year.
 def foo_bar
my_member ? my_member.foo_bar : nil
end 
The rails delegate method allows you to delegate a method to another class. Neat! There are two tweaks that I made to suite [...]]]></description>
			<content:encoded><![CDATA[<div class='snap_preview'><br /><p>I have gotten very tired of writing the same code over and over. And apparently I was so tired I forgot to publish this last year.<br />
<code> def foo_bar<br />
my_member ? my_member.foo_bar : nil<br />
end</code><i> </i><img src="http://spongetech.files.wordpress.com/2007/06/gosponge.jpg?w=312&h=226" align="right" height="226" width="312" /></p>
<p>The rails <a href="http://dev.rubyonrails.org/ticket/4133" title="delegate">delegate </a>method allows you to delegate a method to another class. Neat! There are two tweaks that I made to suite my salty tastes.</p>
<p>1. Nil freaks out. Sure you can write something like<br />
<code>:to =&gt; (my_member or return nil) </code>as pointed out on the <a href="http://dev.rubyonrails.org/ticket/4134">rails ticket</a>. But that is sort of groddy. boo!</p>
<p>2. I want to rename the destination method sometimes. Avoid collisions, make new friends. Win-Win.</p>
<p>Here is <b>delegate_x</b>. Delegate extra! You can list out the delegated methods or, to rename them, put them in a hash of destination_method_name =&gt; target_method_name</p>
<p><code>class WebTwoPointOMGCorp<br />
attr_accessor :giraffe</code></p>
<p><code>delegate_x :hovercraft, :to =&gt; :giraffe<br />
delegate_x :to =&gt; :giraffe, :giraffe_spots =&gt; :num_spots<br />
end</code></p>
<p>The first is equivalent to:<br />
<code>def hover_craft<br />
giraffe ?  giraffe.hover_craft : nil<br />
end</code></p>
<p>and the second</p>
<p><code>def giraffe_spots<br />
giraffe.num_spots if giraffe<br />
end</code></p>
<p>With ActiveRecord :has_one and :belongs_to associations, check out Stefan Kaes&#8217;s<a href="https://railsexpress.de/blog/articles/tag/piggy_back" title="piggy back" target="_blank"> piggyback plugin</a>  to piggy back attributes (define methods) to queried records.</p>
<p>Sweet. A little (terribly formatted) code below. Jam it in the lib or something. Make it a plugin. Just remember, the hovercraft owned by the giraffe is really the hovercraft owned by <code>WebTwoPointOMGCorp</code>.</p>
<p><i>(Actually I just wrote this whole post to show Joel&#8217;s awesome new spongecell giraffe that breathes fire! We love giraffes and so should you.)</i></p>
<blockquote></blockquote>
<blockquote></blockquote>
<p><span id="more-24"></span></p>
<p><code>class Module<br />
# like delegate only better<br />
def delegate_x(*methods)<br />
options = methods.pop<br />
unless options.is_a?(Hash) &amp;&amp; to = options.delete(:to)<br />
</code></p>
<blockquote><p><code> raise ArgumentError, "Delegation needs a target. Supply an</code><br />
<code> options hash with a :to key"</code><br />
<code> end</code></p></blockquote>
<blockquote><p><code>methods.concat(options.keys)</code></p></blockquote>
<blockquote><p><code>unless methods.any?</code><br />
<code> raise ArgumentError, "No delegated methods specified. Specify :method =&gt; :target_method or list methods"</code><br />
<code> end</code><br />
<code></code></p></blockquote>
<blockquote><p><code> methods.each do |method|</code><br />
<code> target_method = options[method]||method</code><br />
<code> module_eval(&lt;&lt;-EOS, "(__DELEGATIONX__)", 1)</code></p>
<blockquote><p><code> def #{ method }(*args, &amp;block)</code><br />
<code> #{to}.__send__(#{target_method.inspect},</code><code>*args, &amp;block) if #{to}</code><br />
<code> end</code></p></blockquote>
<p><code>EOS</code></p></blockquote>
<blockquote><p><code>end</code></p></blockquote>
<p><code>end<br />
end</code></p>
<img alt="" border="0" src="http://feeds.wordpress.com/1.0/categories/spongetech.wordpress.com/24/" /> <img alt="" border="0" src="http://feeds.wordpress.com/1.0/tags/spongetech.wordpress.com/24/" /> <a rel="nofollow" href="http://feeds.wordpress.com/1.0/gocomments/spongetech.wordpress.com/24/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/comments/spongetech.wordpress.com/24/" /></a> <a rel="nofollow" href="http://feeds.wordpress.com/1.0/godelicious/spongetech.wordpress.com/24/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/delicious/spongetech.wordpress.com/24/" /></a> <a rel="nofollow" href="http://feeds.wordpress.com/1.0/gostumble/spongetech.wordpress.com/24/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/stumble/spongetech.wordpress.com/24/" /></a> <a rel="nofollow" href="http://feeds.wordpress.com/1.0/godigg/spongetech.wordpress.com/24/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/digg/spongetech.wordpress.com/24/" /></a> <a rel="nofollow" href="http://feeds.wordpress.com/1.0/goreddit/spongetech.wordpress.com/24/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/reddit/spongetech.wordpress.com/24/" /></a> <img alt="" border="0" src="http://stats.wordpress.com/b.gif?host=spongetech.wordpress.com&blog=535142&post=24&subd=spongetech&ref=&feed=1" /></div>]]></content:encoded>
			<wfw:commentRss>http://spongetech.wordpress.com/2008/02/12/delegate-to-the-giraffe/feed/</wfw:commentRss>
	
		<media:content url="http://spongetech.files.wordpress.com/2007/06/gosponge.jpg" medium="image" />
	</item>
		<item>
		<title>Finding and Fixing Slow and Leaky Requests this MLK</title>
		<link>http://spongetech.wordpress.com/2008/01/21/finding-and-fixing-slow-and-leaky-requests-this-mlk/</link>
		<comments>http://spongetech.wordpress.com/2008/01/21/finding-and-fixing-slow-and-leaky-requests-this-mlk/#comments</comments>
		<pubDate>Mon, 21 Jan 2008 20:14:11 +0000</pubDate>
		<dc:creator>Chris Hobbs</dc:creator>
		
		<category><![CDATA[Uncategorized]]></category>

		<guid isPermaLink="false">http://spongetech.wordpress.com/2008/01/21/finding-and-fixing-slow-and-leaky-requests-this-mlk/</guid>
		<description><![CDATA[Happy MLK! For this year&#8217;s MLK Spongecell has released a new ultra-beta Boxed Calendar. It&#8217;s so ultra-beta we haven&#8217;t even mentioned it on our main blog yet.

If The Reverend had been a system administrator he definitely would not have allowed slow or leaky requests on his system. Spongecell was recently experiencing a very bad leaky [...]]]></description>
			<content:encoded><![CDATA[<div class='snap_preview'><br /><p>Happy MLK! For this year&#8217;s MLK Spongecell has released a new ultra-beta Boxed Calendar. It&#8217;s so ultra-beta we haven&#8217;t even mentioned it on our main blog yet.</p>
<p>
If The Reverend had been a system administrator he definitely would not have allowed slow or leaky requests on his system. Spongecell was recently experiencing a very bad leaky request. Luckily we were logging PIDS to support <a href="http://ckhsponge.wordpress.com/2006/10/11/ruby-on-rails-log-analyzer-rawk/" target="_blank">Rawk</a> so simply watching our mongrels and seeing when a process exploded let me know when and which process was bad. I looked at the logs and saw a few requests for that process at that time. I ran those requests on our staging server and very quickly saw a bad sql query. Turns out some new code found some very old code and the mix wasn&#8217;t pleasant. </p>
<p>
I&#8217;ve also been spending a little bit of time optimizing requests that Rawk reports have shown our server spends a lot of time on. For one of these MySql had decided to start using the wrong index on a paginated join. Thanks to Blythe, our resident ActiveRecord expert, we were able to change the has_many relationship to use an index hint. Here&#8217;s what the code looked like for User:</p>
<p>
<span class="Apple-style-span" style="color:#ff4040;font-family:Monaco;font-size:11px;line-height:normal;"><span style="color:#000000;">has_many(</span>:email_addresses<span style="color:#000000;">,</span> :foreign_key<span style="color:#000000;"> =&gt;</span> :user_id<span style="color:#000000;">,</span> :index_hint<span style="color:#000000;"> =&gt;</span> :fk_ea_user</span>  &#8230;</p>
<p>
Engine Yard also put in fair scheduling into our Nginx setup. By default nginx will distribute requests round-robin which is bad if one request is slow. When nginx sends to that slow mongrel the request will queue and wait for completion. With fair scheduling Nginx sends to available mongrels first thus less waiting.</p>
<p>
I found this picture on the internet. &#8220;Leaky pipes are the biggest wasters.&#8221;<br />
<br />
<img src="http://spongetech.files.wordpress.com/2008/01/bigstockphoto_leaky_hose_743314.jpg" alt="bigstockphoto_leaky_hose_743314.jpg" /></p>
<img alt="" border="0" src="http://feeds.wordpress.com/1.0/categories/spongetech.wordpress.com/35/" /> <img alt="" border="0" src="http://feeds.wordpress.com/1.0/tags/spongetech.wordpress.com/35/" /> <a rel="nofollow" href="http://feeds.wordpress.com/1.0/gocomments/spongetech.wordpress.com/35/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/comments/spongetech.wordpress.com/35/" /></a> <a rel="nofollow" href="http://feeds.wordpress.com/1.0/godelicious/spongetech.wordpress.com/35/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/delicious/spongetech.wordpress.com/35/" /></a> <a rel="nofollow" href="http://feeds.wordpress.com/1.0/gostumble/spongetech.wordpress.com/35/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/stumble/spongetech.wordpress.com/35/" /></a> <a rel="nofollow" href="http://feeds.wordpress.com/1.0/godigg/spongetech.wordpress.com/35/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/digg/spongetech.wordpress.com/35/" /></a> <a rel="nofollow" href="http://feeds.wordpress.com/1.0/goreddit/spongetech.wordpress.com/35/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/reddit/spongetech.wordpress.com/35/" /></a> <img alt="" border="0" src="http://stats.wordpress.com/b.gif?host=spongetech.wordpress.com&blog=535142&post=35&subd=spongetech&ref=&feed=1" /></div>]]></content:encoded>
			<wfw:commentRss>http://spongetech.wordpress.com/2008/01/21/finding-and-fixing-slow-and-leaky-requests-this-mlk/feed/</wfw:commentRss>
	
		<media:content url="http://a.wordpress.com/avatar/ckhsponge-128.jpg" medium="image">
			<media:title type="html">ckhsponge</media:title>
		</media:content>

		<media:content url="http://spongetech.files.wordpress.com/2008/01/bigstockphoto_leaky_hose_743314.jpg" medium="image">
			<media:title type="html">bigstockphoto_leaky_hose_743314.jpg</media:title>
		</media:content>
	</item>
		<item>
		<title>The complete nginx solution to sending flowers and files with rails</title>
		<link>http://spongetech.wordpress.com/2007/11/13/the-complete-nginx-solution-to-sending-flowers-and-files-with-rails/</link>
		<comments>http://spongetech.wordpress.com/2007/11/13/the-complete-nginx-solution-to-sending-flowers-and-files-with-rails/#comments</comments>
		<pubDate>Tue, 13 Nov 2007 22:23:46 +0000</pubDate>
		<dc:creator>blythedunham</dc:creator>
		
		<category><![CDATA[Uncategorized]]></category>

		<category><![CDATA[Nginx]]></category>

		<category><![CDATA[Rails]]></category>

		<category><![CDATA[ruby]]></category>

		<category><![CDATA[X-Accel-Redirect]]></category>

		<category><![CDATA[X-Send-File]]></category>

		<category><![CDATA[x_send_file]]></category>

		<guid isPermaLink="false">http://spongetech.wordpress.com/2007/11/13/the-complete-nginx-solution-to-sending-flowers-and-files-with-rails/</guid>
		<description><![CDATA[Rails send_file is effed. It may send you flowers and whisper sweet nothings into your ear, but believe me, it will steal your memory, your lover and your freetime. If you are using apache or lighttpd, all the cool kids are using the x_send_file plugin. Nginx fans, check out my monkey patch so you too [...]]]></description>
			<content:encoded><![CDATA[<div class='snap_preview'><br /><p>Rails send_file is effed. It may send you flowers and whisper sweet nothings<img src="http://farm2.static.flickr.com/1113/552097932_63d7e5c1d8.jpg?v=0" alt="blythedoll" align="right" height="140" width="175" /> into your ear, but believe me, it will steal your memory, your lover and your freetime. If you are using apache or lighttpd, all the cool kids are using the x_send_file plugin. Nginx fans, check out my monkey patch so you too can send files, flowers and love without crashing mongrels with nginx&#8217;s equivalent  <a href="http://blog.kovyrin.net/2006/11/01/nginx-x-accel-redirect-php-rails/">X-Accel-Redirect</a> header.</p>
<h3>1. Install the  <a href="http://john.guen.in/past/2007/4/17/send_files_faster_with_xsendfile/">x_send_file</a> plugin.<code></code> <code></code></h3>
<p><code>ruby script/plugin install http://john.guen.in/svn/plugins/x_send_file</code></p>
<h3>2. Copy <a href="http://www.acidlunchbox.com/blythe/rails/x_send_file/controller.rb">monkey patch</a> to</h3>
<p>Replace <code>vendor/plugins/x_send_file/lib/x_send_file/controller.rb </code>with <a href="http://www.acidlunchbox.com/blythe/rails/x_send_file/controller.rb">http://www.acidlunchbox.com/blythe/rails/x_send_file/controller.rb</a></p>
<h3>3. Configure things</h3>
<p class="MsoNormal" style="margin:0;"><span style="font-size:10pt;font-family:Arial;"><font><strong>nginx.conf  </strong></font></span></p>
<p class="MsoNormal" style="margin:0;"><span style="font-size:10pt;font-family:Arial;"><font>remember to also add to server  section if sending over ssl</font></span></p>
<p class="MsoNormal" style="margin:0;"><span style="font-size:10pt;font-family:Arial;"></span><font> </font></p>
<p class="MsoNormal" style="margin:0;"><span style="font-size:10pt;font-family:'Courier New';"><span><font>   </font></span><font>location /files {</font></span></p>
<p class="MsoNormal" style="margin:0;"><span style="font-size:10pt;font-family:'Courier New';"><span><font>      </font></span><font>root  /data/spongecell;</font></span></p>
<p class="MsoNormal" style="margin:0;"><span style="font-size:10pt;font-family:'Courier New';"><span><font>      </font></span><font>internal;</font></span></p>
<p class="MsoNormal" style="margin:0;"><span style="font-size:10pt;font-family:'Courier New';"><span><font>    </font></span><font>}</font></span></p>
<p class="MsoNormal" style="margin:0;"><span style="font-size:10pt;font-family:'Courier New';"><font> </font></span></p>
<p class="MsoNormal" style="margin:0;"><span style="font-size:10pt;font-family:Arial;"><font><strong>environment.rb</strong></font></span></p>
<p class="MsoNormal" style="margin:0;"><span style="font-size:10pt;color:#3f7f5f;font-family:'Courier New';"><font>#send files  through nginx</font></span><span style="font-size:10pt;font-family:'Courier New';"></span></p>
<p class="MsoNormal" style="margin:0;"><span style="font-size:10pt;color:black;font-family:'Courier New';"><font>XSendFile::Plugin.options.update(</font></span><span style="font-size:10pt;font-family:'Courier New';"></span></p>
<p class="MsoNormal" style="margin:0;"><span style="font-size:10pt;color:black;font-family:'Courier New';"><span><font>  </font></span></span><font><strong><span style="font-size:10pt;color:#ff4040;font-family:'Courier New';">:header</span></strong><span style="font-size:10pt;color:black;font-family:'Courier New';"> =&gt;  </span><span style="font-size:10pt;color:#2a00ff;font-family:'Courier New';">&#8216;X-Accel-Redirect&#8217;</span><span style="font-size:10pt;color:black;font-family:'Courier New';">,</span><span style="font-size:10pt;font-family:'Courier New';"></span></font></p>
<p class="MsoNormal" style="margin:0;"><span style="font-size:10pt;color:black;font-family:'Courier New';"><span><font>  </font></span></span><font><strong><span style="font-size:10pt;color:#ff4040;font-family:'Courier New';">:root</span></strong><span style="font-size:10pt;color:black;font-family:'Courier New';"> =&gt;  </span><span style="font-size:10pt;color:#2a00ff;font-family:'Courier New';">&#8216;/data/spongecell&#8217;</span><span style="font-size:10pt;color:black;font-family:'Courier New';">,</span><span style="font-size:10pt;font-family:'Courier New';"></span></font></p>
<p class="MsoNormal" style="margin:0;"><span style="font-size:10pt;color:black;font-family:'Courier New';"><span><font>  </font></span></span><font><strong><span style="font-size:10pt;color:#ff4040;font-family:'Courier New';">:file_paths</span></strong><span style="font-size:10pt;color:black;font-family:'Courier New';"> =&gt;  </span><span style="font-size:10pt;color:#2a00ff;font-family:'Courier New';">&#8216;/data/spongecell/files&#8217;</span><span style="font-size:10pt;font-family:'Courier New';"></span></font></p>
<p class="MsoNormal" style="margin:0;"><span style="font-size:10pt;font-family:'Courier New';"><font>)</font></span></p>
<p class="MsoNormal" style="margin:0;"><font> </font></p>
<p class="MsoNormal" style="margin:0;">In this example, x_send_file will create the following response header</p>
<p class="MsoNormal" style="margin:0;"><span style="font-size:9pt;font-family:'Courier New';"><font><font size="2">&gt;&gt; x_send_file  <span style="color:#2a00ff;">&#8216;/data/spongecell/files/snow/iheartbigdumps.jpg&#8217;</span></font></font></span></p>
<p class="MsoNormal" style="margin:0;"><span style="font-size:10pt;font-family:Arial;"></span><span style="font-size:10pt;color:black;font-family:'Courier New';"><font>&gt;&gt;  response.headers[</font></span><span style="font-size:10pt;color:#2a00ff;font-family:'Courier New';"><font>'X-Accel-Redirect'</font></span><span style="font-size:10pt;color:black;font-family:'Courier New';"><font>] </font></span></p>
<p class="MsoNormal" style="margin:0;"><span style="font-size:10pt;color:black;font-family:'Courier New';"></span><span style="font-size:10pt;font-family:'Courier New';"><font>=&gt;  <span style="color:#2a00ff;">&#8216;/files/snow/iheartbigdumps.jpg&#8217;</span></font></span></p>
<p class="MsoNormal" style="margin:0;">&nbsp;</p>
<h3>Other resources:</h3>
<p class="MsoNormal" style="margin:0;"><a href="http://wiki.codemongers.com/NginxXSendfile">Nginx X-Accel-Redirect </a></p>
<p class="MsoNormal" style="margin:0;"><a href="http://blog.kovyrin.net/2006/11/01/nginx-x-accel-redirect-php-rails/">Nginx X-Accel-Redirect with rails and php examples</a></p>
<p class="MsoNormal" style="margin:0;">&nbsp;</p>
<p class="MsoNormal" style="margin:0;">&nbsp;</p>
<p class="MsoNormal" style="margin:0;">&nbsp;</p>
<p class="MsoNormal" style="margin:0;"><span id="more-34"></span></p>
<img alt="" border="0" src="http://feeds.wordpress.com/1.0/categories/spongetech.wordpress.com/34/" /> <img alt="" border="0" src="http://feeds.wordpress.com/1.0/tags/spongetech.wordpress.com/34/" /> <a rel="nofollow" href="http://feeds.wordpress.com/1.0/gocomments/spongetech.wordpress.com/34/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/comments/spongetech.wordpress.com/34/" /></a> <a rel="nofollow" href="http://feeds.wordpress.com/1.0/godelicious/spongetech.wordpress.com/34/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/delicious/spongetech.wordpress.com/34/" /></a> <a rel="nofollow" href="http://feeds.wordpress.com/1.0/gostumble/spongetech.wordpress.com/34/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/stumble/spongetech.wordpress.com/34/" /></a> <a rel="nofollow" href="http://feeds.wordpress.com/1.0/godigg/spongetech.wordpress.com/34/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/digg/spongetech.wordpress.com/34/" /></a> <a rel="nofollow" href="http://feeds.wordpress.com/1.0/goreddit/spongetech.wordpress.com/34/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/reddit/spongetech.wordpress.com/34/" /></a> <img alt="" border="0" src="http://stats.wordpress.com/b.gif?host=spongetech.wordpress.com&blog=535142&post=34&subd=spongetech&ref=&feed=1" /></div>]]></content:encoded>
			<wfw:commentRss>http://spongetech.wordpress.com/2007/11/13/the-complete-nginx-solution-to-sending-flowers-and-files-with-rails/feed/</wfw:commentRss>
	
		<media:content url="http://farm2.static.flickr.com/1113/552097932_63d7e5c1d8.jpg?v=0" medium="image">
			<media:title type="html">blythedoll</media:title>
		</media:content>
	</item>
	</channel>
</rss>