<?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; Rails</title>
	<atom:link href="http://www.pastbedti.me/category/programming/rails/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>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>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>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>
		<item>
		<title>The developers behind Newsdesk have a weblog!</title>
		<link>http://www.pastbedti.me/2008/11/the-developers-behind-newsdesk-have-a-weblog/</link>
		<comments>http://www.pastbedti.me/2008/11/the-developers-behind-newsdesk-have-a-weblog/#comments</comments>
		<pubDate>Tue, 25 Nov 2008 19:21:21 +0000</pubDate>
		<dc:creator>Mathias Stjernström</dc:creator>
				<category><![CDATA[Life]]></category>
		<category><![CDATA[Rails]]></category>
		<category><![CDATA[Ruby]]></category>
		<category><![CDATA[blog]]></category>
		<category><![CDATA[charts]]></category>
		<category><![CDATA[google]]></category>

		<guid isPermaLink="false">http://www.pastbedti.me/?p=236</guid>
		<description><![CDATA[Finally my friends at newsdesk have a blog. They have started off real good with a comparison of three ruby wrappers for Google charts. I have great expectations from the newsdesk developers blog. If you are a Ruby and Rails developer you should definitely keep and eye on them!]]></description>
			<content:encoded><![CDATA[<p>Finally my friends at <a href="http://www.newsdesk.se/">newsdesk</a> have a blog. They have started off real good with <a href="http://developer.newsdesk.se/2008/11/25/using-google-charts-from-rails/">a comparison of three ruby wrappers for Google charts</a>.</p>
<p>I have great expectations from the <a href="http://developer.newsdesk.se/">newsdesk developers blog</a>. If you are a Ruby and Rails developer you should definitely keep and eye on them! </p>
]]></content:encoded>
			<wfw:commentRss>http://www.pastbedti.me/2008/11/the-developers-behind-newsdesk-have-a-weblog/feed/</wfw:commentRss>
		<slash:comments>0</slash:comments>
		</item>
		<item>
		<title>Redirecting with nginx</title>
		<link>http://www.pastbedti.me/2008/05/redirecting-with-nginx/</link>
		<comments>http://www.pastbedti.me/2008/05/redirecting-with-nginx/#comments</comments>
		<pubDate>Wed, 21 May 2008 17:22:37 +0000</pubDate>
		<dc:creator>Mathias Stjernström</dc:creator>
				<category><![CDATA[Hosting]]></category>
		<category><![CDATA[Rails]]></category>
		<category><![CDATA[nginx]]></category>

		<guid isPermaLink="false">http://www.stjernstrom.se/?p=15</guid>
		<description><![CDATA[Today one of our server got in trouble with an ACE encoded IDN domain. The problem seemed to be rails in combination with nginx&#8217;s X-Sendfile feature. The result became that when accessing the site trough the IDN domain x-senfile did not send any files&#8230;. Our quick and dirty solution (until we have found the source/or solved the [...]]]></description>
			<content:encoded><![CDATA[<p>Today one of our server got in trouble with an ACE encoded <a href="http://en.wikipedia.org/wiki/Internationalized_domain_name" target="_blank">IDN</a> domain. The problem seemed to be rails in combination with <a href="http://wiki.codemongers.com/NginxXSendfile" target="_blank">nginx&#8217;s X-Sendfile</a> feature. The result became that when accessing the site trough the IDN domain x-senfile did not send any files&#8230;.</p>
<p>Our quick and dirty solution (<em>until we have found the source/or solved the problem</em>) became redirecting all traffic from the IDN domain to the domain without <a href="http://www.iana.org/domains/idn-tables/tables/se_sv-se_1.0.html" target="_blank">strange-swedish-characters</a>.</p>
<p>With nginx this is as simple as in most webservers just put the following code before you original server configuration in nginx.conf.</p>
<div class="codecolorer-container html4strict 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="html4strict codecolorer" style="padding:5px;font:normal 12px/1.4em Monaco, Lucida Console, monospace;white-space:nowrap">server {<br />
&nbsp; &nbsp; server_name &nbsp;xn--svenskdomn-y5a.se www.xn--svenskdomn-y5a.se;<br />
&nbsp; &nbsp; rewrite ^(.*) http://www.svenskdoman.se$1 permanent;<br />
}</div></td></tr></tbody></table></div>
<p>And Bowang! All requests to www.svenskdomän.se will be redirected to www.svenskdoman.se.</p>
<p>Domain names have been changed to protect the innocent <img src='http://www.pastbedti.me/wp-includes/images/smilies/icon_smile.gif' alt=':-)' class='wp-smiley' /> </p>
<p>Cheers!</p>
]]></content:encoded>
			<wfw:commentRss>http://www.pastbedti.me/2008/05/redirecting-with-nginx/feed/</wfw:commentRss>
		<slash:comments>0</slash:comments>
		</item>
	</channel>
</rss>

