Monday, February 11, 2008

Experiment on Evolution

I have attended very interesting lecture at a local university.
I wish I had enough time to write down the verbs the speaker used to describe what three key figures in the lecture did.
But using my words instead, it was about - Darwin provoked the idea, Dallinger attempted to verify it experimentally, and D'Herelle established the way to experiment it.
Of course, not to mention, that uses life form whose reproduction cycle is very short so that you can observe its evolution.

D'Herelle is the start of Evolutionary medicine.
Evolutionary medicine is very interesting. Bacteriophage therapy makes sense though I acknowledge the points the speaker mentioned - it's alive so you don't necessarily know what would happen after the treatment is completed.

Thursday, February 07, 2008

RSpec Rails screencast

"Story Runner top to bottom screencast"

It's very good and at the same time entertaining to follow as well.

Tuesday, February 05, 2008

Wind-powered generator on the top of the ski hills

Many times at the top of the ski hills and mountains, especially in the high mountains, wind blows very hard.

I have come up with the idea of putting a wind-powered generator on the top of a ski hill. It provides electricity for the lifts. And when the lifts are not used, the generated electricity can be put back to the power grid.

Friday, February 01, 2008

The Psychology of Risks

This is an article in "Communications of the ACM" magazine - January 2008 Volume 51, Number 1.

I just quote.

"The big difference seems to be this: In their personal lives, people tend to consciously and deliberately take risks - though often unaware of possibly serious consequences. When dealing with computer technology, people tend to take risks unconsciously and in some cases unwillingly."

Tuesday, January 29, 2008

Kent Beck on Implementation Patterns

"Kent Beck on Implementation Patterns"

I want to be in the environment where people understand what Kent says in this interview, where I can talk about it and where we can thrive for better together.

Sunday, January 27, 2008

I like Spec::Rails from a different perspective as well

I like Behaviour-Driven Development very much. And that's my primary reason why I like RSpec.

I have another perspective as well about why I like Spec::Rails (RSpec for Rails). The specifications of Views are completely isolated from the Controllers and vice versa. This makes isolating and finding a problem much easier.

Also with the built-in Mock framework, Controller specifications and View specifications become more like Unit Tests (or Unit Specifications, I should say).

With stories to verify the interactions between two components acting as integration test/acceptance test, this approach is much closer to an effective software development dealing with the reality of software development such as frequent changes.

Saturday, January 19, 2008

Bio-diesel hybrid car

I was listening to a radio and it was saying that electric cars were coming out.

I always thought that the next car I would buy is a hybrid car. But after hearing it, I felt like getting electric car instead when it comes out.

Also I have been wondering if they can produce hybrid car using bio-diesel. That is much cleaner than gasoline hybrid car. The source of fuel is clean because it's a plant. And the fuel itself is cleaner.

I want to work on contributing for cleaner energy source.

Thursday, January 10, 2008

Installing MySQL driver gem

I have upgraded MySQL from 5.0.27, which I installed about a year ago when I bought MacBook, to 5.0.45 yesterday. The reason is that I learned from a MySQL users group meeting that there are lots of important fixes in the versions above 5.0.30.

In Ruby on Rails 2.0, it is recommended to install MySQL driver gem because the one that comes with Rails is not for production use. The gem command is described in config/database.yml.
i.e. On Mac OS X 10.5 Leopard,
sudo env ARCHFLAGS="-arch i386" gem install mysql -- --with-mysql-config=/usr/local/mysql/bin/mysql_config

Previously, installing MySQL driver gem had failed. I tried it again today now that I have the latest 5.0 version of MySQL. Then the installation was successful.

Monday, January 07, 2008

Ruby on Rails: Symbol#to_proc defined in ActiveSupport

I found it in a blog entry "An Introduction to Ruby's Enumerable Module"

It is interesting and I think I can describe it as very powerful.

Tuesday, January 01, 2008

Ruby on Rails 2.0: link_to for nested resources

If you specify nested resources in routes.rb such as

map.resources :daily_contents do |daily_content|
daily_content.resources :vocabularies
end

you have to specify a parameter for link_to like this:

<% for vocabulary in @daily_content.vocabularies %>
..
<%= link_to 'Show', [@daily_content, vocabulary] %>
<% end %>

The generated URL is like this:

http://localhost:3000/daily_contents/5/vocabularies/2

Moreover, if @daily_content.entities is just an array, which happens to contain an object of type, Vocabulary, the following works as well:

<% for entity in @daily_content.entities %>
..
<%= link_to 'Show', [@daily_content, entity] %>
<% end %>

Again the generated URL is same as above like:

http://localhost:3000/daily_contents/5/vocabularies/2

Wednesday, December 26, 2007

Problem with installing Ruby 1.9 on Mac OS X 10.5 Leopard

