<?xml version="1.0" encoding="UTF-8"?>
<?xml-stylesheet type="text/xsl" media="screen" href="/~d/styles/rss2full.xsl"?><?xml-stylesheet type="text/css" media="screen" href="http://feeds.feedburner.com/~d/styles/itemcontent.css"?><rss 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/" version="2.0">

<channel>
	<title>Ruby on Rails, London - The Blog by Dynamic50</title>
	
	<link>http://blog.dynamic50.com</link>
	<description>Ruby on Rails, London - The Blog by Dynamic50</description>
	<lastBuildDate>Thu, 29 Apr 2010 16:32:26 +0000</lastBuildDate>
	<generator>http://wordpress.org/?v=2.9.2</generator>
	<language>en</language>
	<sy:updatePeriod>hourly</sy:updatePeriod>
	<sy:updateFrequency>1</sy:updateFrequency>
			<atom10:link xmlns:atom10="http://www.w3.org/2005/Atom" rel="self" type="application/rss+xml" href="http://feeds.feedburner.com/dynamic50" /><feedburner:info xmlns:feedburner="http://rssnamespace.org/feedburner/ext/1.0" uri="dynamic50" /><atom10:link xmlns:atom10="http://www.w3.org/2005/Atom" rel="hub" href="http://pubsubhubbub.appspot.com/" /><feedburner:feedFlare xmlns:feedburner="http://rssnamespace.org/feedburner/ext/1.0" href="http://add.my.yahoo.com/rss?url=http%3A%2F%2Ffeeds.feedburner.com%2Fdynamic50" src="http://us.i1.yimg.com/us.yimg.com/i/us/my/addtomyyahoo4.gif">Subscribe with My Yahoo!</feedburner:feedFlare><feedburner:feedFlare xmlns:feedburner="http://rssnamespace.org/feedburner/ext/1.0" href="http://www.newsgator.com/ngs/subscriber/subext.aspx?url=http%3A%2F%2Ffeeds.feedburner.com%2Fdynamic50" src="http://www.newsgator.com/images/ngsub1.gif">Subscribe with NewsGator</feedburner:feedFlare><feedburner:feedFlare xmlns:feedburner="http://rssnamespace.org/feedburner/ext/1.0" href="http://feeds.my.aol.com/add.jsp?url=http%3A%2F%2Ffeeds.feedburner.com%2Fdynamic50" src="http://o.aolcdn.com/favorites.my.aol.com/webmaster/ffclient/webroot/locale/en-US/images/myAOLButtonSmall.gif">Subscribe with My AOL</feedburner:feedFlare><feedburner:feedFlare xmlns:feedburner="http://rssnamespace.org/feedburner/ext/1.0" href="http://www.bloglines.com/sub/http://feeds.feedburner.com/dynamic50" src="http://www.bloglines.com/images/sub_modern11.gif">Subscribe with Bloglines</feedburner:feedFlare><feedburner:feedFlare xmlns:feedburner="http://rssnamespace.org/feedburner/ext/1.0" href="http://www.netvibes.com/subscribe.php?url=http%3A%2F%2Ffeeds.feedburner.com%2Fdynamic50" src="http://www.netvibes.com/img/add2netvibes.gif">Subscribe with Netvibes</feedburner:feedFlare><feedburner:feedFlare xmlns:feedburner="http://rssnamespace.org/feedburner/ext/1.0" href="http://fusion.google.com/add?feedurl=http%3A%2F%2Ffeeds.feedburner.com%2Fdynamic50" src="http://buttons.googlesyndication.com/fusion/add.gif">Subscribe with Google</feedburner:feedFlare><feedburner:feedFlare xmlns:feedburner="http://rssnamespace.org/feedburner/ext/1.0" href="http://www.pageflakes.com/subscribe.aspx?url=http%3A%2F%2Ffeeds.feedburner.com%2Fdynamic50" src="http://www.pageflakes.com/ImageFile.ashx?instanceId=Static_4&amp;fileName=ATP_blu_91x17.gif">Subscribe with Pageflakes</feedburner:feedFlare><feedburner:feedFlare xmlns:feedburner="http://rssnamespace.org/feedburner/ext/1.0" href="http://www.plusmo.com/add?url=http%3A%2F%2Ffeeds.feedburner.com%2Fdynamic50" src="http://plusmo.com/res/graphics/fbplusmo.gif">Subscribe with Plusmo</feedburner:feedFlare><feedburner:feedFlare xmlns:feedburner="http://rssnamespace.org/feedburner/ext/1.0" href="http://www.thefreedictionary.com/_/hp/AddRSS.aspx?http%3A%2F%2Ffeeds.feedburner.com%2Fdynamic50" src="http://img.tfd.com/hp/addToTheFreeDictionary.gif">Subscribe with The Free Dictionary</feedburner:feedFlare><feedburner:feedFlare xmlns:feedburner="http://rssnamespace.org/feedburner/ext/1.0" href="http://www.bitty.com/manual/?contenttype=rssfeed&amp;contentvalue=http%3A%2F%2Ffeeds.feedburner.com%2Fdynamic50" src="http://www.bitty.com/img/bittychicklet_91x17.gif">Subscribe with Bitty Browser</feedburner:feedFlare><feedburner:feedFlare xmlns:feedburner="http://rssnamespace.org/feedburner/ext/1.0" href="http://www.live.com/?add=http%3A%2F%2Ffeeds.feedburner.com%2Fdynamic50" src="http://tkfiles.storage.msn.com/x1piYkpqHC_35nIp1gLE68-wvzLZO8iXl_JMledmJQXP-XTBOLfmQv4zhj4MhcWEJh_GtoBIiAl1Mjh-ndp9k47If7hTaFno0mxW9_i3p_5qQw">Subscribe with Live.com</feedburner:feedFlare><feedburner:feedFlare xmlns:feedburner="http://rssnamespace.org/feedburner/ext/1.0" href="http://mix.excite.eu/add?feedurl=http%3A%2F%2Ffeeds.feedburner.com%2Fdynamic50" src="http://image.excite.co.uk/mix/addtomix.gif">Subscribe with Excite MIX</feedburner:feedFlare><feedburner:feedFlare xmlns:feedburner="http://rssnamespace.org/feedburner/ext/1.0" href="http://www.webwag.com/wwgthis.php?url=http%3A%2F%2Ffeeds.feedburner.com%2Fdynamic50" src="http://www.webwag.com/images/wwgthis.gif">Subscribe with Webwag</feedburner:feedFlare><feedburner:feedFlare xmlns:feedburner="http://rssnamespace.org/feedburner/ext/1.0" href="http://www.podcastready.com/oneclick_bookmark.php?url=http%3A%2F%2Ffeeds.feedburner.com%2Fdynamic50" src="http://www.podcastready.com/images/podcastready_button.gif">Subscribe with Podcast Ready</feedburner:feedFlare><feedburner:feedFlare xmlns:feedburner="http://rssnamespace.org/feedburner/ext/1.0" href="http://www.wikio.com/subscribe?url=http%3A%2F%2Ffeeds.feedburner.com%2Fdynamic50" src="http://www.wikio.com/shared/img/add2wikio.gif">Subscribe with Wikio</feedburner:feedFlare><feedburner:feedFlare xmlns:feedburner="http://rssnamespace.org/feedburner/ext/1.0" href="http://www.dailyrotation.com/index.php?feed=http%3A%2F%2Ffeeds.feedburner.com%2Fdynamic50" src="http://www.dailyrotation.com/rss-dr2.gif">Subscribe with Daily Rotation</feedburner:feedFlare><item>
		<title>Installing a monitored Mongodb, Ruby 1.9, Nginx stack with Passenger on Ubuntu Linux</title>
		<link>http://blog.dynamic50.com/2010/04/21/installing-a-monitored-mongodb-ruby-1-9-nginx-stack-with-passenger-on-ubuntu-linux/</link>
		<comments>http://blog.dynamic50.com/2010/04/21/installing-a-monitored-mongodb-ruby-1-9-nginx-stack-with-passenger-on-ubuntu-linux/#comments</comments>
		<pubDate>Wed, 21 Apr 2010 10:48:13 +0000</pubDate>
		<dc:creator>Jason Green</dc:creator>
				<category><![CDATA[General]]></category>
		<category><![CDATA[Ruby]]></category>
		<category><![CDATA[ruby on rails]]></category>
		<category><![CDATA[mongodb]]></category>
		<category><![CDATA[nginx]]></category>
		<category><![CDATA[nosql]]></category>
		<category><![CDATA[ubuntu]]></category>

		<guid isPermaLink="false">http://blog.dynamic50.com/?p=962</guid>
		<description><![CDATA[In the spirit of nosql, today I am going to show you how to install a Rails stack on Ubuntu using Mongodb, Nginx, Passenger, Ruby 1.9 and all nicely monitored using monit, my monitoring tool of choice (why don&#8217;t I use god I hear you ask? =&#62; monit = easy maintenance and less resource heavy).

We [...]]]></description>
			<content:encoded><![CDATA[<p>In the spirit of nosql, today I am going to show you how to install a Rails stack on Ubuntu using Mongodb, Nginx, Passenger, Ruby 1.9 and all nicely monitored using monit, my monitoring tool of choice (why don&#8217;t I use god I hear you ask? =&gt; monit = easy maintenance and less resource heavy).</p>

<p>We used to use Nginx for all of our apps back in the good &#8216;ol days of mongrel clustering. Since Phusion Passenger, we like most other development companies, moved straight over to Apache for ease of install and maintenance. However we decided recently that we should look at Nginx again, for its super small memory footprint and low server load, as well as super fast serving. Apache is a beast and on small servers without correct optimisation it can eat up resource at a much quicker rate than Nginx.<br />
We ran some side by side comparables on Nginx vs Apache on a 512 slice and the differences are significant. Anyway&#8230; on to the install!</p>

<p>I have put semi-colons after each line so in theory you can just copy entire blocks and just paste them into your terminal and they will execute.</p>

<p>Firstly on a blank system (logged in as root) add your user account</p>


<pre>adduser deploy;</pre>


<p>Then give this user sudo privileges by editing the sudoers file:</p>


<pre>visudo;</pre>


<p>Make sure the file is correctly saved as sudoers, not sudoers.tmp then log out and back in as your new deploy user.</p>

<p>Now lets get the base system ready, so firstly:</p>


<pre>sudo apt-get update;
sudo apt-get upgrade;
sudo apt-get install build-essential zlib1g-dev libssl-dev libpcre3-dev git-core;</pre>


<p>Now to install Ruby 1.9 and Rubygems<br />
Go grab Ruby from <a href="http://www.ruby-lang.org/en/downloads/">here</a></p>


<pre>cd;
wget ftp://ftp.ruby-lang.org/pub/ruby/1.9/ruby-1.9.1-p376.tar.gz;
tar zxvf ruby-1.9.1-p376.tar.gz;
cd ruby-1.9.1-p376;
./configure; make; sudo make install;</pre>


<p>Now install libopenssl-ruby</p>


<pre>cd;
cd ruby-1.9.1-p376/ext/openssl;
sudo ruby extconf.rb;
make; sudo make install;</pre>


<p>And readline (to avoid the readline errors from the console)</p>


<pre>sudo apt-get install libreadline5 libncurses5-dev libreadline5-dev;
cd;
cd ruby-1.9.1-p376/ext/readline;
ruby extconf.rb;
make; sudo make install;</pre>


<p>Go and fetch Rubygems from <a href="http://rubyforge.org/frs/?group_id=126&amp;release_id=42796">here</a></p>


<pre>cd;
wget http://rubyforge.org/frs/download.php/69365/rubygems-1.3.6.tgz;
tar zxvf rubygems-1.3.6.tgz;
cd rubygems-1.3.6;
sudo ruby setup.rb;</pre>


<p>Check everything is running as expected:</p>


<pre>ruby --version; gem --version;</pre>


<p>And you output should show something like this:</p>


<pre>ruby 1.9.1p376 (2009-12-07 revision 26041) [i686-linux]
1.3.6</pre>


<p>Now to install nginx and passenger:<br />
Grab the latest nginx from <a href="http://nginx.org/en/download.html">here</a></p>


<pre>cd;
wget http://nginx.org/download/nginx-0.7.65.tar.gz;
tar zxvf nginx-0.7.65.tar.gz;</pre>


<p>Before you install this, grab passenger and it will install nginx for you:</p>


<pre>sudo gem update;
sudo gem install passenger --no-ri --no-rdoc;
sudo passenger-install-nginx-module;</pre>


<p>When passenger install loads, select option 2 (advanced) as option one uses an older version of nginx than we just downloaded.<br />
The directory where nginx source code is located is:</p>


<pre>/home/deploy/nginx-0.7.65</pre>


<p>Make sure you specify what user to run as, in the add extra arguments section add the following:</p>


<pre>--user=nginx --group=nginx</pre>


<p>And just go with the defaults for everything else. Nginx gets installed in /opt/nginx<br />
Now add the nginx user:</p>


<pre>sudo adduser --system --no-create-home --disabled-login --disabled-password --group nginx;</pre>


<p>Now install the startup script from linode to get Nginx started:</p>


<pre>cd;
wget http://library.linode.com/web-servers/nginx/installation/reference/init-deb.sh;
sudo mv init-deb.sh /etc/init.d/nginx;
sudo chmod +x /etc/init.d/nginx;
sudo /usr/sbin/update-rc.d -f nginx defaults;</pre>


<p>Now Nginx is installed with passenger support, all we have left to install is Mongodb and monit.<br />
Starting with mongodb, grab the source from <a href="http://www.mongodb.org/display/DOCS/Downloads">here</a>, make sure you get the correct version for your system architecture as the 32 bit has limitations so if you can install the 64 bit, do!<br />
On the system I am installing it is 32 bit:</p>


<pre>wget http://downloads.mongodb.org/linux/mongodb-linux-i686-1.4.1.tgz;
tar zxvf mongodb-linux-i686-1.4.1.tgz;
sudo mv mongodb-linux-i686-1.4.1 /opt/mongodb;</pre>


<p>Now create the data directory for mongo (the following instructions have been taken originally from the tutorials at library.linode.com)</p>


<pre>sudo mkdir -p /data/db/mongodb;
sudo touch /data/db/mongodb.log;</pre>


<p>And create the basic control scripts:</p>


<pre>sudo mkdir /opt/bin/;
sudo mkdir /opt/config/;</pre>


<p>Copy and paste the following into /opt/bin/mongodb-start:</p>


<pre>#!/bin/sh
/opt/mongodb/bin/mongod --config /opt/config/mongodb \
## --upgrade \ ##runs a database upgrade option if needed \</pre>


<p>Copy and paste the following into /opt/bin/mongodb-stop:</p>


<pre>#!/bin/bash

pid=`ps -o pid,command ax | grep mongod | awk '!/awk/ &amp;amp;&amp;amp; !/grep/ {print $1}'`;
if [ &quot;${pid}&quot; != &quot;&quot; ]; then
    kill -2 ${pid};
fi</pre>


<p>Copy and paste the following into /opt/config/mongodb:</p>


<pre># Configuration Options for MongoDB
#
# For More Information, Consider:
# - Configuration Parameters: http://www.mongodb.org/display/DOCS/Command+Line+Parameters
# - File Based Configuration: http://www.mongodb.org/display/DOCS/File+Based+Configuration

dbpath = /data/db/mongodb
logpath = /data/db/mongodb.log
logappend = true

bind_ip = 127.0.0.1
port = 27017
fork = true

auth = true
# noauth = true</pre>


<p>And make sure the files are executable:</p>


<pre>sudo chmod +x /opt/bin/mongodb-start;
sudo chmod +x /opt/bin/mongodb-stop</pre>


<p>Now grab the init script from linode:</p>


<pre>cd;
wget http://library.linode.com/databases/mongodb/reference/init-deb.sh;
sudo mv init-deb.sh /etc/init.d/mongodb;
sudo chmod +x /etc/init.d/mongodb;
sudo /usr/sbin/update-rc.d -f mongodb defaults;</pre>


<p>Add a mongo user and make sure they own the right files:</p>


<pre>sudo adduser --system --no-create-home --disabled-login --disabled-password --group mongodb;
sudo chown mongodb:mongodb -R /data;</pre>


<p>Ok now to install monit:</p>


<pre>sudo apt-get install monit;
sudo mkdir /etc/monit.d;</pre>


<p>Now to configure everything!!!<br />
Let start with nginx:</p>


<pre>sudo mkdir /opt/nginx/vhosts;</pre>


<p>I have created a optimised nginx config file available <a href="http://gist.github.com/372451">here</a>. Grab this and copy the contents into /opt/nginx/conf/nginx.conf<br />
The nginx conf assumes that your declare your servers in /opt/nginx/vhosts. If you have issues with passenger make sure the two lines regarding Passenger point to the correct Ruby and Passenger.<br />
Now create your vitualhosts. For the purpose of this article I am going to create one generic one. You can grab this from the gist <a href="http://gist.github.com/372585">here</a> and then put it inside the vhosts directory.</p>

<p>Thats Nginx done. Now to sort out monit.<br />
First edit the /etc/default/monit file and make sure startup is set to 1, so it starts on boot.<br />
Now create the monit.d directory:</p>


<pre>sudo mkdir /etc/monit.d;</pre>


<p>And then edit the /etc/monit/monitrc file. You can grab a template for this from <a href="http://gist.github.com/373663">here</a>.<br />
I have created one file for everthing in the /etc/monit.d directory. Grab it from <a href="http://gist.github.com/373675">here</a> and then make sure it is executable:</p>


<pre>cd /etc/monit.d;
sudo vi the_file_name;
sudo chmod +x the_file_name;</pre>


<p>It doesn&#8217;t matter what the file is called. Monit will run any file located in the /etc/monit.d directory as we specified that in the monitrc file earlier.<br />
Now start monit!</p>


<pre>sudo /etc/init.d/monit start;
sudo monit;
sudo monit start all;
sudo monit status;</pre>


<p>And that&#8217;s pretty much it! your server is set up with monitoring, nginx, mongodb and ruby 1.9. All you need to do now is set up your deployment strategy.</p><div class="feedflare">
<a href="http://feeds.feedburner.com/~ff/dynamic50?a=wv3rnVpwYyY:k99sqoiH3QQ:yIl2AUoC8zA"><img src="http://feeds.feedburner.com/~ff/dynamic50?d=yIl2AUoC8zA" border="0"></img></a>
</div>]]></content:encoded>
			<wfw:commentRss>http://blog.dynamic50.com/2010/04/21/installing-a-monitored-mongodb-ruby-1-9-nginx-stack-with-passenger-on-ubuntu-linux/feed/</wfw:commentRss>
		<slash:comments>2</slash:comments>
		</item>
		<item>
		<title>Installing Ruby on Rails and MultiRuby on Snow Leopard</title>
		<link>http://blog.dynamic50.com/2010/03/18/installing-ruby-on-rails-and-multiruby-on-snow-leopard/</link>
		<comments>http://blog.dynamic50.com/2010/03/18/installing-ruby-on-rails-and-multiruby-on-snow-leopard/#comments</comments>
		<pubDate>Thu, 18 Mar 2010 10:41:27 +0000</pubDate>
		<dc:creator>Jason Green</dc:creator>
				<category><![CDATA[General]]></category>
		<category><![CDATA[Ruby]]></category>
		<category><![CDATA[ruby on rails]]></category>
		<category><![CDATA[dynamic50]]></category>
		<category><![CDATA[rvm]]></category>
		<category><![CDATA[Snow Leopard]]></category>

		<guid isPermaLink="false">http://blog.dynamic50.com/?p=947</guid>
		<description><![CDATA[Below are instructions on how to install a multi-ruby system, Ruby on Rails and everything you need to run a basic Ruby on Rails setup.

Running the RVM gem (which we show how to install) allows you to easily run multiple Ruby versions and switch seamlessly between them.

First steps:
- Checking your Architecture
Make sure that the stuff [...]]]></description>
			<content:encoded><![CDATA[<p>Below are instructions on how to install a multi-ruby system, Ruby on Rails and everything you need to run a basic Ruby on Rails setup.</p>

<p>Running the <span class="caps">RVM </span>gem (which we show how to install) allows you to easily run multiple Ruby versions and switch seamlessly between them.</p>

<p>First steps:<br />
- Checking your Architecture<br />
Make sure that the stuff you install actually fits your current architecture. Even if you have a machine capable of 64bit it doesn&#8217;t necessarily mean that the OS you are running is 64bit. To check what your mac is running open the terminal and type:</p>


<pre>uname -a</pre>


<p>This should bring back something like this:<br />
I am running this on a Macbook with i386 architecture (32 bit) so I see the following:</p>


<pre>Darwin Dynamic50s-MacBook.local 10.2.0 Darwin Kernel Version 10.2.0: Tue Nov  3 10:37:10 PST 2009; root:xnu-1486.2.11~1/RELEASE_I386 i386</pre>


<p>If I run the same test on a 64 bit machine instead of i386 I see x86_64</p>


<pre>Darwin Dynamic50s-Macbook-Pro.local 10.0.0 Darwin Kernel Version 10.0.0: Tue Nov 3 10:37:34 PDT 2009; root:xnu-1456.1.25~1/RELEASE_X86_64 x86_64</pre>


<p>Keep a note of this as you will need it later.</p>

<p>- Xcode<br />
You need the latest version of xcode so download this from the apple developer site. Do not use the version off of the <span class="caps">CD, </span>get the latest version. Unless you are using XCode to develop for the IPhone, you only need the basic mac version.</p>

<p>- MySQL<br />
If you want to use MySql then you will need to do the following:<br />
If you have previously installed any versions of MySQL (from Macports or other) remove them. Make sure you download the correct version of MySQL for your architecture.<br />
Download version from the MySQL site (DMG) <a href="http://www.mysql.com/downloads/mirror.php?id=385549#mirrors">here</a>.<br />
Make sure you get the right version for your platform, Also install the Prefpane (inside the <span class="caps">DMG </span>file), this makes it really easy to start and stop MySQL from System Preferences.</p>

<p>- Enable MySQL<br />
Go to System Preferences and enable MySQL from the system preference pane. Then start it up and make sure it is running. Before you close the pref pane, make sure the start on start-up is also ticked.</p>

<p><a href="http://blog.dynamic50.com/index.php/2010/03/installing-ruby-on-rails-and-multiruby-on-snow-leopard/screen-shot-2010-03-18-at-10-07-25-3/" rel="attachment wp-att-956"><img src="http://testblog.dynamic50.com/wp-content/uploads/2010/03/Screen-shot-2010-03-18-at-10.07.252.png" alt="Screen shot 2010 03 18 at 10.07.252 Installing Ruby on Rails and MultiRuby on Snow Leopard" title="MySQL PrefPane" width="400" height="193" class="alignnone size-full wp-image-956" /></a></p>

<p>- Git<br />
If you use Git as your repository system then you will need to install it (if you don&#8217;t currently use it, you should be!). To do so go <a href="http://code.google.com/p/git-osx-installer/downloads/list?can=3">here</a> and install it. You can also install this from macports, but I prefer to grab the most up to date version from the google code repos, and it comes packaged as a <span class="caps">DMG.</span></p>

<p>Make sure it runs by opening a new terminal and running</p>


<pre>git --version</pre>


<p>And you should see something like this:</p>


<pre>git version 1.7.0.2</pre>



<p>If it is not there, you probably don&#8217;t have the path set correctly. Mine is located in</p>


<pre>/usr/local/git/bin</pre>


<p>So I have to make sure this bin directory is in my <span class="caps">PATH.</span> If I type:</p>


<pre>env $PATH</pre>


<p>into the terminal I get the following:</p>


<pre>env: /Users/dynamic50/.rvm/rubies/ruby-1.8.7-p249/bin:/Users/dynamic50/.rvm/gems/ruby-1.8.7-p249/bin:/Users/dynamic50/.rvm/gems/ruby-1.8.7-p249%global/bin:/Users/dynamic50/.rvm/bin:/usr/local/mysql-5.1.45-osx10.6-x86_64/bin:/usr/bin:/bin:/usr/sbin:/sbin:/usr/local/bin:/usr/local/git/bin:/usr/X11/bin: No such file or directory</pre>


<p>This shows that it indeed in the path, if it isn&#8217;t, simply add it by editing your .bash_profile file and reloading the terminal.</p>

<p>- Installing <a href="http://rvm.beginrescueend.com/">Ruby version manager</a><br />
The recommended way of installing this is from source. Open up a new terminal and type:</p>


<pre>cd $HOME/.rvm/src &amp;&amp; git clone --depth 1 git://github.com/wayneeseguin/rvm.git &amp;&amp; cd rvm &amp;&amp; ./install</pre>


<p>After install make sure you follow the instructions and add what is required to your bashrc and .bash_profile and the reload your sources (or restart the terminal).<br />
Now install the Ruby versions you want.</p>


<pre>
rvm install 1.8.7
rvm install 1.9.1
rvm install 1.9.2
</pre>


<p>And set a default:</p>


<pre>
rvm --default 1.8.7
rvm default
</pre>


<p>Make sure that you are currently using the default. Open a terminal and type:</p>


<pre>ruby --version</pre>


<p>This should bring back something along the following lines:</p>


<pre>ruby 1.8.7 (2010-01-10 patchlevel 249) [i686-darwin10.2.0]</pre>



<p>I am only going to do the following stuff for Ruby 1.8.7, but if you want to do it for the other Ruby versions installed, simply switch to a different version and then perform the same tasks.<br />
- Installing the MySQL gem:<br />
This always seems to cause a headache and is usually due to architecture flags.<br />
This should work, feel free to write a note in the comments if you are having issues on this and I will try and help out.<br />
For 64bit Intel architecture:</p>


<pre>sudo env ARCHFLAGS=&quot;-arch x86_64&quot; gem install mysql -- --with-mysql-config=/usr/local/mysql/bin/mysql_config</pre>


<p>For 32bit Intel architecture:</p>


<pre>sudo env ARCHFLAGS=&quot;-arch i386&quot; gem install mysql -- --with-mysql-config=/usr/local/mysql/bin/mysql_config</pre>



<p>And thats about it! Now install any other gems required, or better still, use bundler and package them all into your application.</p><div class="feedflare">
<a href="http://feeds.feedburner.com/~ff/dynamic50?a=ddLMQDQl2GM:vTiu0DXJ0hw:yIl2AUoC8zA"><img src="http://feeds.feedburner.com/~ff/dynamic50?d=yIl2AUoC8zA" border="0"></img></a>
</div>]]></content:encoded>
			<wfw:commentRss>http://blog.dynamic50.com/2010/03/18/installing-ruby-on-rails-and-multiruby-on-snow-leopard/feed/</wfw:commentRss>
		<slash:comments>0</slash:comments>
		</item>
		<item>
		<title>Updating Blog Feed</title>
		<link>http://blog.dynamic50.com/2010/03/02/updating-blog-feed/</link>
		<comments>http://blog.dynamic50.com/2010/03/02/updating-blog-feed/#comments</comments>
		<pubDate>Tue, 02 Mar 2010 15:17:25 +0000</pubDate>
		<dc:creator>Jason Green</dc:creator>
				<category><![CDATA[General]]></category>
		<category><![CDATA[blog]]></category>
		<category><![CDATA[dynamic50]]></category>
		<category><![CDATA[feed]]></category>

		<guid isPermaLink="false">http://blog.dynamic50.com/?p=945</guid>
		<description><![CDATA[We have updated our blog feed. You can now get it here: http://feeds.feedburner.com/dynamic50.

Please update your blog reader, we will be deprecating the old feeds shortly.]]></description>
			<content:encoded><![CDATA[<p>We have updated our blog feed. You can now get it here: <a href="http://feeds.feedburner.com/dynamic50">http://feeds.feedburner.com/dynamic50</a>.</p>

<p>Please update your blog reader, we will be deprecating the old feeds shortly.</p><div class="feedflare">
<a href="http://feeds.feedburner.com/~ff/dynamic50?a=6LAsY1GtnmE:BiWRogSKWvc:yIl2AUoC8zA"><img src="http://feeds.feedburner.com/~ff/dynamic50?d=yIl2AUoC8zA" border="0"></img></a>
</div>]]></content:encoded>
			<wfw:commentRss>http://blog.dynamic50.com/2010/03/02/updating-blog-feed/feed/</wfw:commentRss>
		<slash:comments>0</slash:comments>
		</item>
		<item>
		<title>Calculating your Flight Carbon Footprint</title>
		<link>http://blog.dynamic50.com/2010/02/25/calculating-your-flight-carbon-footprint/</link>
		<comments>http://blog.dynamic50.com/2010/02/25/calculating-your-flight-carbon-footprint/#comments</comments>
		<pubDate>Thu, 25 Feb 2010 09:47:37 +0000</pubDate>
		<dc:creator>Jason Green</dc:creator>
				<category><![CDATA[General]]></category>
		<category><![CDATA[News]]></category>
		<category><![CDATA[carbon]]></category>
		<category><![CDATA[carbon footprint]]></category>
		<category><![CDATA[flightcc]]></category>
		<category><![CDATA[Free]]></category>
		<category><![CDATA[ruby on rails]]></category>

		<guid isPermaLink="false">http://blog.dynamic50.com/?p=860</guid>
		<description><![CDATA[We have been pretty busy recently working on carbon calculation tools (using Ruby on Rails). One we have just released is a skinnable flight carbon calculator. This can easily be added to any blog or website.

To embed on to your site, go to: Flight Carbon Calculator and choose a theme and comparable. I have chosen [...]]]></description>
			<content:encoded><![CDATA[<p>We have been pretty busy recently working on carbon calculation tools (using Ruby on Rails). One we have just released is a skinnable flight carbon calculator. This can easily be added to any blog or website.</p>

<p>To embed on to your site, go to: <a href="http://www.dynamic50.com/portfolio/flight_cc">Flight Carbon Calculator</a> and choose a theme and comparable. I have chosen the cloud theme with cans of cola as my comparable. A embed code will appear at the bottom of the page when you have made your choices. Simply copy and paste the embed code straight on to your site. Here&#8217;s an example below.</p>

<p><iframe height="264" width="414" id="flightCarbonCalculated" src="http://flight.carboncalculated.com/iframe/?theme=clouds&amp;comparison=coke"> Dynamic50 Flight CarbonCalculated </iframe></p>

<p>And now you have your own Flight Carbon Calculator, running on Ruby on Rails, embedded into your site!</p><div class="feedflare">
<a href="http://feeds.feedburner.com/~ff/dynamic50?a=xJYX6ULQQqU:usrcSEMe2WA:yIl2AUoC8zA"><img src="http://feeds.feedburner.com/~ff/dynamic50?d=yIl2AUoC8zA" border="0"></img></a>
</div>]]></content:encoded>
			<wfw:commentRss>http://blog.dynamic50.com/2010/02/25/calculating-your-flight-carbon-footprint/feed/</wfw:commentRss>
		<slash:comments>0</slash:comments>
		</item>
		<item>
		<title>Rubymash now has Ruby on Rails Job listings</title>
		<link>http://blog.dynamic50.com/2010/02/24/rubymash-now-has-ruby-on-rails-job-listings/</link>
		<comments>http://blog.dynamic50.com/2010/02/24/rubymash-now-has-ruby-on-rails-job-listings/#comments</comments>
		<pubDate>Wed, 24 Feb 2010 11:21:24 +0000</pubDate>
		<dc:creator>Jason Green</dc:creator>
				<category><![CDATA[General]]></category>
		<category><![CDATA[News]]></category>
		<category><![CDATA[dynamic50]]></category>
		<category><![CDATA[Ruby]]></category>
		<category><![CDATA[ruby on rails]]></category>
		<category><![CDATA[rubymash]]></category>

		<guid isPermaLink="false">http://blog.dynamic50.com/?p=858</guid>
		<description><![CDATA[Rubymash has been ticking along nicely as a map of freelancers and companies working with rails throughout the world. Traffic has been fairly consistent since the site was first released. However all Rubymash offered was a directory of freelancers and companies on a map.

Sticking with the on-a-map idea, we have just released a jobs section [...]]]></description>
			<content:encoded><![CDATA[<p><a href="http://www.rubymash.com">Rubymash</a> has been ticking along nicely as a map of freelancers and companies working with rails throughout the world. Traffic has been fairly consistent since the site was first released. However all <a href="http://www.rubymash.com">Rubymash</a> offered was a directory of freelancers and companies on a map.</p>

<p>Sticking with the on-a-map idea, we have just released a jobs section for Rubymash. Companies can now list the positions they currently have available and they will appear on the map associated with the company. This gives potential employees more information on the Ruby on Rails company they are looking to work for than other jobs sites as you can view company information associated with the job, and also physically see where it is located in the world.</p>

<p>We also added a ad-free jobs feed <a href="http://feeds.feedburner.com/rubymash/jobs">here</a>, so you can follow the jobs as and when they get published.</p>

<p>If you have any ideas of how we can improve this site, please let us know!</p><div class="feedflare">
<a href="http://feeds.feedburner.com/~ff/dynamic50?a=pNa7QmFOz3k:-GVk7Bj3oj0:yIl2AUoC8zA"><img src="http://feeds.feedburner.com/~ff/dynamic50?d=yIl2AUoC8zA" border="0"></img></a>
</div>]]></content:encoded>
			<wfw:commentRss>http://blog.dynamic50.com/2010/02/24/rubymash-now-has-ruby-on-rails-job-listings/feed/</wfw:commentRss>
		<slash:comments>1</slash:comments>
		</item>
		<item>
		<title>Rails 3.0: Mount Multiple Apps as Engines</title>
		<link>http://blog.dynamic50.com/2010/02/22/rails-3-0-mount-multiple-apps-as-engines/</link>
		<comments>http://blog.dynamic50.com/2010/02/22/rails-3-0-mount-multiple-apps-as-engines/#comments</comments>
		<pubDate>Mon, 22 Feb 2010 08:30:58 +0000</pubDate>
		<dc:creator>Anup Narkhede</dc:creator>
				<category><![CDATA[General]]></category>
		<category><![CDATA[ruby on rails]]></category>
		<category><![CDATA[dynamic50]]></category>
		<category><![CDATA[engines]]></category>
		<category><![CDATA[Rails 3.0]]></category>
		<category><![CDATA[Ruby]]></category>

		<guid isPermaLink="false">http://blog.dynamic50.com/?p=852</guid>
		<description><![CDATA[Since last week I have been working on upgrading a major project from Rails 2.3.5 to Rails 3.0.0.beta and also on moving other projects to use the latest version of bundler. Getting all to work was not easy, but this gave me a chance to look into the rails initialization code in detail. Based on [...]]]></description>
			<content:encoded><![CDATA[<p>Since last week I have been working on upgrading a major project from Rails 2.3.5 to Rails 3.0.0.beta and also on moving other projects to use the latest version of bundler. Getting all to work was not easy, but this gave me a chance to look into the rails initialization code in detail. Based on this adventure, I tried to convert some plugins into gems and also explored ways of mounting a Rails 3.0 application into another. Here is a very basic example of how you can mount a reusable Rails 3.0 application into a container application. This might not be the best approach for developing multi apps, but it surely offers some fun <img src='http://blog.dynamic50.com/wp-includes/images/smilies/icon_smile.gif' alt=':)' class='wp-smiley' title="Rails 3.0: Mount Multiple Apps as Engines" /> .</p>

<p>My setup is Rails 3.0.0.beta with ruby 1.9.1 for this example. If the steps sound confusing, you can follow the example code here <a href="http://github.com/railsbob/MyApp">http://github.com/railsbob/MyApp</a>.</p>

<p>First of all, lets create a generic, reusable application. My reusable &#8216;login application&#8217; with one controller is called as &#8216;Saas&#8217;.</p>

<script src="http://gist.github.com/310688.js?file=gistfile1.txt"></script>

<p>To allow sharing of this application by others, we need to wrap it as a Rails::Engine. To do so, add a file named &#8216;engine.rb&#8217; to config folder.</p>

<script src="http://gist.github.com/310689.js?file=gistfile1.txt"></script>

<p>Create a &#8217;saas.rb&#8217; in lib folder which requires this engine.rb. This is required, as we want to load the application as Saas::Engine instead of Saas::Application.</p>

<script src="http://gist.github.com/310690.js?file=gistfile1.txt"></script>

<p>Lets create a container app which mounts the Saas Application.</p>

<p>rails MyApp</p>


<p><strong>To mount it</strong>, copy the Saas application into lib of MyApp.</p>

<p>Saas application&#8217;s routes.rb should be modified to replace Saas::Application by Rails::Application. Also, to keep things modular, add a namespace to the routes.</p>

<script src="http://gist.github.com/310691.js?file=gistfile1.txt"></script>

<p>The next step is to hook Saas app into the initializer process of MyApp. There are many ways to do it, but we will follow the bundler approach.</p>

<p>In MyApp/Gemfile, require the saas application from lib directory as a gem.</p>

<script src="http://gist.github.com/310692.js?file=gistfile1.txt"></script>

<p>At this stage, bundler complains about missing version for saas as it is expecting a gem. So lets add a saas.gemspec at MyApp/lib/saas/saas.gemspec with basic information.</p>

<script src="http://gist.github.com/310693.js?file=gistfile1.txt"></script>

<p>Start the server from the container app and if you go to /saas/sessions you should see the text &#8216;Hi from SessionsController&#8217;.</p>

<p>Note that even if the Saas application was modified to be an engine, it still works as a standalone application when run from its root.<br />
The example code discussed above is available at <a href="http://github.com/railsbob/MyApp">http://github.com/railsbob/MyApp</a>.<br />
.</p><div class="feedflare">
<a href="http://feeds.feedburner.com/~ff/dynamic50?a=gxMSwkwChKs:RDhAoFoUeC8:yIl2AUoC8zA"><img src="http://feeds.feedburner.com/~ff/dynamic50?d=yIl2AUoC8zA" border="0"></img></a>
</div>]]></content:encoded>
			<wfw:commentRss>http://blog.dynamic50.com/2010/02/22/rails-3-0-mount-multiple-apps-as-engines/feed/</wfw:commentRss>
		<slash:comments>2</slash:comments>
		</item>
		<item>
		<title>Mustache And Rails3</title>
		<link>http://blog.dynamic50.com/2010/02/17/mustache-and-rails3/</link>
		<comments>http://blog.dynamic50.com/2010/02/17/mustache-and-rails3/#comments</comments>
		<pubDate>Wed, 17 Feb 2010 09:36:57 +0000</pubDate>
		<dc:creator>Richard Hooker</dc:creator>
				<category><![CDATA[General]]></category>
		<category><![CDATA[Ruby]]></category>
		<category><![CDATA[ruby on rails]]></category>
		<category><![CDATA[rails3 rails ruby mustache]]></category>

		<guid isPermaLink="false">http://blog.dynamic50.com/?p=841</guid>
		<description><![CDATA[Mustach Rails3


  If your UI needs to hold state and do a little more then just returning a html string and
  updating a dom element(not that cool); then json is the way to go.
  Javascript is powerful so it can just receive the json and it can handle the state of the [...]]]></description>
			<content:encoded><![CDATA[<h3>Mustach Rails3</h3>

<p>
  If your UI needs to hold state and do a little more then just returning a html string and<br />
  updating a dom element(not that cool); then json is the way to go.<br />
  Javascript is powerful so it can just receive the json and it can handle the state of the <span class="caps">UI.</span>

  We wanted templates that worked in both worlds; server side and client side; Based on these<br />
  requirements we went for <a href="git://github.com/defunkt/mustache.git"> Mustache </a> and <a href="git://github.com/janl/mustache.js.git"> Mustache.js </a> We also created a template resolver (super easy in rails3) to get these templates from the db so clients could have there own personal view; but that is another story;<br />
</p>

<p>
  However its not the easiest tool to get going in Rails; So based on that fact<br />
  we needed a quick implementation to get us going with Mustache.<br />
  Note: This is not the best approach to solve this problem; Mustache probably<br />
  needs a custom context that can be compliant in the rails3 in a action_view sense;<br />
  This seems to be actually quite hard; from my perspective action_view seems<br />
  to be one the most complexing parts in rails and rails3. I personally think that<br />
  the context should start from a simple hash and layer the extra functionality on<br />
  top in module fashion. But then you are in view helper hell; so in a nut shell I am<br />
  not that sure on that one.<br />
</p>

<p><strong><br />
  What we did<br />
</strong></p>

<ul>
  <li>
    <h4>Create a template handler to get a handle on the mustache</h4>

<p>    <script src="http://gist.github.com/306462.js"></script></p>

  </li>
  <li>
    <h4>Create custom mustache to handle a context that can take
    a ActionView::Context;</h4>

    <script src="http://gist.github.com/306463.js"></script><br />
  </li>
  <li>
    <h4>Register the template handler</h4>

    <script src="http://gist.github.com/306464.js"></script><br />
  </li>

    <h4>Create a ViewModel (view/questions)</h4>

    <script src="http://gist.github.com/306477.js"></script><br />
  </li>
</ul><div class="feedflare">
<a href="http://feeds.feedburner.com/~ff/dynamic50?a=eLv5gYg5UPw:fLIyJQqdSpw:yIl2AUoC8zA"><img src="http://feeds.feedburner.com/~ff/dynamic50?d=yIl2AUoC8zA" border="0"></img></a>
</div>]]></content:encoded>
			<wfw:commentRss>http://blog.dynamic50.com/2010/02/17/mustache-and-rails3/feed/</wfw:commentRss>
		<slash:comments>3</slash:comments>
		</item>
		<item>
		<title>Quick install for ruby 1.9.1 and Rubygems 1.3.5 from source on Ubuntu.</title>
		<link>http://blog.dynamic50.com/2010/02/15/quick-install-for-ruby-1-9-1-and-rubygems-1-3-5-from-source-on-ubuntu/</link>
		<comments>http://blog.dynamic50.com/2010/02/15/quick-install-for-ruby-1-9-1-and-rubygems-1-3-5-from-source-on-ubuntu/#comments</comments>
		<pubDate>Mon, 15 Feb 2010 12:11:33 +0000</pubDate>
		<dc:creator>Jason Green</dc:creator>
				<category><![CDATA[General]]></category>
		<category><![CDATA[Ruby]]></category>
		<category><![CDATA[ruby on rails]]></category>
		<category><![CDATA[dynamic50]]></category>
		<category><![CDATA[ruby 1.9]]></category>
		<category><![CDATA[ubuntu]]></category>

		<guid isPermaLink="false">http://blog.dynamic50.com/?p=835</guid>
		<description><![CDATA[Here&#8217;s a quick howto guide on installing Ruby 1.9.1, Rubygems 1.3.5 and dependencies on Ubuntu.


The apt-sources version of Ruby is not the latest version, as such it is better to compile everything from source.

First make sure your package sources are up to date and you have build essential and zlib1g-dev installed:



sudo apt-get update
sudo apt-get install [...]]]></description>
			<content:encoded><![CDATA[<p>Here&#8217;s a quick howto guide on installing Ruby 1.9.1, Rubygems 1.3.5 and dependencies on Ubuntu.</p>


<p>The apt-sources version of Ruby is not the latest version, as such it is better to compile everything from source.</p>

<p>First make sure your package sources are up to date and you have build essential and zlib1g-dev installed:</p>


<pre>
sudo apt-get update
sudo apt-get install build-essential zlib1g-dev
</pre>



<p>Now grab Ruby 1.9.1 latest stable from <a href="http://www.ruby-lang.org/en/downloads/">here</a>. The latest version at the time of writing is p376.</p>


<pre>
wget ftp://ftp.ruby-lang.org/pub/ruby/1.9/ruby-1.9.1-p376.tar.gz
</pre>



<p>Untar and install it:</p>


<pre>
tar zxvf ruby-1.9.1-p376.tar.gz
cd ruby-1.9.1-p376
./configure
make
sudo make install
</pre>



<p>Now go and get the latest Rubygems. At the time of writing this was 1.3.5. Grab this from <a href="http://rubyforge.org/projects/rubygems/">here</a>.</p>


<pre>
wget http://rubyforge.org/frs/download.php/60718/rubygems-1.3.5.tgz
</pre>



<p>Untar and install it (if you downloaded the tgz)</p>


<pre>
tar zxvf rubygems-1.3.5.tgz
cd rubygems-1.3.5
sudo ruby setup.rb
</pre>



<p>And these should both now be installed.<br />
Check that everything is running:</p>


<pre>
ruby --version; gem --version
</pre>



<p>Your output  should show something like this:</p>


<pre>
ruby 1.9.1p376 (2009-12-07 revision 26041) [x86_64-linux]
1.3.5
</pre>



<p>If you are looking to install Passenger you will also need libopenssl-ruby. To install this, go to the ruby source:</p>


<pre>
cd ruby-1.9.1-p376/ext/openssl
sudo ruby extconf.rb
make
sudo make install
</pre><div class="feedflare">
<a href="http://feeds.feedburner.com/~ff/dynamic50?a=zZrBbQ3tO2E:Ywa3ZrrOQQ0:yIl2AUoC8zA"><img src="http://feeds.feedburner.com/~ff/dynamic50?d=yIl2AUoC8zA" border="0"></img></a>
</div>]]></content:encoded>
			<wfw:commentRss>http://blog.dynamic50.com/2010/02/15/quick-install-for-ruby-1-9-1-and-rubygems-1-3-5-from-source-on-ubuntu/feed/</wfw:commentRss>
		<slash:comments>5</slash:comments>
		</item>
		<item>
		<title>LRUG (February 2010)</title>
		<link>http://blog.dynamic50.com/2010/02/11/lrug-february-2010/</link>
		<comments>http://blog.dynamic50.com/2010/02/11/lrug-february-2010/#comments</comments>
		<pubDate>Thu, 11 Feb 2010 11:20:53 +0000</pubDate>
		<dc:creator>Anup Narkhede</dc:creator>
				<category><![CDATA[General]]></category>
		<category><![CDATA[News]]></category>
		<category><![CDATA[ruby on rails]]></category>
		<category><![CDATA[Birdpie]]></category>
		<category><![CDATA[lrug]]></category>
		<category><![CDATA[Rails 3.0]]></category>

		<guid isPermaLink="false">http://blog.dynamic50.com/?p=817</guid>
		<description><![CDATA[These are the slides of my presentation at LRUG lightening talks 2010. The talk was about a brief introduction of our latest application birdpie.com. Birdpie View more presentations from anupnarkhede. Here are few random snaps from the evening. ]]></description>
			<content:encoded><![CDATA[<p>These are the slides of my presentation at <span class="caps">LRUG </span>lightening talks 2010. The talk was about a brief introduction of our latest application <a title="birdpie.com" href="http://www.birdpie.com" target="_blank" class="broken_link">birdpie.com</a>.</p> <div id="__ss_3128322" style="width: 425px; text-align: left;"><a style="font:14px Helvetica,Arial,Sans-serif;display:block;margin:12px 0 3px 0;text-decoration:underline;" title="Birdpie" href="http://www.slideshare.net/anupnarkhede/birdpie">Birdpie</a><object style="margin:0px" classid="clsid:d27cdb6e-ae6d-11cf-96b8-444553540000" width="425" height="355" codebase="http://download.macromedia.com/pub/shockwave/cabs/flash/swflash.cab#version=6,0,40,0"><param name="allowFullScreen" value="true" /><param name="allowScriptAccess" value="always" /><param name="src" value="http://static.slidesharecdn.com/swf/ssplayer2.swf?doc=lrugbirdpie2-100210175857-phpapp02&amp;stripped_title=birdpie" /><param name="allowfullscreen" value="true" /><embed style="margin:0px" type="application/x-shockwave-flash" width="425" height="355" src="http://static.slidesharecdn.com/swf/ssplayer2.swf?doc=lrugbirdpie2-100210175857-phpapp02&amp;stripped_title=birdpie" allowscriptaccess="always" allowfullscreen="true"></embed></object> <div style="font-size: 11px; font-family: tahoma,arial; height: 26px; padding-top: 2px;">View more <a style="text-decoration:underline;" href="http://www.slideshare.net/">presentations</a> from <a style="text-decoration:underline;" href="http://www.slideshare.net/anupnarkhede">anupnarkhede</a>.</div></div> <p>Here are few random snaps from the evening.</p> <div><object classid="clsid:d27cdb6e-ae6d-11cf-96b8-444553540000" width="400" height="300" codebase="http://download.macromedia.com/pub/shockwave/cabs/flash/swflash.cab#version=6,0,40,0"><param name="flashvars" value="offsite=true&amp;lang=en-us&amp;page_show_url=%2Fphotos%2F33416193%40N02%2Fsets%2F72157623282148351%2Fshow%2F&amp;page_show_back_url=%2Fphotos%2F33416193%40N02%2Fsets%2F72157623282148351%2F&amp;set_id=72157623282148351&amp;jump_to=" /><param name="allowFullScreen" value="true" /><param name="src" value="http://www.flickr.com/apps/slideshow/show.swf?v=71649" /><param name="allowfullscreen" value="true" /><embed type="application/x-shockwave-flash" width="400" height="300" src="http://www.flickr.com/apps/slideshow/show.swf?v=71649" allowfullscreen="true" flashvars="offsite=true&amp;lang=en-us&amp;page_show_url=%2Fphotos%2F33416193%40N02%2Fsets%2F72157623282148351%2Fshow%2F&amp;page_show_back_url=%2Fphotos%2F33416193%40N02%2Fsets%2F72157623282148351%2F&amp;set_id=72157623282148351&amp;jump_to="></embed></object></div><div class="feedflare">
<a href="http://feeds.feedburner.com/~ff/dynamic50?a=BLsxNOz9RsA:RAGbPrFLbFo:yIl2AUoC8zA"><img src="http://feeds.feedburner.com/~ff/dynamic50?d=yIl2AUoC8zA" border="0"></img></a>
</div>]]></content:encoded>
			<wfw:commentRss>http://blog.dynamic50.com/2010/02/11/lrug-february-2010/feed/</wfw:commentRss>
		<slash:comments>0</slash:comments>
		</item>
		<item>
		<title>Linear CSS3 Gradients – Mozilla</title>
		<link>http://blog.dynamic50.com/2010/02/09/linear-css3-gradients-mozilla/</link>
		<comments>http://blog.dynamic50.com/2010/02/09/linear-css3-gradients-mozilla/#comments</comments>
		<pubDate>Tue, 09 Feb 2010 14:21:42 +0000</pubDate>
		<dc:creator>Simon Tsang</dc:creator>
				<category><![CDATA[CSS Stylesheets]]></category>
		<category><![CDATA[General]]></category>
		<category><![CDATA[CSS3]]></category>
		<category><![CDATA[Firefox]]></category>
		<category><![CDATA[Gradients]]></category>
		<category><![CDATA[Mozilla]]></category>

		<guid isPermaLink="false">http://blog.dynamic50.com/?p=750</guid>
		<description><![CDATA[With the recent launch of Firefox 3.6, Firefox finally got support for CSS3 gradients (albeit vendor-specific). Safari (and other webkit based browsers) have had support for CSS gradients for a wee while now, and I will hopefully post about those in more detail in the near future. Today though is going to be exploring the [...]]]></description>
			<content:encoded><![CDATA[<p>With the recent launch of Firefox 3.6, Firefox finally got support for <span class="caps">CSS3 </span>gradients (albeit vendor-specific). Safari (and other webkit based browsers) have had support for <span class="caps">CSS </span>gradients for a wee while now, and I will hopefully post about those in more detail in the near future. Today though is going to be exploring the <code>-moz-linear-gradient</code> <em>value</em>. Radial gradients will have to wait for another day, once I can get my head around them : )</p>

<p>The advantage of using <span class="caps">CSS </span>gradients rather than a tiled image is flexibility and speed. Not needing to load up images can speed up your website performance by reducing both the data needed for a page and more importantly, <a href="http://developer.yahoo.com/performance/rules.html#num_http" target="_blank">http requests</a>. The flexibility comes from the fact that to change a gradient, you need only to change some colour values and/or positions, so no more firing up Photoshop just to change a gradient that starts from black to not-quite-as-black. In addition, using <span class="caps">CSS </span>gradients lets you draw gradients that span the full width or height of an element, no matter the size- something that can&#8217;t quite so easily with a background image.</p>

<h3 class="sifr">Usage</h3>

<p>The <code>-moz-linear-gradient</code> value can be used where background-image value is used. So for example, instead of using&#8230;</p>



<pre>
background-image: url(path/to/image.png);
</pre>



<p>you would use instead (taken from <a href="https://developer.mozilla.org/en/CSS/-moz-linear-gradient" target="_blank">Mozilla Documentation</a>)</p>



<pre>
background-image: -moz-linear-gradient( [&lt;point&gt; || &lt;angle&gt;,]? &lt;stop&gt;, &lt;stop&gt; [, &lt;stop&gt;]* );
</pre>



<p>In English, this means you need to provide it with&#8230;</p>

<ul>
<li>- a starting point or gradient angle (optional)</li>
<li>- a minimum or 2 colour positions</li>
</ul>

<h4 class="sifr">points and angles</h4>

<p>Inclusion of a point and/or angle is optional. If you do not specify one as the first parameter, the gradient will be assumed to go from top to bottom. If you do chose to specify this parameter, you can provide</p>

<ul>
	<li>- A single <code>point</code></li>
	<li>- A single <code>angle</code></li>
	<li>- A <code>point</code> and <code>angle</code> combination</li>

</ul>

<p>A <code>&lt;point&gt;</code> is the standard way of defining an x and y position in <span class="caps">CSS </span>i.e. keyword values such as &#8220;left&#8221;, &#8220;top&#8221;, &#8220;center&#8221; etc.; percentage values or other valid value unit. If you provide only one value, the other is assumed to to &#8220;center&#8221;.</p>

<p>The value of the <code>&lt;angle&gt;</code> can be specified in degrees (<code>deg</code>), gradians(<code>grad</code>) or radians(<code>rad</code>). Unlike the webkit implementation of <span class="caps">CSS </span>gradients, there is no way of defining the end point of the gradient. Instead, the end point is determined by what values you provide.</p>

<h5 class="sifr">&lt;point&gt;</h5>

<p>In the case that you provide only a <code>&lt;point&gt;</code> value, the end point is determined to be the point you would get if you rotated the starting point 180 degrees around the centre of the element being styled. It is much easier to see what is happening in an image, so here is an animation showing the process of creating a gradient with a <code>&lt;point&gt;</code> value of <code>center top</code>, fading from black to white.</p>

<div id="attachment_758" class="wp-caption aligncenter" style="width: 577px"><img src="http://testblog.dynamic50.com/wp-content/uploads/2010/02/mozlineargradient-center_top1.gif" alt="mozlineargradient center top1 Linear CSS3 Gradients   Mozilla" title="mozlineargradient-center_top" width="250" height="250" class="size-full wp-image-758" style="margin:auto;display:block" /><p class="wp-caption-text">-moz-linear-gradient(center top, #000, #fff)</p></div>

<p>The resulting element (Firefox 3.6+ users only):</p>

<div style="height:150px;width:150px;border:3px solid #999;background-image:-moz-linear-gradient(center top, #000, #fff);margin:0 auto 63px auto">&nbsp;</div>

<p>And just for clarity, here is another example, this time using a <code>&lt;point&gt;</code> value of <code>35% 60%</code></p>

<div id="attachment_766" class="wp-caption aligncenter" style="width: 577px"><img src="http://testblog.dynamic50.com/wp-content/uploads/2010/02/mozlineargradient-35_60.gif" alt="mozlineargradient 35 60 Linear CSS3 Gradients   Mozilla" title="mozlineargradient-35_60" width="250" height="250" class="size-full wp-image-766" style="margin:auto;display:block" /><p class="wp-caption-text">-moz-linear-gradient(35% 60%, #000, #fff)</p></div>

<p>And its resulting element:</p>

<div style="height:150px;width:150px;border:3px solid #999;background-image:-moz-linear-gradient(35% 60%, #000, #fff);margin:0 auto 63px auto">&nbsp;</div>

<h5 class="sifr">&lt;angle&gt;</h5>

<p>Determining what actually happens when you provide an <code>angle</code> is quite intuitive, but rather difficult to explain. The <a href="https://developer.mozilla.org/en/CSS/-moz-linear-gradient" target="_blank">Mozilla Developer Documentation</a> description of the process at first glance is pretty confusing, but does convey the right information. It is helpful however, to know that the angles are measured from the x-axis, with positive angles measured anti-clockwise.<br />
<img src="http://testblog.dynamic50.com/wp-content/uploads/2010/02/angles.gif" alt="angles Linear CSS3 Gradients   Mozilla" title="angles" width="250" height="250" class="aligncenter size-full wp-image-785" style="display:block;margin:auto" /></p>

<p>The short description is that it works, pretty much, just like the Gradient Overlay layer effect in Photoshop. The long description is something like this (assuming a specified angle of 150deg)&#8230;</p>

<p>The starting point is placed at one of the element corners (left top; right top; left bottom or right bottom).<br />
<img src="http://testblog.dynamic50.com/wp-content/uploads/2010/02/mozlineargradient-150deg-1.gif" alt="mozlineargradient 150deg 1 Linear CSS3 Gradients   Mozilla" title="mozlineargradient-150deg-1" width="250" height="250" class="aligncenter size-full wp-image-794" style="margin:auto;display:block" /></p>

<p>The corner used depends on the angle provided. The correct corner is the one that allows the specified angle to point <em>into</em> the element.<br />
<img src="http://testblog.dynamic50.com/wp-content/uploads/2010/02/mozlineargradient-150deg-2.gif" alt="mozlineargradient 150deg 2 Linear CSS3 Gradients   Mozilla" title="mozlineargradient-150deg-2" width="250" height="250" class="aligncenter size-full wp-image-795" style="margin:auto;display:block" /></p>

<p>To determine the ending point, you would need to imagine 2 others thing. First is to imagine a line drawn from your start point, along the specified angle (this is known as the axis).<br />
<img src="http://testblog.dynamic50.com/wp-content/uploads/2010/02/mozlineargradient-150deg-3.gif" alt="mozlineargradient 150deg 3 Linear CSS3 Gradients   Mozilla" title="mozlineargradient-150deg-3" width="250" height="250" class="aligncenter size-full wp-image-797" style="margin:auto;display:block" /></p>

<p>The second is to imagine a line drawn from the opposite corner, which is perpendicular to the axis.<br />
<img src="http://testblog.dynamic50.com/wp-content/uploads/2010/02/mozlineargradient-150deg-4.gif" alt="mozlineargradient 150deg 4 Linear CSS3 Gradients   Mozilla" title="mozlineargradient-150deg-4" width="250" height="250" class="aligncenter size-full wp-image-798" style="margin:auto;display:block" /></p>

<p>The ending point would be where these 2 lines meet.<br />
<img src="http://testblog.dynamic50.com/wp-content/uploads/2010/02/mozlineargradient-150deg-5.gif" alt="mozlineargradient 150deg 5 Linear CSS3 Gradients   Mozilla" title="mozlineargradient-150deg-5" width="250" height="250" class="aligncenter size-full wp-image-799" style="margin:auto;display:block" /></p>

<p>And for sake of completenes, here is the full animation</p>

<div id="attachment_802" class="wp-caption aligncenter" style="width: 577px"><img src="http://testblog.dynamic50.com/wp-content/uploads/2010/02/mozlineargradient-150deg.gif" alt="mozlineargradient 150deg Linear CSS3 Gradients   Mozilla" title="mozlineargradient-150deg" width="250" height="250" class="size-full wp-image-802" style="margin:auto;display:block" /><p class="wp-caption-text">-moz-linear-gradient(150deg, #000,#fff)</p></div>

<p>And the resulting element:</p>

<div style="height:150px;width:150px;border:3px solid #999;background-image:-moz-linear-gradient(150deg, #000, #fff);margin:0 auto 63px auto">&nbsp;</div>

<h5 class="sifr">point angle combo</h5>

<p>Providing both a <code>&lt;point&gt;</code> and an <code>&lt;angle&gt;</code> works as you would expect. The start point is taken as the point you provide, and the angle is then drawn as shown above.</p>

<h4 class="sifr">&lt;stop&gt;</h4>

<p>The <code>&lt;stop&gt;</code> value describes 2 things: a colour and the position along the axis at which the colour should appear. As such, a <code>&lt;stop&gt;</code> takes 2 values: a colour value and an optional length value, separated by a space. A gradient will be created from one stop to the next, blending the colour (and even opacity) as needed. Some valid examples would be&#8230;</p>



<pre>
#fff
#999 50%
#a909f2 80px
rgba(255,255,255,0.5) 6em
</pre>



<p>You are required to provide at least 2 stop values, one for the start and one for the end of the gradient. If the first stop value has no position, it is assumed to be 0. If the last stop value has no position, it is assumed to be 100%. For any other <code>&lt;stop&gt;</code> values without positions, it is assumed to be half way between the previous and next <code>&lt;stop&gt;</code> values. Adding additional <code>&lt;stop&gt;</code> values is as easy as chaining them together, separated with a comma (,).</p>

<p>Piecing all these bits together (along with some other css3 bits) we can create some subtle but nice effects such as a glass effect button (Firefox 3.6+ only!).<br />
<a href="#" id="example" style="display:block;width:50px;margin:18px auto;text-decoration:none;text-align:center;font-weight:bold;padding:5px 10px;color:#fff;background-color:#000;background-image:-moz-linear-gradient(center top,rgba(255, 255, 255, 0.5) 0pt,rgba(255, 255, 255, 0.33) 50%,rgba(255, 255, 255, 0) 50%,rgba(255, 255, 255, 0.2) 100%);-moz-border-radius:9px;text-shadow:-1px -1px 0 rgba(0, 0, 0, 0.5);-moz-box-shadow:-1px -1px 0 rgba(255, 255, 255, 0.5), 1px 1px 0 #000000">Button</a></p>

<p>The gradient part of the styling is like so&#8230;</p>



<pre>
a#example{
  background-color: #000;
  background-image: -moz-linear-gradient(
    center top,
    rgba(255, 255, 255, 0.5) 0pt,
    rgba(255, 255, 255, 0.33) 50%,
    rgba(255, 255, 255, 0) 50%,
    rgba(255, 255, 255, 0.2) 100%);
}
</pre><div class="feedflare">
<a href="http://feeds.feedburner.com/~ff/dynamic50?a=TB_6JDK2Svk:8DrenFDxQSg:yIl2AUoC8zA"><img src="http://feeds.feedburner.com/~ff/dynamic50?d=yIl2AUoC8zA" border="0"></img></a>
</div>]]></content:encoded>
			<wfw:commentRss>http://blog.dynamic50.com/2010/02/09/linear-css3-gradients-mozilla/feed/</wfw:commentRss>
		<slash:comments>0</slash:comments>
		</item>
	</channel>
</rss>
