Tue 25 September, 2007

If you don't like something new that's getting a lot of attention, you call it out as being all hype propelled by fanboys enamoured by an immature solution.
If you like that something new, you say it has momentum that's being accelerated by passionate advocates of a fresh approach.
add to del.icio.us. look up in del.icio.us.
add to furlMon 24 September, 2007

add to del.icio.us. look up in del.icio.us.
add to furl
add to del.icio.us. look up in del.icio.us.
add to furl
add to del.icio.us. look up in del.icio.us.
add to furl
add to del.icio.us. look up in del.icio.us.
add to furl
“ Look at the sea. What does it care about offenses?” ”
Buck Mulligan
add to del.icio.us. look up in del.icio.us.
add to furl
add to del.icio.us. look up in del.icio.us.
add to furl
今天是一个发布的日子,XRuby发布了0.3.1,Ruby Hacking Guide中文版发布了第一部分。
XRuby 0.3.1
相比于前一个版本,XRuby 0.3.1最大的进步在于完成标准库的预编译。预编译意味着什么?标准库代码无需在每次运行时编译,这意味着今后使用XRuby的标准库性能会得到一定的提升。
有一个与编译相关的话题。之前,Jon Tirsen曾经谈到JRuby的一个问题,运行在AppServer中会有占用太多内存。经过分析得知,为了提高程序的并发性,程序运行会启动多个JRuby。每个JRuby解析Ruby脚本都会建立一棵完整的语法树,这就意味着,由于这种解析模式本身的限制,对于同样的内容,内存中需要保存多份相同的语法树,这种做法意味着无谓的耗用了大量的内存。采用编译的做法,则可以很好的避免这个问题。因为在运行时,相同的是字节码,而JVM很好的帮我们解决字节码共享问题,无需耗用大量的内存。
RHG终于完成了第一次发布。已经发布的第一部分介绍的是Ruby的对象模型。我正是从这个部分开始了解Ruby实现的,进而完成了XRuby的Runtime的重写。所以,我一直觉得这部分是了解Ruby实现非常好的一个起点。
从翻译Ruby Hacking Guide到现在已经超过了一年,从第一次发布消息算起也超过了9个月。相比XRuby,这个项目的进展可以用异常缓慢形容。这是一本日文书,也是一本技术书,而且是一本讲语言实现的书。任何一个点都会增加翻译的难度。几个懂日语的朋友先进行一遍初译,然后,我对再对译稿进行一遍校验,并根据自己的理解修改译稿,这样的过程无疑延长了处理的时间。这是一个业余时间的项目,而我更多的业余时间在XRuby上,没有太多精力投入上面。种种的因素造成了这个项目的一托再托。
目前,我手头已经有了第二部分全部和第三部分几章的初译稿,不过,按照之前的进度来看,这几章的发布可能要等到许久之后了。如果你有兴趣,可以加入到这个项目中来,这样,有助于加快这个项目的进度。
add to del.icio.us. look up in del.icio.us.
add to furl
add to del.icio.us. look up in del.icio.us.
add to furl
add to del.icio.us. look up in del.icio.us.
add to furl
add to del.icio.us. look up in del.icio.us.
add to furl
add to del.icio.us. look up in del.icio.us.
add to furl
Rewriting existing applications from scratch in a Big Bang-style is rarely a good idea and often ends in failure. Chad Fowler wrote a good post summarizing some of the reasons why a year ago: The Big Rewrite.
add to del.icio.us. look up in del.icio.us.
add to furlSun 23 September, 2007

