<?xml version="1.0" encoding="UTF-8"?>
<posts type="array">
  <post>
    <content>&lt;p&gt;We utilize of lot of &lt;a href="http://en.wikipedia.org/wiki/View_(database)"&gt;read-only Database views&lt;/a&gt; here at SHA, mainly to leverage Rails&amp;#8217; naming conveniences with legacy database schemas.  We also love using &lt;a href="http://github.com/thoughtbot/factory_girl"&gt;Factory Girl&lt;/a&gt; for our tests.  Since we can&amp;#8217;t save data to these views during our testing routine, we need to just build the model objects in memory and &amp;#8220;pretend&amp;#8221; they came out of a query.  Luckily, Factory Girl allows us to do that easily with its &lt;code&gt;Factory.build&lt;/code&gt; method.&lt;/p&gt;
&lt;p&gt;But now there&amp;#8217;s the situation where I want to mock a response to a &lt;code&gt;SomeModel.all&lt;/code&gt; method, in which I want to return a collection of these factory objects.  Here&amp;#8217;s a quick few lines you can add to &lt;code&gt;ActiveSupport::TestCase&lt;/code&gt; in your test_helper.rb that allows you to do this easily:&lt;/p&gt;

&lt;div class="wp_syntax"&gt;&lt;div class="code"&gt;&lt;pre class="ruby" style="font-family:monospace;"&gt;  &lt;span style="color:#008000; font-style:italic;"&gt;# Create a collection of factory objects with options to save to db or just build&lt;/span&gt;
  &lt;span style="color:#9966CC; font-weight:bold;"&gt;def&lt;/span&gt; create_factory_collection&lt;span style="color:#006600; font-weight:bold;"&gt;&amp;#40;&lt;/span&gt;factory_name, size = &lt;span style="color:#006666;"&gt;5&lt;/span&gt;, save_to_database = &lt;span style="color:#0000FF; font-weight:bold;"&gt;false&lt;/span&gt;&lt;span style="color:#006600; font-weight:bold;"&gt;&amp;#41;&lt;/span&gt;
    returning collection = &lt;span style="color:#006600; font-weight:bold;"&gt;&amp;#91;&lt;/span&gt;&lt;span style="color:#006600; font-weight:bold;"&gt;&amp;#93;&lt;/span&gt; &lt;span style="color:#9966CC; font-weight:bold;"&gt;do&lt;/span&gt;
      size.&lt;span style="color:#9900CC;"&gt;times&lt;/span&gt; &lt;span style="color:#9966CC; font-weight:bold;"&gt;do&lt;/span&gt;
        collection &lt;span style="color:#006600; font-weight:bold;"&gt;&amp;lt;&amp;lt;&lt;/span&gt; &lt;span style="color:#006600; font-weight:bold;"&gt;&amp;#40;&lt;/span&gt;save_to_database ? Factory.&lt;span style="color:#9900CC;"&gt;create&lt;/span&gt;&lt;span style="color:#006600; font-weight:bold;"&gt;&amp;#40;&lt;/span&gt;factory_name.&lt;span style="color:#9900CC;"&gt;to_sym&lt;/span&gt;&lt;span style="color:#006600; font-weight:bold;"&gt;&amp;#41;&lt;/span&gt; : Factory.&lt;span style="color:#9900CC;"&gt;build&lt;/span&gt;&lt;span style="color:#006600; font-weight:bold;"&gt;&amp;#40;&lt;/span&gt;factory_name.&lt;span style="color:#9900CC;"&gt;to_sym&lt;/span&gt;&lt;span style="color:#006600; font-weight:bold;"&gt;&amp;#41;&lt;/span&gt;&lt;span style="color:#006600; font-weight:bold;"&gt;&amp;#41;&lt;/span&gt;
      &lt;span style="color:#9966CC; font-weight:bold;"&gt;end&lt;/span&gt;
    &lt;span style="color:#9966CC; font-weight:bold;"&gt;end&lt;/span&gt;
  &lt;span style="color:#9966CC; font-weight:bold;"&gt;end&lt;/span&gt;
