<?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; Mathias Stjernström</title>
	<atom:link href="http://www.pastbedti.me/author/admin/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>Batch rename files with spaces in linux/bash</title>
		<link>http://www.pastbedti.me/2010/10/batch-rename-files-with-spaces-in-linuxbash/</link>
		<comments>http://www.pastbedti.me/2010/10/batch-rename-files-with-spaces-in-linuxbash/#comments</comments>
		<pubDate>Wed, 20 Oct 2010 07:55:04 +0000</pubDate>
		<dc:creator>Mathias Stjernström</dc:creator>
				<category><![CDATA[Linux]]></category>
		<category><![CDATA[Note to self]]></category>
		<category><![CDATA[Operatingsystem]]></category>
		<category><![CDATA[bash]]></category>
		<category><![CDATA[linux]]></category>
		<category><![CDATA[Note]]></category>

		<guid isPermaLink="false">http://www.pastbedti.me/?p=676</guid>
		<description><![CDATA[A reminder for myself how to batch rename files with spaces in bash. This is how i rename files with space to have underscores instead. DO NOT blame me if this commando erases all your files I found several examples how to do this when googling but they all failed. Some of them did nothing [...]]]></description>
			<content:encoded><![CDATA[<p>A reminder for myself how to batch rename files with spaces in bash.</p>
<p>This is how i rename files with space to have underscores instead. DO NOT blame me if this commando erases all your files <img src='http://www.pastbedti.me/wp-includes/images/smilies/icon_smile.gif' alt=':)' class='wp-smiley' />   I found several examples how to do this when googling but they all failed. Some of them did nothing and some erased half my filenames. SO IF YOU USE THIS, PLEASE TRY IT IN A FOLDER WITHOUT IMPORTANT FILES FIRST.</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;">for</span> f <span style="color: #000000; font-weight: bold;">in</span> <span style="color: #000000; font-weight: bold;">*</span><span style="color: #ff0000;">' '</span><span style="color: #000000; font-weight: bold;">*</span>; <span style="color: #000000; font-weight: bold;">do</span> <span style="color: #c20cb9; font-weight: bold;">mv</span> <span style="color: #ff0000;">&quot;<span style="color: #007800;">$f</span>&quot;</span> <span style="color: #ff0000;">&quot;<span style="color: #780078;">`echo $f | sed -e 's/ /_/g'`</span>&quot;</span>; <span style="color: #000000; font-weight: bold;">done</span></div></td></tr></tbody></table></div>
<p>Cheers!</p>
]]></content:encoded>
			<wfw:commentRss>http://www.pastbedti.me/2010/10/batch-rename-files-with-spaces-in-linuxbash/feed/</wfw:commentRss>
		<slash:comments>0</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>5-10 second delay when launching Terminal.app in OSX</title>
		<link>http://www.pastbedti.me/2009/09/5-10-second-delay-when-launching-terminal-in-osx/</link>
		<comments>http://www.pastbedti.me/2009/09/5-10-second-delay-when-launching-terminal-in-osx/#comments</comments>
		<pubDate>Fri, 11 Sep 2009 20:29:36 +0000</pubDate>
		<dc:creator>Mathias Stjernström</dc:creator>
				<category><![CDATA[Operatingsystem]]></category>
		<category><![CDATA[Utilities]]></category>
		<category><![CDATA[console]]></category>
		<category><![CDATA[howto]]></category>
		<category><![CDATA[logging]]></category>
		<category><![CDATA[osx]]></category>
		<category><![CDATA[terminal]]></category>

		<guid isPermaLink="false">http://www.pastbedti.me/?p=540</guid>
		<description><![CDATA[A couple of days ago my Terminal.app (console) got a really annoying feature. When launching the console or when I created a new tab it got stuck for about 5-10 seconds before I got my prompt. If you are like me and are spending most of your time in Terminal.app you understand how annoying this [...]]]></description>
			<content:encoded><![CDATA[<p>A couple of days ago my Terminal.app (console) got a really annoying feature. When launching the console or when I created a new tab it got stuck for about 5-10 seconds before I got my prompt. </p>
<p>If you are like me and are spending most of your time in Terminal.app you understand how annoying this is/was. </p>
<p>I tried to rename .profile, .inputrc and evey other startup script I had in my home folder but the problem did not go away. </p>
<p>Then I found an OSX user which had his Terminal crash when started. He solved his problem by cleaning up some OSX systemlogs. So I thought I try the same trick.</p>
<p>The logfiles which he removed where the asl files under /private/var/log/asl/</p>
<p>I read about them here: <a href="http://macosx.com/tech-support/can-i-deleteasl-log/24223.html">http://macosx.com/tech-support/can-i-deleteasl-log/24223.html</a></p>
<p>But I figured I&#8217;d just remove them all <img src='http://www.pastbedti.me/wp-includes/images/smilies/icon_smile.gif' alt=':)' class='wp-smiley' /> </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">sudo rm -rf /private/var/log/asl/*</div></td></tr></tbody></table></div>
<p>When all asl files where removed my Terminal went back to normal again and I am sooooooo relieved. </p>
<p><strong>This worked for me BUT I do not recommend you to remove anything if you do not know what you are doing!!!<br />
</strong><br />
Cheers!</p>
]]></content:encoded>
			<wfw:commentRss>http://www.pastbedti.me/2009/09/5-10-second-delay-when-launching-terminal-in-osx/feed/</wfw:commentRss>
		<slash:comments>6</slash:comments>
		</item>
		<item>
		<title>Running couchdb under an unprivileged user account.</title>
		<link>http://www.pastbedti.me/2009/04/running-couchdb-under-an-unprivileged-user-account/</link>
		<comments>http://www.pastbedti.me/2009/04/running-couchdb-under-an-unprivileged-user-account/#comments</comments>
		<pubDate>Fri, 10 Apr 2009 18:23:55 +0000</pubDate>
		<dc:creator>Mathias Stjernström</dc:creator>
				<category><![CDATA[Databases]]></category>
		<category><![CDATA[Hosting]]></category>
		<category><![CDATA[couchdb]]></category>
		<category><![CDATA[howto]]></category>
		<category><![CDATA[unprivileged]]></category>

		<guid isPermaLink="false">http://www.pastbedti.me/?p=423</guid>
		<description><![CDATA[When helping a friend last night with couchdb a got stuck when trying to start it as an unprivileged user. The error messages you get from couchdb is far from easy to understand. This is my way of solving it. 1234567$ couchdb kernel-poll not supported; &#34;K&#34; parameter ignored Apache CouchDB 0.9.0 (LogLevel=info) is starting. {&#34;init [...]]]></description>
			<content:encoded><![CDATA[<p>When helping a friend last night with couchdb a got stuck when trying to start it as an unprivileged user. The error messages you get from couchdb is far from easy to understand. </p>
<p>This is my way of solving it.<br />
<span id="more-423"></span></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 /></div></td><td><div class="text codecolorer" style="padding:5px;font:normal 12px/1.4em Monaco, Lucida Console, monospace;white-space:nowrap">$ couchdb<br />
kernel-poll not supported; &quot;K&quot; parameter ignored<br />
Apache CouchDB 0.9.0 (LogLevel=info) is starting.<br />
{&quot;init terminating in do_boot&quot;,{{badmatch,{error,shutdown}},[{couch_server_sup,start_server,1},{erl_eval,do_apply,5},{erl_eval,exprs,5},{init,start_it,1},{init,start_em,1}]}}<br />
<br />
Crash dump was written to: erl_crash.dump<br />
init terminating in do_boot ()</div></td></tr></tbody></table></div>
<p>Even with debug turned on it&#8217;s pretty hard to understand.</p>
<div class="codecolorer-container text 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 />24<br />25<br />26<br />27<br />28<br />29<br />30<br />31<br />32<br />33<br />34<br />35<br />36<br />37<br />38<br />39<br />40<br />41<br />42<br />43<br />44<br /></div></td><td><div class="text codecolorer" style="padding:5px;font:normal 12px/1.4em Monaco, Lucida Console, monospace;white-space:nowrap">kernel-poll not supported; &quot;K&quot; parameter ignored<br />
Apache CouchDB 0.9.0 (LogLevel=debug) is starting.<br />
Configuration Settings [&quot;./couchdb/local.ini&quot;]:<br />
&nbsp; [Couch] BindAddress=&quot;127.0.0.1&quot;<br />
&nbsp; [Couch] ConsoleStartupMsg=&quot;Apache CouchDB is starting.&quot;<br />
&nbsp; [Couch] DbRootDir=&quot;/home/mathias/couchdb&quot;<br />
&nbsp; [Couch] DocumentRoot=&quot;/home/mathias/couchdb/www&quot;<br />
&nbsp; [Couch] LogFile=&quot;/home/mathias/couchdb/couch.log&quot;<br />
&nbsp; [Couch] LogLevel=&quot;debug&quot;<br />
&nbsp; [Couch] Port=&quot;5984&quot;<br />
&nbsp; [Couch] UtilDriverDir=&quot;/usr/local/lib/couchdb/erlang/lib/couch-0.8.1-incubating/priv/lib&quot;<br />
&nbsp; [Couch Query Servers] javascript=&quot;/usr/local/bin/couchjs /usr/local/share/couchdb/server/main.js&quot;<br />
&nbsp; [couchdb] database_dir=&quot;/home/mathias/couchdb&quot;<br />
&nbsp; [couchdb] view_index_dir=&quot;/home/mathias/couchdb&quot;<br />
&nbsp; [httpd] bind_address=&quot;127.0.0.1&quot;<br />
&nbsp; [httpd] port=&quot;5984&quot;<br />
&nbsp; [log] level=&quot;debug&quot;<br />
[error] [&lt;0.41.0&gt;] {error_report,&lt;0.21.0&gt;,<br />
&nbsp; &nbsp; {&lt;0.41.0&gt;,crash_report,<br />
&nbsp; &nbsp; &nbsp;[[{pid,&lt;0.41.0&gt;},<br />
&nbsp; &nbsp; &nbsp; &nbsp;{registered_name,couch_server},<br />
&nbsp; &nbsp; &nbsp; &nbsp;{error_info,<br />
&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp;{exit,<br />
&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp;{badarg,<br />
&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp;[{erlang,list_to_integer,[undefined]},<br />
&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; {couch_server,init,1},<br />
&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; {gen_server,init_it,6},<br />
&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; {proc_lib,init_p_do_apply,3}]},<br />
&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp;[{gen_server,init_it,6},{proc_lib,init_p_do_apply,3}]}},<br />
&nbsp; &nbsp; &nbsp; &nbsp;{initial_call,{couch_server,init,['Argument__1']}},<br />
&nbsp; &nbsp; &nbsp; &nbsp;{ancestors,[couch_primary_services,couch_server_sup,&lt;0.1.0&gt;]},<br />
&nbsp; &nbsp; &nbsp; &nbsp;{messages,[]},<br />
&nbsp; &nbsp; &nbsp; &nbsp;{links,[&lt;0.36.0&gt;]},<br />
&nbsp; &nbsp; &nbsp; &nbsp;{dictionary,[]},<br />
&nbsp; &nbsp; &nbsp; &nbsp;{trap_exit,false},<br />
&nbsp; &nbsp; &nbsp; &nbsp;{status,running},<br />
&nbsp; &nbsp; &nbsp; &nbsp;{heap_size,233},<br />
&nbsp; &nbsp; &nbsp; &nbsp;{stack_size,23},<br />
&nbsp; &nbsp; &nbsp; &nbsp;{reductions,113}],<br />
&nbsp; &nbsp; &nbsp; []]}}<br />
{&quot;init terminating in do_boot&quot;,{{badmatch,{error,shutdown}},[{couch_server_sup,start_server,1},{erl_eval,do_apply,5},{erl_eval,exprs,5},{init,start_it,1},{init,start_em,1}]}}<br />
<br />
Crash dump was written to: erl_crash.dump<br />
init terminating in do_boot ()</div></td></tr></tbody></table></div>
<p>When running things as unprivileged users the usual problems are that you do not have access to read/write files or binding to the lower ports A.K.A. &#8220;well known ports&#8221;.  With that in mind I located the original config files for couchdb with the plan of copying or overriding them. </p>
<p>My config files where located under <strong>/usr/local/etc/couchdb/</strong></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 /></div></td><td><div class="text codecolorer" style="padding:5px;font:normal 12px/1.4em Monaco, Lucida Console, monospace;white-space:nowrap">$ ls -lsa /usr/local/etc/couchdb/<br />
4 -rw-r--r-- 1 root root 2626 2009-04-10 11:58 default.ini<br />
4 -rw-r--r-- 1 root root &nbsp;847 2009-04-10 14:17 local.ini</div></td></tr></tbody></table></div>
<p>Reading the documentation I found out that local.ini is just for overriding stuff and local.ini will never be overwritten by any upgrades. The config files contain lots of settings, but my aim is just to get it to start so I focus on the things that I think is the problem and thats all the PATH settings. </p>
<p>In my  unprivileged users home folder I created a folder named couchdb to hold my config and datafiles. I also created a www folder inside it. </p>
<p>After that I create my local.ini to override my settings:</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 />11<br />12<br />13<br /></div></td><td><div class="text codecolorer" style="padding:5px;font:normal 12px/1.4em Monaco, Lucida Console, monospace;white-space:nowrap">$ cat couchdb/local.ini <br />
<br />
[couchdb]<br />
database_dir = ./couchdb<br />
view_index_dir = ./couchdb<br />
<br />
[httpd]<br />
port = 5984<br />
bind_address = 127.0.0.1<br />
<br />
[log]<br />
level = info<br />
file=./couchdb/couch.log</div></td></tr></tbody></table></div>
<p>When our new config is in place we can try to start couchdb again.</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 /></div></td><td><div class="text codecolorer" style="padding:5px;font:normal 12px/1.4em Monaco, Lucida Console, monospace;white-space:nowrap">$ couchdb -C ./couchdb/local.ini -p ./couchdb/couch.pid -b<br />
Apache CouchDB has started, time to relax.</div></td></tr></tbody></table></div>
<p><strong>-C</strong> means use configuration FILE (chainable, does not reset system default). If we do not want to use the system config at all we can use a lowercase -c but we want to keep our overridden config as small as possible right now.</p>
<p><strong>-p</strong> is the path to our pid file and <strong>-b</strong> tells couchdb to spawn in the background.</p>
<p>If you are on your local machine you can just launch your browser and point it to <a href="http://127.0.0.1:5984/">http://127.0.0.1:5984/</a></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">{&quot;couchdb&quot;:&quot;Welcome&quot;,&quot;version&quot;:&quot;0.9.0&quot;}</div></td></tr></tbody></table></div>
<p>or you can access the admin gui trough: <a href="http://127.0.0.1:5984/_utils/index.html">http://127.0.0.1:5984/_utils/index.html</a>.</p>
<p>After I started to write this blogpost I did found a page on the Couchdb wiki that explains Error messages and solutions and here it is: <a href="http://wiki.apache.org/couchdb/Error_messages">http://wiki.apache.org/couchdb/Error_messages</a>.</p>
<p>Happy haxxing! </p>
]]></content:encoded>
			<wfw:commentRss>http://www.pastbedti.me/2009/04/running-couchdb-under-an-unprivileged-user-account/feed/</wfw:commentRss>
		<slash:comments>5</slash:comments>
		</item>
		<item>
		<title>I have this great device but I cannot use it, thanks to TeliaSonera!</title>
		<link>http://www.pastbedti.me/2009/04/i-have-this-great-device-but-i-cannot-use-it-thanks-to-teliasonera/</link>
		<comments>http://www.pastbedti.me/2009/04/i-have-this-great-device-but-i-cannot-use-it-thanks-to-teliasonera/#comments</comments>
		<pubDate>Fri, 10 Apr 2009 12:25:22 +0000</pubDate>
		<dc:creator>Mathias Stjernström</dc:creator>
				<category><![CDATA[Life]]></category>
		<category><![CDATA[data traffic]]></category>
		<category><![CDATA[greed]]></category>
		<category><![CDATA[iPhone]]></category>
		<category><![CDATA[much money]]></category>
		<category><![CDATA[phone operators]]></category>
		<category><![CDATA[sms]]></category>

		<guid isPermaLink="false">http://www.pastbedti.me/?p=418</guid>
		<description><![CDATA[The iPhone is a really great device. It lacks a few basic features that I misses from ericsson or nokia but overall it&#8217;s a really great device. Where it really kicks ass is when you are out of town and need to find a location or restaurant. This have been great when I am still [...]]]></description>
			<content:encoded><![CDATA[<p>The iPhone is a really great device. It lacks a few basic features that I misses from ericsson or nokia but overall it&#8217;s a really great device.</p>
<p>Where it really kicks ass is when you are out of town and need to find a location or restaurant. This have been great when I am still in the same country but earlier this week I when to Glasgow/scotland and the first thing you get is a welcome SMS from one of the local mobile network operators and here is when the problem arise. </p>
<p><span id="more-418"></span></p>
<p>The problem is that the SMS is more of a warning than a welcome message or even a <strong>HAHA-turn-roaming-on-and-we-gone-make-you-cry-message</strong>.</p>
<p><img src="http://www.pastbedti.me/wp-content/uploads/2009/04/img_0006.png" alt="We are fucking your wallet SMS" title="We are fucking your wallet SMS" width="320" height="480" class="alignnone size-full wp-image-419" /></p>
<p>My problem here is the data traffic. They charge you 40 SEK/MB and that is almost $5/MB. So Starting my facebook application or loading some maps in the iPhone would cost me loooots of money. If I use it all day it would be cheeper to hire a private guide all day and this really pisses me off. The phone operators makes so much money on dataroaming that they have no reasons at all to change it. As long as they all agree and charge the same price. In sweden this is not even legal.</p>
<p>As a reference to the price we charge our customers (list price) 15 SEK / GB and thats almost $2 for ONE GB. We are a really small operator and we pay for all our traffic. The big operators like Telia/Orange/O2 and the rest they do not pay for all they traffic and probably they only pay for a small part of the traffic. </p>
<p>And what makes me even more angry is that I think that the operators will lose money in the end. If the price where not a rip-off I would have spent a couple of hundreds just to have the luxury of a GPS and my emails. But during my stay I did not roam a single time. </p>
<p>I REALLY RELLY HATE GREED!!! </p>
]]></content:encoded>
			<wfw:commentRss>http://www.pastbedti.me/2009/04/i-have-this-great-device-but-i-cannot-use-it-thanks-to-teliasonera/feed/</wfw:commentRss>
		<slash:comments>0</slash:comments>
		</item>
		<item>
		<title>Internet is a virtual share-your-stuff-machine.</title>
		<link>http://www.pastbedti.me/2009/04/internet-is-a-virtual-share-your-stuff-machine/</link>
		<comments>http://www.pastbedti.me/2009/04/internet-is-a-virtual-share-your-stuff-machine/#comments</comments>
		<pubDate>Thu, 02 Apr 2009 14:43:47 +0000</pubDate>
		<dc:creator>Mathias Stjernström</dc:creator>
				<category><![CDATA[Life]]></category>
		<category><![CDATA[ebay]]></category>
		<category><![CDATA[facebook]]></category>
		<category><![CDATA[IPRED]]></category>
		<category><![CDATA[page internet]]></category>
		<category><![CDATA[second life]]></category>
		<category><![CDATA[wikipedia]]></category>
		<category><![CDATA[youtube]]></category>

		<guid isPermaLink="false">http://www.pastbedti.me/?p=411</guid>
		<description><![CDATA[I do not usually blog about this tuff. Hell I do not blog much at all But I think this was pretty cool. Internet is a virtual share-your-stuff-machine. On YouTube you share you creativity. On Facebook you share you life. On Second Life you share your dreams. On Wikipedia you share you knowledge. On Ebay [...]]]></description>
			<content:encoded><![CDATA[<p>I do not usually blog about this tuff. Hell I do not blog much at all <img src='http://www.pastbedti.me/wp-includes/images/smilies/icon_smile.gif' alt=':)' class='wp-smiley' />  But I think this was pretty cool.</p>
<blockquote><p>Internet is a virtual share-your-stuff-machine.<br />
On YouTube you share you creativity.<br />
On Facebook you share you life.<br />
On Second Life you share your dreams.<br />
On Wikipedia you share you knowledge.<br />
On Ebay you share your belongings.
</p></blockquote>
<p>Translated from a swedish blogpost reacting to the new Swedish IPRED law (<a href="http://micco.se/2009/03/delning-blir-en-multimiljardindustri/trackback/">http://micco.se/2009/03/delning-blir-en-multimiljardindustri/</a>)</p>
<p><a href="http://translate.google.com/translate?prev=_t&#038;hl=en&#038;ie=UTF-8&#038;u=http%3A%2F%2Fmicco.se%2F2009%2F03%2Fdelning-blir-en-multimiljardindustri%2F&#038;sl=sv&#038;tl=en&#038;history_state0=">A pretty weak google translation of the page</a></p>
]]></content:encoded>
			<wfw:commentRss>http://www.pastbedti.me/2009/04/internet-is-a-virtual-share-your-stuff-machine/feed/</wfw:commentRss>
		<slash:comments>0</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>
	</channel>
</rss>