add to del.icio.us. look up in del.icio.us.
add to furl
目录
(一)系统环境:
- Ruby 语言 1.8.4版本, 点击这里Ruby1.8.4。要想安装多个Ruby语言运行环境请看这里。
- Rails 框架 1.2.1版本,安装方法请看这里,最简单方法是第一种方法即可。
- Windows XP 或者 Windows 2000操作系统 或者 Linux操作系统
- 需要一个浏览器,如FireFox1.5.0.1以上版本。
- 开发编辑工具 Notepad2 ,安装方法请单击这里,复制一个notepad2.exe,并且更名为vi.exe。
- 在Windows XP上安装Linux核心命令,点击这里。
- 如何在Windows Console下使用命令svn(下载软件),点击这里。
- 安装数据库系统SQLite3,点击这里。
(二)前提条件:
- 在本机Winodw操作系统上,我们的工作目录为d:\works_rails。
- 你的电脑必须在线。
(三)目的:
- 本文将说明网络页面技术jMaki上如何和Rails框架技术相互有机地结合在一起的。
- 本讲座的完整代码请您在Google Code Hosting上查看:
或者下载http://cnruby.googlecode.com/svn/trunk/rails-projects/use-jmakisvn co http://cnruby.googlecode.com/svn/trunk/rails-projects/use-jmaki
(四)解决方案:
- 我们创建Rails框架应用软件的根目录:
mkdir use_jmaki
cd use_jmaki - 安装基于Rails框架的jMaki插件:
我们的实例仅仅使用到jMaki框架软件的一个插件jmaki_yahoo,其它的插件也可以使用,安装方法如下:ruby script/plugin source http://jmaki-goodies.googlecode.com/svn/trunk/rails_plugins
ruby script/plugin install jmaki_core
ruby script/plugin install jmaki_yahooruby script/plugin install jmaki_dojo
ruby script/plugin install jmaki_ext
ruby script/plugin install jmaki_flickr
ruby script/plugin install jmaki_google
ruby script/plugin install jmaki_native
ruby script/plugin install jmaki_scriptaculous
ruby script/plugin install jmaki_spry - 编辑数据库配置文件 database.yml :
vi config\database.yml - 利用Rails框架自动代码生成技术,我们创建一个模型Admin及其相关代码:
ruby script/generate scaffold_resource admin - 针对我们的模板页面文件,增加jMaki技术的相关代码 admins.rhtml,以便使用JavaScript和CSS代码。这是本文的精华部分之一。
vi app/views/layouts/admins.rhtml<%= stylesheet_link_tag "jmaki-standard", :media => "all" -%>
<%= javascript_include_tag "jmaki" -%>
<%= jmaki_setup -%> - 编辑数据库移植技术文件 001_create_admins.rb ,并且创建数据库及其相关表:
vi db/migrate/001_create_admins.rbt.column :username, :string
t.column :password, :string
execute "INSERT INTO admins VALUES(1, 'munich', '24680')"
execute "INSERT INTO admins VALUES(2, 'beijing', '13579')"rake db:migrate - 利用Rails框架技术和jMaki框架技术,修改页面 index.rhtml 文件。注意这是本文的精华部分之二。下面的代码有二部分代码,前面的是利用Rails框架技术把实际存储到一个Array中;后面的是jMaki框架的代码技术。
vi app\views\admins\index.rhtml<h1>Listing admins</h1>
<% @table_data = [] %>
<% for admin in @admins %>
<% @table_data << [ admin.username, admin.password,
link_to('Show', admin_path(admin)),
link_to('Edit', edit_admin_path(admin)),
link_to('Destroy', admin_path(admin), :confirm => 'Are you sure?', :method => :delete)
] %>
<% end %>
<%= jmaki_widget 'yahoo.dataTable',
:args => {
:columns => [
{ :title => 'Usename', :width => 200, :locked => false },
{ :title => 'Password', :width => 75, :renderer => 'italic' },
{ :title => 'Show', :width => 60, :renderer => 'italic' },
{ :title => 'Edit', :width => 60, :renderer => 'italic' },
{ :title => 'Destroy', :width => 60, :renderer => 'italic' },
]
},
:value => @table_data
-%>
<br />
<%= link_to 'New admin', new_admin_path %> - 启动网络服务器:
ruby script\server - 浏览我们的网络应用软件:
start http://localhost:3000/admins
(五)视听教学:
(六)必须注意的问题:
- 利用NetBeans工具,可以更好地使用jMaki框架技术。
(七)参考资料:
- https://ajax.dev.java.net/files/documents/3115/45044/org-netbeans-modules-sun-ajax-updatecenter.nbm
- https://ajax.dev.java.net/servlets/ProjectDocumentList?folderID=0
- http://blogs.sun.com/arungupta/entry/jmaki_on_rails_for_dummies
- http://jmaki.com/
(八)命令清单:
mkdir use_jmaki
cd use_jmaki
ruby script/plugin source http://jmaki-goodies.googlecode.com/svn/trunk/rails_plugins
ruby script/plugin install jmaki_core
ruby script/plugin install jmaki_dojo
ruby script/plugin install jmaki_ext
ruby script/plugin install jmaki_flickr
ruby script/plugin install jmaki_google
ruby script/plugin install jmaki_native
ruby script/plugin install jmaki_scriptaculous
ruby script/plugin install jmaki_spry
ruby script/plugin install jmaki_yahoo
mysqladmin -u root -proot create jmaki
vi config\database.yml
ruby script/generate scaffold_resource admin
vi app/views/layouts/admins.rhtml
<%= stylesheet_link_tag "jmaki-standard", :media => "all" -%>
<%= javascript_include_tag "jmaki" -%>
<%= jmaki_setup -%>
vi db/migrate/001_create_admins.rb
t.column :username, :string
t.column :password, :string
execute "INSERT INTO admins VALUES(1, 'munich', '24680')"
execute "INSERT INTO admins VALUES(2, 'beijing', '13579')"
rake db:migrate
vi app\views\admins\index.rhtml
<h1>Listing admins</h1>
<% @table_data = [] %>
<% for admin in @admins %>
<% @table_data << [ admin.username, admin.password,
link_to('Show', admin_path(admin)),
link_to('Edit', edit_admin_path(admin)),
link_to('Destroy', admin_path(admin), :confirm => 'Are you sure?', :method => :delete)
] %>
<% end %>
<%= jmaki_widget 'yahoo.dataTable',
:args => {
:columns => [
{ :title => 'Usename', :width => 200, :locked => false },
{ :title => 'Password', :width => 75, :renderer => 'italic' },
{ :title => 'Show', :width => 60, :renderer => 'italic' },
{ :title => 'Edit', :width => 60, :renderer => 'italic' },
{ :title => 'Destroy', :width => 60, :renderer => 'italic' },
]
},
:value => @table_data
-%>
<br />
<%= link_to 'New admin', new_admin_path %>
ruby script\server
(九)下载文件pdf:
add to del.icio.us. look up in del.icio.us.
add to furl
The QuarkRuby blog has created a great Ruby on Rails Security Guide that gives you a wealth of links to articles and plugins dealing with security in Rails applications. Everything fromn XSS to CSRF stuff is covered.
add to del.icio.us. look up in del.icio.us.
add to furl
add to del.icio.us. look up in del.icio.us.
add to furl
add to del.icio.us. look up in del.icio.us.
add to furl
add to del.icio.us. look up in del.icio.us.
add to furl
add to del.icio.us. look up in del.icio.us.
add to furl
add to del.icio.us. look up in del.icio.us.
add to furl
add to del.icio.us. look up in del.icio.us.
add to furl
add to del.icio.us. look up in del.icio.us.
add to furl
add to del.icio.us. look up in del.icio.us.
add to furl
add to del.icio.us. look up in del.icio.us.
add to furl
“ Stop me if I violate your sensibilities. ”
Marcel, to a class
add to del.icio.us. look up in del.icio.us.
add to furlSat 22 September, 2007