&amp;nbsp;
  &lt;span style="color:#008000; font-style:italic;"&gt;# Helper method_missing override to create nicely-named collections of factory objects&lt;/span&gt;
  &lt;span style="color:#008000; font-style:italic;"&gt;# For example: create_factory_collection_for_current_students(15,true)&lt;/span&gt;
  &lt;span style="color:#008000; font-style:italic;"&gt;# will call create_factory_collection(:current_students, 15, true)&lt;/span&gt;
  &lt;span style="color:#9966CC; font-weight:bold;"&gt;def&lt;/span&gt; method_missing&lt;span style="color:#006600; font-weight:bold;"&gt;&amp;#40;&lt;/span&gt;requested_method, &lt;span style="color:#006600; font-weight:bold;"&gt;*&lt;/span&gt;args&lt;span style="color:#006600; font-weight:bold;"&gt;&amp;#41;&lt;/span&gt;
    &lt;span style="color:#9966CC; font-weight:bold;"&gt;if&lt;/span&gt; requested_method.&lt;span style="color:#9900CC;"&gt;to_s&lt;/span&gt; =~ &lt;span style="color:#006600; font-weight:bold;"&gt;/&lt;/span&gt;\Acreate_factory_collection_for_&lt;span style="color:#006600; font-weight:bold;"&gt;&amp;#40;&lt;/span&gt;\w&lt;span style="color:#006600; font-weight:bold;"&gt;+&lt;/span&gt;&lt;span style="color:#006600; font-weight:bold;"&gt;&amp;#41;&lt;/span&gt;\Z&lt;span style="color:#006600; font-weight:bold;"&gt;/&lt;/span&gt;
      __send__&lt;span style="color:#006600; font-weight:bold;"&gt;&amp;#40;&lt;/span&gt;&lt;span style="color:#996600;"&gt;&amp;quot;create_factory_collection&amp;quot;&lt;/span&gt;, $&lt;span style="color:#006666;"&gt;1&lt;/span&gt;, &lt;span style="color:#006600; font-weight:bold;"&gt;*&lt;/span&gt;args&lt;span style="color:#006600; font-weight:bold;"&gt;&amp;#41;&lt;/span&gt;
    &lt;span style="color:#9966CC; font-weight:bold;"&gt;else&lt;/span&gt;
      &lt;span style="color:#008000; font-style:italic;"&gt;# Otherwise handle normally #&lt;/span&gt;
      &lt;span style="color:#9966CC; font-weight:bold;"&gt;super&lt;/span&gt;
    &lt;span style="color:#9966CC; font-weight:bold;"&gt;end&lt;/span&gt;
  &lt;span style="color:#9966CC; font-weight:bold;"&gt;end&lt;/span&gt;&lt;/pre&gt;&lt;/div&gt;&lt;/div&gt;

&lt;p&gt;Notice the use of &lt;code&gt;method_missing&lt;/code&gt; above.  It&amp;#8217;s totally unnecessary, but it allows you to call the create_factory_collection method in a nicer way.  For example, if you have a factory called &lt;code&gt;:current_students&lt;/code&gt;, you can create a collection of 10 built current_student objects by calling:&lt;/p&gt;

&lt;div class="wp_syntax"&gt;&lt;div class="code"&gt;&lt;pre class="ruby" style="font-family:monospace;"&gt;create_factory_collection_for_current_students &lt;span style="color:#006666;"&gt;10&lt;/span&gt;&lt;/pre&gt;&lt;/div&gt;&lt;/div&gt;

&lt;p&gt;And you can mock out your responses like so:&lt;/p&gt;

&lt;div class="wp_syntax"&gt;&lt;div class="code"&gt;&lt;pre class="ruby" style="font-family:monospace;"&gt;&lt;span style="color:#9966CC; font-weight:bold;"&gt;def&lt;/span&gt; testing_something_now
  &lt;span style="color:#008000; font-style:italic;"&gt;# Assume I have a LegacyStudent model that is a read-only database view, &lt;/span&gt;
  &lt;span style="color:#008000; font-style:italic;"&gt;# and that I have a Factory for it called &amp;quot;legacy_students&amp;quot;&lt;/span&gt;
  legacy_students = create_factory_collection_for_legacy_students
&amp;nbsp;
  &lt;span style="color:#008000; font-style:italic;"&gt;# Mock out my find-all response&lt;/span&gt;
  LegacyStudent.&lt;span style="color:#9900CC;"&gt;expects&lt;/span&gt;&lt;span style="color:#006600; font-weight:bold;"&gt;&amp;#40;&lt;/span&gt;&lt;span style="color:#ff3333; font-weight:bold;"&gt;:all&lt;/span&gt;&lt;span style="color:#006600; font-weight:bold;"&gt;&amp;#41;&lt;/span&gt;.&lt;span style="color:#9900CC;"&gt;returns&lt;/span&gt;&lt;span style="color:#006600; font-weight:bold;"&gt;&amp;#40;&lt;/span&gt;legacy_students&lt;span style="color:#006600; font-weight:bold;"&gt;&amp;#41;&lt;/span&gt;
