<?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>pastbedti.me &#187; Programming</title>
	<atom:link href="http://www.pastbedti.me/category/programming/feed/" rel="self" type="application/rss+xml" />
	<link>http://www.pastbedti.me</link>
	<description>About ruby, rails, postgresql and stuff....</description>
	<lastBuildDate>Wed, 01 Jun 2011 20:09:49 +0000</lastBuildDate>
	<language>en</language>
	<sy:updatePeriod>hourly</sy:updatePeriod>
	<sy:updateFrequency>1</sy:updateFrequency>
	<generator>http://wordpress.org/?v=3.2.1</generator>
		<item>
		<title>Change PATH environment with Rails and Capistrano</title>
		<link>http://www.pastbedti.me/2011/06/change-path-environment-with-rails-and-capistrano/</link>
		<comments>http://www.pastbedti.me/2011/06/change-path-environment-with-rails-and-capistrano/#comments</comments>
		<pubDate>Wed, 01 Jun 2011 20:09:49 +0000</pubDate>
		<dc:creator>Mathias Stjernström</dc:creator>
				<category><![CDATA[Programming]]></category>
		<category><![CDATA[Rails]]></category>
		<category><![CDATA[Ruby]]></category>
		<category><![CDATA[capistrano]]></category>
		<category><![CDATA[deploy]]></category>

		<guid isPermaLink="false">http://www.pastbedti.me/?p=699</guid>
		<description><![CDATA[Note to self. When deploying my RubyOnRails applications with Capistrano and I get errors like this one 12345servers: &#91;&#34;app.myserver.com&#34;&#93; &#91;app.myserver.com&#93; executing command ** &#91;out :: app.myserver.com&#93; sh: bundle: command not found command finished in 31ms servers: &#91;&#34;app.myserver.com&#34;&#93; &#160; &#160;&#91;app.myserver.com&#93; executing command ** &#91;out :: app.myserver.com&#93; sh: bundle: command not found &#160; &#160;command finished in 31ms [...]]]></description>
			<content:encoded><![CDATA[<p><strong>Note to self.</strong></p>
<div>When deploying my <strong>RubyOnRails</strong> applications with <strong>Capistrano</strong> and I get errors like this one</div>
<p></p>
<div class="codecolorer-container bash twitlight" style="overflow:auto;white-space:nowrap;border:1px solid #9F9F9F;width:435px;"><table cellspacing="0" cellpadding="0"><tbody><tr><td style="padding:5px;text-align:center;color:#888888;background-color:#EEEEEE;border-right: 1px solid #9F9F9F;font: normal 12px/1.4em Monaco, Lucida Console, monospace;"><div>1<br />2<br />3<br />4<br />5<br /></div></td><td><div class="bash codecolorer" style="padding:5px;font:normal 12px/1.4em Monaco, Lucida Console, monospace;white-space:nowrap">servers: <span style="color: #7a0874; font-weight: bold;">&#91;</span><span style="color: #ff0000;">&quot;app.myserver.com&quot;</span><span style="color: #7a0874; font-weight: bold;">&#93;</span><br />
<span style="color: #7a0874; font-weight: bold;">&#91;</span>app.myserver.com<span style="color: #7a0874; font-weight: bold;">&#93;</span> executing <span style="color: #7a0874; font-weight: bold;">command</span><br />
<span style="color: #000000; font-weight: bold;">**</span> <span style="color: #7a0874; font-weight: bold;">&#91;</span>out :: app.myserver.com<span style="color: #7a0874; font-weight: bold;">&#93;</span> sh: bundle: <span style="color: #7a0874; font-weight: bold;">command</span> not found<br />
<span style="color: #7a0874; font-weight: bold;">command</span> finished <span style="color: #000000; font-weight: bold;">in</span> 31ms<br />
servers: <span style="color: #7a0874; font-weight: bold;">&#91;</span><span style="color: #ff0000;">&quot;app.myserver.com&quot;</span><span style="color: #7a0874; font-weight: bold;">&#93;</span> &nbsp; &nbsp;<span style="color: #7a0874; font-weight: bold;">&#91;</span>app.myserver.com<span style="color: #7a0874; font-weight: bold;">&#93;</span> executing <span style="color: #7a0874; font-weight: bold;">command</span> <span style="color: #000000; font-weight: bold;">**</span> <span style="color: #7a0874; font-weight: bold;">&#91;</span>out :: app.myserver.com<span style="color: #7a0874; font-weight: bold;">&#93;</span> sh: bundle: <span style="color: #7a0874; font-weight: bold;">command</span> not found &nbsp; &nbsp;<span style="color: #7a0874; font-weight: bold;">command</span> finished <span style="color: #000000; font-weight: bold;">in</span> 31ms</div></td></tr></tbody></table></div>
<p>Capistrano executes the commands in a very basic shell so the $PATH environment are not the same as when you login through SSH.</p>
<p>One way to solve this is by setting PermitUserEnvironment  to yes in /etc/sshd_config and then add the correct PATH to ~/.ssh/environment</p>
<p>I just found another way that was much easier <img src='http://www.pastbedti.me/wp-includes/images/smilies/icon_smile.gif' alt=':-)' class='wp-smiley' /> </p>
<p>In you <strong>config/deploy.rb</strong> add the following snippet</p>
<div class="codecolorer-container ruby twitlight" style="overflow:auto;white-space:nowrap;border:1px solid #9F9F9F;width:435px;"><table cellspacing="0" cellpadding="0"><tbody><tr><td style="padding:5px;text-align:center;color:#888888;background-color:#EEEEEE;border-right: 1px solid #9F9F9F;font: normal 12px/1.4em Monaco, Lucida Console, monospace;"><div>1<br />2<br />3<br /></div></td><td><div class="ruby codecolorer" style="padding:5px;font:normal 12px/1.4em Monaco, Lucida Console, monospace;white-space:nowrap">set <span style="color:#ff3333; font-weight:bold;">:default_environment</span>, <span style="color:#006600; font-weight:bold;">&#123;</span><br />
&nbsp; <span style="color:#996600;">'PATH'</span> <span style="color:#006600; font-weight:bold;">=&gt;</span> <span style="color:#996600;">&quot;/opt/ruby-enterprise/bin/:$PATH&quot;</span><br />
<span style="color:#006600; font-weight:bold;">&#125;</span></div></td></tr></tbody></table></div>
<p>Thats it! </p>
<p>Cheers!</p>
]]></content:encoded>
			<wfw:commentRss>http://www.pastbedti.me/2011/06/change-path-environment-with-rails-and-capistrano/feed/</wfw:commentRss>
		<slash:comments>1</slash:comments>
		</item>
		<item>
		<title>Nokogiri quote</title>
		<link>http://www.pastbedti.me/2010/04/nokogiri-quote/</link>
		<comments>http://www.pastbedti.me/2010/04/nokogiri-quote/#comments</comments>
		<pubDate>Fri, 02 Apr 2010 20:12:14 +0000</pubDate>
		<dc:creator>Mathias Stjernström</dc:creator>
				<category><![CDATA[Programming]]></category>
		<category><![CDATA[Ruby]]></category>
		<category><![CDATA[funny]]></category>
		<category><![CDATA[parser]]></category>
		<category><![CDATA[quote]]></category>
		<category><![CDATA[xml]]></category>

		<guid isPermaLink="false">http://www.pastbedti.me/?p=665</guid>
		<description><![CDATA[I just have to share this funny quote from the nokogiri website (for those of you that does not know 鋸 it&#8217;s a reeeeeeeeaaally good and fast HTML, XML, SAX, and Reader parser). XML is like violence &#8211; if it doesn’t solve your problems, you are not using enough of it. &#8211; http://nokogiri.org/ Cheers!]]></description>
			<content:encoded><![CDATA[<p>I just have to share this funny quote from the nokogiri website (for those of you that does not know 鋸 it&#8217;s a reeeeeeeeaaally good and fast HTML, XML, SAX, and Reader parser).</p>
<blockquote><p>
XML is like violence &#8211; if it doesn’t solve your problems, you are not using enough of it. &#8211; <a href="http://nokogiri.org/">http://nokogiri.org/</a>
</p></blockquote>
<p>Cheers! </p>
]]></content:encoded>
			<wfw:commentRss>http://www.pastbedti.me/2010/04/nokogiri-quote/feed/</wfw:commentRss>
		<slash:comments>0</slash:comments>
		</item>
		<item>
		<title>Deploying a Sinatra app with Apache and Phusion Passenger a.k.a. mod_rack</title>
		<link>http://www.pastbedti.me/2009/11/deploying-a-sinatra-app-with-apache-and-phusion-passenger-a-k-a-mod_rack/</link>
		<comments>http://www.pastbedti.me/2009/11/deploying-a-sinatra-app-with-apache-and-phusion-passenger-a-k-a-mod_rack/#comments</comments>
		<pubDate>Mon, 30 Nov 2009 22:01:30 +0000</pubDate>
		<dc:creator>Mathias Stjernström</dc:creator>
				<category><![CDATA[Hosting]]></category>
		<category><![CDATA[Programming]]></category>
		<category><![CDATA[Sinatra]]></category>
		<category><![CDATA[apache]]></category>
		<category><![CDATA[deploy]]></category>
		<category><![CDATA[passenger]]></category>
		<category><![CDATA[Ruby]]></category>
		<category><![CDATA[webroot]]></category>

		<guid isPermaLink="false">http://www.pastbedti.me/?p=610</guid>
		<description><![CDATA[My Sinatra + Apache + Passenger setup did not just run Deploying a simple Sinatra rack application under Apache and Phusion Passenger turned out not work out of the box for me. I already had a virtual host so I decided to deploy with passengers sub URI (sub URI documentation). To make this work you&#8217;ll [...]]]></description>
			<content:encoded><![CDATA[<h3>My Sinatra + Apache + Passenger setup did not just run <img src='http://www.pastbedti.me/wp-includes/images/smilies/icon_smile.gif' alt=':)' class='wp-smiley' /> </h3>
<p>Deploying a simple Sinatra rack application under Apache and Phusion Passenger turned out not work out of the box for me. </p>
<p>I already had a virtual host so I decided to deploy with passengers sub URI (<a href="http://www.modrails.com/documentation/Users%20guide.html#deploying_rack_to_sub_uri" target="_blank">sub URI documentation</a>).</p>
<p>To make this work you&#8217;ll need Apache installed with Phusion Passenger setup (<a href="http://www.modrails.com/install.html" target="_blank">Passenger installation</a>)</p>
<p>
<h3>This is what I started with</h3>
<p>This is my folders for the already existing website.</p>
<div class="codecolorer-container bash twitlight" style="overflow:auto;white-space:nowrap;border:1px solid #9F9F9F;width:435px;"><table cellspacing="0" cellpadding="0"><tbody><tr><td style="padding:5px;text-align:center;color:#888888;background-color:#EEEEEE;border-right: 1px solid #9F9F9F;font: normal 12px/1.4em Monaco, Lucida Console, monospace;"><div>1<br />2<br />3<br />4<br /></div></td><td><div class="bash codecolorer" style="padding:5px;font:normal 12px/1.4em Monaco, Lucida Console, monospace;white-space:nowrap"><span style="color: #666666; font-style: italic;"># Existing homedir</span><br />
<span style="color: #000000; font-weight: bold;">/</span>home<span style="color: #000000; font-weight: bold;">/</span>my_web<span style="color: #000000; font-weight: bold;">/</span><br />
<span style="color: #666666; font-style: italic;"># Current webroot</span><br />
<span style="color: #000000; font-weight: bold;">/</span>home<span style="color: #000000; font-weight: bold;">/</span>my_web<span style="color: #000000; font-weight: bold;">/</span>htdocs</div></td></tr></tbody></table></div>
<p>
<h3>Creating folders and files for Sinatra</h3>
<p>The first thing you want to do is to create folders and files for Sinatra.</p>
<div class="codecolorer-container text twitlight" style="overflow:auto;white-space:nowrap;border:1px solid #9F9F9F;width:435px;"><table cellspacing="0" cellpadding="0"><tbody><tr><td style="padding:5px;text-align:center;color:#888888;background-color:#EEEEEE;border-right: 1px solid #9F9F9F;font: normal 12px/1.4em Monaco, Lucida Console, monospace;"><div>1<br /></div></td><td><div class="text codecolorer" style="padding:5px;font:normal 12px/1.4em Monaco, Lucida Console, monospace;white-space:nowrap">mkdir /home/my_web/sinatra</div></td></tr></tbody></table></div>
<div class="codecolorer-container text twitlight" style="overflow:auto;white-space:nowrap;border:1px solid #9F9F9F;width:435px;"><table cellspacing="0" cellpadding="0"><tbody><tr><td style="padding:5px;text-align:center;color:#888888;background-color:#EEEEEE;border-right: 1px solid #9F9F9F;font: normal 12px/1.4em Monaco, Lucida Console, monospace;"><div>1<br />2<br />3<br />4<br />5<br />6<br /></div></td><td><div class="text codecolorer" style="padding:5px;font:normal 12px/1.4em Monaco, Lucida Console, monospace;white-space:nowrap">cd /home/my_web/sinatra<br />
mkdir tmp<br />
mkdir logs<br />
mkdir public<br />
touch app.rb<br />
touch config.ru</div></td></tr></tbody></table></div>
<p>
<h3>Create symlink</h3>
<p>Create a symbolic link from our current webroot to the new Sinatra app so that apache/passenger can find it.</p>
<div class="codecolorer-container bash twitlight" style="overflow:auto;white-space:nowrap;border:1px solid #9F9F9F;width:435px;"><table cellspacing="0" cellpadding="0"><tbody><tr><td style="padding:5px;text-align:center;color:#888888;background-color:#EEEEEE;border-right: 1px solid #9F9F9F;font: normal 12px/1.4em Monaco, Lucida Console, monospace;"><div>1<br /></div></td><td><div class="bash codecolorer" style="padding:5px;font:normal 12px/1.4em Monaco, Lucida Console, monospace;white-space:nowrap"><span style="color: #c20cb9; font-weight: bold;">ln</span> <span style="color: #660033;">-s</span> <span style="color: #000000; font-weight: bold;">/</span>home<span style="color: #000000; font-weight: bold;">/</span>my_web<span style="color: #000000; font-weight: bold;">/</span>sinatra<span style="color: #000000; font-weight: bold;">/</span>public <span style="color: #000000; font-weight: bold;">/</span>home<span style="color: #000000; font-weight: bold;">/</span>my_web<span style="color: #000000; font-weight: bold;">/</span>htdocs<span style="color: #000000; font-weight: bold;">/</span>app</div></td></tr></tbody></table></div>
<p>
<h3>Creating the application</h3>
<p>We also need a Sinatra application for this to work so lets fill those files.</p>
<p>
<h4>File: config.ru</h4>
<div class="codecolorer-container ruby twitlight" style="overflow:auto;white-space:nowrap;border:1px solid #9F9F9F;width:435px;"><table cellspacing="0" cellpadding="0"><tbody><tr><td style="padding:5px;text-align:center;color:#888888;background-color:#EEEEEE;border-right: 1px solid #9F9F9F;font: normal 12px/1.4em Monaco, Lucida Console, monospace;"><div>1<br />2<br />3<br />4<br />5<br />6<br />7<br />8<br />9<br />10<br />11<br /></div></td><td><div class="ruby codecolorer" style="padding:5px;font:normal 12px/1.4em Monaco, Lucida Console, monospace;white-space:nowrap"><span style="color:#CC0066; font-weight:bold;">require</span> <span style="color:#996600;">'app'</span><br />
<br />
set <span style="color:#ff3333; font-weight:bold;">:environment</span>, ENV<span style="color:#006600; font-weight:bold;">&#91;</span><span style="color:#996600;">'RACK_ENV'</span><span style="color:#006600; font-weight:bold;">&#93;</span>.<span style="color:#9900CC;">to_sym</span><br />
set <span style="color:#ff3333; font-weight:bold;">:app_file</span>, &nbsp; &nbsp; <span style="color:#996600;">'app.rb'</span><br />
disable <span style="color:#ff3333; font-weight:bold;">:run</span><br />
<br />
log = <span style="color:#CC00FF; font-weight:bold;">File</span>.<span style="color:#9900CC;">new</span><span style="color:#006600; font-weight:bold;">&#40;</span><span style="color:#996600;">&quot;logs/sinatra.log&quot;</span>, <span style="color:#996600;">&quot;a&quot;</span><span style="color:#006600; font-weight:bold;">&#41;</span><br />
STDOUT.<span style="color:#9900CC;">reopen</span><span style="color:#006600; font-weight:bold;">&#40;</span>log<span style="color:#006600; font-weight:bold;">&#41;</span><br />
STDERR.<span style="color:#9900CC;">reopen</span><span style="color:#006600; font-weight:bold;">&#40;</span>log<span style="color:#006600; font-weight:bold;">&#41;</span><br />
<br />
run <span style="color:#6666ff; font-weight:bold;">Sinatra::Application</span></div></td></tr></tbody></table></div>
<p>
<h4>File: app.rb</h4>
<div class="codecolorer-container ruby twitlight" style="overflow:auto;white-space:nowrap;border:1px solid #9F9F9F;width:435px;"><table cellspacing="0" cellpadding="0"><tbody><tr><td style="padding:5px;text-align:center;color:#888888;background-color:#EEEEEE;border-right: 1px solid #9F9F9F;font: normal 12px/1.4em Monaco, Lucida Console, monospace;"><div>1<br />2<br />3<br />4<br />5<br />6<br />7<br />8<br />9<br />10<br />11<br /></div></td><td><div class="ruby codecolorer" style="padding:5px;font:normal 12px/1.4em Monaco, Lucida Console, monospace;white-space:nowrap"><span style="color:#CC0066; font-weight:bold;">require</span> <span style="color:#996600;">'rubygems'</span><br />
<span style="color:#CC0066; font-weight:bold;">require</span> <span style="color:#996600;">'sinatra'</span><br />
<br />
before <span style="color:#9966CC; font-weight:bold;">do</span> <br />
&nbsp; <span style="color:#008000; font-style:italic;"># Strip the last / from the path</span><br />
&nbsp; request.<span style="color:#9900CC;">env</span><span style="color:#006600; font-weight:bold;">&#91;</span><span style="color:#996600;">'PATH_INFO'</span><span style="color:#006600; font-weight:bold;">&#93;</span>.<span style="color:#CC0066; font-weight:bold;">gsub!</span><span style="color:#006600; font-weight:bold;">&#40;</span><span style="color:#006600; font-weight:bold;">/</span>\<span style="color:#006600; font-weight:bold;">/</span>$<span style="color:#006600; font-weight:bold;">/</span>, <span style="color:#996600;">''</span><span style="color:#006600; font-weight:bold;">&#41;</span><br />
<span style="color:#9966CC; font-weight:bold;">end</span><br />
<br />
get <span style="color:#996600;">''</span> <span style="color:#9966CC; font-weight:bold;">do</span><br />
&nbsp; &nbsp;<span style="color:#996600;">&quot;Hello world&quot;</span><br />
<span style="color:#9966CC; font-weight:bold;">end</span></div></td></tr></tbody></table></div>
<p>
<h3>Apache configuration</h3>
<p>Now we need to setup apache so that it can find our Sinatra app and load it.</p>
<p>The only thing you need to do is add the following line to your existing VirtualHost block:</p>
<div class="codecolorer-container apache twitlight" style="overflow:auto;white-space:nowrap;border:1px solid #9F9F9F;width:435px;"><table cellspacing="0" cellpadding="0"><tbody><tr><td style="padding:5px;text-align:center;color:#888888;background-color:#EEEEEE;border-right: 1px solid #9F9F9F;font: normal 12px/1.4em Monaco, Lucida Console, monospace;"><div>1<br /></div></td><td><div class="apache codecolorer" style="padding:5px;font:normal 12px/1.4em Monaco, Lucida Console, monospace;white-space:nowrap">RackBaseURI /app</div></td></tr></tbody></table></div>
<p>This line will tell passenger to look into our existing webroot for a symlink thats named app and which points to our rack app.  (<a href="http://www.modrails.com/documentation/Users%20guide.html#RackBaseURI" target="_blank">RackBaseURI  documentation</a>)</p>
<p>
<h3>Virtual host entry</h3>
<div class="codecolorer-container apache twitlight" style="overflow:auto;white-space:nowrap;border:1px solid #9F9F9F;width:435px;"><table cellspacing="0" cellpadding="0"><tbody><tr><td style="padding:5px;text-align:center;color:#888888;background-color:#EEEEEE;border-right: 1px solid #9F9F9F;font: normal 12px/1.4em Monaco, Lucida Console, monospace;"><div>1<br />2<br />3<br />4<br />5<br />6<br />7<br />8<br />9<br />10<br />11<br />12<br /></div></td><td><div class="apache codecolorer" style="padding:5px;font:normal 12px/1.4em Monaco, Lucida Console, monospace;white-space:nowrap">&lt;<span style="color: #000000; font-weight:bold;">VirtualHost</span> *:<span style="color: #ff0000;">80</span>&gt;<br />
&nbsp; <span style="color: #00007f;">ServerName</span> www.example.com<br />
&nbsp; <span style="color: #00007f;">ServerAlias</span> example.com<br />
&nbsp; <span style="color: #00007f;">DocumentRoot</span> /home/my_web/htdocs/<br />
&nbsp; RackBaseURI /app<br />
<br />
&nbsp; &lt;<span style="color: #000000; font-weight:bold;">Directory</span> <span style="color: #7f007f;">&quot;/home/my_web/htdocs/&quot;</span>&gt;<br />
&nbsp; &nbsp; <span style="color: #00007f;">Order</span> <span style="color: #00007f;">allow</span>,<span style="color: #00007f;">deny</span><br />
&nbsp; &nbsp; <span style="color: #00007f;">Allow</span> from <span style="color: #0000ff;">all</span><br />
&nbsp; &nbsp; <span style="color: #00007f;">AllowOverride</span> <span style="color: #0000ff;">All</span><br />
&nbsp; &lt;/<span style="color: #000000; font-weight:bold;">Directory</span>&gt;<br />
&lt;/<span style="color: #000000; font-weight:bold;">VirtualHost</span>&gt;</div></td></tr></tbody></table></div>
<p>The best part is that you are allowed to specify this option multiple times. So you can easily setup multiple apps under the same virtual host.</p>
<p>Cheers! </p>
]]></content:encoded>
			<wfw:commentRss>http://www.pastbedti.me/2009/11/deploying-a-sinatra-app-with-apache-and-phusion-passenger-a-k-a-mod_rack/feed/</wfw:commentRss>
		<slash:comments>0</slash:comments>
		</item>
		<item>
		<title>Grouping a timestamp field by date in Ruby On Rails / PostgreSQL</title>
		<link>http://www.pastbedti.me/2009/11/grouping-a-timestamp-field-by-date-in-ruby-on-rails-postgresql/</link>
		<comments>http://www.pastbedti.me/2009/11/grouping-a-timestamp-field-by-date-in-ruby-on-rails-postgresql/#comments</comments>
		<pubDate>Sun, 08 Nov 2009 00:55:09 +0000</pubDate>
		<dc:creator>Mathias Stjernström</dc:creator>
				<category><![CDATA[Databases]]></category>
		<category><![CDATA[PostgreSQL]]></category>
		<category><![CDATA[Rails]]></category>
		<category><![CDATA[Ruby]]></category>
		<category><![CDATA[date]]></category>
		<category><![CDATA[sql]]></category>
		<category><![CDATA[timestamp]]></category>

		<guid isPermaLink="false">http://www.pastbedti.me/?p=563</guid>
		<description><![CDATA[Recently I&#8217;ve been working a lot with dates and tonight I had a hard time finding information about how to group a model by date when the model only have a timestamp column. Lets pretend we have a user model with a created_at attribute which is stored as a timestamp. If we want to plot [...]]]></description>
			<content:encoded><![CDATA[<p>Recently I&#8217;ve been working a lot with dates and tonight I had a hard time finding information about how to group a model by date when the model only have a timestamp column. </p>
<p>Lets pretend we have a user model with a created_at attribute which is stored as a timestamp.</p>
<p>If we want to plot a simple graph showing signups per date this is the way to extract them:</p>
<div class="codecolorer-container ruby twitlight" style="overflow:auto;white-space:nowrap;border:1px solid #9F9F9F;width:435px;"><table cellspacing="0" cellpadding="0"><tbody><tr><td style="padding:5px;text-align:center;color:#888888;background-color:#EEEEEE;border-right: 1px solid #9F9F9F;font: normal 12px/1.4em Monaco, Lucida Console, monospace;"><div>1<br /></div></td><td><div class="ruby codecolorer" style="padding:5px;font:normal 12px/1.4em Monaco, Lucida Console, monospace;white-space:nowrap">User.<span style="color:#9900CC;">count</span><span style="color:#006600; font-weight:bold;">&#40;</span><span style="color:#ff3333; font-weight:bold;">:group</span> <span style="color:#006600; font-weight:bold;">=&gt;</span> <span style="color:#996600;">&quot;DATE(created_at)&quot;</span><span style="color:#006600; font-weight:bold;">&#41;</span></div></td></tr></tbody></table></div>
<p>Thats all there is to it. From this you will get an OrderedHash containing the date and count of users for each date. </p>
<p>One small thing to remember if you are using PostgreSQL. You will need the DATE() function in any ORDER/SELECT statements because PostgreSQL will only select/order by fields thats in the GROUP BY statement and this is a  pretty healthy behavior that many databases (no names here) don&#8217;t care about. Think about it. If you are grouping all users by date and use * as selector how would the database know which username or email address to display?</p>
<p>This is what happens if you try to group by created_at without DATE() -></p>
<div class="codecolorer-container ruby twitlight" style="overflow:auto;white-space:nowrap;border:1px solid #9F9F9F;width:435px;"><table cellspacing="0" cellpadding="0"><tbody><tr><td style="padding:5px;text-align:center;color:#888888;background-color:#EEEEEE;border-right: 1px solid #9F9F9F;font: normal 12px/1.4em Monaco, Lucida Console, monospace;"><div>1<br />2<br />3<br />4<br />5<br />6<br />7<br />8<br />9<br />10<br />11<br />12<br />13<br />14<br />15<br /></div></td><td><div class="ruby codecolorer" style="padding:5px;font:normal 12px/1.4em Monaco, Lucida Console, monospace;white-space:nowrap"><span style="color:#006600; font-weight:bold;">&gt;&gt;</span> User.<span style="color:#9900CC;">count</span><span style="color:#006600; font-weight:bold;">&#40;</span><span style="color:#ff3333; font-weight:bold;">:order</span> <span style="color:#006600; font-weight:bold;">=&gt;</span> <span style="color:#996600;">'created_at DESC'</span>, <span style="color:#ff3333; font-weight:bold;">:group</span> <span style="color:#006600; font-weight:bold;">=&gt;</span> <span style="color:#006600; font-weight:bold;">&#91;</span><span style="color:#996600;">&quot;DATE(created_at)&quot;</span><span style="color:#006600; font-weight:bold;">&#93;</span><span style="color:#006600; font-weight:bold;">&#41;</span> &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; <br />
<span style="color:#6666ff; font-weight:bold;">ActiveRecord::StatementInvalid</span>: PGError: ERROR: &nbsp;column <span style="color:#996600;">&quot;users.created_at&quot;</span> must appear <span style="color:#9966CC; font-weight:bold;">in</span> the GROUP BY clause <span style="color:#9966CC; font-weight:bold;">or</span> be used <span style="color:#9966CC; font-weight:bold;">in</span> an aggregate function<br />
: <span style="color:#CC0066; font-weight:bold;">SELECT</span> count<span style="color:#006600; font-weight:bold;">&#40;</span><span style="color:#006600; font-weight:bold;">*</span><span style="color:#006600; font-weight:bold;">&#41;</span> AS count_all, DATE<span style="color:#006600; font-weight:bold;">&#40;</span>created_at<span style="color:#006600; font-weight:bold;">&#41;</span> AS date_created_at FROM <span style="color:#996600;">&quot;users&quot;</span> &nbsp;GROUP BY DATE<span style="color:#006600; font-weight:bold;">&#40;</span>created_at<span style="color:#006600; font-weight:bold;">&#41;</span> &nbsp;ORDER BY created_at DESC <br />
&nbsp; &nbsp; &nbsp; &nbsp; from <span style="color:#006600; font-weight:bold;">/</span>tmp<span style="color:#006600; font-weight:bold;">/</span>app<span style="color:#006600; font-weight:bold;">/</span>vendor<span style="color:#006600; font-weight:bold;">/</span>rails<span style="color:#006600; font-weight:bold;">/</span>activerecord<span style="color:#006600; font-weight:bold;">/</span>lib<span style="color:#006600; font-weight:bold;">/</span>active_record<span style="color:#006600; font-weight:bold;">/</span>connection_adapters<span style="color:#006600; font-weight:bold;">/</span>abstract_adapter.<span style="color:#9900CC;">rb</span>:<span style="color:#006666;">212</span>:<span style="color:#9966CC; font-weight:bold;">in</span> <span style="color:#996600;">`log'<br />
&nbsp; &nbsp; &nbsp; &nbsp; from /tmp/app/vendor/rails/activerecord/lib/active_record/connection_adapters/postgresql_adapter.rb:507:in `</span>execute<span style="color:#996600;">'<br />
&nbsp; &nbsp; &nbsp; &nbsp; from /tmp/app/vendor/rails/activerecord/lib/active_record/connection_adapters/postgresql_adapter.rb:985:in `select_raw'</span><br />
&nbsp; &nbsp; &nbsp; &nbsp; from <span style="color:#006600; font-weight:bold;">/</span>tmp<span style="color:#006600; font-weight:bold;">/</span>app<span style="color:#006600; font-weight:bold;">/</span>vendor<span style="color:#006600; font-weight:bold;">/</span>rails<span style="color:#006600; font-weight:bold;">/</span>activerecord<span style="color:#006600; font-weight:bold;">/</span>lib<span style="color:#006600; font-weight:bold;">/</span>active_record<span style="color:#006600; font-weight:bold;">/</span>connection_adapters<span style="color:#006600; font-weight:bold;">/</span>postgresql_adapter.<span style="color:#9900CC;">rb</span>:<span style="color:#006666;">972</span>:<span style="color:#9966CC; font-weight:bold;">in</span> <span style="color:#996600;">`select'<br />
&nbsp; &nbsp; &nbsp; &nbsp; from /tmp/app/vendor/rails/activerecord/lib/active_record/connection_adapters/abstract/database_statements.rb:7:in `</span>select_all_without_query_cache<span style="color:#996600;">'<br />
&nbsp; &nbsp; &nbsp; &nbsp; from /tmp/app/vendor/rails/activerecord/lib/active_record/connection_adapters/abstract/query_cache.rb:62:in `select_all'</span><br />
&nbsp; &nbsp; &nbsp; &nbsp; from <span style="color:#006600; font-weight:bold;">/</span>tmp<span style="color:#006600; font-weight:bold;">/</span>app<span style="color:#006600; font-weight:bold;">/</span>vendor<span style="color:#006600; font-weight:bold;">/</span>rails<span style="color:#006600; font-weight:bold;">/</span>activerecord<span style="color:#006600; font-weight:bold;">/</span>lib<span style="color:#006600; font-weight:bold;">/</span>active_record<span style="color:#006600; font-weight:bold;">/</span>calculations.<span style="color:#9900CC;">rb</span>:<span style="color:#006666;">255</span>:<span style="color:#9966CC; font-weight:bold;">in</span> <span style="color:#996600;">`execute_grouped_calculation'<br />
&nbsp; &nbsp; &nbsp; &nbsp; from /tmp/app/vendor/rails/activerecord/lib/active_record/calculations.rb:132:in `</span>calculate<span style="color:#996600;">'<br />
&nbsp; &nbsp; &nbsp; &nbsp; from /tmp/app/vendor/rails/activerecord/lib/active_record/calculations.rb:130:in `catch'</span><br />
&nbsp; &nbsp; &nbsp; &nbsp; from <span style="color:#006600; font-weight:bold;">/</span>tmp<span style="color:#006600; font-weight:bold;">/</span>app<span style="color:#006600; font-weight:bold;">/</span>vendor<span style="color:#006600; font-weight:bold;">/</span>rails<span style="color:#006600; font-weight:bold;">/</span>activerecord<span style="color:#006600; font-weight:bold;">/</span>lib<span style="color:#006600; font-weight:bold;">/</span>active_record<span style="color:#006600; font-weight:bold;">/</span>calculations.<span style="color:#9900CC;">rb</span>:<span style="color:#006666;">130</span>:<span style="color:#9966CC; font-weight:bold;">in</span> <span style="color:#996600;">`calculate'<br />
&nbsp; &nbsp; &nbsp; &nbsp; from /tmp/app/vendor/rails/activerecord/lib/active_record/calculations.rb:48:in `</span>count<span style="color:#996600;">'<br />
&nbsp; &nbsp; &nbsp; &nbsp; from (irb):18</span></div></td></tr></tbody></table></div>
<p>And this is the right way to do it:</p>
<div class="codecolorer-container ruby twitlight" style="overflow:auto;white-space:nowrap;border:1px solid #9F9F9F;width:435px;"><table cellspacing="0" cellpadding="0"><tbody><tr><td style="padding:5px;text-align:center;color:#888888;background-color:#EEEEEE;border-right: 1px solid #9F9F9F;font: normal 12px/1.4em Monaco, Lucida Console, monospace;"><div>1<br />2<br /></div></td><td><div class="ruby codecolorer" style="padding:5px;font:normal 12px/1.4em Monaco, Lucida Console, monospace;white-space:nowrap"><span style="color:#006600; font-weight:bold;">&gt;&gt;</span> User.<span style="color:#9900CC;">count</span><span style="color:#006600; font-weight:bold;">&#40;</span><span style="color:#ff3333; font-weight:bold;">:order</span> <span style="color:#006600; font-weight:bold;">=&gt;</span> <span style="color:#996600;">'DATE(created_at) DESC'</span>, <span style="color:#ff3333; font-weight:bold;">:group</span> <span style="color:#006600; font-weight:bold;">=&gt;</span> <span style="color:#006600; font-weight:bold;">&#91;</span><span style="color:#996600;">&quot;DATE(created_at)&quot;</span><span style="color:#006600; font-weight:bold;">&#93;</span><span style="color:#006600; font-weight:bold;">&#41;</span><br />
<span style="color:#006600; font-weight:bold;">=&gt;</span> <span style="color:#008000; font-style:italic;">#&lt;OrderedHash {&quot;2009-10-14&quot;=&gt;22, &quot;2009-10-25&quot;=&gt;4, &quot;2009-11-04&quot;=&gt;8, &quot;2009-10-15&quot;=&gt;9, &quot;2009-10-26&quot;=&gt;16, &quot;2009-11-05&quot;=&gt;9, &quot;2009-10-16&quot;=&gt;193, &quot;2009-10-27&quot;=&gt;14, &quot;2009-11-06&quot;=&gt;9, &quot;2009-10-17&quot;=&gt;49, &quot;2009-10-28&quot;=&gt;15, &quot;2009-11-07&quot;=&gt;6, &quot;2009-10-18&quot;=&gt;36, &quot;2009-10-29&quot;=&gt;8, &quot;2009-10-19&quot;=&gt;116, &quot;2009-10-30&quot;=&gt;15&gt;</span></div></td></tr></tbody></table></div>
<p>As you may notice the Hash does not look ordered. But if you loop over it you will get them in order:</p>
<div class="codecolorer-container ruby twitlight" style="overflow:auto;white-space:nowrap;border:1px solid #9F9F9F;width:435px;"><table cellspacing="0" cellpadding="0"><tbody><tr><td style="padding:5px;text-align:center;color:#888888;background-color:#EEEEEE;border-right: 1px solid #9F9F9F;font: normal 12px/1.4em Monaco, Lucida Console, monospace;"><div>1<br />2<br />3<br />4<br />5<br />6<br />7<br />8<br />9<br />10<br />11<br />12<br /></div></td><td><div class="ruby codecolorer" style="padding:5px;font:normal 12px/1.4em Monaco, Lucida Console, monospace;white-space:nowrap"><span style="color:#006600; font-weight:bold;">&gt;&gt;</span> User.<span style="color:#9900CC;">count</span><span style="color:#006600; font-weight:bold;">&#40;</span><span style="color:#ff3333; font-weight:bold;">:order</span> <span style="color:#006600; font-weight:bold;">=&gt;</span> <span style="color:#996600;">'DATE(created_at) DESC'</span>, <span style="color:#ff3333; font-weight:bold;">:group</span> <span style="color:#006600; font-weight:bold;">=&gt;</span> <span style="color:#006600; font-weight:bold;">&#91;</span><span style="color:#996600;">&quot;DATE(created_at)&quot;</span><span style="color:#006600; font-weight:bold;">&#93;</span><span style="color:#006600; font-weight:bold;">&#41;</span>.<span style="color:#9900CC;">each</span> <span style="color:#006600; font-weight:bold;">&#123;</span><span style="color:#006600; font-weight:bold;">|</span>u<span style="color:#006600; font-weight:bold;">|</span> <span style="color:#CC0066; font-weight:bold;">puts</span> <span style="color:#996600;">&quot;#{u[0]} -&gt; #{u[1]}&quot;</span> <span style="color:#006600; font-weight:bold;">&#125;</span><br />
<span style="color:#006666;">2009</span><span style="color:#006600; font-weight:bold;">-</span><span style="color:#006666;">11</span><span style="color:#006600; font-weight:bold;">-</span>07 <span style="color:#006600; font-weight:bold;">-&gt;</span> <span style="color:#006666;">6</span><br />
<span style="color:#006666;">2009</span><span style="color:#006600; font-weight:bold;">-</span><span style="color:#006666;">11</span><span style="color:#006600; font-weight:bold;">-</span>06 <span style="color:#006600; font-weight:bold;">-&gt;</span> <span style="color:#006666;">9</span><br />
<span style="color:#006666;">2009</span><span style="color:#006600; font-weight:bold;">-</span><span style="color:#006666;">11</span><span style="color:#006600; font-weight:bold;">-</span>05 <span style="color:#006600; font-weight:bold;">-&gt;</span> <span style="color:#006666;">9</span><br />
<span style="color:#006666;">2009</span><span style="color:#006600; font-weight:bold;">-</span><span style="color:#006666;">11</span><span style="color:#006600; font-weight:bold;">-</span>04 <span style="color:#006600; font-weight:bold;">-&gt;</span> <span style="color:#006666;">8</span><br />
<span style="color:#006666;">2009</span><span style="color:#006600; font-weight:bold;">-</span><span style="color:#006666;">11</span><span style="color:#006600; font-weight:bold;">-</span>03 <span style="color:#006600; font-weight:bold;">-&gt;</span> <span style="color:#006666;">14</span><br />
<span style="color:#006666;">2009</span><span style="color:#006600; font-weight:bold;">-</span><span style="color:#006666;">11</span><span style="color:#006600; font-weight:bold;">-</span>02 <span style="color:#006600; font-weight:bold;">-&gt;</span> <span style="color:#006666;">20</span><br />
<span style="color:#006666;">2009</span><span style="color:#006600; font-weight:bold;">-</span><span style="color:#006666;">11</span><span style="color:#006600; font-weight:bold;">-</span>01 <span style="color:#006600; font-weight:bold;">-&gt;</span> <span style="color:#006666;">10</span><br />
<span style="color:#006666;">2009</span><span style="color:#006600; font-weight:bold;">-</span><span style="color:#006666;">10</span><span style="color:#006600; font-weight:bold;">-</span><span style="color:#006666;">31</span> <span style="color:#006600; font-weight:bold;">-&gt;</span> <span style="color:#006666;">6</span><br />
<span style="color:#006666;">2009</span><span style="color:#006600; font-weight:bold;">-</span><span style="color:#006666;">10</span><span style="color:#006600; font-weight:bold;">-</span><span style="color:#006666;">30</span> <span style="color:#006600; font-weight:bold;">-&gt;</span> <span style="color:#006666;">15</span><br />
<span style="color:#006666;">2009</span><span style="color:#006600; font-weight:bold;">-</span><span style="color:#006666;">10</span><span style="color:#006600; font-weight:bold;">-</span><span style="color:#006666;">29</span> <span style="color:#006600; font-weight:bold;">-&gt;</span> <span style="color:#006666;">8</span><br />
..</div></td></tr></tbody></table></div>
<p>And thats how you group a timestamp field with just its date part.</p>
<p>Cheers!</p>
]]></content:encoded>
			<wfw:commentRss>http://www.pastbedti.me/2009/11/grouping-a-timestamp-field-by-date-in-ruby-on-rails-postgresql/feed/</wfw:commentRss>
		<slash:comments>3</slash:comments>
		</item>
		<item>
		<title>Painful experience with rails InvalidAuthenticityToken</title>
		<link>http://www.pastbedti.me/2009/03/painfully-experience-with-rails-invalidauthenticitytoken/</link>
		<comments>http://www.pastbedti.me/2009/03/painfully-experience-with-rails-invalidauthenticitytoken/#comments</comments>
		<pubDate>Mon, 23 Mar 2009 19:22:25 +0000</pubDate>
		<dc:creator>Mathias Stjernström</dc:creator>
				<category><![CDATA[Hosting]]></category>
		<category><![CDATA[Programming]]></category>
		<category><![CDATA[Rails]]></category>
		<category><![CDATA[Add new tag]]></category>
		<category><![CDATA[domains]]></category>
		<category><![CDATA[painful]]></category>
		<category><![CDATA[staging]]></category>

		<guid isPermaLink="false">http://www.pastbedti.me/?p=406</guid>
		<description><![CDATA[Today I had a really painful experience with rails InvalidAuthenticityToken. It turned out not to have anything to do with rails at all and there is where the painful part come in to play. We had an application which needed a staging environment. When everything where setup and after the first deploy to the new [...]]]></description>
			<content:encoded><![CDATA[<p>Today I had a really painful experience with rails InvalidAuthenticityToken. It  turned out not to have anything to do with rails at all and there is where the painful part come in to play. </p>
<p><span id="more-406"></span></p>
<p>We had an application which needed a staging environment. When everything where setup and after the first deploy to the new environment everything seemed fine at first but when we tried to login we got these fine messages:</p>
<div class="codecolorer-container text twitlight" style="overflow:auto;white-space:nowrap;border:1px solid #9F9F9F;width:435px;"><table cellspacing="0" cellpadding="0"><tbody><tr><td style="padding:5px;text-align:center;color:#888888;background-color:#EEEEEE;border-right: 1px solid #9F9F9F;font: normal 12px/1.4em Monaco, Lucida Console, monospace;"><div>1<br />2<br />3<br />4<br />5<br />6<br />7<br />8<br />9<br />10<br /></div></td><td><div class="text codecolorer" style="padding:5px;font:normal 12px/1.4em Monaco, Lucida Console, monospace;white-space:nowrap">ActionController::InvalidAuthenticityToken (ActionController::InvalidAuthenticityToken):<br />
&nbsp; &nbsp; /vendor/rails/actionpack/lib/action_controller/request_forgery_protection.rb:86:in `verify_authenticity_token'<br />
&nbsp; &nbsp; /vendor/rails/activesupport/lib/active_support/callbacks.rb:178:in `send'<br />
&nbsp; &nbsp; /vendor/rails/activesupport/lib/active_support/callbacks.rb:178:in `evaluate_method'<br />
&nbsp; &nbsp; /vendor/rails/activesupport/lib/active_support/callbacks.rb:166:in `call'<br />
&nbsp; &nbsp; /vendor/rails/actionpack/lib/action_controller/filters.rb:225:in `call'<br />
&nbsp; &nbsp; /vendor/rails/actionpack/lib/action_controller/filters.rb:629:in `run_before_filters'<br />
&nbsp; &nbsp; /vendor/rails/actionpack/lib/action_controller/filters.rb:615:in `call_filters'<br />
&nbsp; &nbsp; /vendor/rails/actionpack/lib/action_controller/filters.rb:610:in `perform_action_without_benchmark'<br />
&nbsp; &nbsp; /vendor/rails/actionpack/lib/action_controller/benchmarking.rb:68:in `perform_action_without_rescue'</div></td></tr></tbody></table></div>
<p>After about two hours of troubleshooting the only problem left where that the browser did not get the cookie. We used telnet to check the headers and the cookie where there&#8230; ok, the browser is broken&#8230;. sure&#8230; </p>
<p>Then, finally it came to me&#8230; what if,&#8230; the hostname is broken? Broken hostname you tell me? Just for fun I changed the hostname and bada-bong bada-bing everything is working&#8230;. Now I get this creepy feeling of the big mistake I have made&#8230; </p>
<p>The thing is that I have worked with domains for many years and I know very well that you CANNOT have underscores in your domains. But my peanut brain do not think of subdomains as a domain-name. So we had a sub-domain with an underscore. Putting a underscore in the domainname makes Safari and some versions of Explorer not to accept cookies and that makes rails AuthenticityToken to treat me as a hacker&#8230;. </p>
<p>As a punishment I will force myself to read RFC 1035 (<a href="http://tools.ietf.org/html/rfc1035">http://tools.ietf.org/html/rfc1035</a>).</p>
<p>Over and out&#8230;. </p>
]]></content:encoded>
			<wfw:commentRss>http://www.pastbedti.me/2009/03/painfully-experience-with-rails-invalidauthenticitytoken/feed/</wfw:commentRss>
		<slash:comments>1</slash:comments>
		</item>
		<item>
		<title>How to compile VIM under OS X</title>
		<link>http://www.pastbedti.me/2009/01/how-to-compile-vim-under-os-x/</link>
		<comments>http://www.pastbedti.me/2009/01/how-to-compile-vim-under-os-x/#comments</comments>
		<pubDate>Sun, 11 Jan 2009 09:53:31 +0000</pubDate>
		<dc:creator>Mathias Stjernström</dc:creator>
				<category><![CDATA[Programming]]></category>
		<category><![CDATA[compiling]]></category>
		<category><![CDATA[osx]]></category>
		<category><![CDATA[Ruby]]></category>
		<category><![CDATA[vim]]></category>

		<guid isPermaLink="false">http://www.pastbedti.me/?p=367</guid>
		<description><![CDATA[Configure and compiling VIM under OS X did not work out-of-the box for me. I did not want to use MacPorts VIM as it&#8217;s dependent on ruby (if you like me want that) and I did not find a way of compiling MacPorts VIM against my local ruby. This post is about how to get [...]]]></description>
			<content:encoded><![CDATA[<p>Configure and compiling <a href="http://www.vim.org/">VIM</a> under OS X did not work out-of-the box for me. I did not want to use <a href="http://www.macports.org/">MacPorts</a> VIM as it&#8217;s dependent on ruby (if you like me want that) and I did not find a way of compiling MacPorts VIM against my local ruby.</p>
<p>This post is about how to get VIM compiling on OS X/intel without the use of  MacPorts.</p>
<p><span id="more-367"></span></p>
<h3>1. Configure without specifying architecture</h3>
<p>When running configure without specifying architecture everything looks fine but when you run make you get this nice little error.</p>
<div class="codecolorer-container bash twitlight" style="overflow:auto;white-space:nowrap;border:1px solid #9F9F9F;width:435px;"><table cellspacing="0" cellpadding="0"><tbody><tr><td style="padding:5px;text-align:center;color:#888888;background-color:#EEEEEE;border-right: 1px solid #9F9F9F;font: normal 12px/1.4em Monaco, Lucida Console, monospace;"><div>1<br />2<br />3<br />4<br />5<br />6<br />7<br />8<br />9<br />10<br />11<br />12<br /></div></td><td><div class="bash codecolorer" style="padding:5px;font:normal 12px/1.4em Monaco, Lucida Console, monospace;white-space:nowrap">.<span style="color: #000000; font-weight: bold;">/</span>configure <span style="color: #660033;">--enable-rubyinterp</span> <span style="color: #660033;">--enable-multibyte</span> <span style="color: #660033;">--with-features</span>=huge<br />
... stripped output ...<br />
<span style="color: #c20cb9; font-weight: bold;">make</span><br />
<br />
Undefined symbols <span style="color: #000000; font-weight: bold;">for</span> architecture ppc:<br />
&nbsp; <span style="color: #ff0000;">&quot;_main&quot;</span>, referenced from:<br />
&nbsp; &nbsp; &nbsp; start <span style="color: #000000; font-weight: bold;">in</span> crt1.10.5.o<br />
ld: symbol<span style="color: #7a0874; font-weight: bold;">&#40;</span>s<span style="color: #7a0874; font-weight: bold;">&#41;</span> not found <span style="color: #000000; font-weight: bold;">for</span> architecture ppc<br />
collect2: <span style="color: #c20cb9; font-weight: bold;">ld</span> returned <span style="color: #000000;">1</span> <span style="color: #7a0874; font-weight: bold;">exit</span> status<br />
lipo: can<span style="color: #ff0000;">'t open input file: /var/folders/os/osNwawQ0Hreve7NDQEugQ++++TI/-Tmp-//ccD17Dx3.out (No such file or directory)<br />
make[1]: *** [Vim] Error 1<br />
make: *** [first] Error 2</span></div></td></tr></tbody></table></div>
<p>I did not do any <a href="http://en.wikipedia.org/wiki/Sherlock_Holmes">Sherlock holmes</a> work to understand this message as I do not need PPC support. I learned that there is a flag called &#8216;<strong>&#8211;with-mac-arch</strong>&#8216;.</p>
<h3>2. configure with specifying architecture</h3>
<div class="codecolorer-container bash twitlight" style="overflow:auto;white-space:nowrap;border:1px solid #9F9F9F;width:435px;"><table cellspacing="0" cellpadding="0"><tbody><tr><td style="padding:5px;text-align:center;color:#888888;background-color:#EEEEEE;border-right: 1px solid #9F9F9F;font: normal 12px/1.4em Monaco, Lucida Console, monospace;"><div>1<br />2<br />3<br />4<br />5<br />6<br />7<br />8<br />9<br />10<br />11<br />12<br /></div></td><td><div class="bash codecolorer" style="padding:5px;font:normal 12px/1.4em Monaco, Lucida Console, monospace;white-space:nowrap"><span style="color: #000000; font-weight: bold;">&gt;</span> .<span style="color: #000000; font-weight: bold;">/</span>configure <span style="color: #660033;">--with-mac-arch</span>=intel <span style="color: #660033;">--enable-rubyinterp</span> <span style="color: #660033;">--enable-multibyte</span> <span style="color: #660033;">--with-features</span>=huge<br />
<br />
checking <span style="color: #660033;">--with-tlib</span> argument... empty: automatic terminal library selection<br />
checking <span style="color: #000000; font-weight: bold;">for</span> tgetent <span style="color: #000000; font-weight: bold;">in</span> -lncurses... <span style="color: #7a0874; font-weight: bold;">&#40;</span>cached<span style="color: #7a0874; font-weight: bold;">&#41;</span> <span style="color: #c20cb9; font-weight: bold;">yes</span><br />
ncurses library is not usable<br />
checking <span style="color: #000000; font-weight: bold;">for</span> tgetent <span style="color: #000000; font-weight: bold;">in</span> -ltermlib... no<br />
checking <span style="color: #000000; font-weight: bold;">for</span> tgetent <span style="color: #000000; font-weight: bold;">in</span> -ltermcap... no<br />
checking <span style="color: #000000; font-weight: bold;">for</span> tgetent <span style="color: #000000; font-weight: bold;">in</span> -lcurses... no<br />
no terminal library found<br />
checking <span style="color: #000000; font-weight: bold;">for</span> tgetent<span style="color: #7a0874; font-weight: bold;">&#40;</span><span style="color: #7a0874; font-weight: bold;">&#41;</span>... configure: error: NOT FOUND<span style="color: #000000; font-weight: bold;">!</span><br />
&nbsp; &nbsp; &nbsp; You need to <span style="color: #c20cb9; font-weight: bold;">install</span> a terminal library; <span style="color: #000000; font-weight: bold;">for</span> example ncurses.<br />
&nbsp; &nbsp; &nbsp; Or specify the name of the library with --with-tlib.</div></td></tr></tbody></table></div>
<p>But as you can see specifying architecture did not even make is trough configure. I tried to specifying &#8211;with-tlib and adding LIBS path did not help. I did spend quite some time on this step to solve this one, but no luck here.</p>
<h3>3. The working solution.</h3>
<p>This became the working solution for me. Not that pretty but it did work <img src='http://www.pastbedti.me/wp-includes/images/smilies/icon_smile.gif' alt=':)' class='wp-smiley' /> </p>
<p>Run ./configure without arch flags.</p>
<div class="codecolorer-container bash twitlight" style="overflow:auto;white-space:nowrap;border:1px solid #9F9F9F;width:435px;"><table cellspacing="0" cellpadding="0"><tbody><tr><td style="padding:5px;text-align:center;color:#888888;background-color:#EEEEEE;border-right: 1px solid #9F9F9F;font: normal 12px/1.4em Monaco, Lucida Console, monospace;"><div>1<br /></div></td><td><div class="bash codecolorer" style="padding:5px;font:normal 12px/1.4em Monaco, Lucida Console, monospace;white-space:nowrap">.<span style="color: #000000; font-weight: bold;">/</span>configure <span style="color: #660033;">--enable-rubyinterp</span> <span style="color: #660033;">--enable-multibyte</span> <span style="color: #660033;">--with-features</span>=huge</div></td></tr></tbody></table></div>
<p>When done, edit src/auto/config.mk and remove PPC arch.<br />
And yes! I know editing src/auto/config.mk  is not that good and that the file is getting overwritten every time you run configure</p>
<div class="codecolorer-container bash twitlight" style="overflow:auto;white-space:nowrap;border:1px solid #9F9F9F;width:435px;"><table cellspacing="0" cellpadding="0"><tbody><tr><td style="padding:5px;text-align:center;color:#888888;background-color:#EEEEEE;border-right: 1px solid #9F9F9F;font: normal 12px/1.4em Monaco, Lucida Console, monospace;"><div>1<br /></div></td><td><div class="bash codecolorer" style="padding:5px;font:normal 12px/1.4em Monaco, Lucida Console, monospace;white-space:nowrap"><span style="color: #000000; font-weight: bold;">&gt;</span> <span style="color: #c20cb9; font-weight: bold;">vim</span> src<span style="color: #000000; font-weight: bold;">/</span>auto<span style="color: #000000; font-weight: bold;">/</span>config.mk</div></td></tr></tbody></table></div>
<p>on Line 26</p>
<div class="codecolorer-container bash twitlight" style="overflow:auto;white-space:nowrap;border:1px solid #9F9F9F;width:435px;"><table cellspacing="0" cellpadding="0"><tbody><tr><td style="padding:5px;text-align:center;color:#888888;background-color:#EEEEEE;border-right: 1px solid #9F9F9F;font: normal 12px/1.4em Monaco, Lucida Console, monospace;"><div>1<br /></div></td><td><div class="bash codecolorer" style="padding:5px;font:normal 12px/1.4em Monaco, Lucida Console, monospace;white-space:nowrap">&nbsp; LDFLAGS &nbsp; = -L. <span style="color: #660033;">-arch</span> ppc <span style="color: #660033;">-arch</span> i386 &nbsp;-L<span style="color: #000000; font-weight: bold;">/</span>usr<span style="color: #000000; font-weight: bold;">/</span>local<span style="color: #000000; font-weight: bold;">/</span>lib</div></td></tr></tbody></table></div>
<p>Remove the PPC part &#8220;<strong>-arch ppc</strong>&#8221;<br />
After removing PPC you can run:</p>
<div class="codecolorer-container bash twitlight" style="overflow:auto;white-space:nowrap;border:1px solid #9F9F9F;width:435px;"><table cellspacing="0" cellpadding="0"><tbody><tr><td style="padding:5px;text-align:center;color:#888888;background-color:#EEEEEE;border-right: 1px solid #9F9F9F;font: normal 12px/1.4em Monaco, Lucida Console, monospace;"><div>1<br />2<br /></div></td><td><div class="bash codecolorer" style="padding:5px;font:normal 12px/1.4em Monaco, Lucida Console, monospace;white-space:nowrap"><span style="color: #c20cb9; font-weight: bold;">make</span><br />
<span style="color: #c20cb9; font-weight: bold;">sudo</span> <span style="color: #c20cb9; font-weight: bold;">make</span> <span style="color: #c20cb9; font-weight: bold;">install</span></div></td></tr></tbody></table></div>
<p>I hope this can save someone else some time and i hope this is one of many to come blog posts that involves VIM!</p>
<p>Cheers! </p>
]]></content:encoded>
			<wfw:commentRss>http://www.pastbedti.me/2009/01/how-to-compile-vim-under-os-x/feed/</wfw:commentRss>
		<slash:comments>4</slash:comments>
		</item>
		<item>
		<title>Handling a staging environment with capistrano / rails</title>
		<link>http://www.pastbedti.me/2009/01/handling-a-staging-environment-with-capistrano-rails/</link>
		<comments>http://www.pastbedti.me/2009/01/handling-a-staging-environment-with-capistrano-rails/#comments</comments>
		<pubDate>Tue, 06 Jan 2009 20:49:06 +0000</pubDate>
		<dc:creator>Mathias Stjernström</dc:creator>
				<category><![CDATA[Hosting]]></category>
		<category><![CDATA[Programming]]></category>
		<category><![CDATA[Rails]]></category>
		<category><![CDATA[Ruby]]></category>
		<category><![CDATA[capistrano]]></category>
		<category><![CDATA[deploy]]></category>
		<category><![CDATA[staging]]></category>

		<guid isPermaLink="false">http://www.pastbedti.me/?p=342</guid>
		<description><![CDATA[Just before christmas I worked with one of our customers new server cluster or cloud if you may. This cluster has production nodes and staging nodes and this post is about how to get capistrano to play nice with both production and the staging environment. I have googled for a solution but all solutions I [...]]]></description>
			<content:encoded><![CDATA[<p>Just before christmas I worked with one of our customers new server cluster or cloud if you may.<br />
This cluster has production nodes and staging nodes and this post is about how to get capistrano to play nice with both production and the staging environment.<br />
<span id="more-342"></span></p>
<p>I have googled for a solution but all solutions I found where pretty ugly so i decided to create my own.  When writing this line I did a test googling just to give an example of a bad example and my first result where the <a href="http://weblog.jamisbuck.org/">buckblogs</a> blog. A post about <a href="http://weblog.jamisbuck.org/2007/7/23/capistrano-multistage">a plugin called multistage</a> I do not how I could miss that <img src='http://www.pastbedti.me/wp-includes/images/smilies/icon_wink.gif' alt=';)' class='wp-smiley' /> </p>
<p>But as my solution is so simple I will continue this post and show you anyway. </p>
<p>As usual I have written to much bullshit and I guess that you just want is some code so here you go.</p>
<div class="codecolorer-container ruby twitlight" style="overflow:auto;white-space:nowrap;border:1px solid #9F9F9F;width:435px;"><table cellspacing="0" cellpadding="0"><tbody><tr><td style="padding:5px;text-align:center;color:#888888;background-color:#EEEEEE;border-right: 1px solid #9F9F9F;font: normal 12px/1.4em Monaco, Lucida Console, monospace;"><div>1<br />2<br />3<br />4<br />5<br />6<br />7<br />8<br />9<br />10<br />11<br />12<br />13<br />14<br />15<br /></div></td><td><div class="ruby codecolorer" style="padding:5px;font:normal 12px/1.4em Monaco, Lucida Console, monospace;white-space:nowrap">desc <span style="color:#996600;">&quot;Run tasks in production enviroment.&quot;</span><br />
task <span style="color:#ff3333; font-weight:bold;">:production</span> <span style="color:#9966CC; font-weight:bold;">do</span><br />
&nbsp; <span style="color:#008000; font-style:italic;"># Production nodes </span><br />
&nbsp; role <span style="color:#ff3333; font-weight:bold;">:app</span>, <span style="color:#996600;">&quot;192.168.1.30&quot;</span><br />
&nbsp; role <span style="color:#ff3333; font-weight:bold;">:app</span>, <span style="color:#996600;">&quot;192.168.2.30&quot;</span><br />
&nbsp; role <span style="color:#ff3333; font-weight:bold;">:db</span>, &nbsp;<span style="color:#996600;">&quot;192.168.1.30&quot;</span>, <span style="color:#ff3333; font-weight:bold;">:primary</span> <span style="color:#006600; font-weight:bold;">=&gt;</span> <span style="color:#0000FF; font-weight:bold;">true</span><br />
<span style="color:#9966CC; font-weight:bold;">end</span> <br />
<br />
desc <span style="color:#996600;">&quot;Run tasks in staging enviroment.&quot;</span><br />
task <span style="color:#ff3333; font-weight:bold;">:staging</span> <span style="color:#9966CC; font-weight:bold;">do</span><br />
&nbsp; <span style="color:#008000; font-style:italic;"># Staging nodes </span><br />
&nbsp; role <span style="color:#ff3333; font-weight:bold;">:web</span>, <span style="color:#996600;">&quot;192.168.1.60&quot;</span><br />
&nbsp; role <span style="color:#ff3333; font-weight:bold;">:app</span>, <span style="color:#996600;">&quot;192.168.2.60&quot;</span><br />
&nbsp; role <span style="color:#ff3333; font-weight:bold;">:db</span>, &nbsp;<span style="color:#996600;">&quot;192.168.1.60&quot;</span>, <span style="color:#ff3333; font-weight:bold;">:primary</span><span style="color:#006600; font-weight:bold;">=&gt;</span><span style="color:#0000FF; font-weight:bold;">true</span><br />
<span style="color:#9966CC; font-weight:bold;">end</span></div></td></tr></tbody></table></div>
<p>This is all there is to it. Splitting your role definitions into different tasks.<br />
Now you may wonder how you use this when deploying or whatever you do.</p>
<p>Just add those tasks as params to <strong>cap</strong>.</p>
<div class="codecolorer-container bash twitlight" style="overflow:auto;white-space:nowrap;border:1px solid #9F9F9F;width:435px;"><table cellspacing="0" cellpadding="0"><tbody><tr><td style="padding:5px;text-align:center;color:#888888;background-color:#EEEEEE;border-right: 1px solid #9F9F9F;font: normal 12px/1.4em Monaco, Lucida Console, monospace;"><div>1<br />2<br />3<br />4<br />5<br /></div></td><td><div class="bash codecolorer" style="padding:5px;font:normal 12px/1.4em Monaco, Lucida Console, monospace;white-space:nowrap">cap staging deploy:check<br />
cap staging deploy<br />
<span style="color: #666666; font-style: italic;"># or </span><br />
cap production deploy:check<br />
cap production deploy</div></td></tr></tbody></table></div>
<p></p>
<h3>And here is a little bonus</h3>
<p>Just to spice this up a bit I added another useful function. A little warning if you are about to deploy to your production environment. When running a big/important site you do not want to deploy into the wrong environment <img src='http://www.pastbedti.me/wp-includes/images/smilies/icon_wink.gif' alt=';-)' class='wp-smiley' /> </p>
<p>This is how the final code looks.</p>
<div class="codecolorer-container ruby twitlight" style="overflow:auto;white-space:nowrap;border:1px solid #9F9F9F;width:435px;height:300px;"><table cellspacing="0" cellpadding="0"><tbody><tr><td style="padding:5px;text-align:center;color:#888888;background-color:#EEEEEE;border-right: 1px solid #9F9F9F;font: normal 12px/1.4em Monaco, Lucida Console, monospace;"><div>1<br />2<br />3<br />4<br />5<br />6<br />7<br />8<br />9<br />10<br />11<br />12<br />13<br />14<br />15<br />16<br />17<br />18<br />19<br />20<br />21<br />22<br />23<br /></div></td><td><div class="ruby codecolorer" style="padding:5px;font:normal 12px/1.4em Monaco, Lucida Console, monospace;white-space:nowrap">desc <span style="color:#996600;">&quot;Run tasks in production enviroment.&quot;</span><br />
task <span style="color:#ff3333; font-weight:bold;">:production</span> <span style="color:#9966CC; font-weight:bold;">do</span><br />
&nbsp; <span style="color:#008000; font-style:italic;"># Prompt to make really sure we want to deploy into prouction</span><br />
&nbsp; <span style="color:#CC0066; font-weight:bold;">puts</span> <span style="color:#996600;">&quot;<span style="color:#000099;">\n</span><span style="color:#000099;">\e</span>[0;31m &nbsp; ######################################################################&quot;</span> <br />
&nbsp; <span style="color:#CC0066; font-weight:bold;">puts</span> <span style="color:#996600;">&quot; &nbsp; #<span style="color:#000099;">\n</span> &nbsp; # &nbsp; &nbsp; &nbsp; Are you REALLY sure you want to deploy to production?&quot;</span><br />
&nbsp; <span style="color:#CC0066; font-weight:bold;">puts</span> <span style="color:#996600;">&quot; &nbsp; #<span style="color:#000099;">\n</span> &nbsp; # &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; Enter y/N + enter to continue<span style="color:#000099;">\n</span> &nbsp; #&quot;</span><br />
&nbsp; <span style="color:#CC0066; font-weight:bold;">puts</span> <span style="color:#996600;">&quot; &nbsp; ######################################################################<span style="color:#000099;">\e</span>[0m<span style="color:#000099;">\n</span>&quot;</span> <br />
&nbsp; proceed = STDIN.<span style="color:#CC0066; font-weight:bold;">gets</span><span style="color:#006600; font-weight:bold;">&#91;</span><span style="color:#006666;">0</span>..<span style="color:#006666;">0</span><span style="color:#006600; font-weight:bold;">&#93;</span> <span style="color:#9966CC; font-weight:bold;">rescue</span> <span style="color:#0000FF; font-weight:bold;">nil</span> <br />
&nbsp; <span style="color:#CC0066; font-weight:bold;">exit</span> <span style="color:#9966CC; font-weight:bold;">unless</span> proceed == <span style="color:#996600;">'y'</span> <span style="color:#006600; font-weight:bold;">||</span> proceed == <span style="color:#996600;">'Y'</span> <br />
&nbsp; <br />
&nbsp; <span style="color:#008000; font-style:italic;"># Production nodes </span><br />
&nbsp; role <span style="color:#ff3333; font-weight:bold;">:app</span>, <span style="color:#996600;">&quot;192.168.1.30&quot;</span><br />
&nbsp; role <span style="color:#ff3333; font-weight:bold;">:app</span>, <span style="color:#996600;">&quot;192.168.2.30&quot;</span><br />
&nbsp; role <span style="color:#ff3333; font-weight:bold;">:db</span>, &nbsp;<span style="color:#996600;">&quot;192.168.1.30&quot;</span>, <span style="color:#ff3333; font-weight:bold;">:primary</span> <span style="color:#006600; font-weight:bold;">=&gt;</span> <span style="color:#0000FF; font-weight:bold;">true</span><br />
<span style="color:#9966CC; font-weight:bold;">end</span> <br />
<br />
desc <span style="color:#996600;">&quot;Run tasks in staging enviroment.&quot;</span><br />
task <span style="color:#ff3333; font-weight:bold;">:staging</span> <span style="color:#9966CC; font-weight:bold;">do</span><br />
&nbsp; <span style="color:#008000; font-style:italic;"># Staging nodes </span><br />
&nbsp; role <span style="color:#ff3333; font-weight:bold;">:web</span>, <span style="color:#996600;">&quot;192.168.1.60&quot;</span><br />
&nbsp; role <span style="color:#ff3333; font-weight:bold;">:app</span>, <span style="color:#996600;">&quot;192.168.2.60&quot;</span><br />
&nbsp; role <span style="color:#ff3333; font-weight:bold;">:db</span>, &nbsp;<span style="color:#996600;">&quot;192.168.1.60&quot;</span>, <span style="color:#ff3333; font-weight:bold;">:primary</span><span style="color:#006600; font-weight:bold;">=&gt;</span><span style="color:#0000FF; font-weight:bold;">true</span><br />
<span style="color:#9966CC; font-weight:bold;">end</span></div></td></tr></tbody></table></div>
<p>
When this code is used you will get something like the image below.<br />
<br />
<img src="http://www.pastbedti.me/wp-content/uploads/2009/01/deploying_to_production.png" alt="Warning when deploying to production" title="Warning when deploying to production" width="562" height="276" class="alignnone size-full wp-image-360" /></p>
<p>And thats all there is to it. The only thing that I think is missing is a warning/notice if you do not specify either production/staging. Like it is now you will get an error when capistrano cannot find any valid servers.</p>
<p>Happy deploying! </p>
]]></content:encoded>
			<wfw:commentRss>http://www.pastbedti.me/2009/01/handling-a-staging-environment-with-capistrano-rails/feed/</wfw:commentRss>
		<slash:comments>8</slash:comments>
		</item>
		<item>
		<title>New version of capistrano_colors released.</title>
		<link>http://www.pastbedti.me/2009/01/new-version-of-capistrano_colors-released/</link>
		<comments>http://www.pastbedti.me/2009/01/new-version-of-capistrano_colors-released/#comments</comments>
		<pubDate>Sun, 04 Jan 2009 15:36:40 +0000</pubDate>
		<dc:creator>Mathias Stjernström</dc:creator>
				<category><![CDATA[gems]]></category>
		<category><![CDATA[Programming]]></category>
		<category><![CDATA[Projects]]></category>
		<category><![CDATA[Rails]]></category>
		<category><![CDATA[Ruby]]></category>
		<category><![CDATA[capistrano]]></category>
		<category><![CDATA[colorize]]></category>
		<category><![CDATA[colors]]></category>
		<category><![CDATA[release]]></category>

		<guid isPermaLink="false">http://www.pastbedti.me/?p=328</guid>
		<description><![CDATA[Just released a new version of capistrano_colors. This is a total rewrite from the last version. This post show some of the bigger changes. The biggest/coolest changes: You can write your own custom machers and colorize rows that&#8217;s special for you. I found a pretty neat way of making capistrano_colors system wide. You can hide [...]]]></description>
			<content:encoded><![CDATA[<p>Just released a new version of capistrano_colors. This is a total rewrite from the last version. This post show some of the bigger changes.<br />
<span id="more-328"></span></p>
<p>The biggest/coolest changes:</p>
<ul>
<li>You can write your own custom machers and colorize rows that&#8217;s special for you.</li>
<li>I found a pretty neat way of making capistrano_colors system wide.</li>
<li>You can hide rows that you do not care for</li>
</ul>
<p>I do not want to bore you more so I&#8217;ll just skip to an example <img src='http://www.pastbedti.me/wp-includes/images/smilies/icon_wink.gif' alt=';)' class='wp-smiley' /> </p>
<p>If you have not already, install capistrano_colors (v.0.5.0)</p>
<div class="codecolorer-container ruby twitlight" style="overflow:auto;white-space:nowrap;border:1px solid #9F9F9F;width:435px;"><table cellspacing="0" cellpadding="0"><tbody><tr><td style="padding:5px;text-align:center;color:#888888;background-color:#EEEEEE;border-right: 1px solid #9F9F9F;font: normal 12px/1.4em Monaco, Lucida Console, monospace;"><div>1<br /></div></td><td><div class="ruby codecolorer" style="padding:5px;font:normal 12px/1.4em Monaco, Lucida Console, monospace;white-space:nowrap">&nbsp; &nbsp;sudo gem install capistrano_colors</div></td></tr></tbody></table></div>
<p>The following commands can go into deploy.rb or ~/.caprc depending if you want cc for a single project or system wide.</p>
<div class="codecolorer-container ruby twitlight" style="overflow:auto;white-space:nowrap;border:1px solid #9F9F9F;width:435px;"><table cellspacing="0" cellpadding="0"><tbody><tr><td style="padding:5px;text-align:center;color:#888888;background-color:#EEEEEE;border-right: 1px solid #9F9F9F;font: normal 12px/1.4em Monaco, Lucida Console, monospace;"><div>1<br />2<br />3<br />4<br />5<br />6<br />7<br />8<br />9<br />10<br /></div></td><td><div class="ruby codecolorer" style="padding:5px;font:normal 12px/1.4em Monaco, Lucida Console, monospace;white-space:nowrap">&nbsp; &nbsp;<span style="color:#CC0066; font-weight:bold;">require</span> <span style="color:#996600;">'capistrano_colors'</span><br />
<br />
&nbsp; &nbsp;capistrano_color_matchers = <span style="color:#006600; font-weight:bold;">&#91;</span><br />
&nbsp; &nbsp; &nbsp;<span style="color:#006600; font-weight:bold;">&#123;</span> <span style="color:#ff3333; font-weight:bold;">:match</span> <span style="color:#006600; font-weight:bold;">=&gt;</span> <span style="color:#006600; font-weight:bold;">/</span>command finished<span style="color:#006600; font-weight:bold;">/</span>, &nbsp; &nbsp; &nbsp; <span style="color:#ff3333; font-weight:bold;">:color</span> <span style="color:#006600; font-weight:bold;">=&gt;</span> <span style="color:#ff3333; font-weight:bold;">:hide</span>, &nbsp; &nbsp; &nbsp;<span style="color:#ff3333; font-weight:bold;">:prio</span> <span style="color:#006600; font-weight:bold;">=&gt;</span> <span style="color:#006666;">10</span> <span style="color:#006600; font-weight:bold;">&#125;</span>,<br />
&nbsp; &nbsp; &nbsp;<span style="color:#006600; font-weight:bold;">&#123;</span> <span style="color:#ff3333; font-weight:bold;">:match</span> <span style="color:#006600; font-weight:bold;">=&gt;</span> <span style="color:#006600; font-weight:bold;">/</span>executing command<span style="color:#006600; font-weight:bold;">/</span>, &nbsp; &nbsp; &nbsp;<span style="color:#ff3333; font-weight:bold;">:color</span> <span style="color:#006600; font-weight:bold;">=&gt;</span> <span style="color:#ff3333; font-weight:bold;">:blue</span>, &nbsp; &nbsp; &nbsp;<span style="color:#ff3333; font-weight:bold;">:prio</span> <span style="color:#006600; font-weight:bold;">=&gt;</span> <span style="color:#006666;">10</span>, <span style="color:#ff3333; font-weight:bold;">:attribute</span> <span style="color:#006600; font-weight:bold;">=&gt;</span> <span style="color:#ff3333; font-weight:bold;">:underscore</span> <span style="color:#006600; font-weight:bold;">&#125;</span>,<br />
&nbsp; &nbsp; &nbsp;<span style="color:#006600; font-weight:bold;">&#123;</span> <span style="color:#ff3333; font-weight:bold;">:match</span> <span style="color:#006600; font-weight:bold;">=&gt;</span> <span style="color:#006600; font-weight:bold;">/</span>^transaction: commit$<span style="color:#006600; font-weight:bold;">/</span>, &nbsp;<span style="color:#ff3333; font-weight:bold;">:color</span> <span style="color:#006600; font-weight:bold;">=&gt;</span> <span style="color:#ff3333; font-weight:bold;">:magenta</span>, &nbsp; <span style="color:#ff3333; font-weight:bold;">:prio</span> <span style="color:#006600; font-weight:bold;">=&gt;</span> <span style="color:#006666;">10</span>, <span style="color:#ff3333; font-weight:bold;">:attribute</span> <span style="color:#006600; font-weight:bold;">=&gt;</span> <span style="color:#ff3333; font-weight:bold;">:blink</span> <span style="color:#006600; font-weight:bold;">&#125;</span>,<br />
&nbsp; &nbsp; &nbsp;<span style="color:#006600; font-weight:bold;">&#123;</span> <span style="color:#ff3333; font-weight:bold;">:match</span> <span style="color:#006600; font-weight:bold;">=&gt;</span> <span style="color:#006600; font-weight:bold;">/</span>git<span style="color:#006600; font-weight:bold;">/</span>, &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp;<span style="color:#ff3333; font-weight:bold;">:color</span> <span style="color:#006600; font-weight:bold;">=&gt;</span> <span style="color:#ff3333; font-weight:bold;">:white</span>, &nbsp; &nbsp; <span style="color:#ff3333; font-weight:bold;">:prio</span> <span style="color:#006600; font-weight:bold;">=&gt;</span> <span style="color:#006666;">20</span>, <span style="color:#ff3333; font-weight:bold;">:attribute</span> <span style="color:#006600; font-weight:bold;">=&gt;</span> <span style="color:#ff3333; font-weight:bold;">:reverse</span> <span style="color:#006600; font-weight:bold;">&#125;</span>,<br />
&nbsp; &nbsp;<span style="color:#006600; font-weight:bold;">&#93;</span><br />
<br />
&nbsp; &nbsp;colorize<span style="color:#006600; font-weight:bold;">&#40;</span> capistrano_color_matchers <span style="color:#006600; font-weight:bold;">&#41;</span></div></td></tr></tbody></table></div>
<p>The only mandatory options are :match, :colors and :prio.</p>
<p>A fast description of the options:</p>
<li>:match     &#8211; A regular expression of the row to match.</li>
<li>:color     &#8211; The color we want on the matching rows.</li>
<li>:prio      &#8211; What prio should this rule have (higher = more prio)</li>
<li>:attribute &#8211; Special effect (:underline, :reverse, :blink)</li>
<li>:level     &#8211; Specify if this matcher should be bound to some of capistranos log levels (info,debug,&#8230;)</li>
<p>A more detailed description can be found at <a href="http://github.com/stjernstrom/capistrano_colors/tree/master">http://github.com/stjernstrom/capistrano_colors/tree/master</a></p>
<p>As this is a rewrite I would love some feedback.</p>
<p>Thanks! </p>
]]></content:encoded>
			<wfw:commentRss>http://www.pastbedti.me/2009/01/new-version-of-capistrano_colors-released/feed/</wfw:commentRss>
		<slash:comments>0</slash:comments>
		</item>
		<item>
		<title>Put some colors on your capistrano output</title>
		<link>http://www.pastbedti.me/2008/12/put-some-colors-of-your-capistrano-output/</link>
		<comments>http://www.pastbedti.me/2008/12/put-some-colors-of-your-capistrano-output/#comments</comments>
		<pubDate>Sat, 20 Dec 2008 23:02:02 +0000</pubDate>
		<dc:creator>Mathias Stjernström</dc:creator>
				<category><![CDATA[gems]]></category>
		<category><![CDATA[Programming]]></category>
		<category><![CDATA[Projects]]></category>
		<category><![CDATA[Ruby]]></category>
		<category><![CDATA[capistrano]]></category>
		<category><![CDATA[colors]]></category>
		<category><![CDATA[Rails]]></category>
		<category><![CDATA[release]]></category>

		<guid isPermaLink="false">http://www.pastbedti.me/?p=304</guid>
		<description><![CDATA[I got so tired of all the messy capistrano output so today I released my first public gem. The name of the gem is capistrano_colors and the aim of the gem is to put some nice and shiny colors on capistrano output. The gem has only been tested with rails but should work wherever capistrano [...]]]></description>
			<content:encoded><![CDATA[<p>I got so tired of all the messy capistrano output so today I released my first public gem.</p>
<p>The name of the gem is <a href="http://github.com/stjernstrom/capistrano_colors/">capistrano_colors</a> and the aim of the gem is to put some nice and shiny colors on capistrano output. The  gem has only been tested with rails but should work wherever capistrano works.</p>
<p>Keep on reading to see some screenshots!<br />
<span id="more-304"></span><br />
Just follow the instruction on the github page (<a href="http://github.com/stjernstrom/capistrano_colors/">http://github.com/stjernstrom/capistrano_colors/</a>) and you will have a colorful output like the second screenshots in no time.</p>
<div id="attachment_313" class="wp-caption alignnone" style="width: 590px"><img class="size-full wp-image-313" title="Capistrano output without capistrano_colors" src="http://www.pastbedti.me/wp-content/uploads/2008/12/capistrano_output_without_capistrano_colors.png" alt="Capistrano output without capistrano_colors" width="580" height="421" /><p class="wp-caption-text">Capistrano output without capistrano_colors</p></div>
<div id="attachment_315" class="wp-caption alignnone" style="width: 590px"><img class="size-full wp-image-315" title="Capistrano output with capistrano_colors" src="http://www.pastbedti.me/wp-content/uploads/2008/12/capistrano_output_with_capistrano_colors.png" alt="Capistrano output with capistrano_colors" width="580" height="415" /><p class="wp-caption-text">Capistrano output with capistrano_colors</p></div>
<p>As you can see the output on the second image is much clearer and easier to understand.</p>
<p>Try it out and let me know what you think! </p>
<p>Cheers!</p>
]]></content:encoded>
			<wfw:commentRss>http://www.pastbedti.me/2008/12/put-some-colors-of-your-capistrano-output/feed/</wfw:commentRss>
		<slash:comments>6</slash:comments>
		</item>
		<item>
		<title>Ruby enterprise edition (REE) on Gentoo failed and some performance experience.</title>
		<link>http://www.pastbedti.me/2008/12/ruby-enterprise-edition-ree-on-gentoo-failed-and-some-performance-experience/</link>
		<comments>http://www.pastbedti.me/2008/12/ruby-enterprise-edition-ree-on-gentoo-failed-and-some-performance-experience/#comments</comments>
		<pubDate>Mon, 15 Dec 2008 20:44:36 +0000</pubDate>
		<dc:creator>Mathias Stjernström</dc:creator>
				<category><![CDATA[Hosting]]></category>
		<category><![CDATA[Programming]]></category>
		<category><![CDATA[Rails]]></category>
		<category><![CDATA[gems]]></category>
		<category><![CDATA[gentoo]]></category>
		<category><![CDATA[performance]]></category>
		<category><![CDATA[Ruby]]></category>
		<category><![CDATA[ruby_enterprise]]></category>

		<guid isPermaLink="false">http://www.pastbedti.me/?p=280</guid>
		<description><![CDATA[Today I got the chance to give Ruby Enterprise Edition a try. We are currently working with a really fun new environment and you do not get better opportunities to try new stuff as when you have a complete new environment thats not in production. So we gave REE a shoot. When compiling REE with got in trouble really fast and this [...]]]></description>
			<content:encoded><![CDATA[<p>Today I got the chance to give <a href="http://www.rubyenterpriseedition.com/">Ruby Enterprise Edition</a> a try. We are currently working with a really fun new environment and you do not get better opportunities to try new stuff as when you have a complete new environment thats not in production. So we gave REE a shoot. When compiling REE with got in trouble really fast and this post is about the quick fix to solve it and some of our early performance results.</p>
<p><span id="more-280"></span></p>
<p>The installation of REE is nothing more that unpacking ruby-enterprise-1.8.6-20081205.tar.gz and the run the installer.</p>
<div class="codecolorer-container bash twitlight" style="overflow:auto;white-space:nowrap;border:1px solid #9F9F9F;width:435px;"><table cellspacing="0" cellpadding="0"><tbody><tr><td style="padding:5px;text-align:center;color:#888888;background-color:#EEEEEE;border-right: 1px solid #9F9F9F;font: normal 12px/1.4em Monaco, Lucida Console, monospace;"><div>1<br /></div></td><td><div class="bash codecolorer" style="padding:5px;font:normal 12px/1.4em Monaco, Lucida Console, monospace;white-space:nowrap"><span style="color: #c20cb9; font-weight: bold;">tar</span> xzvf ruby-enterprise-1.8.6-<span style="color: #000000;">20081205</span>.tar.gz</div></td></tr></tbody></table></div>
<p>And after that we run</p>
<div class="codecolorer-container bash twitlight" style="overflow:auto;white-space:nowrap;border:1px solid #9F9F9F;width:435px;"><table cellspacing="0" cellpadding="0"><tbody><tr><td style="padding:5px;text-align:center;color:#888888;background-color:#EEEEEE;border-right: 1px solid #9F9F9F;font: normal 12px/1.4em Monaco, Lucida Console, monospace;"><div>1<br /></div></td><td><div class="bash codecolorer" style="padding:5px;font:normal 12px/1.4em Monaco, Lucida Console, monospace;white-space:nowrap">.<span style="color: #000000; font-weight: bold;">/</span>ruby-enterprise-1.8.6-<span style="color: #000000;">20081205</span><span style="color: #000000; font-weight: bold;">/</span>installer</div></td></tr></tbody></table></div>
<p>This is when our problems started.</p>
<div class="codecolorer-container bash twitlight" style="overflow:auto;white-space:nowrap;border:1px solid #9F9F9F;width:435px;"><table cellspacing="0" cellpadding="0"><tbody><tr><td style="padding:5px;text-align:center;color:#888888;background-color:#EEEEEE;border-right: 1px solid #9F9F9F;font: normal 12px/1.4em Monaco, Lucida Console, monospace;"><div>1<br />2<br />3<br />4<br />5<br />6<br /></div></td><td><div class="bash codecolorer" style="padding:5px;font:normal 12px/1.4em Monaco, Lucida Console, monospace;white-space:nowrap"><span style="color: #c20cb9; font-weight: bold;">chmod</span> <span style="color: #660033;">-R</span> g+r,o+r,o-w <span style="color: #000000; font-weight: bold;">/</span>opt<span style="color: #000000; font-weight: bold;">/</span>ruby-enterprise-1.8.6-<span style="color: #000000;">20081205</span><span style="color: #000000; font-weight: bold;">/</span>lib<span style="color: #000000; font-weight: bold;">/</span>ruby<br />
<span style="color: #660033;">--------------------------------------------</span><br />
Installing RubyGems...<br />
<span style="color: #000000; font-weight: bold;">/</span>opt<span style="color: #000000; font-weight: bold;">/</span>ruby-enterprise-1.8.6-<span style="color: #000000;">20081205</span><span style="color: #000000; font-weight: bold;">/</span>bin<span style="color: #000000; font-weight: bold;">/</span>ruby setup.rb <span style="color: #660033;">--no-ri</span> <span style="color: #660033;">--no-rdoc</span><br />
<span style="color: #000000; font-weight: bold;">/</span>opt<span style="color: #000000; font-weight: bold;">/</span>ruby-enterprise-1.8.6-<span style="color: #000000;">20081205</span><span style="color: #000000; font-weight: bold;">/</span>bin<span style="color: #000000; font-weight: bold;">/</span>ruby: no such <span style="color: #c20cb9; font-weight: bold;">file</span> to load <span style="color: #660033;">--</span> auto_gem <span style="color: #7a0874; font-weight: bold;">&#40;</span>LoadError<span style="color: #7a0874; font-weight: bold;">&#41;</span><br />
<span style="color: #000000; font-weight: bold;">***</span> Cannot <span style="color: #c20cb9; font-weight: bold;">install</span> RubyGems</div></td></tr></tbody></table></div>
<p>This one took some time to find but first I could not understand why auto_gem was not found and also why it tried to load auto_gem when the installation of rubygems is not done.</p>
<p>After a few minutes of thinking and digging i found my environment variable RUBYOPT which was set to -rauto_gem.</p>
<div class="codecolorer-container bash twitlight" style="overflow:auto;white-space:nowrap;border:1px solid #9F9F9F;width:435px;"><table cellspacing="0" cellpadding="0"><tbody><tr><td style="padding:5px;text-align:center;color:#888888;background-color:#EEEEEE;border-right: 1px solid #9F9F9F;font: normal 12px/1.4em Monaco, Lucida Console, monospace;"><div>1<br /></div></td><td><div class="bash codecolorer" style="padding:5px;font:normal 12px/1.4em Monaco, Lucida Console, monospace;white-space:nowrap"><span style="color: #007800;">RUBYOPT</span>=-rauto_gem</div></td></tr></tbody></table></div>
<p>This one makes rubygems to autoload when you run something in ruby. I already had this line because i had ruby/rubygems installed before we installed REE. I still want this enviroment but not during the installation so i disabled it by starting the installer like this:</p>
<div class="codecolorer-container bash twitlight" style="overflow:auto;white-space:nowrap;border:1px solid #9F9F9F;width:435px;"><table cellspacing="0" cellpadding="0"><tbody><tr><td style="padding:5px;text-align:center;color:#888888;background-color:#EEEEEE;border-right: 1px solid #9F9F9F;font: normal 12px/1.4em Monaco, Lucida Console, monospace;"><div>1<br /></div></td><td><div class="bash codecolorer" style="padding:5px;font:normal 12px/1.4em Monaco, Lucida Console, monospace;white-space:nowrap"><span style="color: #007800;">RUBYOPT</span>=<span style="color: #ff0000;">&quot;&quot;</span> .<span style="color: #000000; font-weight: bold;">/</span>ruby-enterprise-1.8.6-<span style="color: #000000;">20081205</span><span style="color: #000000; font-weight: bold;">/</span>installer</div></td></tr></tbody></table></div>
<p>Passing the environment variable before the command just sets it for this command.</p>
<p>If you do want this change permanent some digging in /etc found there is no less that 3 files where this variable is set <em>(depending of shells)</em>.</p>
<div class="codecolorer-container bash twitlight" style="overflow:auto;white-space:nowrap;border:1px solid #9F9F9F;width:435px;"><table cellspacing="0" cellpadding="0"><tbody><tr><td style="padding:5px;text-align:center;color:#888888;background-color:#EEEEEE;border-right: 1px solid #9F9F9F;font: normal 12px/1.4em Monaco, Lucida Console, monospace;"><div>1<br />2<br />3<br />4<br /></div></td><td><div class="bash codecolorer" style="padding:5px;font:normal 12px/1.4em Monaco, Lucida Console, monospace;white-space:nowrap"><span style="color: #c20cb9; font-weight: bold;">grep</span> <span style="color: #660033;">-R</span> <span style="color: #ff0000;">&quot;RUBYOPT&quot;</span> <span style="color: #000000; font-weight: bold;">*</span><br />
csh.env:setenv RUBYOPT <span style="color: #ff0000;">'-rauto_gem'</span><br />
env.d<span style="color: #000000; font-weight: bold;">/</span>10rubygems:<span style="color: #007800;">RUBYOPT</span>=<span style="color: #ff0000;">&quot;-rauto_gem&quot;</span><br />
profile.env:export <span style="color: #007800;">RUBYOPT</span>=<span style="color: #ff0000;">'-rauto_gem'</span></div></td></tr></tbody></table></div>
<p>After changing this variable everything worked as expected! </p>
<p>So far our experience with REE is great. With plain old ruby we where running about 15 <a href="http://www.modrails.com/">passenger (mod_rails)</a> instances and we where using around 1.6GB memory. After The ruby enterprise upgrade we are now using 26 instances with only 1.7GB memory. CPU loads when stressing seems to be 50% less with REE and pages load times are much more stable.</p>
<p>You have to take these measurements with a bit of salt because we only had around an hour of testing but they seem pretty impressive so far.</p>
<p>I will get back with more performance data as we play.</p>
<p>Cheers! </p>
]]></content:encoded>
			<wfw:commentRss>http://www.pastbedti.me/2008/12/ruby-enterprise-edition-ree-on-gentoo-failed-and-some-performance-experience/feed/</wfw:commentRss>
		<slash:comments>9</slash:comments>
		</item>
	</channel>
</rss>