Flight STR–TXL, Sunday
Flying with air berlin is very pleasant: You get to choose from five newspapers, get free coffee and cake, and they show you the stupid (albeit rendered) security video on a TV screen.
Sunday evening
Time for some Bratwurst (pics)! After arriving at our apartment and figuring out how the WLAN is supposed to work, we take the tube to Kalkscheune where lots of people are already. The rug-b people made name tags for us. (Hey Vico!) After we all had enough Bratwurst, some go play Werewolf while we decide to go to the Tacheles (a.k.a. “shitty building”) and have some beer.
Monday
Since I didn’t book any tutorial sessions, it’s time to sleep out. We try to fix the WLAN but completely fuck it up. (You should have seen us trying to even find the router!) Later, we go to the great St. Oberholz (blog) cafe which has good coffee, good food, free wifi and Bionade. Not to forget nice waiters (Hey Ines!) and lots of Mac users. I had a heavy walnut tarte.
Monday evening
We missed Dave Thomas’s keynote because had a big Thai dinner. It was awesome and very tasty. And hot. Some go play Werewolf. Later we tried to find the Havanna Club Club, where there was a guy which a friend of a friend one of us knows. We searched for an hour, and ended up at the Madonna Bar, where we had some beer.
Tuesday
Being a bit late, I rushed into the DHH keynote. He showed evolutionary advancements on the way to Rails 2.0, for example automatic database setup, easier-to-read ActiveRecord inspects (yay) and partials by object type (which is pretty nice). He also demonstrated how to add new content-types to create special output for the iPhone. Finally, he announced a Rails 2.0 preview release to appear shortly after the conference.
Then, I attend the first sessions: Deployment and Continuous Integration from the Trenches by Fernand Galiana, who talked about new features in Capistrano 2 such as namespaces, different deployment strategies and events, which allow for seperation of aspects. After a whirlwind tour of cap2 we learned about certain traps and how to avoid them, for example by using lazy variable expansion. He also showed best practices such as factoring common code with load, multistage deployment and caches, which also can use rsync now. Fernand concluded his talk by showing a quick example of how to write your own tasks and announcing his Rails-driven Capistrano frontend dubbed Capote. His talk was amusing and full of hilarious engineering pictures.
Next up was Dr. Nic Williams with his excellent talk Meta-Magic in Rails: Become a Master Magician which started with a list of features he liked in Ruby and which help doing meta-stuff like the flexible syntax and the highly dynamic behavior. He explained he likes “a big number of complexity” and went on to compare Perl with a puppy unconscious of itself, Java with Keith Richards, and Ruby with Matrix’s Neo, who knows everything about himself and his environment. He introduced his Magic Models which use const_missing to generate ActiveRecord models on the fly and outlined a few important meta-programming techniques. It was a really funny and instructive talk (at least if you are not already a Ruby pro).
In the lunch break, I got to know some found the Havanna Club Club later, and it was just where we searched. Sigh.
In the afternoon, I attended Really scaling Rails by Britt
Selvitelle, who works for flickrtwitter (thanks,
nec). After explaining to the audience that most of them probably
won’t need his hints yet, he explained their mongrel setup (they only
proxy one request at a time from Apache to each mongrel, so requests
won’t queue up) and gave tips on benchmarking actions. He insisted on
not over-architecting. Furthermore, he explained how to create
daemons for long-running tasks (such as informing 10000 followers of
twitter’s popular users) and how to cache DB queries. He also
introduced starling, which is an in-house queue server they wrote. If
you can, cheat, he recommended to us, meaning that users won’t notice
if things don’t update in real time or are totally synchronous. He
also told about essential things for deployment, such as monitoring
and easy deploy/rollback. Scaling is only needed where it matters.
Lastly, he explained the importance of an API for twitter and how it
was relevant for the big community they now have.
The next talk was Improving the Rails ecosystem by Evan Phoenix, the leader of the Rubinius project. He talked about how a better Ruby results in a better Rails and how Rubinius is focused on improving some Ruby deficiencies, like full operator overloading (you can overload != by itself), better memory usage (better sharing among forked processes), .rba archives for easier code deployment and more readable and informative backtraces. He announced they would release a 1.0 at the end of the year and concluded the talk with an extensive Q&A session. This was a very funny talk as well, last but not the least because of his sole usage of made-up statistics. (Rubinius is faster than three-legged dogs and turtles, but slower than the Space Shuttle, you knew?)
The day ended with Roy Fielding’s keynote The Rest on REST2, who once looked at the entire web—back when it was fifty sites. After a short history of the web until 1995, we got to know he was the main HTTP RFC editor and he went on outlining the web’s architecture. He explained how REST implies hypertext in some sense and how it made the web bigger. He also told he had a look at Rails and tried to show how to make it more RESTful (he lauded the CRUD); most things already can be done easily. It was a good talk (have a look at the slides, they are self-explaining mostly) and I really liked the small quotes on top of each slide.
Tuesday evening
We had some Schnitzel at a restaurant Unter den Linden which name I forgot. Then, we headed to RejectConf which took place at the Pirate Cove (noone noticed that tomorrow would be Talk Like A Pirate Day, though. Arrr!!) Some went to play Werewolf.
Dr. Nic praised me for even being able to talk about Ruby meta-programming after some rounds of Jägermeister shots. No big deal. ;-)
The caboosers also got a new set of t-shirts. (Thanks, chrissturm.)
Wednesday
The second day of the conference sessions started with Best Practices by Marcel Molina Jr. and Michael Koziarski of the Rails core team. (We learned Jamis Buck wasn’t there because his wife got a child.) They noticed most Rails projects stuff too much stuff into the controller and not enough into models. They explained that the controller merely should contain action code and most of the business logic belongs to the models. Marcel recommened the Smalltalk Best Practices book again, which is really worth a read. Michael talked about how association proxies make you code easier to understand and how to factor code into many descriptive methods.
Then, I attended JRuby at Thoughtworks by Ola Bini, who complained about MRI having threading issues, bad unicode support, and speed and GC problems. JRuby, which was started in 2001(!), tries to address all these problems. He also told that Java 6 made JRuby twice as fast without changing anything. JRuby will be compiled to bytecode to allow obfuscation, which is important for certain businesses. It also allows for easier deployment. At the end of his talk, he introduced his new Apress book “JRuby on Rails”.
After this, I went to Ruby on Rails Security by Heiko Webers, which was a lemon. He tried to shock the audience by telling he saw lots of session ids on the wifi, but proceded to give a totally boring talk about essential security concepts which would have been demonstrated a lot better by, well, demonstrating them. More action please!
In the lunch break, I met David Chelimsky of the RSpec team. We talked a bit about BDD and the future of RSpec and test/spec. He also explained the new StoryRunner to me. Then, I met Geoffrey Grosenbach and we recorded a Ruby on Rails podcast out of the blue!
The first afternoon session I attended was Browser-based Testing of Massive Ajax-using Rails Applications with Selenium, by Till Vollmer of MindMeister, a pretty neat AJAX mindmapping tool. He explained what Selenium is, and how usual tests don’t test browser behavior, which is essential for them. After a quick overview of Selenium’s features, he demonstrated their test suite for a live example.
Next was Functional JavaScript Development with Prototype by Ben Nolan. He told about JavaScript lambdas and what binding them means and went on talking about Prototypes enumberable extensions which have lots of useful methods like invoke, pluck or inGroupsOf. He mentioned taking some Haskell courses at university and stated JavaScript code is much easier to develop and debug when it consists of small, idempotent functions. Also, he recommended to store data in the DOM and not in private properties of JavaScript objects.
After the afternoon break, I went to Jay Fields’ talk on Extending Rails to Use the Presenter Pattern which was very fuzzy and mellow. He couldn’t really get his point across and most of the audience left the session without knowing what a presenter even is, which is kind of sad since it surely could have been useful in some situations. Or not.
The last session, PhD on Rails by Sam Aaron however saved the day. It was such a refreshing, intelligent and humorous talk that I completely forgot to take notes. Let me try to remember: He created a database backed system to keep track of objects which are rendered in a three dimensional spaces and then implemented a query language to operate on them. Really cool. And the first person I met that uses VRML.
Wednesday evening
We tried to find a restaurant for roughly 25 persons which was not that easy. We ended up in a pretty expensive French brasserie, but I liked my dinner. Some went to play Werewolf. The rest went to Ambulance Bar where we had half a dozen cocktails each. They were very good. We got back to the appartment at 3am, just before the Werewolf players finished.
Thursday
I decided to stay one more day after the conference, and we spent all day at St. Oberholz again. I had a great tiramisu and a beagel. Yum.
Thursday evening
We decided to go to the Fernsehturm for dinner, had a Weizenbier up there waiting until we could enter the spinning restaurant, which was pretty cool. The food was far better than I expected and not even that expensive.
After dinner, we went back to the appartment because we all would need to wake up pretty early.
Flight TXL–FMM, Friday
I had to wake up 6am to get to the airport in time. I met Geoffrey there again and we had another little chat. I flew back with tuifly, which let me chose whether I wanted to be seated to the window or not but had no free coffee or other features. They play the stupid security video for you. It was a bit cheaper, though.
General points
git is gaining popularity among Ruby hackers, I saw lots of them installing it and toying around.
Berlin: I had forgotten how great the city is. The complete and utter lack of aesthetics actually is appealing, but the icky typography in the subway hurts my soul.
NP: Bob Dylan—This Wheels On Fire
add to del.icio.us. look up in del.icio.us.
add to furl
Beim heutigen Bücherflohmarkt in der vhs (meiner Zivistelle ab Oktober übrigens) erworben:
Georg Unger, Die Rettung des Denkens. Exkurse über mathematische, physikalische und kybernetische Grundbegriffe.
Albert Einstein und Leopold Infeld, Die Evolution der Physik. Von Newton bis zur Quantentheorie.
Jürgen Dahl, Der Tag des Astronomen ist die Nacht. Von der Vergeblichkeit der Himmels-Erforschung.
Ephraim Kishon, Der seekranke Walfisch oder Ein Israeli auf Reisen.
Ephraim Kishon, Arche Noah, Touristenklasse.
William Gibson, Neuromancer (Deutsch).
Roger Price, Des Drudels Kern. Drudel für Anfänger und Fortgeschrittene.
Friedrich Dürrenmatt, Der Besuch der alten Dame. Tragische Komödie.
Bertolt Brecht, Leben des Galilei.
Friedrich Nietzsche, Also sprach Zarathustra. (Kann man am Bildschirm nicht lesen.)
Unkosten: 7€.
P.S.: Kennt jemand eine schöne, unixige Buchverwaltung, die Metadaten von Amazon und so integrieren kann?
NP: Bob Dylan—Death Of Emmet Till
add to del.icio.us. look up in del.icio.us.
add to furl
The problem: how do you dynamically generate arbitrarily large downloadable zip files from PHP? All of the existing solutions I found all generate a local temp file, which means the server needs to
- have a web-writable directory large enough to store the intermediate temp file, and
- be able to generate and start streaming the entire file before the client times out
I wasn't particularly fond of either constraint, so I came up with a solution: ZipStream-PHP. ZipStream is a library for dynamically streaming dynamic zip files from PHP without writing to the disk at all on the server. Using it is dirt simple, too. Here's how:
# create a new stream object
$zip = new ZipStream('example.zip');
# then add one or more files
# add first file
$data = file_get_contents('some_file.gif');
$zip->add_file('some_file.gif', $data);
# add second file
$data = file_get_contents('another_file.txt');
$zip->add_file('another_file.txt', $data);
# finally, finish the stream
$zip->finish();
You can also set file comments and creation dates, like so:
$data = file_get_contents('foo.txt');
$zip->add_file('foo.txt', $data, array(
'comment' => 'this is an interesting comment',
'time' => time() - 3600, # created one hour ago
));
Here are the links, enjoy:
add to del.icio.us. look up in del.icio.us.
add to furl
- Randy Pausch's last lecture
A remarkable talk by CMU CS Professor Pausch on How to Achieve Your Childhood Dreams.
add to del.icio.us. look up in del.icio.us.
add to furl
add to del.icio.us. look up in del.icio.us.
add to furl
If you are serious about computer science and/or programming, you will be learning Lisp. Finding good material can be tricky. However, for an outstanding Common Lisp tutorial (or any Lisp tutorial) I highly recommend Peter Seibel’s Practical Common Lisp .
Peter has made it freely available on the Net, though I encourage you to consider buying a printed version. It will rewards those who have taken the time and trouble to publish such a work, and (hopefully) encourage more such publications.
add to del.icio.us. look up in del.icio.us.
add to furl
Tip Set TextMate to Default to Ruby Mode For New Files
$ defaults write com.macromates.textmate OakDefaultLanguage E00B62AC-6B1C-11D9-9B1F-000D93589AF6
add to del.icio.us. look up in del.icio.us.
add to furl
add to del.icio.us. look up in del.icio.us.
add to furl
add to del.icio.us. look up in del.icio.us.
add to furl
add to del.icio.us. look up in del.icio.us.
add to furl
add to del.icio.us. look up in del.icio.us.
add to furlFri 21 September, 2007

add to del.icio.us. look up in del.icio.us.
add to furl
- Microsoft Pro Photo site
Absolutely stunning photography site. Wonderful photos in the galleries by some of my favorite landscape photographers
add to del.icio.us. look up in del.icio.us.
add to furl
add to del.icio.us. look up in del.icio.us.
add to furl
The party in Berlin came to an end all too soon. I had a blast there and so did everyone else it seemed. Such a fantastic atmosphere and group of people. If you weren’t able to make it, you can peruse the presentation slides or the pictures. Thanks to everyone who made it possible and to all who was able to come.
add to del.icio.us. look up in del.icio.us.
add to furl
There’s a lot of action going on in the Rails IDE space these days. Besides Aptana RadRails, which has been around for a long time, Sun’s got impressive Rails support in the new NetBeans, and just this week CodeGear launched their 3rdRail IDE, which also looks like a great setup.
I’m personally not quite ready to leave TextMate behind, but it’s encouraging to see all these options for dedicated Rails IDEs. It’s not going to be long before they’ll be giving regular text editors a serious run for their money.
add to del.icio.us. look up in del.icio.us.
add to furl
JRuby语言内部报道:软件包Jar无Manifest问题
- 说明:尽管JRuby语言版本1.0.1已经发行,但是JRuby运行环境还是有些问题没有得到解决。要是我们的Java语言软件包jar中没有目录META-INF,就有可能出现错误。
- 错误报告及其实例:
http://jira.codehaus.org/browse/JRUBY-1229
add to del.icio.us. look up in del.icio.us.
add to furlThu 20 September, 2007

