Friday, February 26, 2010

Installing Ruby 1.9.1 with Ruby Version Manager (RVM) on Mac OS X Snow Leopard

For some reason, Ruby 1.9.1 didn't install on my Mac OS X Snow Leopard because of an error:


Error running 'make ', please check /Users/home_dir/.rvm/log/ruby-1.9.1-p378/make*.log


The error in ~/.rvm/log/ruby-1.9.1-p378/make*.log:


compiling readline



readline.c: In function ‘username_completion_proc_call’:
readline.c:1159: error: ‘username_completion_function’ undeclared (first use in this function)
readline.c:1159: error: (Each undeclared identifier is reported only once
readline.c:1159: error: for each function it appears in.)
make[1]: *** [readline.o] Error 1
make: *** [mkmain.sh] Error 1


So compiling Ruby 1.9.1 with the default readline installed on Snow Leopard didn't work.

By looking at "rvm --help" or ~/.rvm/README, there is an option to specify custom configure options, i.e. -C|--configure. Also there is a flag to force ./configure on install even if Makefile already exists, i.e. --reconfigure.

So I installed readline with MacPorts and installed Ruby 1.9.1 with the option and the flag:


$ sudo port install readline

$ rvm install 1.9.1 --reconfigure --configure --with-readline-dir=/opt/local


Then installation succeeded.

Saturday, December 19, 2009

United Nations Press Conference in Copenhagen Climate Change Conference

The most interesting press conference I have ever seen in the conference.

Press Conference by United Nations on December 19, 2009.

Copenhagen Climate Change Conference

First of all, I have a great respect to all the people, delegates and leaders of the countries, who worked so hard for long hours day and night, staying overnight into late in the morning. Many of them haven't slept for 48 hours.

I have been following it watching the webcast.

At around 3am in the local time, the draft of what is called Copenhagen Accord was presented in front of the Plenary, asking the parties to consider in one hour, after only small number of countries in the closed door spent many hours to draft it, leaving majority of delegates waiting. It was good that the one hour timeline approach was soon dropped.

Basically majority of the parties were forced to swallow what was created by small number of countries (it seems to me, possibly even before the beginning of the conference). The draft should have been created in the Plenary involving all the parties. All the parties were working hard and willing to do whatever takes to solve this difficult problem of climate change all two weeks.

I have been following the last Plenary overnight taking a break here and there and after almost 12 hours later, I couldn't continue any more unfortunately, so I could not see how it was ended. But the those hours saw the involvement of all the parties and that should have been the way all throughout the two weeks. I think that may have brought a better result.

Friday, December 18, 2009

United States' attitude in Copenhagen Climate Change Conference

Since the beginning of the Conference, there have been many informal consultations involving only a small number of countries despite the fact that the delegates from many countries were there to work in the plenaries. And many countries expressed their concern about "transparency".

Now the United States is using the same word, "transparency", for a different context.

First of all, if "transparency" is important, they should ratify the Kyoto Protocol, instead of just announcing what they do about clean energy technology in their country.

Second, while they used the word, "transparency", they formed a closed door meeting with only handful of countries, despite the fact that great majority of the head of states and the leaders are there in the Conference. What they are doing doesn't have any "transparency".

It almost sounds like to me that they took advantage of the situation where many countries are upset about "transparency" in the Conference and used the same word in a different context to diffuse people's attention away from their own responsibilities. In other words, the perception of the majority of parties have been that the United States and China are the blocker of the deal and the United States manipulated to make it look as if China is the only problem.

Wednesday, December 16, 2009

Tokyo Cabinet (rufus-tokyo) - TableQuery :stroreq and :numoreq

Quick note about what I found.

The documentation for Rufus::Tokyo::TableQuery says "string/number which is equal to at least one token" for :stroreq and :numoreq, respectively. But this collection of tokens cannot be an array. It must be a string with tokens separated by comma.

How did I find that array doesn't work?

First, it didn't return the expected result.

Then I looked at the code for the add method by clicking on "View source" and found that to_s is called immediately on the passed val (in this case, a collection of tokens). So if array is passed, to_s is called on it, which only returns a string concatenating all the array elements. So how the code following it can distinguish the tokens for the string, e.g. "123"? - (1 and 23) or (1 and 2 and 3), etc?

So I simply tried passing a string with tokens separated by comma, e.g. "1,2,3". Then it worked.

Ruby on Rails: background job for uploading file

Quick note.

Running the work of uploading file in the background using Delayed Job doesn't work well because it has a problem with serializing the data into YAML::Object that it uses.

Workling with Spawn works well.

Wednesday, December 09, 2009

Very informative webcast about climate change

It was very informative.

COP 15 Media Training Workshop

Bolivia's position on the climate crisis

I think what they say hits the points.