&amp;nbsp;
  &lt;span style="color:#008000; font-style:italic;"&gt;# Continue testing in peace ...&lt;/span&gt;
&lt;span style="color:#9966CC; font-weight:bold;"&gt;end&lt;/span&gt;&lt;/pre&gt;&lt;/div&gt;&lt;/div&gt;

&lt;p&gt;You can also see the &lt;a href="http://gist.github.com/287253"&gt;GitHub gist for this code here&lt;/a&gt;.&lt;/p&gt;
</content>
    <created-at type="datetime">2010-01-27T15:00:22-05:00</created-at>
    <guid>http://opensource.sha.cornell.edu/blog/?p=227</guid>
    <id type="integer">89</id>
    <published-at type="datetime">2010-01-27T11:17:05-05:00</published-at>
    <source-url>http://opensource.sha.cornell.edu/blog/2010/01/27/easily-create-collections-of-factory-girl-objects/</source-url>
    <summary>We utilize of lot of read-only Database views here at SHA, mainly to leverage Rails&amp;#8217; naming conveniences with legacy database schemas.  We also love using Factory Girl for our tests.  Since we can&amp;#8217;t save data to these views during our testing routine, we need to just build the model objects in memory and [...]</summary>
    <title>Easily Create Collections of Factory Girl Objects During Tests</title>
    <updated-at type="datetime">2010-01-27T15:00:22-05:00</updated-at>
  </post>
  <post>
    <content>&lt;p&gt;Rails has this handy feature called dirty objects, which allows you to easily see how a record has changed during its lifetime.  You get several handy methods on each ActiveRecord object:&lt;/p&gt;

&lt;div class="wp_syntax"&gt;&lt;div class="code"&gt;&lt;pre class="ruby" style="font-family:monospace;"&gt;task = Task.&lt;span style="color:#9900CC;"&gt;first&lt;/span&gt;
task.&lt;span style="color:#9900CC;"&gt;changed&lt;/span&gt;?  &lt;span style="color:#008000; font-style:italic;"&gt;# =&amp;gt; false&lt;/span&gt;
&amp;nbsp;
task.&lt;span style="color:#9900CC;"&gt;name&lt;/span&gt; = &lt;span style="color:#996600;"&gt;&amp;quot;My New Name&amp;quot;&lt;/span&gt;
task.&lt;span style="color:#9900CC;"&gt;changed&lt;/span&gt;?  &lt;span style="color:#008000; font-style:italic;"&gt;# =&amp;gt; true&lt;/span&gt;
task.&lt;span style="color:#9900CC;"&gt;name_was&lt;/span&gt;  &lt;span style="color:#008000; font-style:italic;"&gt;# =&amp;gt; &amp;quot;The Original Name&amp;quot;&lt;/span&gt;&lt;/pre&gt;&lt;/div&gt;&lt;/div&gt;

&lt;p&gt;And so forth.&lt;/p&gt;
&lt;p&gt;The new &lt;a href="http://github.com/daphonz/dirty_associations"&gt;Dirty Associations plugin&lt;/a&gt; allows you to track changes made to your model&amp;#8217;s associations using an interface similar to the original dirty object behavior.  &lt;/p&gt;
&lt;p&gt;Say we have an ActiveRecord class:&lt;/p&gt;

&lt;div class="wp_syntax"&gt;&lt;div class="code"&gt;&lt;pre class="ruby" style="font-family:monospace;"&gt;&lt;span style="color:#9966CC; font-weight:bold;"&gt;class&lt;/span&gt; Task &lt;span style="color:#006600; font-weight:bold;"&gt;&amp;lt;&lt;/span&gt; &lt;span style="color:#6666ff; font-weight:bold;"&gt;ActiveRecord::Base&lt;/span&gt;
  belongs_to &lt;span style="color:#ff3333; font-weight:bold;"&gt;:user&lt;/span&gt;
  has_many &lt;span style="color:#ff3333; font-weight:bold;"&gt;:todos&lt;/span&gt;
  has_many &lt;span style="color:#ff3333; font-weight:bold;"&gt;:comments&lt;/span&gt;