I have tried to install Ruby 1.9 from tar ball. But so far, there is a problem and it's not successful.

I borrowed the ideas from the following sites:

"Building Ruby, Rails, Subversion, Mongrel, and MySQL on Mac OS X"

"Ruby on Rails install on 10.5 OS X"

"Trouble with Readline and Building Ruby 1.9"

(Also the same post under ruby-forum: "Trouble with Readline and Building Ruby 1.9")

Still Ruby make is failing with regard to readline.


By the way, I miss Linux package managers. It was easy to see which version of what is installed. MacPort is trying to achieve the same thing. But so far, it was not successful to install it. When it comes to package management, I think Linux is better.

Ruby 1.9 Released

You can download it from Ruby Programming Language site.

Sunday, December 23, 2007

Location of Ruby gems for the preinstalled Ruby on Mac OS X 10.5 Leopard

It's /Library/Ruby/Gems/1.8/gems/

The preinstalled Ruby is /usr/bin/ruby (note: execute "which ruby" from command line), which is a symbolic link to

/System/Library/Frameworks/Ruby.framework/Versions/
Current/usr/bin/ruby


So you would think that the location of the gems is under

/System/Library/Frameworks/Ruby.framework/Versions/
Current/usr/lib/ruby/gems/1.8/gems


just like when you install Ruby manually.
But when I looked at the Rails gem under the directory, it was rails-1.2.3.

I performed a search for "rails" gem under each directory under the path as a root user but all the searches found only the same rails-1.2.3.
So finally I performed a search for the entire directory tree, i.e. executed

find / -name "rails" -print

as a root user. And here it is, it found

/Library/Ruby/Gems/1.8/gems/rails-2.0.1/bin/rails

By the way, as a side note, I wanted to see if "/Library/Ruby/Gems/1.8/gems/rails-2.0.1/bin/rails" is sym-linked from /usr/bin/rails (by executing "ls -alFh /usr/bin/rails"). But it isn't. /usr/bin/rails is not a symbolic link of anything. It's an executable file.

This whole thing is very confusing to me.
All I wanted to do was to look at the Rails 2.0.1 source code.

Thursday, December 20, 2007

Ruby on Rails 2.0 configuration files, etc.

I have read through the files in the Rails project generated with Ruby on Rails 2.0, such as the configuration files, etc. e.g. /config/boot.rb, /config/environment.rb.

I've found that they are more well-written and well-structured.

Ruby gem install error with Mac OS X 10.5 Leopard

I attempted to install ruby-debug gem but it failed with a message:

ERROR: Error installing ruby-debug:
ERROR: Failed to build gem native extension.

/System/Library/Frameworks/Ruby.framework/Versions/1.8/usr/bin/ruby extconf.rb install ruby-debug can't find header files for ruby.


This was because the installed Mac OS X Xcode Tools was old, specifically, GCC was old. I had to install Xcode Tools 3.0, which is actually shipped with Mac OS X 10.5 Leopard DVD. You can also download it.

Thursday, December 13, 2007

Switched to TextMate

As I updated to Ruby on Rails 2.0, I decided to try out TextMate.

After getting used to it after reading its documents, I came to like it because its Ruby and Ruby on Rails Bundles seem to have lots of good features.

But I didn't necessarily like its Subversion Bundle. I had to do "svn import" from the command line, delete the local Rails directory (of course, after backing it up), and check out the directory from the Subversion. Otherwise, there is no .svn folder. With Subversion (Eclipse Subversion Plugin), you don't have to delete the local directory. Maybe there is a better way to make this work in TextMate and I would like to know it.

Sunday, December 09, 2007

Ruby MetaProgramming

Watch the video
"MetaProgramming - Extending Ruby for Fun and Profit"

Isn't this wonderful?

Updating to Ruby on Rails 2.0

Until today, I have been using Ruby I installed manually on /usr/local/ (/usr/local/bin/ruby) because that's how I installed it on Mac OS X 4 Tiger. When I purchased Mac OS X 5 Leopard several days after it was released, I noticed that Ruby was installed under /usr (/usr/bin/ruby) as a part of Mac OS X developer tools. But I kept my .profile with "export PATH=/usr/local/bin:/usr/local/sbin:$PATH" because I had lots of gems installed already under the Ruby under /usr/local (/usr/local/lib/ruby).

Today as a part of updating to Ruby on Rails 2.0, I switched to use the Ruby included with Mac OS X developer tools (under /usr). And updated Rails gem under that location (under /user):

1. Commented out "export PATH=/usr/local/bin:/usr/local/sbin:$PATH" in my .profile. Restarted the shell.

2. Executed "gem update rails".

Ruby on Rails 2.0 Released

See Ruby on Rails official site and Ruby on Rails weblog.