add to del.icio.us. look up in del.icio.us.
add to furl
The biggest surprise at RailsConf Europe 2007 was hearing Craig McClanahan from Sun speak. Craig is the creator of Struts, the original blockbuster web framework for Java, and more recently Java Server Faces. Not exactly an obvious advocate for Ruby on Rails, but he sure played the part well.
And not just on a superficial level because Sun was a diamond sponsor of the conference, but from months of experience developing Rails applications using the latest techniques and frameworks (like pushing the envelope with Active Resource). He even went as far as to say that developing web applications in Java after working with Rails would probably not be a particularly pleasant experience for him. Wow.
Sun's support for Rails goes even further, though. Their work on making Netbeans a kick-ass Rails IDE seems to be progressing at a rapid clip (and already winning fans). Yet it pales in comparison to the rise of JRuby as driven by Thomas, Charles, and Ola. These guys are improving their JVM implementation of Ruby at a truly insane speed.
JRuby on Rails is already in production at a fair number of companies. The Rails is just a WAR argument is certainly making it easier for companies like ThoughtWorks to push Rails deep into the enterprise. Throw the "integrate with your Java legacy" argument on top (where you can even go as far as work with EJBs!) and it's easy to see why The Enterprise is getting all giddy.
"Why are they doing all this?", that's a common concern with most Ruby folks (and a question I must have asked them personally at least half a dozen times ;)). Apparently, they see this as something quite simple: A Sun that's heavily involved with Rails on the software side is a Sun that's much better positioned to sell loads of hardware to run all these new Rails applications in both the enterprise and to start-ups.
It seems to be working too. Joyent is running all their new gear with Sun badges. And they got some serious applications cooking there, including Twitter.
So it's kinda hard to argue with their good deeds. Which is a peculiar feeling for a Rails person to have towards a company that used to be regarded solely as the high church of enterprisey. I guess that they've accepted that Java (the language) is no longer always the answer regardless of the question, as it used to be.
Yet there's still that nagging doomsday image of a mystery man sitting somewhere inside of Sun petting a black cat with a hollow laugh just waiting to reveal his evil master plan as the reason for all this. But the exceptional work and high character of people like Tim Bray, Nick Sieger, Thomas Enebo, Charles Nutter, and now even Craig McClanahan championing Ruby and Rails inside Sun, I think I'll have to waive goodbye to the last sliver of that suspicion very soon.
add to del.icio.us. look up in del.icio.us.
add to furl
It's hard to fathom that we've just finished our fourth RailsConf in just 15 months. The first one already seems so long ago, which just underlines how fast things have been moving in the Rails world.
It's even more impressive to think of all the people we've had go through the conferences. More than three thousands attendees combined and some of the most interesting speakers in technology.
This year I was especially pleased to hear Roy Fielding speak and to have the opportunity to chat with him afterwards. The past year and a half been about trying to understand and implement the ideas and the specifications that Roy has been involved with for more than a decade. It was very pleasing to hear him talk so warmly of our progress so far.
Sun continued to surprise positively (and still slightly puzzling), but I had so much to say about that, I went ahead and wrote it up separately in Sun surprises at RailsConf Europe 2007.
As I process all the inputs from the conference, I'm sure I'll have more to say. But for now I want to make sure to thank everyone involved. Ruby Central and O'Reilly did a spectacular job organizing everything. And I had a great time speaking to so many different users of Rails. The most amazing things are being done with this framework we're building.
P.S.: My keynote slides were few and almost entirely without meaning out of context, but Casper Fabricius did a good job with his summary.
add to del.icio.us. look up in del.icio.us.
add to furlWed 19 September, 2007