&amp;nbsp;
  keep_track_of &lt;span style="color:#ff3333; font-weight:bold;"&gt;:user&lt;/span&gt;, &lt;span style="color:#ff3333; font-weight:bold;"&gt;:todos&lt;/span&gt;  &lt;span style="color:#008000; font-style:italic;"&gt;# enable dirty methods for these associations only&lt;/span&gt;
&lt;span style="color:#9966CC; font-weight:bold;"&gt;end&lt;/span&gt;&lt;/pre&gt;&lt;/div&gt;&lt;/div&gt;

&lt;p&gt;Now you can enable the dirty association methods merely by calling &lt;code&gt;enable_dirty_associations&lt;/code&gt; on an instantiated object:&lt;/p&gt;

&lt;div class="wp_syntax"&gt;&lt;div class="code"&gt;&lt;pre class="ruby" style="font-family:monospace;"&gt;task = Task.&lt;span style="color:#9900CC;"&gt;first&lt;/span&gt;
task.&lt;span style="color:#9900CC;"&gt;enable_dirty_associations&lt;/span&gt; &lt;span style="color:#9966CC; font-weight:bold;"&gt;do&lt;/span&gt;
&amp;nbsp;
  task.&lt;span style="color:#9900CC;"&gt;user&lt;/span&gt; = User.&lt;span style="color:#9900CC;"&gt;last&lt;/span&gt; &lt;span style="color:#008000; font-style:italic;"&gt;# replace the user association&lt;/span&gt;
&amp;nbsp;
  task.&lt;span style="color:#9900CC;"&gt;associations_changed&lt;/span&gt;?  &lt;span style="color:#008000; font-style:italic;"&gt;# =&amp;gt; true&lt;/span&gt;
&amp;nbsp;
  task.&lt;span style="color:#9900CC;"&gt;user_changed&lt;/span&gt;?  &lt;span style="color:#008000; font-style:italic;"&gt;# =&amp;gt; true&lt;/span&gt;
  task.&lt;span style="color:#9900CC;"&gt;user_was&lt;/span&gt;  &lt;span style="color:#008000; font-style:italic;"&gt;# =&amp;gt; ...original user object...&lt;/span&gt;
  task.&lt;span style="color:#9900CC;"&gt;user_id_was&lt;/span&gt;  &lt;span style="color:#008000; font-style:italic;"&gt;# =&amp;gt; 3&lt;/span&gt;
&amp;nbsp;
  task.&lt;span style="color:#9900CC;"&gt;todos&lt;/span&gt;.&lt;span style="color:#9900CC;"&gt;create&lt;/span&gt;&lt;span style="color:#006600; font-weight:bold;"&gt;&amp;#40;&lt;/span&gt;&lt;span style="color:#ff3333; font-weight:bold;"&gt;:name&lt;/span&gt; &lt;span style="color:#006600; font-weight:bold;"&gt;=&amp;gt;&lt;/span&gt; &lt;span style="color:#996600;"&gt;&amp;quot;New Todo&amp;quot;&lt;/span&gt;&lt;span style="color:#006600; font-weight:bold;"&gt;&amp;#41;&lt;/span&gt;  &lt;span style="color:#008000; font-style:italic;"&gt;# build and create a new has_many association&lt;/span&gt;
&amp;nbsp;
  task.&lt;span style="color:#9900CC;"&gt;todos_changed&lt;/span&gt;?  &lt;span style="color:#008000; font-style:italic;"&gt;# =&amp;gt; true&lt;/span&gt;
  task.&lt;span style="color:#9900CC;"&gt;todos_added&lt;/span&gt;?  &lt;span style="color:#008000; font-style:italic;"&gt;# =&amp;gt; true&lt;/span&gt;
  task.&lt;span style="color:#9900CC;"&gt;todos_removed&lt;/span&gt;?  &lt;span style="color:#008000; font-style:italic;"&gt;# =&amp;gt; false&lt;/span&gt;
  task.&lt;span style="color:#9900CC;"&gt;todos_were&lt;/span&gt;  &lt;span style="color:#008000; font-style:italic;"&gt;# =&amp;gt; ...collection of todos objects at the start of tracking...&lt;/span&gt;
  task.&lt;span style="color:#9900CC;"&gt;todo_ids_were&lt;/span&gt; &lt;span style="color:#008000; font-style:italic;"&gt;# =&amp;gt; [370,39,298]&lt;/span&gt;
