Archive

Archive for September, 2009

Class, Module and Test Example

September 27th, 2009 Jonathan 10 comments

In the Sunday section, we created a small application that several students requested the final source for. It includes examples of:

  • Class inheritance
  • Raising and catching exceptions
  • Using a module via include and extend
  • Testing using Test::Unit
  • Spreading code between multiple files
  • Using method_missing to dynamically add methods
  • How to tune a Ukulele for fun and profit

I tried to make use of as much of the last two lectures as possible. If you have any questions about how this works, or why things are done the way they are, feel free to comment below.
You can click here to downloaded the completed source code.

Run “ruby section.rb” to actually run the application. Edit this file as you see fit.

Run “ruby instrument_test.rb” to run the tests.

Categories: Announcements Tags:

Assignment 1, Question 4

September 16th, 2009 john No comments

For Assignment 1, Question 4, you may assume that the sorted order of the values is distinct.

Categories: Announcements Tags:

Problems with lecture02.zip download should be fixed

September 13th, 2009 john 1 comment

One of you reported a problem running the Ruby code in the download for the 2nd lecture.

I reproduced it at work, and it turned out that when I fixed a bug in JRuby, I compiled it with Java 1.6.

But for maximum portability, it needed to be 1.5.

So that should be all better.

Categories: Announcements Tags:

Lecture 2 ZIP: bug

September 11th, 2009 john No comments

I seem to have introduced a bug that presents one from running the code in Lecture 2.

A temporary work-around is to download the ZIP for the second hour of Lecture 1, and take Lecture 2’s -all.html file, and put it into the root of the unzipped lecture.

I will fix it this evening and will upload a repaired copy.

Categories: Announcements Tags:

Lecture 2 available for download; and about slides with recording

September 11th, 2009 john 3 comments

Students,

The slides for Lecture 2 are available for download on the downloads page.

Note that you want to open the “-all.html” page (there are now separate .html files for each slide, for the benefit of Harvard – it’s a lot easier for me to just leave them in the ZIP).

About the slides that we hope will now show with the recorded lecture:

Remember that the recorded lectures will appear here: http://cm.dce.harvard.edu/2010/01/12923/videopage.shtml

When Harvard releases the recorded lecture, it should now be accompanied with the slides, which should be synchronized with the lecture. However, the code might not run in the browser. If that is the case, you will want to use the slides in the download. (The runnable Ruby was not designed to be delivered over the web; one of the components is about 10MB, and it takes a long time to load over the wire. There is also a lot of JavaScript that fools around with frames, and the Harvard slide system is framed, so there is doubtless a conflict.)

John

Categories: Announcements Tags:

Diagnostics for Flash for recorded lectures

September 9th, 2009 john No comments

If you have problems with the recorded lectures, you may find this page helpful for diagnosing the problem:

http://cm.dce.harvard.edu/forms/troubleshoot_flash.shtml

Categories: Announcements Tags:

Just sent out section assignments

September 6th, 2009 john 2 comments

Students,

I just e-mailed section assignments to you from my john at 7fff dot com e-mail address (e-mail #3), with a subsequent e-mail from my jgnorman at fas.harvard.edu e-mail (e-mail #4).

There are notes in the #3 e-mail about how we can change sections if you have a good reason. We probably won’t get to section swaps until Tuesday evening.

If you didn’t get the e-mail, that means:

(1) It went into your junk folder – check that first.

(2) Or, your e-mail in the Harvard system is no good.

(3) Or, a wild thing ate it.

Let me know if there was a problem, and I’ll re-send.

John

Categories: Announcements Tags:

For Assignment 0: Rails 2.3.3 only

September 4th, 2009 john No comments

Annoyingly, the newest version of Rails, 2.3.4, has a bug that we might as well avoid.

So, we shall stick to 2.3.3 only, until this is cleared up.

To check your version number, do

gem list

You should a display something like this (with versions 2.3.3 or 2.3.4):


*** LOCAL GEMS ***

actionmailer (2.3.3)
actionpack (2.3.3)
activerecord (2.3.3)
activeresource (2.3.3)
activesupport (2.3.3)
cgi_multipart_eof_fix (2.5.0)
daemons (1.0.10)
eventmachine (0.12.8)
fastthread (1.0.7)
gem_plugin (0.2.3)
rack (1.0.0)
rails (2.3.3)
rake (0.8.7)
sqlite3-ruby (1.2.5)
thin (1.2.2)

If at this point you the 2.3.4 versions of rails, actionmailer, actionpack, activerecord, activeresource, and activesupport, do

gem uninstall rails actionmailer actionpack activerecord activeresource activesupport

If you are asked “which versions,” select “all of them.”

Then to install Rails at version 2.3.3, specify the version number, and gem install sqlite3-ruby separately:

gem install rails -v 2.3.3
gem install sqlite3-ruby

Sorry about this. Rails 2.3.4 introduces an issue when using Ruby 1.9.1 (see https://rails.lighthouseapp.com/projects/8994-ruby-on-rails/tickets/3144-undefined-method-for-string-ror-234). For our pedagogical purposes, 2.3.3 will be fine, and it is likely that there will soon be a 2.3.5 that has the updates for 2.3.4 and has a fix for this recently-introduced bug.

John

Categories: Announcements Tags:

[ignore - see next] Assignment 0: Rails 2.3.3 or 2.3.4 ok

September 4th, 2009 john No comments

See next newest post.

Rails just got a release bump, probably because of a recent security fix.

So we will accept Rails 2.3.3 or 2.3.4 for Assignment 0 (2.3.4 preferred; but no worries if you’ve already installed and submitted with 2.3.3).

Categories: Announcements Tags:

September 4th, 2009 john No comments

I’ve added a “Note” regarding how to follow the posts and comments here via Twitter.

(The Notes drop-down is at the top of the page — I’m not linking to it so you will notice what’s up there in the navigation.)

Categories: Announcements Tags: