Lonely Planet Images

August 31st, 2009

Lonely Planet, the experts in independent travel information now present Lonely Planet Images (LPI). LPI is a digital image library with a unique and comprehensive collection of over 300,000 downloadable travel photographs taken by some of the best travel photographers in the business.

Lonely Planet Images

Its Chinese collection is relatively small so far. Hmm hmm…

When doing performance in local box, we found that requests are waiting to be processed due to Rails is single-threaded by default. We changed the configuration to enable multi-threaded mode as described in this blog entry:

Thread safety for your Rails

(also refer to Rails 2.2 release notes )

The most important change was to eager-load /lib directory, and thus move libraries for test out of it.

config.threadsafe! also disables automatic loading by ActiveSupport::Dependencies. Alternatively, you can just add lib/ directory to eager load paths. The following inside production.rb will do that :
config.eager_load_paths << "#{RAILS_ROOT}/lib"

We had some rough tests to ensure the functionality is not broken. Multi-threaded mode also might require more memory than single-threaded mode. Still keep testing.

rake stats (again)

June 8th, 2009

用Ruby翻新一个Java的系统。原来系统功能代码47311行,测试代码13440行(都只计算Java代码)。还没翻完。

+----------------------+-------+-------+---------+---------+-----+-------+
| Name                 | Lines |   LOC | Classes | Methods | M/C | LOC/M |
+----------------------+-------+-------+---------+---------+-----+-------+
| Controllers          |  1403 |  1188 |      31 |     131 |   4 |     7 |
| Helpers              |   361 |   311 |       0 |      52 |   0 |     3 |
| Models               |  2236 |  1837 |      77 |     270 |   3 |     4 |
| Libraries            |  2115 |  1740 |      30 |     156 |   5 |     9 |
| Model specs          |  2443 |  2022 |       0 |      18 |   0 |   110 |
| View specs           |     0 |     0 |       0 |       0 |   0 |     0 |
| Controller specs     |  3315 |  2716 |       0 |       2 |   0 |  1356 |
| Helper specs         |   374 |   310 |       0 |       0 |   0 |     0 |
| Library specs        |   822 |   708 |       0 |       3 |   0 |   234 |
+----------------------+-------+-------+---------+---------+-----+-------+
| Total                | 13069 | 10832 |     138 |     632 |   4 |    15 |
+----------------------+-------+-------+---------+---------+-----+-------+
  Code LOC: 5076     Test LOC: 5756     Code to Test Ratio: 1:1.1

这次是JRuby on Rails。我特别喜欢它的部署脚本。

JRuby/LDAP over SSL

March 25th, 2009

Integrating ActiveDirectory with JRuby on Rails. Blocked by SSL issue. (Actually not AD but ADAM. Check how to configure ADAM for SSL on Windows XP without a certificate server )

Jeff: Here we have a question about JRuby/LDAP: how to establish SSLConn to ActiveDirectory, given we have got the certificate file (xxx.cer)?

Ola: Very good question. At the moment I don’t have the answer – and I’m not sure it’s possible. Have you considered using net/ldap instead? It’s pure Ruby and very nice.

~~(╯﹏╰)~~

And then I figured it out. What we need is (1) import the certificate to a keystore, and (2) specify the location of keystore to JRuby.

# command line
keytool -keystore "./cacerts" -import -file Authority.cer
# JRuby
java.lang.System::setProperty("javax.net.ssl.trustStore", "/path/to/cacerts");

And…that’s it. Now we can connect to ADAM over SSL.

conn = LDAP::SSLConn.new(host=LDAP_HOST, port=636)

Oracle AppsLab Blog
"Mix is Live"
http://tinyurl.com/2hcp8p
An announcement of the Mix application we built in partnership with Oracle. In case you had forgotten, we have a logo/link at the bottom of every page of the application -- there for Oracle's 300,000 customers to see. By the end of the recent Oracle OpenWorld conference, the Mix had over 1,500 signups.

Oracle AppsLab Blog
"Let's Mix"
http://tinyurl.com/26fal3
The Mix application built in less than 5 weeks "with the help of the wonderful people at ThoughtWorks." Mike Royle, Toby Tripp, Matthew Wastrodowski and Sid Pinney were all part of this relationship.

InfoQ
Oracle Mix: First large JRuby on Rails app online
http://tinyurl.com/yqjzqb
ThoughtWorks, JRuby and Ola mentioned in excerpts

Oracle AppsLab Blog
Mix, JRuby on Rails, Small Teams, Agile, and it’s Effects on the World
http://tinyurl.com/26fg5p
A good post about JRuby and its role in the Mix development. Ola Bini and ThoughtWorks are mentioned.

Jini脚本语言唯Java马首是瞻Alexey(在一个邮件里)说Ruby就是新时代的COBOL。两种说法的意思是一样的:在Java平台上跑Ruby程序,同时收获两个世界最好的东西。

Oracle已经尝试了。Oracle Mix是一个社会网络站点,也是第一个大型的JRuby on Rails的应用。效率?效率真的不错。Oracle的同志说,Mix每秒能处理400~600个请求。比较不理想的是内存使用情况,这里有一个已知的问题存在。不过在Oracle那样的强大服务器上,这个已经不成问题,于是也没有人去动它。

更好的想象来自HibernateActiveRecord的不足是显而易见的,但用Ruby重新实现一个Hibernate不是件很轻松的事,特别是考虑到Hibernate支持那么多数据库。那么,Hibernate加一个Convention over Configuration的Ruby API又如何呢?把Hibernate融入Rails又如何呢?Alexey正在着手做一些东西。

近在眼前的,JRuby on Rails感觉上更像是一个Java的框架,而不是另一个平台,这让它更容易被比较保守的企业和政府客户接受,特别是那些已经在J2EE服务器上投入了大量成本的客户。现在好了,你的投资重新焕发青春,开发效率提升5倍。谁会不喜欢呢?

JRubyWorks: J2EE on Rails

August 18th, 2007

(NOTE: JRubyWorks keeps moving forward and this article may not be up to date.)

How to run your Rails application with J2EE web servers (such as Jetty and Tomcat)? Here’s a solution:

1. Set JRUBY_HOME environment variable properly.

export JRUBY_HOME=/usr/lib/jruby

2. Install ActiveRecord-JDBC.

jruby -S gem install ActiveRecord-JDBC -y

3. Install JRubyWorks plugin.

script/plugin install \
http://jrubyworks.rubyforge.org/svn/trunk/jrubyworks/

4. Configure your Rails application as this article. JRubyWorks plugin includes mysql-connector by default. If you use database other than MySQL, you can put corresponding JDBC driver in ${RAILS_ROOT}/lib/java directory and JRubyWorks will take care of it conventionally.

5. Run your application and try it at http://localhost:8080. Also you can find a WAR file of your application in ${RAILS_ROOT}/war directory. You can deploy it to other J2EE web servers.

jruby -S rake retty

JRubyWorks is based on JRuby Rails Integration and hope to make the integration easier. It’s quite immature so far, apparently. Your feedback and contribution will be very helpful and highly appreciated.