&amp;nbsp;
&lt;span style="color:#9966CC; font-weight:bold;"&gt;end&lt;/span&gt;&lt;/pre&gt;&lt;/div&gt;&lt;/div&gt;

&lt;p&gt;You can install this plugin into your Rails application with the following command:&lt;/p&gt;

&lt;div class="wp_syntax"&gt;&lt;div class="code"&gt;&lt;pre class="command" style="font-family:monospace;"&gt;script/plugin install git://github.com/daphonz/dirty_associations.git&lt;/pre&gt;&lt;/div&gt;&lt;/div&gt;

&lt;p&gt;Comments, questions, and (especially) bug reports are highly valued.  You can use the &lt;a href="http://github.com/daphonz/dirty_associations"&gt;GitHub page for Dirty Associations&lt;/a&gt; to pass these along, and also read more documentation, examples, etc.&lt;/p&gt;
</content>
    <created-at type="datetime">2010-01-25T15:02:45-05:00</created-at>
    <guid>http://opensource.sha.cornell.edu/blog/?p=211</guid>
    <id type="integer">88</id>
    <published-at type="datetime">2010-01-25T13:04:08-05:00</published-at>
    <source-url>http://opensource.sha.cornell.edu/blog/2010/01/25/introducing-the-dirty-associations-plugin/</source-url>
    <summary>Rails has this handy feature called dirty objects, which allows you to easily see how a record has changed during its lifetime.  You get several handy methods on each ActiveRecord object:

task = Task.first
task.changed?  # =&amp;#62; false
&amp;#160;
task.name = &amp;#34;My New Name&amp;#34;
task.changed?  # =&amp;#62; true
task.name_was  # =&amp;#62; &amp;#34;The Original Name&amp;#34;

And so forth.
The new [...]</summary>
    <title>Introducing the Dirty Associations Plugin</title>
    <updated-at type="datetime">2010-01-25T15:02:45-05:00</updated-at>
  </post>
  <post>
    <content>&lt;p&gt;This was a nasty one.&lt;/p&gt;
&lt;p&gt;We&amp;#8217;ve been using Rails on &lt;a href="http://www.modrails.com"&gt;Phusion Passenger&lt;/a&gt; for the past year now and have had a lot of fun and satisfaction with it.  But there was one lingering problem that we could not ignore any further: file uploads.&lt;/p&gt;
&lt;p&gt;Almost every time we attempted to upload a file from a multipart form, we&amp;#8217;d trigger an &amp;#8220;Internal Server Error&amp;#8221; page.  Not a Rails 500 error, mind you, but a low-level, default Apache internal server error.  Ouch.&lt;/p&gt;
&lt;blockquote&gt;&lt;p&gt;
Spoiler: we fixed the issue by setting the &amp;#8220;PassengerUploadBufferDir&amp;#8221; parameter to &amp;#8220;/tmp&amp;#8221;
&lt;/p&gt;&lt;/blockquote&gt;
&lt;p&gt;This was a hard problem to track down.  It was made more difficult in that, occasionally, a file upload would work.  This situation would occur using Paperclip, or without, attempting to resize an image or not.  Gleh.  Our Apache logs listed no useful information, even when setting the PassengerLogLevel to a higher level.&lt;/p&gt;
&lt;p&gt;We eventually ran an strace on our httpd instance and attempted to upload a file through a Rails app.  Hidden among the 58 Mb of output, we found this telltale line:&lt;/p&gt;

&lt;div class="wp_syntax"&gt;&lt;div class="code"&gt;&lt;pre class="apache" style="font-family:monospace;"&gt;write(&lt;span style="color: #ff0000;"&gt;2&lt;/span&gt;, &lt;span style="color: #7f007f;"&gt;&amp;quot;[ pid=3024 file=ext/apache2/Hooks.cpp:727 time=2010-01-13 15:05:45.723 ]:
Unexpected error in mod_passenger: An error occured while buffering HTTP upload data to a temporary file in tmp/passenger.2839&amp;quot;&lt;/span&gt;..., &lt;span style="color: #ff0000;"&gt;770&lt;/span&gt;) = &lt;span style="color: #ff0000;"&gt;770&lt;/span&gt;&lt;/pre&gt;&lt;/div&gt;&lt;/div&gt;