I just got a Blackberry for work, and I've been looking around for some simple applications. The entire experience reminds me of looking for Windows Mobile software; a bunch of small, money grubbing companies trying to nickel and dime people for things they have no business charging for. $5 for a crappy theme that you obviously spent 15 minutes on? No thanks, I'll make my own. $15 for your E-Book reader? I already made a mistake when I bought your shitty software for my PDA two years ago; I won't be fooled again. What a bunch of thieving bastards.
The good news is that I did manage to find a couple of decent applications. Here they are:
- MidpSSH: Mobile SSH client. Brian dug this one up. The source is also a pretty good reference for MIDP development.
- Opera Mini: The crackberry comes with a half-assed built-in browser. Opera Mini makes up the other half by resizing images and scaling the page so it fits nicely on your screen.
- jmIrc: Decent mobile IRC client.
Also, Blackberry Freaks and GetJar both have lists of free software for the Blackberry. Actually, GetJar is useful for any J2ME/MIDP-capable device; that's where I got most of the software for my Samsung t809. There's also midlet.org, although everything there seems to be straight out of 2002.
The best overall Blackberry forum I've found so far seems to be Blackberry Forums. I particularly like the developer forum.
I also managed to get the MIDP SDK up and running
without too much effort. You basically just uncompress the archive
wherever, then add the $MIDP_DIR/classes directory to your
classpath when compiling your .java files. It includes an
MIDP emulator which works fine for several applications I've tried, and
also seems to hate the JAD files I'm generating for no apparent reason.
Oh well. Here are the interesting MIDP and Blackberry development links
I've dug up:
- Sun J2ME MIDP 2.0 API Reference.
- Blackberry JDE on Linux: The information here looks a bit dated, but it still might be useful.
- J2ME Low-Level Network Programming with MIDP 2.0
- Bill Day's java ME Archive.
- MIDlet JAR Signing.
- Device programming with MIDP: Great three-part series on the MIDP API. The articles pre-date MIDP 2.0 but they include plenty of examples and links for additional information. Be sure to click the Print link at the bottom to view all the pages concatenated together.
Fire an email or comment my way if you've got any more useful links.
add to del.icio.us. look up in del.icio.us.
add to furl
add to del.icio.us. look up in del.icio.us.
add to furl
《管窥Ruby——类的变量》写在去年,写成之后便更新了一次,因为最初的描述存在一些偏差。即便如此,jxb8901依然指出了其中的一些不足。最近,dennis-zane再次提出了这个问题。回过头来仔细品味,确实有些地方写得不是很到位,索性把它重新写过。
管窥Ruby——类的变量
变量和方法是面向对象难以割舍的两个重要组成部分。在《管窥Ruby——类的方法》中,我们谈到方法,沿着这条路继续,我们再来看看类中的变量。
开始之前,我们还是要再次回顾RClass的定义:
struct RClass {
struct RBasic basic;
struct st_table *iv_tbl;
struct st_table *m_tbl;
VALUE super;
};
(ruby.h)
如果你看过《管窥Ruby——类的方法》,了解了方法存储方式,变量的存储方式便也一目了然了,同样的st_table,意味着同样的处理方式。
不得不承认的一点是,在讨论类的方法时,我故意忽略了一个事实:方法分为类的方法和实例的方法两种。如果对其它语言实现有些许了解,我们知道,这两种方法差别仅仅是this(C++或Java的说法),到了底层时,这个差别可以视为无物,可以统一存放。关于这点,有兴趣可以参考一下《深入Java虚拟机》,它的第五章讲解了虚拟机内方法的表现形式。在Ruby中,类的方法和实例的方法并不是存放在一起的,这里定义的实际上是实例方法,而类的方法是定义在类的Singleton类中。
遇到变量时,我们会碰到同样的问题:类的变量和实例变量是无法统一管理的。因为类的变量只有唯一的一份,而实例变量则是每个实例都有一份。所以,RClass存放的并不是真正实例变量。代码是说明问题的最好方式,下面这段代码说明了如何设置实例变量:
VALUE
rb_ivar_set(obj, id, val)
VALUE obj;
ID id;
VALUE val;
{
if (!OBJ_TAINTED(obj) && rb_safe_level() >= 4)
rb_raise(rb_eSecurityError, "Insecure: can't modify instance variable");
if (OBJ_FROZEN(obj)) rb_error_frozen("object");
switch (TYPE(obj)) {
case T_OBJECT:
case T_CLASS:
case T_MODULE:
if (!ROBJECT(obj)->iv_tbl) ROBJECT(obj)->iv_tbl = st_init_numtable();
st_insert(ROBJECT(obj)->iv_tbl, id, val);
break;
default:
generic_ivar_set(obj, id, val);
break;
}
return val;
},
(variable.c)
抛开前面那些复杂的东西,直接来看switch语句后面的内容。这里存在两种情况,对于存在T_OBJECT、T_CLASS和T_MODULE标记的,变量会写入iv_tbl,而其余的情况则转交 generic_ivar_set处理。iv_tbl是“实例变量表(instance value table)”的缩写,不过,如果当前对象是个类对象,这个“实例”变量实际上就是类变量,所以,这个名字多少有些名不符实。
除此之外,还有一个generic_ivar_set。下面是generic_ivar_set的实现:
static void
generic_ivar_set(obj, id, val)
VALUE obj;
ID id;
VALUE val;
{
st_table *tbl;
if (rb_special_const_p(obj)) {
special_generic_ivar = 1;
}
if (!generic_iv_tbl) {
generic_iv_tbl = st_init_numtable();
}
if (!st_lookup(generic_iv_tbl, obj, (st_data_t *)&tbl)) {
FL_SET(obj, FL_EXIVAR);
tbl = st_init_numtable();
st_add_direct(generic_iv_tbl, obj, (st_data_t)tbl);
st_add_direct(tbl, id, val);
return;
}
st_insert(tbl, id, val);
}
(variable.c)
同样忽略一些非主干的部分,我们看到,这段代码先在一个generic_iv_tbl中进行查找,用作查找键值的是对象实例(obj),而目标同样是一个st_table。得到这个表之后,利用变量名做键值将值插入到表中。我们便不难分析在这种做法中实例变量的存储方式。存在一个全局的实例变量表,走到这里的实例都在其中拥有一席之地,而实例变量存储在实例对应的表中。Ruby通过这样一个二级结构,解决了这些实例变量存储的问题。
了解过基本的做法之后,随之而来的一个问题就是,这些代码都会在什么情况下起作用。
代码已经说得很明白了,只有在有那几个标记的情况下,才会直接调用iv_tbl。T_CLASS和T_MODULE都很好理解,那什么情况下会有T_OBJECT呢?在C Ruby中,在Ruby层次上定义的类,生成的实例都是会标有T_OBJECT(参见《管窥Ruby——Allocator》)。所以,所有由Ruby层次上生成的对象都会走到这里来。
那generic_ivar_set呢?除了那几个标志外的其他部分都会走到这里。除此之外的标志表示什么呢?读一下代码我们便不难发现,几乎就是builtin的几个类,比如数组、字符串、正则表达式等等。那为什么这些builtin类没有一个iv_tbl。对于这些builtin而言,它们真正的实例变量都是以C的形式给出,所以,额外存在一个iv_tbl实际上是一种空间上的浪费。
虽然不是常态,但我们依然可以为这些builtin类添加自己的实例成员。为了保持Ruby的动态特性,这才有了generic_ivar_set的存在。
add to del.icio.us. look up in del.icio.us.
add to furlTue 18 September, 2007

add to del.icio.us. look up in del.icio.us.
add to furlMon 17 September, 2007

clevercss可以把按python格式些的文件,一次性转换成css文件。开发的时候,则要动态转换了。
http://sandbox.pocoo.org/clevercss/
http://lucumr.pocoo.org/cogitations/2007/09/17/using-clevercss-in-django/...
add to del.icio.us. look up in del.icio.us.
add to furl