Saturday, May 30, 2009

Speakers of RubyKaigi2009 are revealed

In RubyKaigi2009 Japanese site, all speakers are revealed. In English site, only keynote speakers are revealed, but session speakers are not yet at the moment.

Schedules are not revealed both in Japanese and in English site.

Wednesday, May 27, 2009

Qt Puzzle (answer part)

(continued from phosphorescence: Qt Puzzle (question part))

Difference between pattern 1 and pattern 2 is #include declaration. Entire QtGui module is included in pattern 1, and necessary Qt classes are included in pattern 2 one by one.

What happens by this difference? A compile error like below occurs.


log10 method is not found. log10 method is declared on <cmath>, and probably, some class in QtGui module includes it. But, it isn't QApplication class or QLabel class. So pattern 2 need to include <cmath> explicitly like below.
#include <QApplication>
#include <QLabel>
#include <cmath>

int main(int argc, char *argv[])
{
QApplication a(argc, argv);
int source_number = 100;
QString message = "log10("
+ QString::number(source_number)
+ ") = "
+ QString::number(log10(source_number));
QLabel *label = new QLabel(message);
label->show();
return a.exec();
}

Then, compile and run successfully. This dialog appears.

Monday, May 25, 2009

Qt Puzzle (question part)

There are 2 simple Qt programs.

pattern 1
#include <QtGui>

int main(int argc, char *argv[])
{
QApplication a(argc, argv);
int source_number = 100;
QString message = "log10("
+ QString::number(source_number)
+ ") = "
+ QString::number(log10(source_number));
QLabel *label = new QLabel(message);
label->show();
return a.exec();
}

pattern 2
#include <QApplication>
#include <QLabel>

int main(int argc, char *argv[])
{
QApplication a(argc, argv);
int source_number = 100;
QString message = "log10("
+ QString::number(source_number)
+ ") = "
+ QString::number(log10(source_number));
QLabel *label = new QLabel(message);
label->show();
return a.exec();
}

2 programs are the same mostly, and these seem to run correctly. But, only pattern 1 runs correctly, and pattern 2 doesn't. Why? and How? to be continued...

Friday, May 22, 2009

rbrcc

Command rbrcc is a generator from Qt resource collection file(.qrc) to ruby class. Demos and examples of Qt 4.5.1 SDK have some resource collection files. Let's try to generate ruby classes from these resource collection files with below ruby codes:
qt_dir = '/opt/qtsdk-2009.02/qt'
target_dir = '/path/to/target_dir'
`find #{qt_dir}/demos #{qt_dir}/examples -name '*.qrc'`.split.each do |resouce_file|
  basename = File.basename resouce_file, '.qrc'
  `/opt/ruby-1.9.1/bin/rbrcc #{resouce_file} -o #{target_dir}/#{basename}.rb`
end

Ruby classes are generated, and these contain hex of binaries listed in resource collection files.

Tuesday, May 19, 2009

Where has Qt::Thread gone?

QThread class is a thread implementation of Qt. I tried to refer an appropriate API of QtRuby: i.e. Qt::Thread. Let's type rbqtapi command.
>/opt/ruby-1.9.1/bin/rbqtapi Qt::Thread
ERROR: class 'Qt::Thread' not found

Oh, what's wrong? Paths are correct and there's no typo. I searched about this matter on the web, then found some information on ruby-talk-google.

quote:
There's no Qt::Thread because Ruby lacks support for native threads
(at least, for the moment), so it's not really feasible to implement.

Okay, I see. Certainly, Qt's thread is native thread, and Ruby 1.8's thread had been a green thread. So it's no worse that QtRuby wasn't support QThread(Qt::Thread).

But now, Ruby 1.9's thread has become native thread. So this is improvement point for QtRuby.

Saturday, May 16, 2009

Netbeans 6.7 Beta allows Ruby 1.9 syntax

NetBeans 6.7 beta was released 3 weeks ago. As I mentioned at phosphorescence: IDE for Ruby 1.9.1, NetBeans 6.5 didn't allow ruby 1.9 syntax. But NetBeans 6.7(beta) not too? So I download from here, install, and check it. Result is below.


There are 3 ruby 1.9 syntaxes.
  • optional argument allowed not in last
  • ->() lambda
  • .() lambda call
As you can see, no warnings!(Of course, run successfully.)

Thursday, May 14, 2009

Ruby 1.9.1 p129 was released

2 days ago, ruby 1.9.1 p129 was released. So I download and re-install its package like this entry. Let's check.
>/opt/ruby-1.9.1/bin/ruby --version
ruby 1.9.1p129 (2009-05-12 revision 23412) [x86_64-linux]

Then I re-build Qtruby like this entry.

Monday, May 11, 2009

When "gem update --system" fails on Windows

If you install ruby on windows by uncompressing its zip file, "gem update --system" fails in intact because dynamic link library of zlib doesn't exist on the load path. So you need to download zlib compiled DLL from zlib home Site.

After finishing download, uncompress the zip file of DLL, and deploy ruby's bin directory. But, there's one important step that oftenly eliminated. It's renaming from zlib1.dll to zlib.dll. Then "gem update --system" succeeds.

Sunday, May 3, 2009

Spring short vacation

In Japan, first week of May is short vacation week. Of course, I take a short vacation, so I suspend posts and comments to this blog for a moment. Resume will be May 11, 2009.

Saturday, May 2, 2009

Book Review : Debug Hacks

I read Debug Hacks that was introduced by past post and by author himself.


Before reviewing this book, there are two things should be mentioned. First, endorsement is written by Matz. Second, the drawn on the cover is kayaributa (in Kanji characters: 蚊遣豚). This is swine-shaped ceramic container in Japan, to contain mosquito-insecticides: i.e. debug!

To return to the review, as many other Japanese bloggers said, I also think more suitable title for this book is "Debug Hacks for Linux kernel". This book contains 66 debug hacks, and most of these are debugs for Linux kernel, anothers are few. But, these are good case studies not by using itself, for applying our own domain flexibly. In that sense, this book is similar to Beautiful Code.

Finally, I list my applicable hacks from this book by number. The applicable soon are #2, #5 and #66. And the applicable on someday are #18, #23, #26, #52, #53 and #56. Of course, it's different for different individuals, so let's check yourself.