<?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>Leonard Teo</title>
	<atom:link href="http://www.leonardteo.com/feed/" rel="self" type="application/rss+xml" />
	<link>http://www.leonardteo.com</link>
	<description></description>
	<lastBuildDate>Sat, 28 Jan 2012 02:47:59 +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>Bak Kut Teh &#8211; Chinese Pork Rib Soup</title>
		<link>http://www.leonardteo.com/2012/01/bak-kut-teh-chinese-pork-rib-soup/</link>
		<comments>http://www.leonardteo.com/2012/01/bak-kut-teh-chinese-pork-rib-soup/#comments</comments>
		<pubDate>Sat, 28 Jan 2012 02:43:55 +0000</pubDate>
		<dc:creator>Leo</dc:creator>
				<category><![CDATA[Food]]></category>
		<category><![CDATA[Reminders to myself]]></category>

		<guid isPermaLink="false">http://www.leonardteo.com/?p=694</guid>
		<description><![CDATA[I&#8217;ve been experimenting with making bak kut teh &#8211; basically pork rib soup. It&#8217;s super yummy. I finally got it down tonight. Ingredients (serves 2) ~900 grams of pork ribs 1 bulb of garlic (yes, a whole bulb) &#8211; take out all the cloves and peel them 5 star anise 3 cinnamon sticks 1 tablespoon [...]]]></description>
			<content:encoded><![CDATA[<p>I&#8217;ve been experimenting with making bak kut teh &#8211; basically pork rib soup. It&#8217;s super yummy. I finally got it down tonight.</p>
<p><strong>Ingredients (serves 2)</strong></p>
<ul>
<li>~900 grams of pork ribs</li>
<li>1 bulb of garlic (yes, a whole bulb) &#8211; take out all the cloves and peel them</li>
<li>5 star anise</li>
<li>3 cinnamon sticks</li>
<li>1 tablespoon of white peppercorns</li>
<li>1 tablespoon of black peppercorns</li>
<li>1 teaspoon of ginger</li>
<li>A pot of boiling water filled about 1/3 &#8211; enough to cover the pork ribs</li>
</ul>
<p>Cut the pork ribs into individual pieces. Throw into boiling water. Throw in everything. Cover, cook for 1 hour. If you lose water while cooking, just add more. No biggie. This is not a precise dish.</p>
<p>Give each person a bowl of soup with pork ribs.</p>
<p>Serve with steamed rice. Make soy sauce available to put in the soup or rice.</p>
<p>The above is super easy and very very tasty.</p>
]]></content:encoded>
			<wfw:commentRss>http://www.leonardteo.com/2012/01/bak-kut-teh-chinese-pork-rib-soup/feed/</wfw:commentRss>
		<slash:comments>0</slash:comments>
		</item>
		<item>
		<title>Ubuntu 11.10 Sound Blaster X-Fi ridiculous workaround</title>
		<link>http://www.leonardteo.com/2012/01/ubuntu-11-10-sound-blaster-x-fi-ridiculous-workaround/</link>
		<comments>http://www.leonardteo.com/2012/01/ubuntu-11-10-sound-blaster-x-fi-ridiculous-workaround/#comments</comments>
		<pubDate>Wed, 25 Jan 2012 02:07:06 +0000</pubDate>
		<dc:creator>Leo</dc:creator>
				<category><![CDATA[Reminders to myself]]></category>

		<guid isPermaLink="false">http://www.leonardteo.com/?p=692</guid>
		<description><![CDATA[Since I installed Ubuntu 11.10, my Sound Blaster X-Fi sound card stutters and doesn&#8217;t play back sound. The way to fix this is to open terminal and run &#8220;ubuntu-bug&#8221;. That&#8217;s it. Plays back fine until next reboot. Ridiculous bug.]]></description>
			<content:encoded><![CDATA[<p>Since I installed Ubuntu 11.10, my Sound Blaster X-Fi sound card stutters and doesn&#8217;t play back sound. The way to fix this is to open terminal and run &#8220;ubuntu-bug&#8221;. That&#8217;s it. Plays back fine until next reboot.</p>
<p>Ridiculous bug.</p>
]]></content:encoded>
			<wfw:commentRss>http://www.leonardteo.com/2012/01/ubuntu-11-10-sound-blaster-x-fi-ridiculous-workaround/feed/</wfw:commentRss>
		<slash:comments>0</slash:comments>
		</item>
		<item>
		<title>Steak on Mushrooms with Red Wine Sauce and Caesar Salad</title>
		<link>http://www.leonardteo.com/2012/01/steak-on-mushrooms-and-caesar-salad/</link>
		<comments>http://www.leonardteo.com/2012/01/steak-on-mushrooms-and-caesar-salad/#comments</comments>
		<pubDate>Mon, 16 Jan 2012 01:32:05 +0000</pubDate>
		<dc:creator>Leo</dc:creator>
				<category><![CDATA[Food]]></category>
		<category><![CDATA[Rambling]]></category>
		<category><![CDATA[Reminders to myself]]></category>

		<guid isPermaLink="false">http://www.leonardteo.com/?p=680</guid>
		<description><![CDATA[One of my new year resolutions in 2012 is to try a new recipe every weekend. I decided this weekend to try a steak on mushrooms with red wine sauce. I found this recipe on Epicurious and adapted it to stuff I could easily buy at the local grocery store. I also made a caesar salad [...]]]></description>
			<content:encoded><![CDATA[<p>One of my new year resolutions in 2012 is to try a new recipe every weekend. I decided this weekend to try a steak on mushrooms with red wine sauce. I found this recipe on <a href="http://www.epicurious.com/recipes/food/views/Hanger-Steak-with-Mushrooms-and-Red-Wine-Sauce-367758">Epicurious</a> and adapted it to stuff I could easily buy at the local grocery store. I also made a caesar salad from scratch. This serves as a reminder to myself so that I can cook the same thing again.</p>
<p><a href="http://www.leonardteo.com/wp-content/uploads/2012/01/hangarsteak.jpg"><img class="aligncenter size-medium wp-image-682 colorbox-680" title="hangarsteak" src="http://www.leonardteo.com/wp-content/uploads/2012/01/hangarsteak-500x375.jpg" alt="" width="500" height="375" /></a></p>
<h2>Steak on Mushrooms with Red Wine Sauce</h2>
<ul>
<li>3 tablespoons extra-virgin olive oil</li>
<li>12 ounces mixed mushrooms, cut up</li>
<li>Table salt</li>
<li>Ground black pepper</li>
<li>4 tablespoons butter</li>
<li>1.5 pounds steak</li>
<li>3 garlic cloves diced</li>
<li>1x 6&#8243; sprig rosemary</li>
<li>1 cup red wine</li>
<li>3/4 cup chicken stock</li>
</ul>
<div>Heat 2 tablespoons of olive oil in skillet on medium heat. Sautee mushrooms, put on some salt and pepper. Put aside.</div>
<div></div>
<div>Melt about 1 tablespoon of butter in the same skillet. Put in steak, garlic and rosemary. Cook roughly 3 mins per side, until medium rare. Transfer steak, garlic and rosemary to cutting board.</div>
<div></div>
<div>In the same skillet, put in wine. Boil for 3 mins. Pour in chicken stock. Bring to boil for about 5 mins, boiling it down. Mix in 3 tablespoons of butter. Put in mushrooms. Season with salt and ground black pepper.</div>
<div></div>
<div>Put mushrooms and some sauce onto serving plates. Slice meat. Put on top of mushrooms.</div>
<div></div>
<div>Eat with a good, hearty red wine. We had a cabernet savignon.</div>
<div>&nbsp;</div>
<div>&nbsp;</div>
<h2>Caesar Salad from Scratch</h2>
<div>This recipe is adapted from <a href="http://www.grouprecipes.com/46082/real-caesar-dressing.html">this one</a>.</div>
<div>
<ul>
<li>2 egg yolks</li>
<li>2 tablespoons dijon mustard</li>
<li>bacon bits (buy a packet)</li>
<li>4 cloves chopped garlic</li>
<li>4 tablespoons balsamic vinegar</li>
<li>3 tablespoons lemon juice</li>
<li>dash of worcestershire sauce</li>
<li>1 cup olive oil</li>
<li>2-3 tablespoons of parmesan cheese</li>
<li>Romain lettuce</li>
<li>Croutons</li>
</ul>
<div>Mix egg yolk, mustard, bacon, garlic, balsamic vinegar, lemon juice and worcestershire sauce in bowl. Slowly add olive oil while mixing. Add parmesan cheese.</div>
</div>
<div></div>
<div>Wash and chop romain lettuce. Spin in salad spinner.</div>
<div></div>
<div>Serve as a bed of lettuce and croutons. Let guests put on the dressing themselves.</div>
<div></div>
<div>The above is awesome. Very tasty caesar salad and much much better than store bought caesar dressing.</div>
]]></content:encoded>
			<wfw:commentRss>http://www.leonardteo.com/2012/01/steak-on-mushrooms-and-caesar-salad/feed/</wfw:commentRss>
		<slash:comments>0</slash:comments>
		</item>
		<item>
		<title>2012 Resolution: Retire Internet Explorer 8</title>
		<link>http://www.leonardteo.com/2011/12/2012-resolution-retire-internet-explorer-8/</link>
		<comments>http://www.leonardteo.com/2011/12/2012-resolution-retire-internet-explorer-8/#comments</comments>
		<pubDate>Sat, 31 Dec 2011 14:45:51 +0000</pubDate>
		<dc:creator>Leo</dc:creator>
				<category><![CDATA[Rambling]]></category>
		<category><![CDATA[Web Development]]></category>

		<guid isPermaLink="false">http://www.leonardteo.com/?p=670</guid>
		<description><![CDATA[One of the biggest frustrations that I have as a professional web developer is Internet Explorer &#8211; more specifically IE8, which is currently refusing to die because it is &#8220;good enough but not quite&#8221;. Here we are, trying to move forward with new technology on HTML5 standards that work across most modern browsers, except things [...]]]></description>
			<content:encoded><![CDATA[<p>One of the biggest frustrations that I have as a professional web developer is Internet Explorer &#8211; more specifically IE8, which is currently refusing to die because it is &#8220;good enough but not quite&#8221;. Here we are, trying to move forward with new technology on HTML5 standards that work across most modern browsers, except things don&#8217;t look or work quite right in IE8. Corporations still give out computers to employees with IE8 pre-installed. Enough is enough. Let&#8217;s make 2012 the year that we, as a body of web professionals, begin to retire IE8.</p>
<h2>How?</h2>
<p>From now on, every site that I deliver for clients will have, by default, an <a href="http://www.ie8nomore.com">IE8nomore</a> header (or variant), which will only show up when a user with IE8 or less browses to the site. If a client specifically wants me to support IE8, they will need to pay extra for it. It&#8217;s that simple. Clients need to be educated that IE8 is just bad software. If they have the chance to tell you that a site you created doesn&#8217;t work in IE8, you&#8217;re too late. You need to put the header in <em>by default</em> so that when they, or their colleagues browse to your site, they immediately see that their browser is outdated. It&#8217;s psychological. <em>They</em> need to upgrade. <em>You</em> don&#8217;t need to lower your standards.</p>
<p><a href="http://www.leonardteo.com/wp-content/uploads/2011/12/ie8nomore.jpg"><img class="aligncenter size-full wp-image-671 colorbox-670" title="ie8nomore" src="http://www.leonardteo.com/wp-content/uploads/2011/12/ie8nomore.jpg" alt="" width="604" height="82" /></a></p>
<p>If you&#8217;re a professional web developer, make it your resolution. Let&#8217;s rid the world of standard-less browsers. Let&#8217;s nail IE8 and please be done with it.</p>
<h2>Links</h2>
<p><a href="http://ie8nomore.com/">IE8nomore header</a><br />
<a href="http://www.ie6nomore.com/">IE6nomore header</a> (the original)</p>
]]></content:encoded>
			<wfw:commentRss>http://www.leonardteo.com/2011/12/2012-resolution-retire-internet-explorer-8/feed/</wfw:commentRss>
		<slash:comments>0</slash:comments>
		</item>
		<item>
		<title>Rails, Bootstrap and will_paginate</title>
		<link>http://www.leonardteo.com/2011/12/rails-bootstrap-and-will_paginate/</link>
		<comments>http://www.leonardteo.com/2011/12/rails-bootstrap-and-will_paginate/#comments</comments>
		<pubDate>Thu, 29 Dec 2011 14:13:55 +0000</pubDate>
		<dc:creator>Leo</dc:creator>
				<category><![CDATA[Reminders to myself]]></category>
		<category><![CDATA[Web Development]]></category>

		<guid isPermaLink="false">http://www.leonardteo.com/?p=642</guid>
		<description><![CDATA[If you&#8217;re using Ruby on Rails, you&#8217;ll likely use the will_paginate plugin. If you use Twitter&#8217;s Bootstrap CSS framework as well, you&#8217;ll notice that the pagination is all messed up. This gist fixes it: # application_helper.rb # https://gist.github.com/1205828 # Based on https://gist.github.com/1182136 class BootstrapLinkRenderer &#60; ::WillPaginate::ViewHelpers::LinkRenderer protected &#160; def html_container&#40;html&#41; tag :div, tag&#40;:ul, html&#41;, container_attributes [...]]]></description>
			<content:encoded><![CDATA[<p>If you&#8217;re using Ruby on Rails, you&#8217;ll likely use the will_paginate plugin. If you use Twitter&#8217;s Bootstrap CSS framework as well, you&#8217;ll notice that the pagination is all messed up. This <a href="https://gist.github.com/1205828">gist</a> fixes it:</p>

<div class="wp_syntax"><div class="code"><pre class="ruby" style="font-family:monospace;">  <span style="color:#008000; font-style:italic;"># application_helper.rb</span>
  <span style="color:#008000; font-style:italic;"># https://gist.github.com/1205828</span>
  <span style="color:#008000; font-style:italic;"># Based on https://gist.github.com/1182136</span>
  <span style="color:#9966CC; font-weight:bold;">class</span> BootstrapLinkRenderer <span style="color:#006600; font-weight:bold;">&lt;</span> ::<span style="color:#6666ff; font-weight:bold;">WillPaginate::ViewHelpers::LinkRenderer</span>
    protected
&nbsp;
    <span style="color:#9966CC; font-weight:bold;">def</span> html_container<span style="color:#006600; font-weight:bold;">&#40;</span>html<span style="color:#006600; font-weight:bold;">&#41;</span>
      tag <span style="color:#ff3333; font-weight:bold;">:div</span>, tag<span style="color:#006600; font-weight:bold;">&#40;</span><span style="color:#ff3333; font-weight:bold;">:ul</span>, html<span style="color:#006600; font-weight:bold;">&#41;</span>, container_attributes
    <span style="color:#9966CC; font-weight:bold;">end</span>
&nbsp;
    <span style="color:#9966CC; font-weight:bold;">def</span> page_number<span style="color:#006600; font-weight:bold;">&#40;</span>page<span style="color:#006600; font-weight:bold;">&#41;</span>
      tag <span style="color:#ff3333; font-weight:bold;">:li</span>, link<span style="color:#006600; font-weight:bold;">&#40;</span>page, page, <span style="color:#ff3333; font-weight:bold;">:rel</span> <span style="color:#006600; font-weight:bold;">=&gt;</span> rel_value<span style="color:#006600; font-weight:bold;">&#40;</span>page<span style="color:#006600; font-weight:bold;">&#41;</span><span style="color:#006600; font-weight:bold;">&#41;</span>, :<span style="color:#9966CC; font-weight:bold;">class</span> <span style="color:#006600; font-weight:bold;">=&gt;</span> <span style="color:#006600; font-weight:bold;">&#40;</span><span style="color:#996600;">'active'</span> <span style="color:#9966CC; font-weight:bold;">if</span> page == current_page<span style="color:#006600; font-weight:bold;">&#41;</span>
    <span style="color:#9966CC; font-weight:bold;">end</span>
&nbsp;
    <span style="color:#9966CC; font-weight:bold;">def</span> gap
      tag <span style="color:#ff3333; font-weight:bold;">:li</span>, link<span style="color:#006600; font-weight:bold;">&#40;</span><span style="color:#9966CC; font-weight:bold;">super</span>, <span style="color:#996600;">'#'</span><span style="color:#006600; font-weight:bold;">&#41;</span>, :<span style="color:#9966CC; font-weight:bold;">class</span> <span style="color:#006600; font-weight:bold;">=&gt;</span> <span style="color:#996600;">'disabled'</span>
    <span style="color:#9966CC; font-weight:bold;">end</span>
&nbsp;
    <span style="color:#9966CC; font-weight:bold;">def</span> previous_or_next_page<span style="color:#006600; font-weight:bold;">&#40;</span>page, text, classname<span style="color:#006600; font-weight:bold;">&#41;</span>
      tag <span style="color:#ff3333; font-weight:bold;">:li</span>, link<span style="color:#006600; font-weight:bold;">&#40;</span>text, page <span style="color:#006600; font-weight:bold;">||</span> <span style="color:#996600;">'#'</span><span style="color:#006600; font-weight:bold;">&#41;</span>, :<span style="color:#9966CC; font-weight:bold;">class</span> <span style="color:#006600; font-weight:bold;">=&gt;</span> <span style="color:#006600; font-weight:bold;">&#91;</span>classname<span style="color:#006600; font-weight:bold;">&#91;</span><span style="color:#006666;">0</span>..<span style="color:#006666;">3</span><span style="color:#006600; font-weight:bold;">&#93;</span>, classname, <span style="color:#006600; font-weight:bold;">&#40;</span><span style="color:#996600;">'disabled'</span> <span style="color:#9966CC; font-weight:bold;">unless</span> page<span style="color:#006600; font-weight:bold;">&#41;</span><span style="color:#006600; font-weight:bold;">&#93;</span>.<span style="color:#9900CC;">join</span><span style="color:#006600; font-weight:bold;">&#40;</span><span style="color:#996600;">' '</span><span style="color:#006600; font-weight:bold;">&#41;</span>
    <span style="color:#9966CC; font-weight:bold;">end</span>
  <span style="color:#9966CC; font-weight:bold;">end</span>
&nbsp;
  <span style="color:#9966CC; font-weight:bold;">def</span> page_navigation_links<span style="color:#006600; font-weight:bold;">&#40;</span>pages<span style="color:#006600; font-weight:bold;">&#41;</span>
    will_paginate<span style="color:#006600; font-weight:bold;">&#40;</span>pages, :<span style="color:#9966CC; font-weight:bold;">class</span> <span style="color:#006600; font-weight:bold;">=&gt;</span> <span style="color:#996600;">'pagination'</span>, <span style="color:#ff3333; font-weight:bold;">:inner_window</span> <span style="color:#006600; font-weight:bold;">=&gt;</span> <span style="color:#006666;">2</span>, <span style="color:#ff3333; font-weight:bold;">:outer_window</span> <span style="color:#006600; font-weight:bold;">=&gt;</span> <span style="color:#006666;">0</span>, <span style="color:#ff3333; font-weight:bold;">:renderer</span> <span style="color:#006600; font-weight:bold;">=&gt;</span> BootstrapLinkRenderer, <span style="color:#ff3333; font-weight:bold;">:previous_label</span> <span style="color:#006600; font-weight:bold;">=&gt;</span> <span style="color:#996600;">'&amp;larr;'</span>.<span style="color:#9900CC;">html_safe</span>, <span style="color:#ff3333; font-weight:bold;">:next_label</span> <span style="color:#006600; font-weight:bold;">=&gt;</span> <span style="color:#996600;">'&amp;rarr;'</span>.<span style="color:#9900CC;">html_safe</span><span style="color:#006600; font-weight:bold;">&#41;</span>
  <span style="color:#9966CC; font-weight:bold;">end</span></pre></div></div>

]]></content:encoded>
			<wfw:commentRss>http://www.leonardteo.com/2011/12/rails-bootstrap-and-will_paginate/feed/</wfw:commentRss>
		<slash:comments>0</slash:comments>
		</item>
		<item>
		<title>Deploying Ruby on Rails 3.1 on Ubuntu</title>
		<link>http://www.leonardteo.com/2011/12/deploying-ruby-on-rails-on-ubuntu/</link>
		<comments>http://www.leonardteo.com/2011/12/deploying-ruby-on-rails-on-ubuntu/#comments</comments>
		<pubDate>Tue, 27 Dec 2011 07:18:48 +0000</pubDate>
		<dc:creator>Leo</dc:creator>
				<category><![CDATA[Reminders to myself]]></category>
		<category><![CDATA[Web Development]]></category>

		<guid isPermaLink="false">http://www.leonardteo.com/?p=618</guid>
		<description><![CDATA[This serves as a reminder for me on getting Ruby on Rails 3.1.3 running on Ubuntu (tested on 10.01 LTS). Install git using apt-get: sudo apt-get install git-svn Install build dependencies: sudo apt-get install gcc g++ build-essential libssl-dev libreadline5-dev zlib1g-dev linux-headers-generic libsqlite3-dev Install rvm (Ruby Version Manager) bash -s stable &#60; &#60;&#40;curl -s https://raw.github.com/wayneeseguin/rvm/master/binscripts/rvm-installer &#41; [...]]]></description>
			<content:encoded><![CDATA[<p>This serves as a reminder for me on getting Ruby on Rails 3.1.3 running on Ubuntu (tested on 10.01 LTS). </p>
<p>Install git using apt-get:</p>

<div class="wp_syntax"><div class="code"><pre class="bash" style="font-family:monospace;"><span style="color: #c20cb9; font-weight: bold;">sudo</span> <span style="color: #c20cb9; font-weight: bold;">apt-get</span> <span style="color: #c20cb9; font-weight: bold;">install</span> <span style="color: #c20cb9; font-weight: bold;">git-svn</span></pre></div></div>

<p>Install build dependencies:</p>

<div class="wp_syntax"><div class="code"><pre class="bash" style="font-family:monospace;"><span style="color: #c20cb9; font-weight: bold;">sudo</span> <span style="color: #c20cb9; font-weight: bold;">apt-get</span> <span style="color: #c20cb9; font-weight: bold;">install</span> <span style="color: #c20cb9; font-weight: bold;">gcc</span> <span style="color: #c20cb9; font-weight: bold;">g++</span> build-essential libssl-dev libreadline5-dev zlib1g-dev linux-headers-generic libsqlite3-dev</pre></div></div>

<p>Install rvm (Ruby Version Manager)</p>

<div class="wp_syntax"><div class="code"><pre class="bash" style="font-family:monospace;"><span style="color: #c20cb9; font-weight: bold;">bash</span> <span style="color: #660033;">-s</span> stable <span style="color: #000000; font-weight: bold;">&lt;</span> <span style="color: #000000; font-weight: bold;">&lt;</span><span style="color: #7a0874; font-weight: bold;">&#40;</span>curl <span style="color: #660033;">-s</span> https:<span style="color: #000000; font-weight: bold;">//</span>raw.github.com<span style="color: #000000; font-weight: bold;">/</span>wayneeseguin<span style="color: #000000; font-weight: bold;">/</span>rvm<span style="color: #000000; font-weight: bold;">/</span>master<span style="color: #000000; font-weight: bold;">/</span>binscripts<span style="color: #000000; font-weight: bold;">/</span>rvm-installer <span style="color: #7a0874; font-weight: bold;">&#41;</span></pre></div></div>

<p>Put RVM into .bash_rc file so that you can run it easily:</p>

<div class="wp_syntax"><div class="code"><pre class="bash" style="font-family:monospace;"><span style="color: #7a0874; font-weight: bold;">echo</span> <span style="color: #ff0000;">'[[ -s &quot;$HOME/.rvm/scripts/rvm&quot; ]] &amp;&amp; . &quot;$HOME/.rvm/scripts/rvm&quot; # Load RVM function'</span> <span style="color: #000000; font-weight: bold;">&gt;&gt;</span> ~<span style="color: #000000; font-weight: bold;">/</span>.bash_rc</pre></div></div>

<p>Reload bash settings:</p>

<div class="wp_syntax"><div class="code"><pre class="bash" style="font-family:monospace;"><span style="color: #7a0874; font-weight: bold;">source</span> ~<span style="color: #000000; font-weight: bold;">/</span>.bash_rc</pre></div></div>

<p>That should install rvm. Now you can use it to install Ruby:</p>

<div class="wp_syntax"><div class="code"><pre class="bash" style="font-family:monospace;">rvm <span style="color: #c20cb9; font-weight: bold;">install</span> 1.9.2</pre></div></div>

<p>Make sure to switch into the correct version of Ruby:</p>

<div class="wp_syntax"><div class="code"><pre class="bash" style="font-family:monospace;">rvm use 1.9.2</pre></div></div>

<p>Install Rails:</p>

<div class="wp_syntax"><div class="code"><pre class="bash" style="font-family:monospace;">gem <span style="color: #c20cb9; font-weight: bold;">install</span> rails</pre></div></div>

<p>This takes a while&#8230;.</p>
<p>Install Apache:</p>

<div class="wp_syntax"><div class="code"><pre class="bash" style="font-family:monospace;"><span style="color: #c20cb9; font-weight: bold;">sudo</span> <span style="color: #c20cb9; font-weight: bold;">apt-get</span> <span style="color: #c20cb9; font-weight: bold;">install</span> apache2</pre></div></div>

<p>Install Phusion Passenger:</p>

<div class="wp_syntax"><div class="code"><pre class="bash" style="font-family:monospace;">gem <span style="color: #c20cb9; font-weight: bold;">install</span> passenger</pre></div></div>


<div class="wp_syntax"><div class="code"><pre class="bash" style="font-family:monospace;">passenger-install-apache2-module</pre></div></div>

<p>Follow the instructions on screen.</p>
<p>Setup Apache virtual hosting the way you normally do. Make the DocumentRoot the rails public directory.</p>

<div class="wp_syntax"><div class="code"><pre class="apache" style="font-family:monospace;">&lt;<span style="color: #000000; font-weight:bold;">VirtualHost</span> *:<span style="color: #ff0000;">80</span>&gt;
        <span style="color: #00007f;">ServerName</span> ec2-<span style="color: #ff0000;">107</span>-<span style="color: #ff0000;">21</span>-<span style="color: #ff0000;">154</span>-<span style="color: #ff0000;">173</span>.compute-<span style="color: #ff0000;">1</span>.amazonaws.com
        RailsEnv production
        <span style="color: #00007f;">DocumentRoot</span> /home/ubuntu/depot/public
        &lt;<span style="color: #000000; font-weight:bold;">Directory</span> /home/ubuntu/depot/public&gt;
                <span style="color: #00007f;">Options</span> <span style="color: #0000ff;">Indexes</span> <span style="color: #0000ff;">FollowSymLinks</span> MultiViews
                <span style="color: #00007f;">AllowOverride</span> <span style="color: #0000ff;">All</span>
                <span style="color: #00007f;">Order</span> <span style="color: #00007f;">allow</span>,<span style="color: #00007f;">deny</span>
                <span style="color: #00007f;">allow</span> from <span style="color: #0000ff;">all</span>
        &lt;/<span style="color: #000000; font-weight:bold;">Directory</span>&gt;
&nbsp;
&lt;/<span style="color: #000000; font-weight:bold;">VirtualHost</span>&gt;</pre></div></div>

<p>When deploying an app make sure to run bundle install to make sure all the dependencies are installed. This includes mysql, etc.</p>
<p>Rails 3.1 needs a Javascript runtime. </p>
<p>Add this to your gemfile:</p>

<div class="wp_syntax"><div class="code"><pre class="ruby" style="font-family:monospace;">gem <span style="color:#996600;">'execjs'</span>
gem <span style="color:#996600;">'therubyracer'</span></pre></div></div>

<p>Run:</p>

<div class="wp_syntax"><div class="code"><pre class="bash" style="font-family:monospace;">bundle <span style="color: #c20cb9; font-weight: bold;">install</span></pre></div></div>

<p>Make sure to setup your DB using:</p>

<div class="wp_syntax"><div class="code"><pre class="bash" style="font-family:monospace;">rake db:setup <span style="color: #007800;">RAILS_ENV</span>=<span style="color: #ff0000;">&quot;production&quot;</span></pre></div></div>

<p>Restart apache:</p>

<div class="wp_syntax"><div class="code"><pre class="bash" style="font-family:monospace;"><span style="color: #c20cb9; font-weight: bold;">sudo</span> service apache2 restart</pre></div></div>

<p>Load your browser and visit the site. Hopefully it works, if it doesn&#8217;t, check logs/production.log and trace from there.</p>
<h2>Asset Pipeline Gotchas</h2>
<p>The new asset pipeline in Rails may cause your app to fail. </p>
<p>When you deploy an app, make sure that you precompile the assets using:</p>

<div class="wp_syntax"><div class="code"><pre class="bash" style="font-family:monospace;">bundle <span style="color: #7a0874; font-weight: bold;">exec</span> rake assets:precompile</pre></div></div>

<p>If you are including css files that are not in your application.css manifest, you need to manually include them in your config/environments/production.rb:</p>

<div class="wp_syntax"><div class="code"><pre class="ruby" style="font-family:monospace;">config.<span style="color:#9900CC;">assets</span>.<span style="color:#9900CC;">precompile</span> <span style="color:#006600; font-weight:bold;">+</span>= <span style="color:#006600; font-weight:bold;">&#91;</span><span style="color:#996600;">'960.css'</span><span style="color:#006600; font-weight:bold;">&#93;</span></pre></div></div>

<p>Note: After recompiling assets you will need to restart your rails app. Do this either by restarting apache or creating/modifying &#8220;tmp/restart.txt&#8221; in your rails app. Passenger will look at the timestamp for restart.txt and restart rails accordingly.</p>
]]></content:encoded>
			<wfw:commentRss>http://www.leonardteo.com/2011/12/deploying-ruby-on-rails-on-ubuntu/feed/</wfw:commentRss>
		<slash:comments>0</slash:comments>
		</item>
		<item>
		<title>Rcconf &#8211; Tool to edit Linux boot services</title>
		<link>http://www.leonardteo.com/2011/11/rcconf-tool-to-edit-linux-boot-services/</link>
		<comments>http://www.leonardteo.com/2011/11/rcconf-tool-to-edit-linux-boot-services/#comments</comments>
		<pubDate>Tue, 15 Nov 2011 20:53:07 +0000</pubDate>
		<dc:creator>Leo</dc:creator>
				<category><![CDATA[Reminders to myself]]></category>
		<category><![CDATA[Web Development]]></category>

		<guid isPermaLink="false">http://www.leonardteo.com/?p=610</guid>
		<description><![CDATA[I know I&#8217;ll forget this because I only have to edit runlevel services once in a blue moon. Use a tool called rcconf. You may have to install it using apt-get.]]></description>
			<content:encoded><![CDATA[<p>I know I&#8217;ll forget this because I only have to edit runlevel services once in a blue moon. Use a tool called rcconf. You may have to install it using apt-get.</p>
]]></content:encoded>
			<wfw:commentRss>http://www.leonardteo.com/2011/11/rcconf-tool-to-edit-linux-boot-services/feed/</wfw:commentRss>
		<slash:comments>0</slash:comments>
		</item>
		<item>
		<title>Video Textures SIGGRAPH Paper Implementation</title>
		<link>http://www.leonardteo.com/2011/11/video-textures-siggraph-paper-implementation/</link>
		<comments>http://www.leonardteo.com/2011/11/video-textures-siggraph-paper-implementation/#comments</comments>
		<pubDate>Mon, 14 Nov 2011 23:25:40 +0000</pubDate>
		<dc:creator>Leo</dc:creator>
				<category><![CDATA[Computer Graphics]]></category>

		<guid isPermaLink="false">http://www.leonardteo.com/?p=604</guid>
		<description><![CDATA[I&#8217;m doing another course at Concordia to keep my brain active. This term, I was asked to implement the Video Textures SIGGRAPH paper by Schodl et al (2000). Schodl&#8217;s paper introduces a new medium called a “video texture” (not to be mistaken with a texture map that uses an video file as its source). Basically [...]]]></description>
			<content:encoded><![CDATA[<p>I&#8217;m doing another course at Concordia to keep my brain active. This term, I was asked to implement the <a href="http://www.cc.gatech.edu/cpl/projects/videotexture/SIGGRAPH2000/index.htm">Video Textures SIGGRAPH paper by Schodl et al (2000)</a>. Schodl&#8217;s paper introduces a new medium called a “video texture” (not to be mistaken with a texture map that uses an video file as its source). Basically the paper involves taking arbitrary input video footage and turning it into infinitely looping videos. I implemented the video texture synthesis in C++ on Mac OS X, utilizing the OpenCV framework. I also integrated the video textures in an OpenGL application.</p>
<p><a href="http://www.leonardteo.com/videotextures">Read my paper here</a></p>
<p><a href="http://www.leonardteo.com/2011/11/video-textures-siggraph-paper-implementation/"><em>Click here to view the embedded video.</em></a></p>
]]></content:encoded>
			<wfw:commentRss>http://www.leonardteo.com/2011/11/video-textures-siggraph-paper-implementation/feed/</wfw:commentRss>
		<slash:comments>0</slash:comments>
		</item>
		<item>
		<title>VBulletin single sign on</title>
		<link>http://www.leonardteo.com/2011/11/vbulletin-single-sign-on/</link>
		<comments>http://www.leonardteo.com/2011/11/vbulletin-single-sign-on/#comments</comments>
		<pubDate>Tue, 01 Nov 2011 16:01:29 +0000</pubDate>
		<dc:creator>Leo</dc:creator>
				<category><![CDATA[Reminders to myself]]></category>
		<category><![CDATA[Web Development]]></category>

		<guid isPermaLink="false">http://www.leonardteo.com/?p=599</guid>
		<description><![CDATA[I figure I would write this because I searched around for a suitable solution and it&#8217;s quite frustrating to find. VBulletin (the company) runs a very tight community and generally don&#8217;t help people who want to hack or extend the software. In my case, I am integrating VBulletin into a client&#8217;s custom application and trying [...]]]></description>
			<content:encoded><![CDATA[<p>I figure I would write this because I searched around for a suitable solution and it&#8217;s quite frustrating to find. VBulletin (the company) runs a very tight community and generally don&#8217;t help people who want to hack or extend the software. In my case, I am integrating VBulletin into a client&#8217;s custom application and trying to get single sign on to work. Do a search and you&#8217;ll find VBulletin telling people who have asked the same question &#8220;we won&#8217;t help you. Go to vbulletin.org.&#8221; When you do get to vbulletin.org, you can&#8217;t see any code because you&#8217;re not a licensed user. Very frustrating.</p>
<p>So&#8230;here it is.</p>
<p>VBulletin stores two cookie vars that can be used for single sign on:</p>
<ul>
<li>bb_userid &#8211; look in the &#8216;user&#8217; table, it is the field &#8216;userid&#8217;</li>
<li>bb_password &#8211; md5(user.password . COOKIE_SALT)</li>
</ul>
<p>When a user visits the forum, it can login based on the above.</p>
<p>Once you authenticate that the user can login in your app, read the user row from the vbulletin database. Take the password (which is already hashed) and concatenate the COOKIE_SALT constant to it. You can find COOKIE_SALT defined in /includes/functions.php. You then md5 hash this string and set the cookie as bb_password.</p>
<p>When setting your cookie, remember to set the domain to one that vbulletin can read. If you&#8217;re using different subdomains (e.g.   www.leonardteo.com for the main app and forums.leonardteo.com for the forums) simply set the domain to &#8220;.leonardteo.com&#8221;. In VBulletin, you&#8217;ll want to go into the admincp and change the cookie domain to the same.</p>
<p>By setting these two cookies, you should be able to login with your app and it will automatically login to VBulletin as well.</p>
<p><strong>Logout</strong><br />
Make sure you set the logout routine as well. Your logout routine needs to clear three cookies:</p>
<ul>
<li>bb_userid</li>
<li>bb_password</li>
<li>bb_sessionhash</li>
</ul>
<p>Enjoy.</p>
]]></content:encoded>
			<wfw:commentRss>http://www.leonardteo.com/2011/11/vbulletin-single-sign-on/feed/</wfw:commentRss>
		<slash:comments>0</slash:comments>
		</item>
		<item>
		<title>My rant about storing crucial web app settings in a database</title>
		<link>http://www.leonardteo.com/2011/11/my-rant-about-storing-crucial-web-app-settings-in-a-database/</link>
		<comments>http://www.leonardteo.com/2011/11/my-rant-about-storing-crucial-web-app-settings-in-a-database/#comments</comments>
		<pubDate>Tue, 01 Nov 2011 12:51:37 +0000</pubDate>
		<dc:creator>Leo</dc:creator>
				<category><![CDATA[Rambling]]></category>
		<category><![CDATA[Web Development]]></category>

		<guid isPermaLink="false">http://www.leonardteo.com/?p=591</guid>
		<description><![CDATA[I&#8217;ve been coding PHP for a long time. Since 1999 actually. That means that for most of my adult life, I&#8217;ve been working with this programming language in the web-o-sphere in general. I&#8217;ve gotten to work on many applications and continue to do so. I&#8217;ve also gotten to use many off-the-shelf apps including WordPress, Expression [...]]]></description>
			<content:encoded><![CDATA[<p>I&#8217;ve been coding PHP for a long time. Since 1999 actually. That means that for most of my adult life, I&#8217;ve been working with this programming language in the web-o-sphere in general. I&#8217;ve gotten to work on many applications and continue to do so. I&#8217;ve also gotten to use many off-the-shelf apps including WordPress, Expression Engine and VBulletin. Today, I&#8217;d like to rant about two conventions that these all have in common, and why we need to be rid of them.</p>
<h2>1. Storing paths and URLs in the database</h2>
<p>This happens in WordPress, Expression Engine and VBulletin. Basically, the idea is that all settings must be stored in a database table because&#8230;well&#8230;it&#8217;s supposed to be easier. The user updates a setting in the admin control panel, and it stores those settings in a database. The problem with storing paths in a database like this is that it makes the app less portable. For example, say you want to move an installation of any of the above-said apps to a different domain, it&#8217;s not as simple as tarballing the entire application, running mysqldump and restoring on the other side. You&#8217;d think that changing the config file would get it to work but this is only half the battle. WordPress and Vbulletin, for example, stores the actual URL of the application in the database, so when it does any redirect (e.g. when you login to the admin control panel), it will redirect to your OLD site.</p>
<p>WordPress does something else that I consider evil. When you upload images, it stores the full web path in the meta data. This is also a problem when you move to another domain because all your images are now pointing to the old domain. I&#8217;ve had to write scripts that change all metadata values and wordpress settings when porting from one domain to another. It&#8217;s annoying.</p>
<p><strong>Why is this an issue though?</strong></p>
<p>Development. For most people, the above shouldn&#8217;t matter because you have a blog that you installed on a webserver; you update it and all&#8217;s well. You never run a local copy of the site for development. As a developer though, I have to usually get local and staging copies of the website running. This means that I&#8217;m constantly having to do all kinds of shenanigans to get these instances running on different servers.</p>
<p>I used to think that this was simply a bad design limited to a couple of web apps but it seems like a whole plethora of web apps suffer from this. While working for Gnomon, we bought into Expression Engine, thinking that this would be the silver bullet that kills WordPress. Nada. EE is just as BADLY designed! (not just for the reasons above, but many others)</p>
<h2>2. Serializing Critical Settings</h2>
<p>PHP has a neat function called serialize(). It takes data and turns it into a string. The data can be read back in easily. This is great for many things. For example, if you have user accounts and each user has their own settings, it&#8217;s probably useful to just serialize their settings data and save it as a single string in the database.</p>
<p>Crucial site settings though, should NEVER be serialized in a database. I would go as far to say that as a rule of thumb, if the setting is crucial enough to make or break an installation of an app, it should be in a config file. This relates to my first rant as well. Many settings can be put in the database, but some settings (like paths), should just be in flat config files that can be quickly changed when moving the app.</p>
<p>I was absolutely shocked when using Expression Engine that crucial app-breaking settings like upload paths were not only stored in the database but SERIALIZED. I ended up writing a script that can move an entire installation of EE from one server to another in a single command line, and it&#8217;s really long because it had to connect to the database, unserialize the data, make modifications, re-serialize the data, write back to database.</p>
<p>It shouldn&#8217;t be this hard.</p>
<h2>My recommendation</h2>
<p>My recommendation is to follow this rule of thumb: if the setting is crucial enough to make or break an installation of an app, it should be in a config file.</p>
<p>Absolute paths like upload paths, etc. should be stored in a config file.</p>
<p>If the application needs a site-wide URL, this should be in a config file.</p>
<p>Individual asset links in the database should link to the relative location (i.e. minus the hostname.) e.g. not http://leonardteo.com/image1.jpg, but /image1.jpg instead. Even better, just store &#8216;image1.jpg&#8217; and use a configuration setting to determine what the path to that image is.</p>
<p>The litmus test should be: Tarball an application, dump the database. Copy everything to a different computer/hostname. Restore everything. If you can&#8217;t get the site up and running again without accessing and changing values in the database, fail.</p>
<h2>A practical benefit &#8211; fast deployment</h2>
<p>On a closing note, one of the benefits of running critical site settings in config files, is that you can switch configurations based on the hostname.</p>
<p>E.g. in your config file:</p>
<pre>switch ($_SERVER['SERVER_NAME']){
    case 'cgacontest.local':
        define('SITE_MODE', "LOCAL");
        break;
    case 'cgacontest.test':
        define('SITE_MODE', "TEST");
        break;
    case '3dsmaxdesign.cgarchitect.com':
        define('SITE_MODE', "LIVE");
        break;
}</pre>
<p>With the above code, we can switch between site modes and run different configurations automatically based on the hostname. This means that when it comes to deployment, I simply push any changes to the server without having to change configuration.</p>
<p>&nbsp;</p>
]]></content:encoded>
			<wfw:commentRss>http://www.leonardteo.com/2011/11/my-rant-about-storing-crucial-web-app-settings-in-a-database/feed/</wfw:commentRss>
		<slash:comments>0</slash:comments>
		</item>
	</channel>
</rss>