&lt;p&gt;Digging through Passenger&amp;#8217;s /apache2/Hooks.cpp code, we found that Passenger treats differently-sized uploads in different ways.  Anything less than 8kb is stored in memory for the duration of the request, and anything larger than this is written to the disk.  When we checked the filesize of the uploads that had been working, they were smaller than 8kb.  &lt;/p&gt;
&lt;p&gt;Ok, so we had narrowed it down to when Passenger attempted to buffer uploaded files to disk.  In the error above, you can see that Passenger is attempting to write the file to /tmp/passenger.xxxx/, which is its scratch area tied to a particular PID of &amp;#8216;xxxx&amp;#8217;.  Looking at the permissions for that file, we saw that it was owned by root, and our apache user had no write permissions to that directory.  &lt;/p&gt;
&lt;p&gt;This was surely the root of the problem (heh): Passenger was freaking out when it attempted to buffer the uploaded file.  This happens even before it spins up the Rails instance, so it would just throw an exception to Apache, which would then render it&amp;#8217;s 500 error page.&lt;/p&gt;
&lt;p&gt;After digging around in Passenger&amp;#8217;s documentation, we found this setting:&lt;/p&gt;
&lt;blockquote&gt;&lt;p&gt;
&lt;a href="http://www.modrails.com/documentation/Users%20guide%20Apache.html#PassengerUploadBufferDir"&gt;5.10. PassengerUploadBufferDir &lt;directory&gt;&lt;/a&gt;&lt;/p&gt;
&lt;p&gt;Phusion Passenger buffers large file uploads to disk in order prevent slow file uploads from blocking web applications. By default, a subdirectory in the system&#8217;s temporary files directory (or a subdirectory in the directory specified in PassengerTempDir, if set) is automatically created for storing these buffered file uploads.&lt;/p&gt;
&lt;p&gt;This configuration directive allows you to specify a different directory for storing buffered file uploads.
&lt;/p&gt;&lt;/blockquote&gt;
&lt;p&gt;We added this line in our httpd.conf:&lt;/p&gt;

&lt;div class="wp_syntax"&gt;&lt;div class="code"&gt;&lt;pre class="apache" style="font-family:monospace;"&gt;PassengerUploadBufferDir /tmp&lt;/pre&gt;&lt;/div&gt;&lt;/div&gt;

&lt;p&gt;And our uploads work perfectly.  We just had to specify the default Apache /tmp file (where it has write-permissions).&lt;/p&gt;
</content>
    <created-at type="datetime">2010-01-14T15:00:52-05:00</created-at>
    <guid>http://opensource.sha.cornell.edu/blog/?p=187</guid>
    <id type="integer">87</id>
    <published-at type="datetime">2010-01-14T10:53:38-05:00</published-at>
    <source-url>http://opensource.sha.cornell.edu/blog/2010/01/14/uploading-files-in-rails-triggers-a-500-error-the-answer-for-us-anyway/</source-url>
    <summary>This was a nasty one.
We&amp;#8217;ve been using Rails on Phusion Passenger for the past year now and have had a lot of fun and satisfaction with it.  But there was one lingering problem that we could not ignore any further: file uploads.
Almost every time we attempted to upload a file from a multipart form, [...]</summary>
    <title>Uploading Files in Rails Triggers a 500 error &#8211; The Answer (for us, anyway)</title>
    <updated-at type="datetime">2010-01-14T15:00:52-05:00</updated-at>
  </post>
  <post>
    <content>&lt;p&gt;If you&amp;#8217;re at Cornell University, that is.  &lt;/p&gt;
&lt;p&gt;Cornell used to use an archaic numeric coding system to designate different semesters, 70 = Fall, 20 = Spring, etc.  But a few years ago, the University switched from that system to a new one, using letters: F = Fall, S = Spring, U = Summer.  Sometimes they get combined into a compound version with a 2-digit year included, i.e. U09, or S07.&lt;/p&gt;
&lt;p&gt;We recently release a simple ruby library for parsing between these types of naming schemas, as well as breaking out the year and full semester name.  It&amp;#8217;s available as a Rails Plugin, but you can also use it as a straight up library as long as you have active_support library installed.  The script has a full test-suite, and even better, it&amp;#8217;s available on &lt;a href="http://www.github.com"&gt;GitHub&lt;/a&gt; with a BSD license, so you can fork away to heart&amp;#8217;s content, or just take it and use it (all 10 of you).&lt;/p&gt;
&lt;p&gt;You can get the code at the following GitHub URL:&lt;br /&gt;
&lt;a href="http://github.com/daphonz/Cornell-Semester-Translator"&gt;http://github.com/daphonz/Cornell-Semester-Translator&lt;/a&gt;&lt;/p&gt;
</content>
    <created-at type="datetime">2010-01-07T15:00:22-05:00</created-at>
    <guid>http://opensource.sha.cornell.edu/blog/?p=183</guid>
    <id type="integer">86</id>
    <published-at type="datetime">2010-01-07T09:52:24-05:00</published-at>
    <source-url>http://opensource.sha.cornell.edu/blog/2010/01/07/handle-legacy-semester-naming-with-ease/</source-url>
    <summary>If you&amp;#8217;re at Cornell University, that is.  
