<?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>redconfetti</title>
	<atom:link href="http://www.redconfetti.com/feed/" rel="self" type="application/rss+xml" />
	<link>http://www.redconfetti.com</link>
	<description>the journal of maxwell keyes</description>
	<lastBuildDate>Tue, 24 Jan 2012 17:04:22 +0000</lastBuildDate>
	<language>en</language>
	<sy:updatePeriod>hourly</sy:updatePeriod>
	<sy:updateFrequency>1</sy:updateFrequency>
	<generator>http://wordpress.org/?v=3.3.1</generator>
		<item>
		<title>Deleting Git Branches in Remote Repository</title>
		<link>http://www.redconfetti.com/2012/01/deleting-git-branches-in-remote-repository/</link>
		<comments>http://www.redconfetti.com/2012/01/deleting-git-branches-in-remote-repository/#comments</comments>
		<pubDate>Tue, 24 Jan 2012 17:04:09 +0000</pubDate>
		<dc:creator>redconfetti</dc:creator>
				<category><![CDATA[web development]]></category>
		<category><![CDATA[branch]]></category>
		<category><![CDATA[git]]></category>

		<guid isPermaLink="false">http://www.redconfetti.com/?p=1046</guid>
		<description><![CDATA[I had recently used a branch to handle all the modifications I was making to a system for a Rails 3.1 upgrade from Rails 2.4.3. After I merged my changes back into the master branch, I deleted the &#8216;rails3&#8242; branch locally, but it still remained on the remote server. I found that &#8216;git push origin...]]></description>
			<content:encoded><![CDATA[<p>I had recently used a branch to handle all the modifications I was making to a system for a Rails 3.1 upgrade from Rails 2.4.3. After I merged my changes back into the master branch, I deleted the &#8216;rails3&#8242; branch locally, but it still remained on the remote server.</p>
<p>I found that &#8216;git push origin :branch_name&#8217; will delete the repository from the remote server if the branch has been removed locally.</p>
<pre class="brush:shell">
$ git push origin :rails3
To git@redconfetti.com:myrepo.git
 - [deleted]         rails3
</pre>
]]></content:encoded>
			<wfw:commentRss>http://www.redconfetti.com/2012/01/deleting-git-branches-in-remote-repository/feed/</wfw:commentRss>
		<slash:comments>0</slash:comments>
		</item>
		<item>
		<title>Survival without Technology</title>
		<link>http://www.redconfetti.com/2012/01/survival-without-technology/</link>
		<comments>http://www.redconfetti.com/2012/01/survival-without-technology/#comments</comments>
		<pubDate>Mon, 09 Jan 2012 03:22:34 +0000</pubDate>
		<dc:creator>redconfetti</dc:creator>
				<category><![CDATA[survival]]></category>

		<guid isPermaLink="false">http://www.redconfetti.com/?p=1029</guid>
		<description><![CDATA[Used without permission by Hometown Seeds I&#8217;ve been thinking of getting more involved in a hobby which I&#8217;m motivated to follow and invest my free time and resources into, which is relatively low cost, and that also might help me make contacts in person and online with like minded people. I might even be able...]]></description>
			<content:encoded><![CDATA[<div class="alignleft" style="font-size:9px;"><img class="size-medium wp-image-1031" title="survival_garden" src="http://www.redconfetti.com/wp-content/uploads/2012/01/survival_garden-300x199.jpg" alt="" width="300" height="199" /><br />
Used without permission by <a href="http://www.hometownseeds.com/survival-seeds-c-213/survival-seeds-peace-of-mind-for-your-family-p-35?zenid=bca328e42d30cec298d513c73af3c97d" target="_blank">Hometown Seeds</a></div>
<p>I&#8217;ve been thinking of getting more involved in a hobby which I&#8217;m motivated to follow and invest my free time and resources into, which is relatively low cost, and that also might help me make contacts in person and online with like minded people. I might even be able to provide a website with resources (starting with this blog post), or even use my existing skills to make a website application specially tailored to compliment this hobby. It might turn into a business. This is what I need.</p>
<p>One of the things that interests me is survivalism. My main strength in this world is my knowledge of technology. Without electricity, and agreed upon methods of communication (i.e. the Internet), my skills are worthless. It&#8217;s important that we remember how to do things to meet our own needs, instead of being dependent on this system that currently exists. It&#8217;s important that we create a hub of resources that can serve as guides to survival in any horrible scenario that realistically could occur during our lifetimes. I&#8217;m not talking about apocalypse, but economic hardship, or civil conflicts, or even natural disasters.</p>
<p>I want to cover topics like sewing (making clothes), agriculture and animal husbandry (making food), finding sources of water (including well drilling), making or finding shelter, etc. etc. I&#8217;d even like to cover ways of keeping technology in various ways, such as solar power or minimal fossil fuels. One way I do this right now is by using a motorcycle for transportation. My transportation costs are way down because of this.</p>
<p>I love the spirit of the internet to provide open source software to benefit humanity. Just the same there is a community of engineers contributing their ideas to the open source community, known as <a href="http://opensourceecology.org/wiki/Global_Village_Construction_Set">Global Village Construction Set</a>.</p>
<p><iframe src="http://player.vimeo.com/video/16106427?title=0&amp;byline=0&amp;portrait=0" width="400" height="225" frameborder="0" webkitAllowFullScreen mozallowfullscreen allowFullScreen></iframe>
<p><a href="http://vimeo.com/16106427">Global Village Construction Set in 2 Minutes</a> from <a href="http://vimeo.com/opensourceecology">Open Source Ecology</a> on <a href="http://vimeo.com">Vimeo</a>.</p>
]]></content:encoded>
			<wfw:commentRss>http://www.redconfetti.com/2012/01/survival-without-technology/feed/</wfw:commentRss>
		<slash:comments>0</slash:comments>
		</item>
		<item>
		<title>How to Loose Weight, Feel Great, and Drop the Medication</title>
		<link>http://www.redconfetti.com/2012/01/how-to-loose-weight-feel-great-and-drop-the-medication/</link>
		<comments>http://www.redconfetti.com/2012/01/how-to-loose-weight-feel-great-and-drop-the-medication/#comments</comments>
		<pubDate>Mon, 09 Jan 2012 02:34:30 +0000</pubDate>
		<dc:creator>redconfetti</dc:creator>
				<category><![CDATA[personal]]></category>
		<category><![CDATA[fat loss]]></category>
		<category><![CDATA[health]]></category>
		<category><![CDATA[primal blueprint]]></category>

		<guid isPermaLink="false">http://www.redconfetti.com/?p=1025</guid>
		<description><![CDATA[I just watched this movie. It was very inspirational. I was on a similar regimen called The Primal Blueprint for several months. I went from 310 lbs to 275 lbs. Unlike the vegetable/fruit juice diet in this movie, I ate steamed veggies and meat without worrying about fat content (similar to how cave men eat)....]]></description>
			<content:encoded><![CDATA[<p>I just watched this movie. It was very inspirational.</p>
<p><object width="512" height="288" classid="clsid:d27cdb6e-ae6d-11cf-96b8-444553540000" codebase="http://download.macromedia.com/pub/shockwave/cabs/flash/swflash.cab#version=6,0,40,0"><param name="allowFullScreen" value="true" /><param name="src" value="http://www.hulu.com/embed/GDauqN1yS1-kSS-mQF2Ipw" /><param name="allowfullscreen" value="true" /><embed width="512" height="288" type="application/x-shockwave-flash" src="http://www.hulu.com/embed/GDauqN1yS1-kSS-mQF2Ipw" allowFullScreen="true" allowfullscreen="true" /></object></p>
<p>I was on a similar regimen called <a href="http://www.marksdailyapple.com/primal-blueprint-101/" target="_blank">The Primal Blueprint</a> for several months. I went from 310 lbs to 275 lbs. Unlike the vegetable/fruit juice diet in this movie, I ate steamed veggies and meat without worrying about fat content (similar to how cave men eat).</p>
<p>Overall the concept is the same. Cut out all the flour, sugar, and processed foods. Get more nutrients in your diet. Your body will adjust, and will require extra water to detox and convert to ketosis. You will feel better, exercise will be more enjoyable, and you&#8217;ll see clearly that you are finally making progress and it will lift your spirits.</p>
<hr />
<p>When I was on The Primal Blueprint lifestyle (diet and exercise), I didn&#8217;t crave the bad foods as much. I walked through an aisle at a grocery store that was filled with cereal, and it really didn&#8217;t temp me so much.</p>
<p>Any time I had tried to fast, I always ended up getting a horrible headache that got close to being a migrane. If someone told me to do some sort of extreme diet, I would totally consider the idea crazy, because I did not want to put myself in such pain just to feel defeated afterwards.</p>
<p>I learned that you won&#8217;t get a headache transitioning into the diet if you get fat, nutrients, and drink a lot of water.</p>
<p>Fats are okay. It&#8217;s best to start the diet and allow yourself to have as much fat as you want in the beginning. You won&#8217;t necessarily feel the need to have a bunch of fat later. I got to the point eventually where I was fine with extremely lean grilled fish and veggies with very little butter. Don&#8217;t even think about fat as an issue. Have Bacon, eggs, and veggies with cheese in the morning, have two uncured premium hot dogs with a bunch of steamed veggies for lunch, and then have a nice grilled chicken, steak, or fish for dinner with a bunch of steamed veggies as well. Mix it up. Asparagus sometimes, brocolli and cauliflower other times. Zuccini. Use as much butter as you want, with a little salt, or even alfredo sauce.</p>
<p>If you had protein (meat), fat (also in meat/animal products), and vegetables (fiber/nutrients), for your first meal, that will be the best transition to the diet for you. If you feel you need something still, eat more. You don&#8217;t have to count or measure. Your bodys natural feeling of needing more, or needing to stop, will kick in. It&#8217;s no longer being thrown out of whack, with blood sugar spikes and abysmal dips, so you won&#8217;t get a headache from blood sugar irregularity.</p>
<p>You might get a headache from dehydration that you&#8217;re unaware of though. I didn&#8217;t know it, but my body needs water every time I start on the diet again. If I drink a lot of water, and just ignore the bloating look I get (especially the 2nd chin), it subsides in a day or so and I become leaner looking in the neck than I did before going on the diet. It&#8217;s like my body goes into detox mode, and to do this well it needs water&#8230;or else I do get a headache.</p>
<p>It was so amazing to find out that I was only experiencing intense cravings for food every 3-4 hours, including sometimes symptoms such as headaches or even shakes, just because of the flour, sugar, and processed foods. Those foods are easily available, long lasting, and addicting, and it seems like this is important for the world to realize. We&#8217;ve slowly become part of a system where junk food outlets and the medical system have locked us into a perpetual dependency, which is plummeting our culture into a major imbalance and major dysfunction. Health care costs are up because of the cost of keeping us alive. Our productivity and sense of life, mentally, physically, and spiritually, is down because of how we are poisoning our own bodies. I am so glad that I&#8217;ve found a cure, and this movie above is just another two or three examples of how change is possible.</p>
<p>I was on the Primal Blueprint for about 3 months and lost 35 pounds. I&#8217;ve been off the Primal Blueprint for over a month now, and I&#8217;ve put about 5 pounds back on. I plan on getting myself into the right space where I&#8217;m motivated to get myself out of this addiction to junk food (especially bread). I&#8217;ve already shopped for groceries which have no flour or sugar. Time to get back on track.</p>
]]></content:encoded>
			<wfw:commentRss>http://www.redconfetti.com/2012/01/how-to-loose-weight-feel-great-and-drop-the-medication/feed/</wfw:commentRss>
		<slash:comments>0</slash:comments>
		</item>
		<item>
		<title>Rails 3 on WHM / cPanel VPS Server</title>
		<link>http://www.redconfetti.com/2012/01/rails-3-on-whm-cpanel-vps-server/</link>
		<comments>http://www.redconfetti.com/2012/01/rails-3-on-whm-cpanel-vps-server/#comments</comments>
		<pubDate>Sun, 08 Jan 2012 17:14:58 +0000</pubDate>
		<dc:creator>redconfetti</dc:creator>
				<category><![CDATA[Ruby on Rails]]></category>
		<category><![CDATA[capistrano]]></category>
		<category><![CDATA[cpanel]]></category>
		<category><![CDATA[passenger]]></category>
		<category><![CDATA[rails3.1]]></category>

		<guid isPermaLink="false">http://www.redconfetti.com/?p=998</guid>
		<description><![CDATA[cPanel is working towards making Rails 3 applications run natively with Passenger, setup via the cPanel interface. I&#8217;m not really sure if this will be ideal, as most organizations deploy their apps to the server using Capistrano, not uploading via FTP or something. I&#8217;ve been hosting a number of PHP driven sites, including this blog,...]]></description>
			<content:encoded><![CDATA[<p>cPanel is <a href="http://forums.cpanel.net/f145/mod_rails-passenger-instead-mongrel-rails-3-support-case-44197-a-152577-p3.html" target="_blank">working towards making Rails 3 applications run natively</a> with Passenger, setup via the cPanel interface. I&#8217;m not really sure if this will be ideal, as most organizations deploy their apps to the server using Capistrano, not uploading via FTP or something.</p>
<p>I&#8217;ve been hosting a number of PHP driven sites, including this blog, from a shared hosting service for quite a while now. Shared hosting is fine for personal websites or even small businesses with 4-5 page brochure style websites that do not receive lots of traffic, but they&#8217;re not fine if slow performance or intermittent downtime causes you to loose business (or even the respect of your visitors). In such cases I recommend a VPS, because you control who you&#8217;re hosting and thus can ensure optimal uptime and performance. I highly recommend <a href="http://www.linode.com/" target="_blank">Linode</a> as a VPS provider.</p>
<p>I&#8217;ve been using the shared hosting for PHP/Wordpress sites, and a VPS to host the Ruby on Rails applications I&#8217;ve been working on. Really this is expensive, so I&#8217;m wanting to consolidate to one VPS for everything.</p>
<p>I&#8217;ve been forewarned that cPanel does things it&#8217;s own way, so if you&#8217;re trying to do something out-of-the-box you can run into issues. I&#8217;m aware of this, and through this article will let you know if setting up a Rails 3.1.3 hosting environment is possible with a WHM / cPanel server (RELEASE version 11.30.5, build 3). I plan on using Gitosis under an account to host repositories, Capistrano for deployment, and Passenger with Apache2 already provided by cPanel.</p>
<h2>Installing Ruby</h2>
<p>To stay within the &#8220;box&#8221; of the cPanel environment, I installed Ruby using the script provided by cPanel </p>
<pre class="brush:shell">
/scripts/installruby
</pre>
<h2>Gitosis</h2>
<p>To setup Gitosis you have to first install Python tools.</p>
<pre class="brush:shell">
yum -y install python-setuptools
</pre>
<p>Next, to install Git, you&#8217;ll have to use a special command because cPanel has configured /etc/yum.conf to exclude certain packages, including perl packages, so that they do not break or conflict with the cPanel system. Use the following command to install Git:</p>
<pre class="brush:shell">
yum --disableexcludes=main install git
</pre>
<p>From the root home directory, download and install Gitosis.</p>
<pre class="brush:shell">
cd /root
git clone git://eagain.net/gitosis.git
cd gitosis
python setup.py install
</pre>
<p>Next create an account to host your Git repositories from the WHM interface. I&#8217;ve added a user with the user name &#8216;git&#8217;, and used &#8216;git.web-app-host.com&#8217; as the domain (a subdomain under my hosting service domain). Set the password to a very long secure password. You won&#8217;t be needing it again, as you&#8217;ll be using an SSH key to authenticate.</p>
<p>After you&#8217;re done creating the cPanel account which will host the repositories, copy your public key from your local machine to your root users home direcotry ( /root/ ).</p>
<pre class="brush:shell">
scp ~/.ssh/id_rsa.pub root@vps.web-app-host.com:/root
</pre>
<p>Go back to your SSH session as &#8216;root&#8217; on the server and run this command to initialize the Gitosis repository under the &#8216;git&#8217; user account.</p>
<pre class="brush:shell">
root@vps [~]# sudo -H -u git gitosis-init < /root/id_rsa.pub
Initialized empty Git repository in /home/git/repositories/gitosis-admin.git/
Reinitialized existing Git repository in /home/git/repositories/gitosis-admin.git/
</pre>
<p>NOTE: Do not use the 'Manage SSH Keys' option from the cPanel for the Git acccount, as this will remove the Gitosis-admin repository key from /home/git/.ssh/authorized_keys.</p>
<p>Run the following command to make sure the post-update hook is executable. If this isn't done, then tasks performed by Gitosis after you commit an update aren't performed (i.e. creating new repositories).</p>
<pre class="brush:shell">
sudo chmod u+x /home/git/repositories/gitosis-admin.git/hooks/post-update
</pre>
<p>On your local machine, run the following command to clone the Gitosis-admin repository, used to manage your repositories on the server, to your local machine.</p>
<pre class="brush:shell">
git clone git@<YOURSERVER>:gitosis-admin.git
</pre>
<p>This should look like this:</p>
<pre class="brush:shell">
$ git clone git@vps.web-app-host.com:gitosis-admin.git
Cloning into 'gitosis-admin'...
stdin: is not a tty
remote: Counting objects: 5, done.
remote: Compressing objects: 100% (5/5), done.
remote: Total 5 (delta 0), reused 5 (delta 0)
Receiving objects: 100% (5/5), done.
</pre>
<hr />
Note: If you are prompted for a password when running this clone command, you likely have some sort of SSH configuration not setup properly on your local machine. If you're using multiple keys with various hosts, check ~/.ssh/config and make sure you're using the proper syntax. Run 'ssh git@<YOURSERVER> -v' to get a verbose output of what's happening when the SSH session is initialized to investigate further.</p>
<hr />
<p>On the remote machine, go ahead and delete your public key from the root users home directory.</p>
<pre class="brush:shell">
rm /root/id_rsa.pub
</pre>
<p>After cloning the Gitosis repository to your local machine, you simply modify and commit changes to the 'gitosis.conf' file inside of the 'gitosis-admin' folder.</p>
<p>If you're configuring new users, simply add their public SSH keys to the 'keydir' folder with the '.pub' file extension. Refer to these users using the filename of the public key file without the '.pub' extension.</p>
<p>For instance I've added a repository called 'marketsim', and then added 'marketsim' to the 'writable' setting for the gitosis-admin group.</p>
<pre class="brush:text">
[gitosis]

[group gitosis-admin]
writable = gitosis-admin marketsim
members = jason@mymacbook.local

[repo marketsim]
gitweb = no
description = Market Simulation App
owner = Jason Miller
daemon = no
</pre>
<p>Alternatively I could create a new group with writable access to the 'marketsim' repository.</p>
<pre class="brush:text">
[gitosis]

[group gitosis-admin]
writable = gitosis-admin
members = jason@mymacbook.local

[group marketsim-team]
members = jason@mymacbook.local
writable = marketsim

[repo marketsim]
gitweb = no
description = Market Simulation App
owner = Jason Miller
daemon = no
</pre>
<p>I could add 'newteammember.pub' in the 'keydir' folder, then add 'newteammember' after 'jason@mymacbook.local' separated by a space. This would make another team member part of that group which has write access to the repository.</p>
<p>After configuring a new repository, and giving my own local user write access to that repository, I've push the changes via a commit to the remote gitosis-admin repository.</p>
<p>NOTE: You may receive the warning "remote: WARNING:gitosis.gitweb.set_descriptions:Cannot find 'yourrepo' in '/home/git/repositories'". Ignore this and continue.</p>
<p>Now I'm going to initialize my new repository and push it to the remote server.</p>
<pre class="brush:shell">
$ cd marketsim
$ git init .
$ git add .
$ git commit -m "initial commit"
$ git remote add origin git@vps.web-app-host.com:marketsim.git
$ git push origin master
stdin: is not a tty
Initialized empty Git repository in /home/git/repositories/marketsim.git/
Counting objects: 3, done.
Writing objects: 100% (3/3), 209 bytes, done.
Total 3 (delta 0), reused 0 (delta 0)
To git@vps.web-app-host.com:marketsim.git
 * [new branch]      master -> master
</pre>
<h2>Deploying to Server</h2>
<p>I've created an account with the username 'marketsi' to host the deployed application (cPanel only allows up to 8 characters for the username). Then I've logged into that account and added my public key via the SSH/Shell Access > Manage SSH Keys section of the cPanel account. </p>
<p>For property deployment you'll need to install the 'Bundler' gem so that the deployment script can install the gems needed for your application. You'll need to install this as 'root' so that the 'bundle' script is available under /usr/bin/bundle.</p>
<pre class="brush:shell">
$ ssh root@vps.web-app-host.com
root@vps [~]# gem install bundler
Fetching: bundler-1.0.21.gem (100%)
Successfully installed bundler-1.0.21
1 gem installed
Installing ri documentation for bundler-1.0.21...
Installing RDoc documentation for bundler-1.0.21...
root@vps [~]# which bundle
/usr/bin/bundle
</pre>
<p>I've modified my deploy.rb file for my Rails application like so:</p>
<pre class="brush:rails">
require "bundler/capistrano"
load "deploy/assets"

#############################################################
# Settings

set :application, "marketsim"
default_run_options[:pty] = true  # Must be set for the password prompt from git to work
set :use_sudo, false

set :user, "marketsi"  # The server's user for deploys
set :deploy_to, "/home/#{user}/rails"
set :ssh_options, { :forward_agent => true }

set :domain, "marketsim.org"
server domain, :app, :web
role :db, domain, :primary => true

#############################################################
# Git

set :scm, :git
set :repository,  "git@vps.web-app-host.com:marketsim.git"
set :branch, "master"
set :deploy_via, :remote_cache

#############################################################
# Passenger

namespace :passenger do
  desc "Restart Application"
  task :restart do
    run "touch #{current_path}/tmp/restart.txt"
  end
end

after :deploy, "passenger:restart"
</pre>
<p>Now to run the script to setup the deployment directories on the remote server.</p>
<pre class="brush:shell">
cap deploy:setup
</pre>
<p>This created a folder under /home/marketsi/rails with the 'releases' and 'shared' folder. Now I'll actually deploy.</p>
<pre class="brush:shell">
cap deploy
</pre>
<p>The gems were installed with no issue by Bundler for me. Hopefully the same goes for you.</p>
<h2>Passenger</h2>
<p>The next step is to configure Apache to serve the Rails application for my domain name. Install the Passenger gem via SSH logged in as root:</p>
<pre class="brush:shell">
gem install passenger
</pre>
<p>Install Passenger using the Apache module installation command. All dependencies should be found and displayed in green.</p>
<pre class="brush:shell">
passenger-install-apache2-module
</pre>
<p>At the end of the installation script it provides the Apache configuration settings which you place in httpd.conf. Since we're using cPanel, which over-writes the Apache configuration when the EasyApache system is used to rebuild Apache, PHP, and other modules, place this configuration in /usr/local/apache/conf/includes/pre_main_global.conf.</p>
<pre class="brush:text">
# /usr/local/apache/conf/includes/pre_main_global.conf
LoadModule passenger_module /usr/lib/ruby/gems/1.8/gems/passenger-3.0.11/ext/apache2/mod_passenger.so
PassengerRoot /usr/lib/ruby/gems/1.8/gems/passenger-3.0.11
PassengerRuby /usr/bin/ruby
</pre>
<p>Next make a backup of the httpd.conf, run the configuration distiller script, rebuild, and then restart Apache.</p>
<pre class="brush:shell">
cp /usr/local/apache/conf/httpd.conf /usr/local/apache/conf/httpd.conf.bak-modrails
/usr/local/cpanel/bin/apache_conf_distiller --update
/scripts/rebuildhttpdconf
/etc/init.d/httpd restart
</pre>
<p>The cPanel system makes the Apache Document Root for each account map to /home/username/public_html. Because of this you will need to remove the 'public_html' directory, and then create a symlink from that directory to the 'public' directory for your applications current release:</p>
<pre class="brush:shell">
rm -rf /home/marketsi/public_html/
ln -s /home/marketsi/rails/current/public /home/marketsi/public_html
chown marketsi:nobody public_html/
chmod 750 public_html/
</pre>
<p>Next add a .htaccess file in your application under the 'public' folder, and make sure it contains 'RailsBaseURI /', as well as a directive with the PassengerAppRoot.</p>
<pre class="brush:rails">
RailsBaseURI /
PassengerAppRoot /home/marketsi/rails/current
</pre>
<h2>MySQL Database</h2>
<p>If your application returns an error page 'We're sorry, but something went wrong.', check the production.log file on the server. In my case, the application was running, but it couldn't connect to the database with the existing database.yml settings for production.</p>
<p>As cPanel controls the MySQL databases and usernames, you'll have to create a database manually via the cPanel, create the user and assign all privileges to it for the database, and then configure your database.yml appropriately.</p>
]]></content:encoded>
			<wfw:commentRss>http://www.redconfetti.com/2012/01/rails-3-on-whm-cpanel-vps-server/feed/</wfw:commentRss>
		<slash:comments>1</slash:comments>
		</item>
		<item>
		<title>Trippy</title>
		<link>http://www.redconfetti.com/2012/01/trippy/</link>
		<comments>http://www.redconfetti.com/2012/01/trippy/#comments</comments>
		<pubDate>Fri, 06 Jan 2012 04:52:19 +0000</pubDate>
		<dc:creator>redconfetti</dc:creator>
				<category><![CDATA[personal]]></category>

		<guid isPermaLink="false">http://www.redconfetti.com/?p=992</guid>
		<description><![CDATA[Stare at this for a while, then look at something near you.]]></description>
			<content:encoded><![CDATA[<p>Stare at this for a while, then look at something near you.</p>
<p><img src="http://www.redconfetti.com/wp-content/uploads/2012/01/what_the_52.gif" alt="" title="what_the_52" width="500" height="500" class="alignnone size-full wp-image-993" /></p>
]]></content:encoded>
			<wfw:commentRss>http://www.redconfetti.com/2012/01/trippy/feed/</wfw:commentRss>
		<slash:comments>0</slash:comments>
		</item>
		<item>
		<title>Configuring Rails 3.1.3 under Sub-URI</title>
		<link>http://www.redconfetti.com/2012/01/configuring-rails-3-1-3-under-sub-uri/</link>
		<comments>http://www.redconfetti.com/2012/01/configuring-rails-3-1-3-under-sub-uri/#comments</comments>
		<pubDate>Wed, 04 Jan 2012 06:02:40 +0000</pubDate>
		<dc:creator>redconfetti</dc:creator>
				<category><![CDATA[Ruby on Rails]]></category>
		<category><![CDATA[linkedin]]></category>
		<category><![CDATA[rails3.1]]></category>
		<category><![CDATA[relative_url_root]]></category>
		<category><![CDATA[sub-uri]]></category>

		<guid isPermaLink="false">http://www.redconfetti.com/?p=969</guid>
		<description><![CDATA[In setting up a new Rails app recently I was told that it needed to be served under the sub-URI of &#8216;/info&#8217;. I hadn&#8217;t done this before with a Rails app, and I expected that it could be tricky. I checked online to see how this is done and found references to the &#8216;relative_url_root&#8217; setting,...]]></description>
			<content:encoded><![CDATA[<p>In setting up a new Rails app recently I was told that it needed to be served under the sub-URI of &#8216;/info&#8217;. I hadn&#8217;t done this before with a Rails app, and I expected that it could be tricky.</p>
<p>I checked online to see how this is done and found references to the &#8216;relative_url_root&#8217; setting, but then shortly found that this has been deprecated.</p>
<p>I&#8217;m using Phusion Passenger with Apache 2, so I inserted the following configuration into my VirtualHost entry for the site.</p>
<pre class="brush:text">
Alias /info /home/myapp/current/public
&lt;Location /info&gt;
  PassengerAppRoot /home/myapp/current
  RailsEnv production
&lt;/Location&gt;
</pre>
<p>The Rails application was expecting requests from the root of the site still. I found a StackOverflow article where someone suggested configuring all the routes under the &#8220;/info&#8221; scope like so:</p>
<pre class="brush:rails">
# config/routes.rb
scope "/info" do
  root :to =&gt; "welcome#index"
  resources :posts
end
</pre>
<p>This worked fine in development mode. I just made sure to pull up the pages using http://localhost:3000/info/</p>
<p>I had tested this in production before building out the application further, and it seemed to work fine. Later on when I deployed after many updates, I found that the application was referencing precompiled assets using &#8216;/assets/&#8217; and not &#8216;/info/assets/&#8217;. Further investigation pointed out that I needed to configure assets with a prefix like so:</p>
<pre class="brush:rails">
# config/application.rb
config.assets.prefix = "/info/assets"
</pre>
<p>This seemed like it would help, but this caused assets to be precompiled under &#8216;public/info/assets&#8217;.</p>
<p>I had previously Googled for &#8216;rails 3.1 subdirectory path&#8217;, not registering that the more appropriate keyword is &#8216;sub URI&#8217; for what I&#8217;m trying to accomplish.</p>
<p>It turns out that the best way to do this with Passenger is to mount the application to the sub-URI using the proper Apache configuration, and leave it up to the Rack interface to handle serving the requests to the Rails application, without using any Rails application configuration for the sub-URI.</p>
<p>I removed the scoped routes, and the assets prefix, returning my application to it&#8217;s default configuration. I then created a symbolic link for &#8216;info&#8217; in the websites DocumentRoot, pointing to the &#8216;public&#8217; folder of my application as per the <a href="http://www.modrails.com/documentation/Users%20guide%20Apache.html#deploying_rack_to_sub_uri" target="_blank">Passenger documentation</a>.</p>
<pre class="brush:shell">
ln -s /home/myapp/current/public /home/mysite/public_html/info
</pre>
<p>I added the appropriate configuration into my VirtualHost entry as advised by the Passenger documentation, but this only worked for the root of the website, not my admin area I had wanted to serve from /info/admin/. All I got was a 404 page from the main site.</p>
<p>I found that the following configuration worked perfectly, with the symbolic link still needing to be present.</p>
<pre class="brush:text">
Alias /info /home/myapp/current/public
&lt;Location /info&gt;
  PassengerAppRoot /home/myapp/current
  RackEnv production
  RackBaseURI /info
&lt;/Location&gt;
</pre>
<p>You might notice that I&#8217;m using &#8216;RackEnv production&#8217; instead of &#8216;RailsEnv production&#8217;. This is because I recall at some point previously that Rails 3.0 applications are Rack Applications, and thus you have to use &#8216;RackEnv&#8217; instead for Passenger to load the application in the proper environment mode.</p>
<hr />
<p>Update 01/04/12: I&#8217;m using the <a href="https://github.com/spohlenz/tinymce-rails" target="_blank">TinyMCE-Rails plugin</a> to provide a WYSIWYG editor for one of the resources in my application. It&#8217;s not loading in production however (surprise, surprise). I checked into the precompiled Javascript file being served from the live server, and I see it includes the following:</p>
<pre class="brush:javascript">
window.tinyMCEPreInit=window.tinyMCEPreInit||{base:"/assets/tinymce",query:"3.4.7",suffix:""}
</pre>
<p>The &#8216;base&#8217; value should be &#8216;/info/assets/tinymce&#8217;. I see that in the TinyMCE-Rails gem the coding for this is:</p>
<pre class="brush:rails">
window.tinyMCEPreInit = window.tinyMCEPreInit || {
  base:   '<%= Rails.application.config.assets.prefix %>/tinymce',
  query:  '<%= TinyMCE::VERSION %>',
  suffix: ''
};
</pre>
<p>All call to &#8216;asset_path(&#8216;rails.png&#8217;)&#8217; in production returns &#8216;/info/assets/rails-e4b51606cd77fda2615e7439907bfc92.png&#8217; so Rails is honoring the RackSubURI setting configured for Passenger. The following returns the same path.</p>
<p>The reason why this works is that the Rails asset helpers pull the relative_url_root value from the controller configuration, which must receive it from the Rack configuration. When deploying the app using Capistrano, such configuration is not present, and thus the correct path cannot be included in the precompiled assets.</p>
<p>The issue was reported via Git hub in issue #<a href="https://github.com/rails/rails/issues/3259" target="_blank">3259</a> and #<a href="https://github.com/rails/rails/issues/2435" target="_blank">2435</a>, and a fix will was implemented in Rails 3.2, with a possibly backport to Rails 3.1.4. </p>
<p>It appears that you&#8217;ll need to add a configuration to your application.rb or environments/production.rb, depending on how your development and production environments are setup.</p>
<pre class="brush:rails">
# config/environments/production.rb

# Use sub-uri in production
config.relative_url_root = '/info'
</pre>
<p>Or possibly configure your deployment script to include the environment variable when precompiling.</p>
<pre class="brush:shell">
RAILS_RELATIVE_URL_ROOT="/info" bundle exec rake assets:precompile
</pre>
<p>I wanted to test this, but I can&#8217;t seem to update to Rails 3.2, or install a new Rails app using edge Rails.</p>
<pre class="brush:shell">
rails new testapp --edge
.
.
.
Bundler could not find compatible versions for gem "actionpack":
  In Gemfile:
    sass-rails (>= 0) ruby depends on
      actionpack (~> 3.1.0) ruby

    rails (>= 0) ruby depends on
      actionpack (4.0.0.beta)
</pre>
<p>I&#8217;m just going to configure my app under a subdomain instead of sub-uri for now.</p>
]]></content:encoded>
			<wfw:commentRss>http://www.redconfetti.com/2012/01/configuring-rails-3-1-3-under-sub-uri/feed/</wfw:commentRss>
		<slash:comments>0</slash:comments>
		</item>
		<item>
		<title>Custom Rake Tasks Not Loading</title>
		<link>http://www.redconfetti.com/2012/01/custom-rake-tasks-not-loading/</link>
		<comments>http://www.redconfetti.com/2012/01/custom-rake-tasks-not-loading/#comments</comments>
		<pubDate>Sun, 01 Jan 2012 22:57:34 +0000</pubDate>
		<dc:creator>redconfetti</dc:creator>
				<category><![CDATA[Ruby on Rails]]></category>
		<category><![CDATA[rake]]></category>

		<guid isPermaLink="false">http://www.redconfetti.com/?p=953</guid>
		<description><![CDATA[I recently went to create a new Rake task under /lib/tasks in a Rails application I&#8217;m working on. I didn&#8217;t understand why the rake tasks weren&#8217;t showing when I would run &#8216;rake -T&#8217; from the command line. When I&#8217;d try to run the task itself I would get a &#8216;Don&#8217;t know how to build task&#8217;...]]></description>
			<content:encoded><![CDATA[<p>I recently went to create a new Rake task under /lib/tasks in a Rails application I&#8217;m working on. I didn&#8217;t understand why the rake tasks weren&#8217;t showing when I would run &#8216;rake -T&#8217; from the command line.</p>
<p>When I&#8217;d try to run the task itself I would get a &#8216;Don&#8217;t know how to build task&#8217; error.</p>
<p>I just realized that I was naming my task file with the &#8216;.rb&#8217; extension, and not &#8216;.rake&#8217;. Doh!</p>
]]></content:encoded>
			<wfw:commentRss>http://www.redconfetti.com/2012/01/custom-rake-tasks-not-loading/feed/</wfw:commentRss>
		<slash:comments>1</slash:comments>
		</item>
		<item>
		<title>Troubleshooting ActiveResource Requests</title>
		<link>http://www.redconfetti.com/2012/01/troubleshooting-activeresource-requests/</link>
		<comments>http://www.redconfetti.com/2012/01/troubleshooting-activeresource-requests/#comments</comments>
		<pubDate>Sun, 01 Jan 2012 22:46:52 +0000</pubDate>
		<dc:creator>redconfetti</dc:creator>
				<category><![CDATA[Ruby on Rails]]></category>
		<category><![CDATA[ActiveResource]]></category>
		<category><![CDATA[HighRise]]></category>
		<category><![CDATA[linkedin]]></category>
		<category><![CDATA[REST API]]></category>

		<guid isPermaLink="false">http://www.redconfetti.com/?p=947</guid>
		<description><![CDATA[I&#8217;m currently working on an app which integrates with the HighRise API using the Highrise Ruby wrapper gem. The classes defined by the gem rely on ActiveResource, the Ruby library included with Rails for interfacing with RESTful resources like the HighRise API. Sometimes I&#8217;m not sure if the requests being made via the commands I&#8217;m...]]></description>
			<content:encoded><![CDATA[<p>I&#8217;m currently working on an app which integrates with the <a href="http://developer.37signals.com/highrise/people" target="_blank">HighRise API</a> using the <a href="https://github.com/tapajos/highrise" target="_blank">Highrise Ruby wrapper gem</a>. The classes defined by the gem rely on ActiveResource, the Ruby library included with Rails for interfacing with RESTful resources like the HighRise API.</p>
<p>Sometimes I&#8217;m not sure if the requests being made via the commands I&#8217;m using are making the right calls on the HighRise API.</p>
<p>I found this thread on StackOverflow: <a href="http://stackoverflow.com/questions/227907/how-do-i-view-the-http-response-to-an-activeresource-request" target="_blank">How do I view the HTTP response to an ActiveResource request?</a>. The solution I found helpful was this one on <a href="http://www.jroller.com/bokmann/entry/debugging_activerecord_web_services" target="_blank">overriding ActiveResource::Connection</a> so that it outputs the debug output. This worked for me even with Rails 3.1.</p>
<p>Just in case this article with the code disappears, here is the initializer code you can use to view the HTTP session data from the console. I&#8217;ve added an if statement to make sure the HTTP data is only outputted to the standard output in development mode, for <a href="http://ruby-doc.org/stdlib-1.9.3/libdoc/net/http/rdoc/Net/HTTP.html#method-i-set_debug_output" target="_blank">security purposes</a>, as well as requires the environment variable &#8216;HTTPDEBUG&#8217;.</p>
<pre class="brush:rails"># /config/initializers/connection.rb
class ActiveResource::Connection
  # Creates new Net::HTTP instance for communication with
  # remote service and resources.
  def http
    http = Net::HTTP.new(@site.host, @site.port)
    http.use_ssl = @site.is_a?(URI::HTTPS)
    http.verify_mode = OpenSSL::SSL::VERIFY_NONE if http.use_ssl
    http.read_timeout = @timeout if @timeout
    #Here's the addition that allows you to see the output
    if Rails.env == 'development' &amp;&amp; ENV['HTTPDEBUG']
      http.set_debug_output $stderr
    end
    return http
  end
end</pre>
<p>You can open the Rails console using &#8216;HTTPDEBUG=true rails c&#8217; to activate the console with debugging output displayed in the console mode.</p>
]]></content:encoded>
			<wfw:commentRss>http://www.redconfetti.com/2012/01/troubleshooting-activeresource-requests/feed/</wfw:commentRss>
		<slash:comments>0</slash:comments>
		</item>
		<item>
		<title>Example Rake Task</title>
		<link>http://www.redconfetti.com/2012/01/example-rake-task/</link>
		<comments>http://www.redconfetti.com/2012/01/example-rake-task/#comments</comments>
		<pubDate>Sun, 01 Jan 2012 22:26:28 +0000</pubDate>
		<dc:creator>redconfetti</dc:creator>
				<category><![CDATA[Ruby on Rails]]></category>
		<category><![CDATA[linkedin]]></category>
		<category><![CDATA[rake]]></category>

		<guid isPermaLink="false">http://www.redconfetti.com/?p=943</guid>
		<description><![CDATA[Here is example rake task code which you can use and modify the next time you&#8217;re setting up new Rake tasks for a Rails app from scratch. The example includes the syntax for setting the default task, running multiple tasks in order, and a task which includes multiple arguments. This coding syntax works with Rails...]]></description>
			<content:encoded><![CDATA[<p>Here is example rake task code which you can use and modify the next time you&#8217;re setting up new Rake tasks for a Rails app from scratch. The example includes the syntax for setting the default task, running multiple tasks in order, and a task which includes multiple arguments. This coding syntax works with Rails 3.1.</p>
<pre class="brush:rails"># /lib/tasks/mytask.rake
namespace :mytask do

  task :default =&gt; 'mytask:full_run'

  desc "run all tasks in proper order"
  task :full_run =&gt; [:example_task_one, :example_task_two] do
    puts "All tasks ran and completed at #{Time.now}"
  end

  desc "example task without arguments"
  task :example_task_one =&gt; :environment do
    # task code goes here
    puts "Example Task One completed"
  end

  desc "example task with arguments"
  task :example_task_two, [:arg1, :arg2] =&gt; :environment do |t, args|
    # if no arguments, display docs
    if args.count == 0
      puts ''
      puts "rake mytask:example_task[arg1,arg2]"
      puts "arg1: description of first argument"
      puts "arg2: description of second argument"
      puts ''
      puts "example:"
      puts "rake mytask:example_task[123,'456']"
      puts ''
    else
      # task code goes here
      puts "Running task with arg1: #{args.arg1}, and arg2: #{args.arg2}"
      puts "Example Task Two completed"
    end
  end
end</pre>
<p>Special thanks to Jason Seifer for his <a href="http://jasonseifer.com/2010/04/06/rake-tutorial" target="_blank">Rake Tutorial</a> which made this possible.</p>
]]></content:encoded>
			<wfw:commentRss>http://www.redconfetti.com/2012/01/example-rake-task/feed/</wfw:commentRss>
		<slash:comments>1</slash:comments>
		</item>
		<item>
		<title>Adding a New User in Ubuntu</title>
		<link>http://www.redconfetti.com/2011/12/adding-a-new-user-in-ubuntu/</link>
		<comments>http://www.redconfetti.com/2011/12/adding-a-new-user-in-ubuntu/#comments</comments>
		<pubDate>Thu, 29 Dec 2011 18:15:35 +0000</pubDate>
		<dc:creator>redconfetti</dc:creator>
				<category><![CDATA[Ubuntu]]></category>
		<category><![CDATA[linkedin]]></category>

		<guid isPermaLink="false">http://www.redconfetti.com/?p=939</guid>
		<description><![CDATA[Adding User When setting up a new website manually on an Ubuntu server you need to establish a user account with a home directory, and Bash shell access to the server. useradd -m testuser -s /bin/bash After creating the account you&#8217;ll want to assign a password for the account. passwd testuser]]></description>
			<content:encoded><![CDATA[<h2>Adding User</h2>
<p>When setting up a new website manually on an Ubuntu server you need to establish a user account with a home directory, and Bash shell access to the server.</p>
<pre class="brush:shell">useradd -m testuser -s /bin/bash</pre>
<p>After creating the account you&#8217;ll want to assign a password for the account.</p>
<pre class="brush:shell">passwd testuser</pre>
]]></content:encoded>
			<wfw:commentRss>http://www.redconfetti.com/2011/12/adding-a-new-user-in-ubuntu/feed/</wfw:commentRss>
		<slash:comments>0</slash:comments>
		</item>
	</channel>
</rss>