(The embedded video below doesn't seem to work well. So I put a link, too)








Saturday, December 05, 2009

Musique Jazz - Sadao Watanabe "Rendez-vous"

Un saxophoniste, Sadao Watanabe (渡辺貞夫).

Parce que je l'écoute souvent à YouTube parce que je ne le trouve pas encore dans iTune ou autre, j'ai décidé de le mettre ici.

Friday, November 27, 2009

Une pièce de musique traditionnelle du japon « Sakura »

Mon professeur du cours de musique m'a demandé de trouver une vidéo de la pièce de musique japonaise qui s'appelle « Sakura » qui veut dire fleurs de cerise. J'en ai trouvé une. C'est belle.



Monday, November 23, 2009

World Wildlife Fund: Oil and Ice Tour: Are we giving up ice for oil?

I attended an event by World Wildlife Fund the other day.

It is incredible that one barrel of oil (natural gas) is used par three barrels of oil produced being extracted from tar sand. What a waste of natural gas!

The speaker said that in order to sustain civilization, the ratio of the energy used and the energy generated must be at least 1:5.

Saturday, November 21, 2009

Tokyo Cabient and rufus/tokyo table locking

This may be obvious but I just write it anyway.

It is from http://rufus.rubyforge.org/rufus-tokyo/Rufus/Tokyo/Table.html and what I tried out based on the information there.

1. When you instantiate Rufus::Tokyo::Table, it gets the default mode of :write and :create, which locks the table.

-> So instantiating another fails with "Rufus::Tokyo::TokyoError: (err 16) lock error".

2. If the mode is :read and 'f' (non blocking lock), multiple instances can be created and each can read.

-> But when one is with the mode :write and 'f' (non blocking lock), instantiating another with the mode :read and 'f' fails with "Rufus::Tokyo::TokyoError: (err 16) lock error".

3. When one is instantiated with the mode :write and 'f' (non blocking lock), instantiating another with the mode :read and 'e' (non locking) succeeds.

-> And you can read from either instances.

-> When you write a value with that first instance with the mode :write and 'f', you can read the value from that first instance. But in order to read the value from the other second instance with the mode :read and 'e', you have to first close it and instantiate a new one with the mode :read and 'e'. Otherwise, that second instance doesn't read the newly added value.

4. When multiple instances are instantiated in the same thread (e.g same Rails console), thread occurs with "Rufus::Tokyo::TokyoError: (err 1) threading error".

5. If table file is never created, the mode :create must be specified.

20th Anniversary of the fall of Berlin Wall

I wanted to write what I felt at that time but have been busy.

November 9, 2009 was the 20th anniversary of the fall of Berlin Wall.

20 years ago, I was thinking of visiting East Europe to be in the middle of the change. But I didn't because the only experience of traveling abroad that far was China and I wasn't sure if I could go around. Instead, I traveled to Malaysia, Singapore, and Australia.
That itself was a good experience. But I regret that I didn't go to East Europe at that time.

Looking back, after gaining lots of experience traveling abroad, I think I was able to go around there without a problem, finding a hotel, etc.

During these 20 years, what have I done?
Surely, my intention in my mind has been always doing something good, contributing to protect human rights and democracy, etc. But in reality, I haven't achieved anything in those long 20 years, caught up with unimportant things.

Tuesday, September 15, 2009

Upgrade to Mac OS X Snow Leopard (as a development machine for Ruby on Rails) 2

All I was trying to do was to switch to MySQL 64bit. That led to changing the whole thing. Installed MySQL 5.1 64bit. I had to switch to the preinstalled Ruby 1.8.7 instead of the one I had installed using MacPorts before because mysql gem installation failed. And that led to installing the gems under /usr and uninstalling the ones that are not 64bit and reinstalling them. There were much more.

Usually, I write what I did to make it work. But it's too long. So I just leave it to say that I'm happy that it's finally all set.

Sunday, September 06, 2009

Upgrade to Mac OS X Snow Leopard (as a development machine for Ruby on Rails)

I have upgraded from OS X 10.5 Leopard to 10.6 Snow Leopard recently.

Then I couldn't access MySQL any more.

After many trials such as installing 64 bit MySQL, etc, I found that all the directories and files except for data and lib had been deleted under MySQL directory and also symbolic link to it when the Snow Leopard upgrade was done. In my case, I had mysql-5.0.45-osx10.4-i686 under /usr/local and I used to have the symbolic link called mysql under /usr/local pointing to it. I found the problem by looking at Time Machine.

So I restored the /usr/local/mysql-5.0.45-osx10.4-i686 directory from the backup using Time Machine and then restored mysql symbolic link.

MySQL setup GUI under "System Preferences..." (under Apple mark menu) didn't work. i.e. MySQL server didn't either start or stop by clicking on the button there. So I restarted Mac OS X in order to start MySQL server.

Then I was able to access to MySQL as before.

The next step is installing 64 bit MySQL to take advantage of OS X Snow Leopard.

(By the way, I'm using MySQL 5.0 because I learned from a local MySQL user group, it's not worth upgrading to 5.1. But I hope it's worth upgrading OS X to Snow Leopard.)

Wednesday, May 27, 2009

Steve Nash and his contribution toward environmental issues

Steve Nash, a professional basketball (NBA) player for Phoenix Suns wears basketball shoes made out of recycled materials. He initiated to put solar panel at the roof of the stadium. He advocates many practices such as riding a bike or skateboard and actually practices them.

I like him very much.
For many years, it has been because of his basketball skills and smart plays.
Now I admire him.
That's because I have learned his initiatives.

Wednesday, April 08, 2009

Cucumber and restful_authentication

I have started to use Cucumber.
But I'm using restful_authentication for the Ruby on Rails application I'm working on and I had to deal with it.
It turned out that all I have to do was to add a step like the following (My actual code has a role parameter - e.g. admin - but I omitted it here for simplicity):

Given /^I am logged in$/ do
User.create!( :first_name => 'quire',
:last_name => 'smith',
:login => 'quire',
:email => 'quire@example.com',
:password => 'test',
:password_confirmation => 'test' )
post "/login", :login => 'quire', :password => 'test'
end


By the way, in routes.rb, I'm setting the following as described in restful_authentication:

map.login '/login', :controller => 'sessions', :action => 'new'


P.S. Actually, it didn't work quite well in the steps later on. I will do more investigation.