Cornell used to use an archaic numeric coding system to designate different semesters, 70 = Fall, 20 = Spring, etc.  But a few years ago, the University switched from that system to a new one, using letters: F = Fall, S = Spring, U = Summer. [...]</summary>
    <title>Handle Legacy Semester Naming With Ease</title>
    <updated-at type="datetime">2010-01-07T15:00:22-05:00</updated-at>
  </post>
  <post>
    <content>&lt;p&gt;I was browsing through the Rails source code, and came across this nice little snippet.  To paraphrase:&lt;/p&gt;

&lt;div class="wp_syntax"&gt;&lt;div class="code"&gt;&lt;pre class="ruby" style="font-family:monospace;"&gt;&lt;span style="color:#006600; font-weight:bold;"&gt;&amp;#91;&lt;/span&gt;&lt;span style="color:#996600;"&gt;&amp;quot;val1&amp;quot;&lt;/span&gt;,&lt;span style="color:#996600;"&gt;&amp;quot;val2&amp;quot;&lt;/span&gt;,&lt;span style="color:#996600;"&gt;&amp;quot;val3&amp;quot;&lt;/span&gt;&lt;span style="color:#006600; font-weight:bold;"&gt;&amp;#93;&lt;/span&gt; &lt;span style="color:#006600; font-weight:bold;"&gt;*&lt;/span&gt; &lt;span style="color:#996600;"&gt;'&amp;amp;'&lt;/span&gt;
&lt;span style="color:#008000; font-style:italic;"&gt;# returns =&amp;gt; &amp;quot;val1&amp;amp;val2&amp;amp;val3&amp;quot;&lt;/span&gt;&lt;/pre&gt;&lt;/div&gt;&lt;/div&gt;

&lt;p&gt;Yes, multiplying an array by a string does the equivalent of an array &lt;code&gt;join()&lt;/code&gt; method.  So the above is equivalent to:&lt;/p&gt;

&lt;div class="wp_syntax"&gt;&lt;div class="code"&gt;&lt;pre class="ruby" style="font-family:monospace;"&gt;&lt;span style="color:#006600; font-weight:bold;"&gt;&amp;#91;&lt;/span&gt;&lt;span style="color:#996600;"&gt;&amp;quot;val1&amp;quot;&lt;/span&gt;,&lt;span style="color:#996600;"&gt;&amp;quot;val2&amp;quot;&lt;/span&gt;,&lt;span style="color:#996600;"&gt;&amp;quot;val3&amp;quot;&lt;/span&gt;&lt;span style="color:#006600; font-weight:bold;"&gt;&amp;#93;&lt;/span&gt;.&lt;span style="color:#9900CC;"&gt;join&lt;/span&gt;&lt;span style="color:#006600; font-weight:bold;"&gt;&amp;#40;&lt;/span&gt;&lt;span style="color:#996600;"&gt;'&amp;amp;'&lt;/span&gt;&lt;span style="color:#006600; font-weight:bold;"&gt;&amp;#41;&lt;/span&gt;
&lt;span style="color:#008000; font-style:italic;"&gt;# returns =&amp;gt; &amp;quot;val1&amp;amp;val2&amp;amp;val3&amp;quot;&lt;/span&gt;&lt;/pre&gt;&lt;/div&gt;&lt;/div&gt;

</content>
    <created-at type="datetime">2009-11-24T14:55:26-05:00</created-at>
    <guid>http://opensource.sha.cornell.edu/blog/?p=178</guid>
    <id type="integer">85</id>
    <published-at type="datetime">2009-11-24T11:44:49-05:00</published-at>
    <source-url>http://opensource.sha.cornell.edu/blog/2009/11/24/ruby-trick-of-the-day/</source-url>
    <summary>I was browsing through the Rails source code, and came across this nice little snippet.  To paraphrase:

