<?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>danielsenhwong.com &#187; dan</title>
	<atom:link href="http://blog.danielsenhwong.com/author/Dan/feed/" rel="self" type="application/rss+xml" />
	<link>http://blog.danielsenhwong.com</link>
	<description></description>
	<lastBuildDate>Tue, 22 Feb 2011 01:54:46 +0000</lastBuildDate>
	<language>en</language>
	<sy:updatePeriod>hourly</sy:updatePeriod>
	<sy:updateFrequency>1</sy:updateFrequency>
	<generator>http://wordpress.org/?v=3.1.1</generator>
		<item>
		<title>Would you recognize yourself?</title>
		<link>http://blog.danielsenhwong.com/2011/02/would-you-recognize-yourself/</link>
		<comments>http://blog.danielsenhwong.com/2011/02/would-you-recognize-yourself/#comments</comments>
		<pubDate>Tue, 22 Feb 2011 01:27:01 +0000</pubDate>
		<dc:creator>dan</dc:creator>
				<category><![CDATA[Personal]]></category>
		<category><![CDATA[personal]]></category>
		<category><![CDATA[reflection]]></category>

		<guid isPermaLink="false">http://blog.danielsenhwong.com/?p=103</guid>
		<description><![CDATA[I&#8217;ve recently spent a lot of time thinking about how I&#8217;ve changed over the past five and ten years. Arbitrary time points to be sure, but any significant amount more than that, and we&#8217;re talking about a middle school-aged kid, and really, how is that at all useful? I think this really came out of [...]]]></description>
			<content:encoded><![CDATA[<p>I&#8217;ve recently spent a lot of time thinking about how I&#8217;ve changed over the past five and ten years. Arbitrary time points to be sure, but any significant amount more than that, and we&#8217;re talking about a middle school-aged kid, and really, how is that at all useful? I think this really came out of interviewing applicants for my undergraduate institution.</p>
<p>To the point: if the person you were five or ten years ago were to meet the person you are today, would you recognize yourself? What would you think? How about the reverse: if the person you are today were to meet the person you were five or ten years ago, what would you think?</p>
]]></content:encoded>
			<wfw:commentRss>http://blog.danielsenhwong.com/2011/02/would-you-recognize-yourself/feed/</wfw:commentRss>
		<slash:comments>0</slash:comments>
		</item>
		<item>
		<title>Context is Important</title>
		<link>http://blog.danielsenhwong.com/2011/02/context-is-important/</link>
		<comments>http://blog.danielsenhwong.com/2011/02/context-is-important/#comments</comments>
		<pubDate>Wed, 16 Feb 2011 05:22:01 +0000</pubDate>
		<dc:creator>dan</dc:creator>
				<category><![CDATA[Personal]]></category>
		<category><![CDATA[personal]]></category>
		<category><![CDATA[relationship]]></category>

		<guid isPermaLink="false">http://blog.danielsenhwong.com/2011/02/context-is-important/</guid>
		<description><![CDATA[Judge me all you like for leaving and ending things the way I did, but your opinion is meaningless if you lack the facts. I was the one being abused in an emotionally abusive relationship. I left.]]></description>
			<content:encoded><![CDATA[<p>Judge me all you like for leaving and ending things the way I did, but your opinion is meaningless if you lack the facts.</p>
<p>I was the one being abused in an emotionally abusive relationship. I left.</p>
]]></content:encoded>
			<wfw:commentRss>http://blog.danielsenhwong.com/2011/02/context-is-important/feed/</wfw:commentRss>
		<slash:comments>0</slash:comments>
		</item>
		<item>
		<title>Comparing Schools</title>
		<link>http://blog.danielsenhwong.com/2011/02/comparing-schools/</link>
		<comments>http://blog.danielsenhwong.com/2011/02/comparing-schools/#comments</comments>
		<pubDate>Fri, 11 Feb 2011 22:54:04 +0000</pubDate>
		<dc:creator>dan</dc:creator>
				<category><![CDATA[Personal]]></category>
		<category><![CDATA[developmental biology]]></category>
		<category><![CDATA[genetic medicine]]></category>
		<category><![CDATA[graduate school]]></category>
		<category><![CDATA[research]]></category>
		<category><![CDATA[science]]></category>
		<category><![CDATA[stem cell biology]]></category>
		<category><![CDATA[tissue engineering]]></category>

		<guid isPermaLink="false">http://blog.danielsenhwong.com/?p=101</guid>
		<description><![CDATA[This is a work in progress. If I attend , it might mean that I head down a basic science path. I&#8217;m not sure at what point I&#8217;d be able to mash tissue engineering into my career, if ever. Angiogenesis comes close, but isn&#8217;t really the same thing. Also, lots of friends here, but I&#8217;m [...]]]></description>
			<content:encoded><![CDATA[<p>This is a work in progress.</p>
<p>If I attend <span style="background-color: #44286f;"> </span><span style="background-color: #ffffff;"> </span>, it might mean that I head down a basic science path. I&#8217;m not sure at what point I&#8217;d be able to mash tissue engineering into my career, if ever. Angiogenesis comes close, but isn&#8217;t really the same thing. Also, lots of friends here, but I&#8217;m worried that if I attend and become the ridiculous student I should have been as an undergrad, people will hold it against me. Social currency is money, of which I have and will have little.</p>
<p>If I attend <span style="background-color: #562600;"> </span><span style="background-color: #417dc1;"> </span>, I can mash tissue engineering into my career immediately. There are at least three different laboratories I could rotate through that, at the very least, have collaborations which involve tissue engineering. I also have a few friends here, but they&#8217;re all in school and similarly busy. Social currency is intelligence, which is great.</p>
<p>If I attend <span style="background-color: #eecfa1;"> </span><span style="background-color: #00285c;"> </span>, I&#8217;m not sure what I&#8217;d really be doing. Genetic Medicine research looks very interesting, but tissue engineering is not something that is done here. Few friends in the area. High cost of living without much justification. Social currency: connections.</p>
<p>Table below.<br />
<span id="more-101"></span></p>
<table style="padding: 2px; border: 1px solid gray; margin-bottom: 10px;">
<tbody>
<tr>
<th style="padding: 2px; border: 1px solid #DDDDDD; min-width: 100px; background-color: #cccccc;"></th>
<th style="padding: 2px; border: 1px solid #DDDDDD; min-width: 185px; background-color: #cccccc;"> <span style="background-color: #44286f;"> </span><span style="background-color: #ffffff;"> </span></th>
<th style="padding: 2px; border: 1px solid #DDDDDD; min-width: 185px; background-color: #cccccc;"> <span style="background-color: #562600;"> </span><span style="background-color: #417dc1;"> </span></th>
<th style="padding: 2px; border: 1px solid #DDDDDD; min-width: 185px; background-color: #cccccc;"> <span style="background-color: #eecfa1;"> </span><span style="background-color: #00285c;"> </span></th>
</tr>
<tr>
<th style="padding: 2px; border: 1px solid #DDDDDD;">Research</th>
<td style="padding: 2px; border: 1px solid #DDDDDD;">Basic Science: stem cell biology, developmental biology &#8211; angiogenesis</td>
<td style="padding: 2px; border: 1px solid #DDDDDD;">Basic Science: cell, molecular, and developmental biology &#8211; tissue engineering applications</td>
<td style="padding: 2px; border: 1px solid #DDDDDD;">Basic science</td>
</tr>
<tr>
<th style="padding: 2px; border: 1px solid #DDDDDD;">Stipend</th>
<td style="padding: 2px; border: 1px solid #DDDDDD;">$32,890</td>
<td style="padding: 2px; border: 1px solid #DDDDDD;">$30,000</td>
<td style="padding: 2px; border: 1px solid #DDDDDD;">$27,000</td>
</tr>
<tr>
<th style="padding: 2px; border: 1px solid #DDDDDD;"> Health Insurance</th>
<td style="padding: 2px; border: 1px solid #DDDDDD;">Included, same coverage as faculty.</td>
<td style="padding: 2px; border: 1px solid #DDDDDD;">Included, same coverage as faculty, $3,400 annually</td>
<td style="padding: 2px; border: 1px solid #DDDDDD;">Included, $1,650 annually</td>
</tr>
<tr>
<th style="padding: 2px; border: 1px solid #DDDDDD;"> Housing Costs</th>
<td style="padding: 2px; border: 1px solid #DDDDDD;">$1000/mo. ($850 &#8211; $1600), very close to campus (&lt; 1 mi.)</td>
<td style="padding: 2px; border: 1px solid #DDDDDD;">$850/mo. ($600 &#8211; $1500), range of options. Most reasonably-priced will be ~2-5 mi. from campus, in vibrant neighborhoods, with easy transit connections.</td>
<td style="padding: 2px; border: 1px solid #DDDDDD;">$850/mo. ($600 &#8211; $1500), range of options. Most reasonably-priced will be ~2-5 mi. from campus, in varying neighborhoods, most with annoying transit connections.</td>
</tr>
<tr>
<th style="padding: 2px; border: 1px solid #DDDDDD;"> Size of Incoming Class</th>
<td style="padding: 2px; border: 1px solid #DDDDDD;">~50</td>
<td style="padding: 2px; border: 1px solid #DDDDDD;">~16 (?)</td>
<td style="padding: 2px; border: 1px solid #DDDDDD;">~10</td>
</tr>
<tr>
<th style="padding: 2px; border: 1px solid #DDDDDD;"> Rotations</th>
<td style="padding: 2px; border: 1px solid #DDDDDD;">Four. In DB: rotate in labs with different model systems. Select lab after fourth rotation.</td>
<td style="padding: 2px; border: 1px solid #DDDDDD;">Four. No restrictions. Select lab after fourth rotation.</td>
<td style="padding: 2px; border: 1px solid #DDDDDD;">Three. Four possible, but not common.</td>
</tr>
<tr>
<th style="padding: 2px; border: 1px solid #DDDDDD;"> Academic Atmosphere</th>
<td style="padding: 2px; border: 1px solid #DDDDDD;">Collegial, friendly. Collaboration encouraged, but evidence not shown during interview.</td>
<td style="padding: 2px; border: 1px solid #DDDDDD;">Collegial, friendly. Collaboration encouraged, and very evident from interdisciplinary work with engineering school at main campus.</td>
<td style="padding: 2px; border: 1px solid #DDDDDD;">Collegial, friendly. Older lab format rather than newer open lab arrangement.</td>
</tr>
<tr>
<th style="padding: 2px; border: 1px solid #DDDDDD;"> Student Happiness</th>
<td style="padding: 2px; border: 1px solid #DDDDDD;">High?</td>
<td style="padding: 2px; border: 1px solid #DDDDDD;">High</td>
<td style="padding: 2px; border: 1px solid #DDDDDD;">Medium?</td>
</tr>
<tr>
<th style="padding: 2px; border: 1px solid #DDDDDD;"> Professional Development</th>
<td style="padding: 2px; border: 1px solid #DDDDDD;">Grant-writing course offered, required. If grant/fellowship is earned and awarded following second year, reward from institution is a trip to any int&#8217;l conference, or a computer &lt; $2500.</td>
<td style="padding: 2px; border: 1px solid #DDDDDD;">Grant-writing courses available, not required, not well-developed? Can take course at other local institutions.</td>
<td style="padding: 2px; border: 1px solid #DDDDDD;">Grant-writing, scientific writing course required.</td>
</tr>
<tr>
<th style="padding: 2px; border: 1px solid #DDDDDD;"> Campus Location</th>
<td style="padding: 2px; border: 1px solid #DDDDDD;">Excellent. Downtown. Very walkable neighborhood, many transportation options. Walking is a viable option if transit is unavailable, though housing options make transit unnecessary. Biking is definitely possible, though, again, likely unnecessary.</td>
<td style="padding: 2px; border: 1px solid #DDDDDD;">Excellent. Downtown. Very walkable neighborhood, many transportation options. Walking might be a viable option if transit is unavailable  (~60 minutes). Biking is definitely possible; secure bike storage available with registration.</td>
<td style="padding: 2px; border: 1px solid #DDDDDD;">Just outside downtown. Several transportation options. Walking might be a viable option if transit is unavailable (~60 minutes). Biking is definitely possible; bike storage unknown.</td>
</tr>
<tr>
<th style="padding: 2px; border: 1px solid #DDDDDD;"> Public Transit</th>
<td style="padding: 2px; border: 1px solid #DDDDDD;">Excellent, 24/7</td>
<td style="padding: 2px; border: 1px solid #DDDDDD;">Excellent, 6am-midnight. On one line, but within six blocks of several others.</td>
<td style="padding: 2px; border: 1px solid #DDDDDD;">Depends. 5:30am-11:30pm. Frequent delays. Accessible only by two lines which share the same track.</td>
</tr>
<tr>
<th style="padding: 2px; border: 1px solid #DDDDDD;"> Safety</th>
<td style="padding: 2px; border: 1px solid #DDDDDD;">unknown</td>
<td style="padding: 2px; border: 1px solid #DDDDDD;">unknown</td>
<td style="padding: 2px; border: 1px solid #DDDDDD;">unknown</td>
</tr>
<tr>
<th style="padding: 2px; border: 1px solid #DDDDDD;"> Airport Accessibility</th>
<td style="padding: 2px; border: 1px solid #DDDDDD;">Mediocre, depends on airport. Allow 60-90 minutes for travel.</td>
<td style="padding: 2px; border: 1px solid #DDDDDD;">Excellent. Allow 45 minutes for travel.</td>
<td style="padding: 2px; border: 1px solid #DDDDDD;">Depends on airport. One is excellent, the other two are mediocre at best. Allow 45 minutes travel for the first, 90+minutes for the other two.</td>
</tr>
<tr>
<th style="padding: 2px; border: 1px solid #DDDDDD;"> Student Life</th>
<td style="padding: 2px; border: 1px solid #DDDDDD;">Student council appears to be very active; weekly happy hours.</td>
<td style="padding: 2px; border: 1px solid #DDDDDD;">Student very involved, at least with respect to interviews and admissions. Not certain about weekly happy hours; outing seem to be coordinated by department.</td>
<td style="padding: 2px; border: 1px solid #DDDDDD;">Graduate Student Association. Very little exposure to graduate students during interview and on tours.</td>
</tr>
<tr>
<th style="padding: 2px; border: 1px solid #DDDDDD;"> Facilities</th>
<td style="padding: 2px; border: 1px solid #DDDDDD;">Excellent facilities, more than ample resources. Primary building is new (&lt; 20 y/o), oldest relevant building 20-40 y/o.</td>
<td style="padding: 2px; border: 1px solid #DDDDDD;">Excellent facilities, sufficient resources. They even have an oligo synthesis core! Primary building is brand-new or renovated (&lt; 10 y/o), oldest relevant building is 20-30 y/o.</td>
<td style="padding: 2px; border: 1px solid #DDDDDD;">Older building in the process of being renovated. Core facilities not emphasized, and no one was particularly excited about talking to me about them.</td>
</tr>
<tr>
<th style="padding: 2px; border: 1px solid #DDDDDD;"> Athletics Facilities</th>
<td style="padding: 2px; border: 1px solid #DDDDDD;">Unknown quality; located at main campus (&lt; 2 mi.) and shared with undergrads.</td>
<td style="padding: 2px; border: 1px solid #DDDDDD;">Brand-new, on-campus. Reasonable size.</td>
<td style="padding: 2px; border: 1px solid #DDDDDD;">Gym membership to school facilities shared with undergrads provided first two years. Facilities not shown.</td>
</tr>
<tr>
<th style="padding: 2px; border: 1px solid #DDDDDD;"> Are Faculty Interested?</th>
<td style="padding: 2px; border: 1px solid #DDDDDD;">Yes! One (JVT) actively sought me out during the time between interviews, and another (MT) has offered a rotation position. Positive encouragement from every interviewer for my research goals. Every interviewer sent congratulatory e-mails w/in one week of receiving acceptance.</td>
<td style="padding: 2px; border: 1px solid #DDDDDD;">Yes? One (IH) thought my question about his work would make for a good project. Positive encouragement from every interviewer for my research goals.</td>
<td style="padding: 2px; border: 1px solid #DDDDDD;">Depends on airport. One is excellent, the other two are mediocre at best. Allow 45 minutes travel for the first, 90+minutes for the other two.</td>
</tr>
<tr>
<th style="padding: 2px; border: 1px solid #DDDDDD;"> New City?</th>
<td style="padding: 2px; border: 1px solid #DDDDDD;">No, but different neighborhood.</td>
<td style="padding: 2px; border: 1px solid #DDDDDD;">Yes.</td>
<td style="padding: 2px; border: 1px solid #DDDDDD;">No.</td>
</tr>
<tr>
<th style="padding: 2px; border: 1px solid #DDDDDD;"> Excited?</th>
<td style="padding: 2px; border: 1px solid #DDDDDD;">Very! Low initial expectations, but thoroughly impressed.</td>
<td style="padding: 2px; border: 1px solid #DDDDDD;">Very! High expectations to start, and were exceeded.</td>
<td style="padding: 2px; border: 1px solid #DDDDDD;">Not very.</td>
</tr>
</tbody>
</table>
]]></content:encoded>
			<wfw:commentRss>http://blog.danielsenhwong.com/2011/02/comparing-schools/feed/</wfw:commentRss>
		<slash:comments>1</slash:comments>
		</item>
		<item>
		<title>Setting up Ruby on Rails in OS X</title>
		<link>http://blog.danielsenhwong.com/2011/01/setting-up-ruby-on-rails-in-os-x/</link>
		<comments>http://blog.danielsenhwong.com/2011/01/setting-up-ruby-on-rails-in-os-x/#comments</comments>
		<pubDate>Mon, 10 Jan 2011 00:54:01 +0000</pubDate>
		<dc:creator>dan</dc:creator>
				<category><![CDATA[Projects]]></category>
		<category><![CDATA[Tech]]></category>
		<category><![CDATA[Web Dev]]></category>
		<category><![CDATA[apache]]></category>
		<category><![CDATA[mac os x]]></category>
		<category><![CDATA[mysql]]></category>
		<category><![CDATA[php]]></category>
		<category><![CDATA[ruby on rails]]></category>
		<category><![CDATA[web development]]></category>

		<guid isPermaLink="false">http://blog.danielsenhwong.com/?p=96</guid>
		<description><![CDATA[I consulted quite a few sources online to try and figure out how to do this, and ran into a few problems that took entirely too much time to solve. Now that I&#8217;ve figured them out, I&#8217;m writing the solutions here in the event I need them again. Hopefully they&#8217;ll be useful to a few [...]]]></description>
			<content:encoded><![CDATA[<p>I consulted quite a few sources online to try and figure out how to do this, and ran into a few problems that took entirely too much time to solve. Now that I&#8217;ve figured them out, I&#8217;m writing the solutions here in the event I need them again. Hopefully they&#8217;ll be useful to a few other people as well.</p>
<p><strong>Goals</strong></p>
<p>Create a Ruby on Rails development environment with Apache, MySQL, and PHP.</p>
<p>There are several possible ways of doing this, but since OS X is a Unix-based platform, I don&#8217;t see any reason to use pre-compiled packages like MacPorts and replacing the built-in software. Plus, this is supposed to be a learning experience.</p>
<p><strong>Sources</strong></p>
<p><a href="http://maestric.com/doc/mac/apache_php_mysql_snow_leopard">http://maestric.com/doc/mac/apache_php_mysql_snow_leopard</a></p>
<p><a href="http://michaelgracie.com/2009/09/23/plugging-mcrypt-into-php-on-mac-os-x-snow-leopard-10.6.1/">http://michaelgracie.com/2009/09/23/plugging-mcrypt-into-php-on-mac-os-x-snow-leopard-10.6.1/</a></p>
<p><span id="more-96"></span></p>
<p><strong>Basic Setup</strong></p>
<p>OS X comes with Apache, Ruby, Rails, and PHP pre-loaded; the specific versions of each are dependent upon the installed version of OS X. In my case, I am starting with a fresh installation of Snow Leopard (10.6), and beginning by downloading all available System Updates, which brings my system to version 10.6.5, with Apache version 2.2.15, Ruby 1.8.7, Rails 2.3.5 , and PHP 5.3.3.</p>
<p>In order to use the pre-loaded Apache installation, go to &#8220;System Preferences&#8221; &gt; &#8220;Sharing&#8221;  and check &#8220;Web Sharing&#8221;. This will enable the Apache web server. If you ever need to restart the server, either uncheck and re-check this box, or use the command &lt;code&gt;sudo apachectl restart&lt;/code&gt; from the command line.</p>
<p>Next, we need a compiler, so we&#8217;ll install Apple&#8217;s Xcode Developer Tools, which can be found on the OS X installation CD/DVD and also online directly from Apple (<a href="http://developer.apple.com/technologies/tools/xcode.html">http://developer.apple.com/technologies/tools/xcode.html</a>). I have version 3.2.3 installed. I&#8217;m writing this up after having performed all of the updates, so the initial version may have been different.</p>
<p><strong>MySQL</strong></p>
<p>MySQL doesn&#8217;t come installed as part of the normal OS X distribution; just OS X Server. No problem; just download an OS X *.dmg package for MySQL Community Server: <a href="http://www.mysql.com/downloads/mysql/#downloads">http://www.mysql.com/downloads/mysql/#downloads</a></p>
<p>Note: OS X Snow Leopard (10.6) and later compile in 64-bit C, so be sure to download the 64-bit version of MySQL (x86_64 suffix). This took me a while to figure out, as I had downloaded the 32-bit version for my 32-bit kernel. I thought it made sense. Version 5.1 should work just fine; I didn&#8217;t try 5.5.</p>
<p>Anyway, the MySQL *.dmg contains three files: the MySQL installer, the MySQL Startup Item installer, and the Preference Pane item. Install them in the order I have listed here. Once it&#8217;s installed, go ahead and try starting the server. The indicator in the Preference Pane item should turn green.</p>
<p>Edit /etc/profile and add &#8220;PATH=$PATH:/usr/local/mysql/bin&#8221;, otherwise you&#8217;ll have to type the full path to the mysql and mysqladmin executables in order to use them.</p>
<p><strong>PHP</strong></p>
<p>You&#8217;ll need to enable PHP by un-commenting a line beginning with &#8220;LoadModule php5_module&#8230;&#8221; in your Apache configuration file, typically found at /private/etc/apache2/apache2.conf.</p>
<p>Additionally, you&#8217;ll have to create a php.ini file in /etc/, which is most easily done by making a copy of &#8220;/etc/php.ini.default&#8221;. While you&#8217;re doing that, un-comment the line for your time zone, and enter a valid value. Additionally, change the three occurrences of &#8220;/var/mysql/mysql.sock&#8221; to &#8220;/tmp/mysql.sock&#8221; in order to point PHP at your MySQL installation.</p>
<p>I like using phpMyAdmin to manage my MySQL databases, so I&#8217;ll need to install this. The process is straightforward and well-documented. However, once you do this, you&#8217;ll notice that you&#8217;ll need PHP to have been compiled with the mcrypt extension, and the OS X distribution hasn&#8217;t been. Not to worry, Michael Gracie has a solution to that problem (<a href="http://michaelgracie.com/2009/09/23/plugging-mcrypt-into-php-on-mac-os-x-snow-leopard-10.6.1/">http://michaelgracie.com/2009/09/23/plugging-mcrypt-into-php-on-mac-os-x-snow-leopard-10.6.1/</a>).  Be sure to update the version numbers of the different software packages accordingly.</p>
<p>Restart the Apache server so these changes to php.ini take effect.</p>
<p><strong>Ruby on Rails</strong></p>
<p>I&#8217;m going to be using Rails 3.0, so I&#8217;ll need to update RubyGems with &#8220;sudo gem update &#8211;system&#8221; followed by &#8220;sudo gem update&#8221; to update all installed gems.</p>
<p>I&#8217;ll need to install a database adapter so that RoR can interface with MySQL. Rails 3 defaults to the mysql2 gem for MySQL databases, so we&#8217;ll install that with &#8220;sudo gem install mysql2 &#8212; &#8211;with-mysql-config=/usr/local/mysql/bin/mysql_config&#8221;.</p>
<p>I want to use the devise plugin for user authentication, so I&#8217;ll install that and its dependent gem, warden.</p>
<p>Finally, I want to use passenger to deploy my Rails application just to make my life easier: &#8220;sudo gem install passenger&#8221; followed by &#8220;sudo passenger-install-apache2-module&#8221; and follow the directions.</p>
<p><strong>Done!</strong></p>
<p>I was going to write more about configuring virtual hosts, but this post languished with &#8220;draft&#8221; status for over a week already.</p>
]]></content:encoded>
			<wfw:commentRss>http://blog.danielsenhwong.com/2011/01/setting-up-ruby-on-rails-in-os-x/feed/</wfw:commentRss>
		<slash:comments>0</slash:comments>
		</item>
		<item>
		<title>Counting records by category [RoR]</title>
		<link>http://blog.danielsenhwong.com/2010/10/counting-records-by-category-ror/</link>
		<comments>http://blog.danielsenhwong.com/2010/10/counting-records-by-category-ror/#comments</comments>
		<pubDate>Tue, 19 Oct 2010 18:10:09 +0000</pubDate>
		<dc:creator>dan</dc:creator>
				<category><![CDATA[Projects]]></category>
		<category><![CDATA[Web Dev]]></category>
		<category><![CDATA[ruby on rails]]></category>

		<guid isPermaLink="false">http://blog.danielsenhwong.com/?p=94</guid>
		<description><![CDATA[In my Rails application, I have an inventory of items described by three models: the items (cryovials), the place they&#8217;re stored (dewar), and the information about which vials is stored where (ln2_locations). The reason I used three models, rather than rolling the attributes of the third (ln2_locations) into the actual item was that in reality, [...]]]></description>
			<content:encoded><![CDATA[<p>In my Rails application, I have an inventory of items described by three models: the items (<strong>cryovials</strong>), the place they&#8217;re stored (<strong>dewar</strong>), and the information about which vials is stored where (<strong>ln2_locations</strong>).</p>
<p>The reason I used three models, rather than rolling the attributes of the third (<strong>ln2_locations</strong>) into the actual item was that in reality, we normally freeze down multiple vials with the same content at the same time.  I would like to implement this kind of mass assignment at a later time.</p>
<p>Anyway, it is often useful to be able to determine what we have stored, and how much of each different type of content is present. It&#8217;s one thing to know what the SQL code would be to retrieve these records; it&#8217;s another to convert that to an ActiveRecord query when you&#8217;re just learning.</p>
<p>What I would like to do is look at my items (<strong>cryovials</strong>), and pull out the unique content values (e.g. cell types), then go back and count how many vials I have with that content. It would be pretty easy to accomplish this as two separate statements, but that would involve iteration and two separate SQL queries. Best to leave it as one query where I count and select unique fields simultaneously:</p>
<p>Rails:</p>
<pre class="brush: ruby; title: ;">@summary = Ln2Location.select(&amp;quot;count(*) count, contents&amp;quot;).joins(:cryovial).where(:present =&gt; true).group(:contents)</pre>
<p>SQL:</p>
<pre class="brush: sql; title: ;">SELECT count(*) count, contents FROM `ln2_locations` INNER JOIN `cryovials` ON `cryovials`.`id` = `ln2_locations`.`cryovial_id` WHERE (`ln2_locations`.`present` = 1) GROUP BY contents</pre>
<p>I&#8217;m selecting on Ln2Locations because there&#8217;s a property, &#8220;present,&#8221; which I&#8217;m using to select only the vials which haven&#8217;t been physically removed from the collection. Additionally, the relationship between the models is as follows:</p>
<pre class="brush: ruby; title: ;">class Cryovial &lt; ActiveRecord::Base
# Relationships
belongs_to :user
has_many :dewars, :through =&gt; :ln2_location
has_many :ln2_locations
accepts_nested_attributes_for :ln2_locations
</pre>
<pre class="brush: ruby; title: ;">class Dewar &lt; ActiveRecord::Base
# Relationships
belongs_to :laboratory
belongs_to :location
has_many :cryovials, :through &lt; :ln2_locations</pre>
<pre class="brush: ruby; title: ;">class Ln2Location &lt; ActiveRecord::Base
# Relationships
belongs_to :dewar
belongs_to :cryovial</pre>
<p>So only the child model, Ln2Locations, contains the foreign key that would be used to generate the join table.</p>
]]></content:encoded>
			<wfw:commentRss>http://blog.danielsenhwong.com/2010/10/counting-records-by-category-ror/feed/</wfw:commentRss>
		<slash:comments>0</slash:comments>
		</item>
		<item>
		<title>Ruby on Rails: Integrating Devise</title>
		<link>http://blog.danielsenhwong.com/2010/10/ruby-on-rails-integrating-devise/</link>
		<comments>http://blog.danielsenhwong.com/2010/10/ruby-on-rails-integrating-devise/#comments</comments>
		<pubDate>Fri, 15 Oct 2010 03:57:26 +0000</pubDate>
		<dc:creator>dan</dc:creator>
				<category><![CDATA[Projects]]></category>
		<category><![CDATA[Web Dev]]></category>
		<category><![CDATA[devise]]></category>
		<category><![CDATA[ruby on rails]]></category>

		<guid isPermaLink="false">http://blog.danielsenhwong.com/2010/10/ruby-on-rails-integrating-devise/</guid>
		<description><![CDATA[It is possible to integrate devise into your rails app as part of your user model in order to provide authentication support. - add desired attributes to migration file - make added attributes accessible in model file - either roll your own views or add fields to generated views That&#8217;s it. It really isn&#8217;t difficult [...]]]></description>
			<content:encoded><![CDATA[<p>It is possible to integrate devise into your rails app as part of your user model in order to provide authentication support.</p>
<p>- add desired attributes to migration file<br />
- make added attributes accessible in model file<br />
- either roll your own views or add fields to generated views</p>
<p>That&#8217;s it. It really isn&#8217;t difficult or different than making any other model.</p>
<p>I was worried that it would be complicated, and spent a lot of time reading about devise to be sure. It&#8217;s so easy, no one writes about it.</p>
]]></content:encoded>
			<wfw:commentRss>http://blog.danielsenhwong.com/2010/10/ruby-on-rails-integrating-devise/feed/</wfw:commentRss>
		<slash:comments>0</slash:comments>
		</item>
		<item>
		<title>Database Optimization: Indexing</title>
		<link>http://blog.danielsenhwong.com/2010/10/database-optimization-indexing/</link>
		<comments>http://blog.danielsenhwong.com/2010/10/database-optimization-indexing/#comments</comments>
		<pubDate>Wed, 13 Oct 2010 14:26:38 +0000</pubDate>
		<dc:creator>dan</dc:creator>
				<category><![CDATA[Projects]]></category>
		<category><![CDATA[Web Dev]]></category>
		<category><![CDATA[database]]></category>
		<category><![CDATA[mysql]]></category>
		<category><![CDATA[ruby on rails]]></category>
		<category><![CDATA[web development]]></category>

		<guid isPermaLink="false">http://blog.danielsenhwong.com/?p=92</guid>
		<description><![CDATA[After installing devise, I was looking through the migration file, and noticed a couple add_index commands. Reading up on what this actually does, I came across a couple interesting articles about database optimization: Optimizing your MySQL Application Indexing for DB performance details: http://www.railsbrain.com/api/rails-2.0.2/doc/index.html?a=M001468&#38;name=add_index I don&#8217;t plan to build a giant Rails application, but Rails is [...]]]></description>
			<content:encoded><![CDATA[<p>After installing devise, I was looking through the migration file, and noticed a couple add_index commands. Reading up on what this actually does, I came across a couple interesting articles about database optimization:</p>
<p><a href="http://articles.sitepoint.com/print/optimizing-mysql-application">Optimizing your MySQL Application</a></p>
<p><a href="http://weblog.jamisbuck.org/2006/10/23/indexing-for-db-performance">Indexing for DB performance</a></p>
<p>details: <a href="http://www.railsbrain.com/api/rails-2.0.2/doc/index.html?a=M001468&amp;name=add_index">http://www.railsbrain.com/api/rails-2.0.2/doc/index.html?a=M001468&amp;name=add_index</a></p>
<p>I don&#8217;t plan to build a giant Rails application, but Rails is known to have scalability issues. Still good to be aware of these points.</p>
]]></content:encoded>
			<wfw:commentRss>http://blog.danielsenhwong.com/2010/10/database-optimization-indexing/feed/</wfw:commentRss>
		<slash:comments>0</slash:comments>
		</item>
		<item>
		<title>Ruby on Rails: on shared hosting, user authentication</title>
		<link>http://blog.danielsenhwong.com/2010/10/ruby-on-rails-on-shared-hosting-user-authentication/</link>
		<comments>http://blog.danielsenhwong.com/2010/10/ruby-on-rails-on-shared-hosting-user-authentication/#comments</comments>
		<pubDate>Tue, 12 Oct 2010 20:23:44 +0000</pubDate>
		<dc:creator>dan</dc:creator>
				<category><![CDATA[Projects]]></category>
		<category><![CDATA[Web Dev]]></category>
		<category><![CDATA[customer service]]></category>
		<category><![CDATA[lab]]></category>
		<category><![CDATA[lithium hosting]]></category>
		<category><![CDATA[ruby on rails]]></category>
		<category><![CDATA[tech support]]></category>
		<category><![CDATA[web development]]></category>
		<category><![CDATA[web hosting]]></category>

		<guid isPermaLink="false">http://blog.danielsenhwong.com/?p=89</guid>
		<description><![CDATA[* As usual, this post on Ruby on Rails is more documentation of my development process to supplement my notebook and memory. I can try to answer questions, but please keep in mind that I&#8217;m learning too. I&#8217;ve bought the eBook version of the 4th edition of the Pragmatic Programmers&#8217; Agile Web Development with Rails. [...]]]></description>
			<content:encoded><![CDATA[<p><em>* As usual, this post on Ruby on Rails is more documentation of my development process to supplement my notebook and memory. I can try to answer questions, but please keep in mind that I&#8217;m learning too.</em></p>
<p>I&#8217;ve bought the eBook version of the 4th edition of the Pragmatic Programmers&#8217; <span style="text-decoration: underline;"><a href="http://pragprog.com/titles/rails4/agile-web-development-with-rails">Agile Web Development with Rails</a></span>. It&#8217;s still in beta, but my main goal is to see how things have changed between Rails 2.x and Rails 3. The book also covers some basic user authentication, but it&#8217;s very simplistic. In the interest of getting my project up and going quickly, I looked into <a href="http://github.com/binarylogic/authlogic">authlogic</a> and <a href="http://github.com/plataformatec/devise">devise/warden</a>.</p>
<p>Both authlogic and devise/warden were <a href="http://www.themomorohoax.com/2009/02/21/rails-2-3-authentication-comparison">highly recommended by mischa</a> after building an application that did some direct comparisons of several different RoR user authentication solutions. Good enough for me. devise appears to be more lightweight, so I&#8217;ll try that one first.</p>
<p>A little bit about my server setup: I&#8217;m hosted with <a href="https://www.lithiumhosting.com/billing/aff.php?aff=070">Lithium Hosting</a>, which is a great deal and has fantastic customer service. They&#8217;re not paying me to pitch the service, though clicking the link above and then signing up for a plan gives me referral credits or something. It&#8217;s a shared hosting service, so I manage my site with cPanel if I need/want to, and I&#8217;ve added on SSH access to my account so I don&#8217;t really need to use cPanel.</p>
<p>Once the server upgraded to Rails 3.0/Ruby 1.8.7, a couple things happened: my rails apps stopped starting automatically (cPanel feature), cPanel could no longer start my rails apps, and I couldn&#8217;t create a new Rails app with a MySQL database.</p>
<p>Solutions:</p>
<p>1) install the <a href="http://rubygems.org/gems/mysql2">mysql2 gem</a>, which is the new mysql database adapter used by Rails 3. The compilers are disabled on my host, so this was done via support ticket.</p>
<p>2) add mongrel to my Gemfile,</p>
<p><code lang="ruby">#project/Gemfile<br />
gem 'mongrel'</code></p>
<p>Mongrel isn&#8217;t automatically started in development mode. cPanel still won&#8217;t start my application, so starting the server is done via SSH with</p>
<p><code lang="rails">rails server --port=[port]</code></p>
<p>So now I can create a new project</p>
<p><code lang="rails">rails new project --database=mysql</code></p>
<p>and start the server. However, I don&#8217;t have a good way of authenticating users.</p>
<p>So, back to the support tickets to have both authlogic and devise installed. Once tech support has done that (seven minutes. really.), check if they&#8217;re installed for me:</p>
<p><code lang="ruby">gem server --port=[port]</code></p>
<p>and navigate to mysite.com:[port]. They&#8217;re not, run a couple commands from the command line:</p>
<p><code lang="rails">gem install devise<br />
gem install authlogic</code></p>
<p>Which should install the gems and make them available to me. Checking again as above, and both devise and authlogic are present. Add the appropriate lines to my Gemfile. Then, since I&#8217;m trying out devise first, install it:</p>
<p><code lang="rails">rails generate devise:install</code></p>
<p>That&#8217;s all for now.</p>
]]></content:encoded>
			<wfw:commentRss>http://blog.danielsenhwong.com/2010/10/ruby-on-rails-on-shared-hosting-user-authentication/feed/</wfw:commentRss>
		<slash:comments>0</slash:comments>
		</item>
		<item>
		<title>Ruby on Rails: Migrating data, too</title>
		<link>http://blog.danielsenhwong.com/2010/10/ruby-on-rails-migrating-data-too/</link>
		<comments>http://blog.danielsenhwong.com/2010/10/ruby-on-rails-migrating-data-too/#comments</comments>
		<pubDate>Tue, 05 Oct 2010 15:50:40 +0000</pubDate>
		<dc:creator>dan</dc:creator>
				<category><![CDATA[Web Dev]]></category>
		<category><![CDATA[lab]]></category>
		<category><![CDATA[migration]]></category>
		<category><![CDATA[ruby on rails]]></category>
		<category><![CDATA[web development]]></category>

		<guid isPermaLink="false">http://blog.danielsenhwong.com/?p=86</guid>
		<description><![CDATA[Sometimes it makes sense to re-organize information in such a way that changing the database structure is necessary. It&#8217;s not terribly difficult to do this in Ruby on Rails. I&#8217;m writing this more to file this away somewhere I won&#8217;t accidentally delete it: class CreateLn2Locations &#60; ActiveRecord::Migration def self.up # create table create_table :ln2_locations do [...]]]></description>
			<content:encoded><![CDATA[<p>Sometimes it makes sense to re-organize information in such a way that changing the database structure is necessary. It&#8217;s not terribly difficult to do this in Ruby on Rails.</p>
<p>I&#8217;m writing this more to file this away somewhere I won&#8217;t accidentally delete it:<br />
<span id="more-86"></span><br />
<code lang="ruby"><br />
class CreateLn2Locations &lt; ActiveRecord::Migration<br />
def self.up<br />
# create table<br />
create_table :ln2_locations do |t|<br />
t.integer :vial_id<br />
t.integer :dewar_id<br />
t.integer :canister<br />
t.integer :cane<br />
t.integer :position<br />
t.boolean :present, :default =&gt; 1<br />
t.date :date</code></p>
<p><code lang="ruby">t.timestamps<br />
end</p>
<p># reset column information so that the model can access the database<br />
Ln2Location.reset_column_information</p>
<p># take values previous held in columns by vial model, move to ln2_location<br />
Vial.find(:all).each do |vial|<br />
Ln2Location.create(:vial_id =&gt; vial.id,<br />
:dewar_id =&gt; vial.dewar_id,<br />
:canister =&gt; vial.canister,<br />
:cane =&gt; vial.cane,<br />
:position =&gt; vial.position,<br />
:date =&gt; vial.date)<br />
end</p>
<p># remove extra columns from vials table<br />
remove_column :vials, :dewar_id<br />
remove_column :vials, :canister<br />
remove_column :vials, :cane<br />
remove_column :vials, :position<br />
remove_column :vials, :depleted<br />
end</p>
<p>def self.down<br />
# undo changes; first, add columns back to vials table<br />
add_column :vials, :dewar_id, :integer<br />
add_column :vials, :canister, :integer<br />
add_column :vials, :cane, :integer<br />
add_column :vials, :position, :integer<br />
add_column :vials, :depleted, :boolean, :default =&gt; 0</p>
<p># reset column information so the model can access the re-created columns<br />
Vial.reset_column_information</p>
<p># copy data from ln2_location records to corresponding vial record<br />
Ln2Location.find(:all).each do |ln2|<br />
Vial.find(ln2.vial_id).update_attributes(<br />
:dewar_id =&gt; ln2.dewar_id,<br />
:canister =&gt; ln2.canister,<br />
:cane =&gt; ln2.cane,<br />
:position =&gt; ln2.position<br />
)<br />
end</p>
<p></code></p>
<p><code lang="ruby"> # remove table<br />
drop_table :ln2_locations<br />
end<br />
end<br />
</code></p>
]]></content:encoded>
			<wfw:commentRss>http://blog.danielsenhwong.com/2010/10/ruby-on-rails-migrating-data-too/feed/</wfw:commentRss>
		<slash:comments>0</slash:comments>
		</item>
		<item>
		<title>Biking Updates</title>
		<link>http://blog.danielsenhwong.com/2010/07/biking-updates/</link>
		<comments>http://blog.danielsenhwong.com/2010/07/biking-updates/#comments</comments>
		<pubDate>Sat, 24 Jul 2010 23:18:58 +0000</pubDate>
		<dc:creator>dan</dc:creator>
				<category><![CDATA[Uncategorized]]></category>
		<category><![CDATA[biking]]></category>
		<category><![CDATA[danger]]></category>

		<guid isPermaLink="false">http://blog.danielsenhwong.com/?p=82</guid>
		<description><![CDATA[Three weeks ago, I finally bought a bike after talking about it for about two years. Last night, I was almost doored by a guy getting out of his car. He opened his door, then kicked it out open even more without looking back. There were four other people on bicycles in front of me, [...]]]></description>
			<content:encoded><![CDATA[<p><a href="http://www.cannondale.com/usa/usaeng/Products/Bikes/Recreation-Urban/Quick/Quick-CX/Details/1312-0QRXR-Quick-CX-Rigid"><img class="alignright size-medium wp-image-83" title="Cannondale Quick CX Rigid" src="http://blog.danielsenhwong.com/wp-content/uploads/2010/07/580_400_3014_sourceImage1-300x171.jpg" alt="Cannondale Quick CX Rigid" width="300" height="171" /></a>Three weeks ago, I finally bought a <a href="http://www.cannondale.com/usa/usaeng/Products/Bikes/Recreation-Urban/Quick/Quick-CX/Details/1312-0QRXR-Quick-CX-Rigid">bike</a> after talking about it for about two years.</p>
<p>Last night, I was almost doored by a guy getting out of his car. He opened his door, then kicked it out open even more without looking back. There were four other people on bicycles in front of me, and a patio full of restaurant patrons who would have seen if I had hit the door and gone through the window. Thank goodness I was already on the brake. Bike lanes are great, but I don&#8217;t really like being in the door zone. And so much for lights alerting drivers to my presence.</p>
]]></content:encoded>
			<wfw:commentRss>http://blog.danielsenhwong.com/2010/07/biking-updates/feed/</wfw:commentRss>
		<slash:comments>0</slash:comments>
		</item>
	</channel>
</rss>