&amp;#91;&amp;#34;val1&amp;#34;,&amp;#34;val2&amp;#34;,&amp;#34;val3&amp;#34;&amp;#93; * '&amp;#38;'
# returns =&amp;#62; &amp;#34;val1&amp;#38;val2&amp;#38;val3&amp;#34;

Yes, multiplying an array by a string does the equivalent of an array join() method.  So the above is equivalent to:

&amp;#91;&amp;#34;val1&amp;#34;,&amp;#34;val2&amp;#34;,&amp;#34;val3&amp;#34;&amp;#93;.join&amp;#40;'&amp;#38;'&amp;#41;
# returns =&amp;#62; &amp;#34;val1&amp;#38;val2&amp;#38;val3&amp;#34;

</summary>
    <title>Ruby Trick Of the Day</title>
    <updated-at type="datetime">2009-11-24T14:55:26-05:00</updated-at>
  </post>
  <post>
    <content>&lt;p&gt;Well, not all of them, but some big ones.&lt;/p&gt;
&lt;p&gt;I noticed the other day, via Google&amp;#8217;s AJAX Libraries page, that they host a variety of popular JS frameworks that you can load directly via the standard &lt;code&gt;&amp;lt;script/&amp;gt;&lt;/code&gt; tag. So instead of hosting, say, JQuery, on my own server, I can just reference Google&amp;#8217;s copy like this:&lt;/p&gt;

&lt;div class="wp_syntax"&gt;&lt;div class="code"&gt;&lt;pre class="html" style="font-family:monospace;"&gt;&amp;lt;script language=&amp;quot;javascript&amp;quot; src=&amp;quot;http://ajax.googleapis.com/ajax/libs/jquery/1.3.1/jquery.min.js&amp;quot; type=&amp;quot;text/javascript&amp;quot;&amp;gt;&amp;lt;/script&amp;gt;&lt;/pre&gt;&lt;/div&gt;&lt;/div&gt;

&lt;p&gt;It&amp;#8217;s like having your own basic asset host. &lt;a href="http://code.google.com/apis/ajaxlibs/documentation/index.html#AjaxLibraries"&gt;Here&amp;#8217;s the full list&lt;/a&gt;, (hint: includes JQuery, Prototype, the Yahoo UI library, and a few others).&lt;/p&gt;
&lt;p&gt;So why would you want to do this?  Two reasons:&lt;/p&gt;
&lt;ol&gt;
&lt;li&gt;HTTP can only have two concurrent requests from a single server.  That means everything from your site will is downloaded two-at-a-time.  If you&amp;#8217;re loading a lot of different resources (images, css files, js files, etc), they all have to wait in line to be downloaded.  But if you link to your JS library via Google, that&amp;#8217;s a new server, and the browser can call that independently from the other resources on your site.  This means your page will load faster.&lt;/li&gt;
&lt;li&gt;You save bandwidth.  Those JS libraries can be reasonably large, but with this method, Google pays for that bandwidth, not you.&lt;/li&gt;
&lt;/ol&gt;
&lt;p&gt;Google claims that it will host these files &amp;#8220;indefinitely&amp;#8221;, but even if they don&amp;#8217;t, it&amp;#8217;s a reasonably quick action to re-set the reference back to your own server.&lt;/p&gt;
</content>
    <created-at type="datetime">2009-11-19T13:45:28-05:00</created-at>
    <guid>http://opensource.sha.cornell.edu/blog/?p=173</guid>
    <id type="integer">2</id>
    <published-at type="datetime">2009-11-18T09:47:00-05:00</published-at>
    <source-url>http://opensource.sha.cornell.edu/blog/2009/11/18/using-google-to-host-your-javascript-assets/</source-url>
    <summary>Well, not all of them, but some big ones.
I noticed the other day, via Google&amp;#8217;s AJAX Libraries page, that they host a variety of popular JS frameworks that you can load directly via the standard &amp;#60;script/&amp;#62; tag. So instead of hosting, say, JQuery, on my own server, I can just reference Google&amp;#8217;s copy like this:

&amp;#60;script [...]</summary>
    <title>Using Google To Host Your Javascript Assets</title>
    <updated-at type="datetime">2009-11-19T13:45:28-05:00</updated-at>
  </post>
</posts>
