123
 123

Sat 29 March, 2008

Click here to bookmark this link.Channel Image09:05 Ruby语言:谁能够超越Rails框架?» 天天红玉世界
谁能够超越Rails框架?
  • 说明
    • Waves 是一款很有前途的Ruby语言网络软件框架。它是一种全新的思维,而不是简单的模仿;集成当前最好的软件包,而不是轻易的纳入;不仅注意软件开发的细节,更重要的是以软件全局为出发点。

add to del.icio.us add to del.icio.us. look up in del.icio.us.   add to furl.net add to furl

Fri 28 March, 2008

Click here to bookmark this link.Channel Image23:11 RSpec Story简介» LetRails
Story是RSpec的新功能,目前还处于试验阶段,在讲解RSpec Story之前,先让我们来看看什么是Story? 什么是Story? Story是BDD中的概念,我们可以简单的将它看作是对应用特性的描述(feature),举个...
add to del.icio.us add to del.icio.us. look up in del.icio.us.   add to furl.net add to furl
Click here to bookmark this link.Channel Image12:54 Twitter Updates for 2008-03-27» halostatue
Who is Bright Star (brightstar) and why are they sending me a package? # Listening to TWiP 007: Street Rules # @dmarsh I’m going to RF, but I have my own issues with how it’s been pulled together wrt the TO Ruby community. # @dmarsh and I suspect that "girlfriend daycare" is the sort of juvenile thing that [...]
add to del.icio.us add to del.icio.us. look up in del.icio.us.   add to furl.net add to furl
Click here to bookmark this link.Channel Image09:08 新規開始» Matzにっき
日曜学校の私のクラスは今日からテキストの最初からに戻る。 今まで私のクラス(基礎)にいた人たちには上のクラスにいってもらう、 という話だったのだが、ふたを開けたらみんな戻ってきている。 慕われているのはありがたいが、もうそろそろ上のクラスに上がってもよいと思ったんだけどなあ。 教義の基礎から学び直す。
add to del.icio.us add to del.icio.us. look up in del.icio.us.   add to furl.net add to furl
Click here to bookmark this link.Channel Image09:08 Why Rails Will Not Reign Supreme (and why you shouldn't want it to)» Matzにっき
Rubyが「Reign Supreme」にならない理由。 っていうか、そもそもなる必要ないじゃん、って話。 「Reign Supreme」ってのは、世間を席巻とかいうような意味だろうか。 が、ビジネス的に世間に広く受け入れられるってことは いいことばかりではない。むしろ、悪いことの方が多いから、 RubyはRubyのままでいてほしい、というところか。 私もそう思う。ただし、Rubyで幸せになれる人には増えてほしいので、 ある程度広まってくれるのがありがたいので痛し痒しだ。 また、話題性がないとわたし(たち)のビジネスモデルが成立しない(ご飯が食べ..
add to del.icio.us add to del.icio.us. look up in del.icio.us.   add to furl.net add to furl
Click here to bookmark this link.Channel Image09:08 MOONGIFT: >> VMWareの開発でも利用されているソースコードレビュー共有ソフトウェア「Review Board」» Matzにっき
先日、Ruby開発用のコラボレーションツールについて考えてみたが、 こういうのもいいかもなあ。
add to del.icio.us add to del.icio.us. look up in del.icio.us.   add to furl.net add to furl
Click here to bookmark this link.Channel Image09:08 How Rubinius SendSites Work - Part 1 ,A+ Building a Better Ruby» Matzにっき
RubiniusのメソッドキャッシュであるSendSiteについて。 普通のインラインキャッシュとどう違うのかよくわからなかったんだけど、 統計情報を格納しているから、キャッシュ精度が高まるとかそういうことなのかな。 YARVもインラインキャッシュを実装しているのだが、 現時点ではoffになっている。ある程度性能が出るそうだから、 ぜひonにしたいんだけど、品質に(まだ)自信がないのだそうだ。
add to del.icio.us add to del.icio.us. look up in del.icio.us.   add to furl.net add to furl
Click here to bookmark this link.Channel Image08:44 半路出家» 梦想风暴

不知道算是幸运,还是不幸,我参与的多数项目,如果不是从头开始,我也是最开始加入的几个人之一,所以,我通常对项目的来龙去脉都比较清楚。这次,我有机会尝试一下在一头雾水的情况下开始一个项目。

这个项目已经进行了超过一个月,因为客户需要在赶在最近的一次发布之前,增加一些功能。老板按照目前的进度估算了一下,如果不加人,这个任务很难完成,于是客户很合作的同意增加两个人。就这样,我成了临时工。事实上,在这个阶段进入,项目早就过了最初的阶段,远远望去,没有几百也有几十的程序文件屹立在那里。虽然有最熟悉项目的人为我们介绍了项目的背景和架构,但这些宏观层面上的东西,对于编写代码这样“微观”的操作而言,几乎是没有任何直接的帮助。作为一个新人加入到项目,除了发呆,我还能做什么呢?

回想在以前公司的情形,大多数新进项目的人多半是得到一大堆文档,然后,有人语重心长的说,先把文档看了吧!且不说这些文档这种东西几乎写出来就过时,单单读完这些文档就需要花费很多时间。运气好的话,还有代码可以对应,但千万不要指望你能够一下子读懂这些代码。也许,你会想找别人来问,如果不出意外,大多数人都会不明就里的非常忙,忙到有时间上网聊天却没有时间给你讲这些东西。事实上,很多人即便自己做了很多东西,也不一定能够清晰的描述出来,所以,即便找到一个“闲”人,成功从他那弄明白这些东西的概率也很低。其结果是,我们经常会看到一些人在那对着电脑上的文档发呆。

在ThoughtWorks,我也恨不得找到一堆这样的无聊文档来打发时间,以此来享受偷懒的时光。遗憾的是,完全没有这种机会。因为那些“文档”会被视为浪费,这在以消除浪费为己任的敏捷来看,是无论如何不能接受的。于是,我在找不到任何借口的情况下,进入项目的第一天,就开始写程序了。不了解项目,怎么写程序?这是个问题。

敏捷实践中,有一个叫做Pair Programming的,从字面上来看,就是两个人一起开发。对于ThoughtWorker们来说,Pair是一种常态。所以,我在开发时也会有一个Pair,虽然我对项目一头雾水,但我的Pair已经在这个项目上工作了很长一段时间,所以,他很清楚这个项目的一切,差不多一切,因为代码是集体所有,所以,他在开发过程中会接触到各个部分。

拿到我们要做的Story,我的Pair会结合这个Story给我介绍上下文,并结合代码大致描述一下我们要做的事情。虽然在这个项目上我是新手,但我并不是对编程一无所知。有了这些基本的信息,我至少对我们要做什么,以及如何来做,在心里已经形成了一个大致的印象。刚开始时,基本上是我的Pair在主导开发,一边做一边告诉我,我们已经走到了哪里。渐渐的,我已经对我们在做的代码有了一些认识,开发也开始由一个人主导转向两个人讨论。随着开发的深入,我也发现了现有做法的一些不足,于是,我提出对代码进行重构,并给出了自己的分析和建议。我的Pair在听了之后,认为这是一个可行的建议,于是,我们毫不留情的将那段大家看着不舒服的代码改掉,这段代码从此清净了。

这就是在加入项目前几天所做的事情,虽然我目前还不能对整个项目有个很好的把握,但是,我相信,我已经开始在这个项目中起作用了。我想,Pair Programming是主要原因。正如前面所说,虽然我对项目很无知,但我的Pair很好的弥补了我的不足。正是两个人的协调工作,让我可以在对项目没有完整认识的情况下,可以很快入门,以最快的速度融入到开发之中。

曾几何时,我对Pair Programming的认识还停留在大家一起写程序和知识分享上,原来它对半路出家的人帮助也很大。虽然《人月神话》教导我们说,加人起不了很大的作用,但Pair的方式至少可以在相当大的程度上发挥新人的价值,削弱加人带来的负面影响。


add to del.icio.us add to del.icio.us. look up in del.icio.us.   add to furl.net add to furl
Click here to bookmark this link.Channel Image05:23 移动软件:iPhone手机的SDK视频» 天天红玉世界

iPhone手机的SDK视频

  • 视频说明
    • 在这个视频中,Apple公司展示了iPhone SDK及其所开发iPhone软件,同时也说明了iPhone软件营销模式,这种模式将会给软件业的未来带来什么。

add to del.icio.us add to del.icio.us. look up in del.icio.us.   add to furl.net add to furl

Thu 27 March, 2008

Click here to bookmark this link.Channel Image23:49 send Email via Gmail of Google Apps in your Rails project» Suave's Blog
最近正式推出 Google Apps,提供了 Email/Calendar/Docs/… 一堆功能,最重要的一个就是 Email 了,大家可以在 Gmail 中使用自己的域名。我们为多背一公斤申请了 1kg.org。设置了 MX 记录和 CNAME,不知...
add to del.icio.us add to del.icio.us. look up in del.icio.us.   add to furl.net add to furl
Click here to bookmark this link.Channel Image21:09 「Rubyは◎,Seasar2は♪」---Linux Foundation JapanがSIに使えるOSS一覧,利用実績でレーティング:ITpro» Matzにっき
OSSを使ったSIにおける実績をまとめたレポート。 「Rubyが◎」というのは実際のところどうなのか、という気がしないでもないが、 確かに実績はずいぶんたまっているような気はする。
add to del.icio.us add to del.icio.us. look up in del.icio.us.   add to furl.net add to furl
Click here to bookmark this link.Channel Image21:09 culann.com >> Blog Archive >> And the greatest of these is laziness» Matzにっき
エラーが発生したら、エラーページにテストコードを表示する。 今後は二度と同じエラーは起こさない、という怠惰さ。 テストファースト開発じゃなくて、テストファーストデバッグか。 なかなかテストから入る(TDD)とか、挙動を定義する(BDD)とかは 導入しにくい人でもこっちなら始めやすいかも。 もちろん網羅的なテストにはならないんだろうけど。
add to del.icio.us add to del.icio.us. look up in del.icio.us.   add to furl.net add to furl
Click here to bookmark this link.Channel Image21:09 Sapphire - Two New Re-Implementations of Ruby» Matzにっき
先日、Sapphireについてとりあげたばかりだが、 同じことを考えるのは一人じゃなかった、という話。 もうひとつ別のSapphire(やっぱりRubyのフォーク)があって、 それら両方の紹介。 前回紹介したSapphireの方が現実主義みたい。
add to del.icio.us add to del.icio.us. look up in del.icio.us.   add to furl.net add to furl
Click here to bookmark this link.Channel Image21:09 Rails deployment a solved problem? Just upload & it works?» Matzにっき
Ruby on RailsはPHPとくらべてDeployが弱い、PHPはアップロードするだけで そこそこの速度で動くのに、Railsはdevelopmentモードはアップロードするだけだが遅いし、 productionモードはサーバーをリスタートさせなきゃいけない(し、FastCGIとか面倒)というのが、 一般的な評判だが、それを改善する(かもしれない)Apacheモジュールmodrails。 動画が紹介されているんだけど、普段からRailsを使わない私にはうれしさがよくわからなかった。 でも、いいものなんだよね、きっと。
add to del.icio.us add to del.icio.us. look up in del.icio.us.   add to furl.net add to furl
Click here to bookmark this link.Channel Image17:13 Obie Fernandez: Big Name Companies Using Ruby on Rails» Matzにっき
Ruby on Railsを使っている有名企業。 amazon.com BBC CapGemini BPN Cisco C|Net EA (Electronic Arts) IBM JP Morgan NASA Oakley Oracle Siemens ThoughtWorks Yahoo! あまり公表はされてないが筆者(Obie Fernandez)の知ってるのでは、他に John Deere New York Times NBC Barclays LA Times Chicago Tribune Orbitz Google Turner Media Limewire もある。
add to del.icio.us add to del.icio.us. look up in del.icio.us.   add to furl.net add to furl
Click here to bookmark this link.Channel Image17:13 Amazon.co.jp: Googleを支える技術 ~巨大システムの内側の世界 [WEB+DB PRESS plusシリーズ]: 西田 圭介» Matzにっき
Googleってのは相当オープンな企業で、普通なら秘密にしてしまうような 内部情報も(最新ではないにしても)論文などでオープンにしてしまう。 が、それを わかりやすい言葉で 一箇所にまとめる のはなかなか大変なことだ。本書はそれを実現した貴重な本だと思う。 著者の西田さんは私の(NaClでの)元同僚。 OpenCOBOLコンパイラなどでお世話になった。 前書きを依頼された時、 本当は検索技術とか得意じゃないので、 お断りしようかと思ったのだが、 実際に中身を読んだら、思ったよりずっとわかりやすく書いてあるし、 いろいろな人の参考..
add to del.icio.us add to del.icio.us. look up in del.icio.us.   add to furl.net add to furl
Click here to bookmark this link.Channel Image15:06 Why Most People Don’t Trust Economists, Exhibit 732:» halostatue
John McCain’s economics advisor, Kevin Hasset, is quoted by the New York Times as saying: What really happens is that the economy grows more vigorously when you lower tax rates. It is beyond the reach of economic science to explain precisely why that happens, but it does. Dani Rodrik calls this shift faith-based economics. I agree. (Via Dani [...]
add to del.icio.us add to del.icio.us. look up in del.icio.us.   add to furl.net add to furl
Click here to bookmark this link.Channel Image15:06 Twitter Updates for 2008-03-26» halostatue
TigerDirect.ca loses on a sale because they only use UPS, Canada’s greediest shipping company. # @lrz they’re a disaster as a company. I won’t do business with them. I’ll do business with Wal*Mart first. # Grr. Can’t figure out why Time Machine is borking this backup. # @zeldman worse, they do it to us Canadians, too. # @robertbrook that’s [...]
add to del.icio.us add to del.icio.us. look up in del.icio.us.   add to furl.net add to furl
Click here to bookmark this link.Channel Image11:15 LuRuJu 将jude的模型当成Rails的model类使用» Ruby 语言 思想驱动生活
LuRuJu是Lube between Ruby and JUDE的缩写,它的目的就是无缝链接ror程序和jude的模型 特点包括: 1.配置简单,只需要把jude文件放到RAILS_ROOT/app/model下即可。Jude模型会作为mvc的m来被使用。目前实现了类之间的1对1,1对n关联。也支持类之间的继承关系。 2.不需要再维护migrate文件,只需运行 lor:db:create就可以了。表的定义使用jude文件中的定义。 3.可以往model里追加Ruby代码来扩种业务逻辑等 4.和config.cache_classes联动,不需要重启rails就可以修改jude文件并使之有效。 5.即可以用jruby,也可以用cruby 这个软件的作者是野村周平,文档 多是日文,不过看代码应该能看的差不多。 主页是 http://luruju.com/
add to del.icio.us add to del.icio.us. look up in del.icio.us.   add to furl.net add to furl
Click here to bookmark this link.Channel Image10:57 南沙坡 黄埔庄» Ruby 语言 思想驱动生活
6年没去过了,现在应该变样了吧。路的名字和店的名字都忘了,现在只记得位置和方向而已。 南沙坡位于交大东边,交大家属院南边,黄埔庄离西安理工大学不远,就在它的马路对过。除了南沙坡,还有北沙坡,黄埔庄等。这些地方都可以号称城中村,里面破乱程度可见一斑。黄埔庄这3个字就庄字有把握,其它不记得了。隐隐记得可能从交大过来进庄的地方有个柱子,写的可能是皇帝的皇。离兴庆公园那么近,有个皇字不算什么了。可能黄埔这两个字比如容易输入吧,导致网上的名字都成了黄埔庄了。在庄门口北边高台上,也就是交大电脑城对面有一个眼镜店,上学时在那里花130多配的眼镜,虽然踢球撞坏过几次,不过到现在还在用着。 南沙坡里很多筒子楼,都是出租给大学生的。我也曾经在一个4层楼的楼顶小屋住过1个月,不是第4层,是楼顶,能上去,房东又盖了个小房子。每天大早上有人去晒衣服,足够把我吵醒。在太阳的照射下,到处都能隐隐闻到尿的味道。也难怪,公共厕所要走3分钟左右,在一个稍有人气的卖随身听的店的旁边。半夜里经常被哗哗的撒尿声惊醒,不知道男的女的。 这些地方吃的都很便宜,有一次跟同学吃麻辣烫,锅底免费,酒水自带,荤素2毛,一共吃了7块钱,现在想想,简直是神仙过的日子一样。理工大南面进了路口是九龙,挺有名了,在同学中。各种聚会等都是来这里的。菜很好吃,毕竟上大学之前我属于几乎没有去饭店吃过的人。九龙对面是贾六灌汤包,久闻其名,未尝其味,有点遗憾。不过是有一定原因的,就是不远处有一个3块钱1笼的灌汤包我觉得是我这么多年来吃的最好吃的包子了。可惜在毕业之前就被拆了。如果能找到当时的师傅,我一定会为他投资开个店。这个店的原来位置在交大商场南面一点,路东。 其它的,比如牛肉面,凉皮,包子,肉夹馍,羊肉泡馍,盖浇饭,以及其它各种各样的面也都是好吃不贵,数不胜数。说了半天,还是想去再去一次而已。
add to del.icio.us add to del.icio.us. look up in del.icio.us.   add to furl.net add to furl
Click here to bookmark this link.Channel Image09:14 mod_rails is on the way» Riding Rails - home

Hongli and crew from Phusion have been hard at work for some time to fix the ease-of-deployment issue on Apache with their Passenger project. They now have a video that demos how simple it’ll be to install and get running with mod_rails. Check it out.


add to del.icio.us add to del.icio.us. look up in del.icio.us.   add to furl.net add to furl
Click here to bookmark this link.Channel Image06:13 Pratik joins core, retired members go alumni» Riding Rails - home

We’re shaking up the Rails core group a bit. First, please welcome Pratik Naik as the newest member of the group.

He’s been doing great work all around the framework and has been spearheading both the documentation branch in git and a thorough cleanup of Action View internals. We’re really happy to hand him the commit keys to the repository.

Second, we’ve created the Rails core alumni for all the proud members of the core group who are no longer in the day-to-day improvement of the framework itself. All of the alumni are still busy working in the Ruby on Rails ecosystem, but either have their hands full with their business or has dedicated their open source time to other initiatives.

We’re incredibly grateful for all the works you guys have done for Ruby on Rails over the years. And you’re all welcome back in the active core group any time you decide. Thanks guys!

Finally, this means that the current active core group is about half its former size. We’d like to add a few more to that, so hopefully we can pick a few more people who’ve been doing varied work on the framework for a sustained period of time soon.


add to del.icio.us add to del.icio.us. look up in del.icio.us.   add to furl.net add to furl
Click here to bookmark this link.Channel Image05:49 Ruby语言:太阳公司Ruby语言开发中心» 天天红玉世界
Click here to bookmark this link.Channel Image02:08 思考実験 - immutableな言語» Matzにっき
しかし、改めて考えてみると Erlangってば、参照透過性はないし、 静的型はないし、関数型言語である必要はないのではないか。 Erlangを真に特徴づけているのは、 immutableな値 アクターモデル ではないだろうか。他のものは目立つけど実はそれほど重要じゃない。 アクターモデルがあるから、並列プログラミングが簡潔に記述でき、 値がimmutableであるから、「オブジェクトの状態」で悩むことがない。 オブジェクトのアイデンティティが重視されないから、 メモリ空間を超えて値を伝搬しても影響がない。 おまけに(GCの)実装としてはラ..
add to del.icio.us add to del.icio.us. look up in del.icio.us.   add to furl.net add to furl
Click here to bookmark this link.Channel Image02:08 休日» Matzにっき
春分の日でお休みなので、 下の二人を連れてフォーゲルパークへ。 鳥たちをみて喜んでいた。 モモイロペリカンがけっこう頑張って芸をしていた。 頭、いいのね。そうとう大きい(羽を広げると1.5m以上ありそう)が、 まだ生後10ヶ月というのも驚き。
add to del.icio.us add to del.icio.us. look up in del.icio.us.   add to furl.net add to furl
Click here to bookmark this link.Channel Image02:08 【コラム】エンジニアのための英語術 (43) 論理のルールに従って主張を整理する - 英語でプレゼンテーション その2 | マイコミジャーナル» Matzにっき
先日のGoogle TechTalkの内容を「アメリカ流プレゼンテーション」流儀にしたがうと こんな感じになると言う話。勉強になるが、正直恥ずかしい。 ただし、これはあくまでも「アメリカ(ビジネス?)流儀」である。 RubyConfとかOSCONとかでプレゼンするギークたちはもうちょっと別の流儀にしたがっている印象がある。 それと、私のプレゼンに対するコメントには、 ネガティブに取り扱われているのは発音や語彙で、 ここで言われているようなフォーマットに踏み込んだものがないことからも ギークたちの間では原田さんの紹介してくださってい..
add to del.icio.us add to del.icio.us. look up in del.icio.us.   add to furl.net add to furl
Click here to bookmark this link.Channel Image02:08 『プログラミングErlang』» Matzにっき
しばらく前に献本していただいていた本を読む。 しばらく前に言語探訪で紹介していたりするのだが、 こうやってまとめて読んでみるとかなり知らないことが多い。 「ビット構文」とか、pack/unpackより便利かもしれない。 あと、多重代入の代わりにパターンマッチとか。 ただ、文法はちょっと分かりにくい。 よくわからない句読点のルールとか、endとか。 単一代入しかない関数型言語というのは 「普通の言語」とは、かなり異なったプログラミングスタイルを要求するが、 その故に便利な点も数多くあるなあ。副作用がないから プロセスが遠..
add to del.icio.us add to del.icio.us. look up in del.icio.us.   add to furl.net add to furl
Click here to bookmark this link.Channel Image02:08 Ruby as an AppleScript Replacement?» Matzにっき
先日、MacRubyについて、AppleScriptの代替になるのでは、と書いたが、 実際にやってみた例。 tell application "TextEdit" get paragraph 1 of document "Read Me" end tell が、こうなる。 app('TextEdit').documents['Read Me'].paragraphs[1].get おおむね好評のようだ。
add to del.icio.us add to del.icio.us. look up in del.icio.us.   add to furl.net add to furl

Wed 26 March, 2008

Click here to bookmark this link.Channel Image12:47 Twitter Updates for 2008-03-25» halostatue
I have set a goal for myself to meet in three years and change. With discipline, I will meet it long before then. # @chartier have CC stopped sucking? I swear, Einstein on the Beach is their only good song… # @chartier they opened for The Who in TO a few years back, and I couldn’t think [...]
add to del.icio.us add to del.icio.us. look up in del.icio.us.   add to furl.net add to furl

Tue 25 March, 2008

Click here to bookmark this link.Channel Image22:25 程序设计语言的表达——内部DSL» 梦想风暴
使用Java实现内部领域特定语言
One Lair and Twenty Ruby DSLs
Implementing an Internal DSL

上面几个文章都是关于DSL的,不过,在这里,我并不是太关心DSL的话题,我更感兴趣的是代码的写法。按照这几篇的分类方法,直接用程序设计语言编写的DSL算是内部DSL,也就是说,所谓内部DSL,也就是一种标准的程序代码。

Kent Beck在他的《Implementation Patterns》的第三章《A Theory Of Programming》中,谈到了编程的价值观(Value):Communication(沟通)、Simplicity(简单)和Flexibility(灵活)。如果说简单和灵活很容易理解的话,那么把沟通放在价值观中,尤其排在所有价值观的第一位,则显现出Kent Beck对于编程的深刻。在这个软件开发越来越需要协作的年代,写代码的时候,多站在让别人理解的角度考虑一下,会极大提升代码的可读性。在ThoughtWorks的招聘流程中,有一个Code Review的环节,拜这个环节所赐,我看过很多人的代码,不在少数的应聘者其代码唯一的优点就是完成了需求。以沟通为标准进行衡量,这显然是不够的。

同样,以沟通为标准,那么内部DSL显然在这方面做得更好,因为DSL本身就是为了让人更容易理解而存在的。这几篇文章中提供了很多内部DSL的手法,比如Method ChainingExpression Builder等等。抛开DSL这样的BuzzWord,这些方法应该属于增强程序本身表达能力的方法。

JDK有一个很好的Method Chaining的例子:StringBuffer的append方法。

StringBuffer sb = new StringBuffer();
sb.append("log1").append("log2").append("log3");

这样的写法显然比下面的写法更为简洁,尤其是需要往StringBuffer中添加很多内容的时候。

StringBuffer sb = new StringBuffer();
sb.append("log1");
sb.append("log2");
sb.append("log3");

在我看来,这些内部DSL技术为我们打开了一扇窗,它让我们在编写代码,尤其作为API提供的代码时,有了一个新的思考方向。当然,并不是一味的应用这些内部DSL技术就会写出好代码,作为一个有经验的软件开发人员,我们需要一定的鉴别能力,分辨出究竟怎样做才会真正的提高代码的“沟通”能力。

之前写过两篇关于程序设计语言表达的blog(12),虽然这篇不像那两篇一样讨论语言的差异,但也算是在语言表达能力上的探讨吧!
add to del.icio.us add to del.icio.us. look up in del.icio.us.   add to furl.net add to furl
Click here to bookmark this link.Channel Image15:09 Twitter Updates for 2008-03-24» halostatue
@timburks Perry the Cynic isn’t Anonymous Coward, at least. A pseudonym is a little more honest when consistent. He is googlable reliably. # @duncan What do you think of the TrekPod? (http://trek-tech.com/Go/) # @MicheBel It is disappointing; I think the whole colour wars thing is silly. One could, be more explicit with "coral".) # @timburks that would be [...]
add to del.icio.us add to del.icio.us. look up in del.icio.us.   add to furl.net add to furl
Click here to bookmark this link.Channel Image08:11 Generation Help» James Britt - Code, Content, Caffiene

A small plea to people writing code generator tools.

If you have a tool that creates, say, an application skeleton, like this:

$ wooblegen appname

please do not blindly process an argument of “help”.

A few times I’ve forgotten the options to one or another tool, invoked it with an argument of ‘help’, and ended up with a boatload of directories and files, none of which were very helpful.

The correct behavior would be to scold the user (such as myself) , explaining that the standard invocation would be possibly -h or --h or -help or -H, but not, you know, help. Then give a choice to generate stuff or get help.


add to del.icio.us add to del.icio.us. look up in del.icio.us.   add to furl.net add to furl
Click here to bookmark this link.Channel Image05:07 Presenting Code ... An Update» { |one, step, back| }

I received some feedback on the ‘Presenting Code’ post from yesterday.

Presenting Code … An Update

I got lots of feedback on the “Presenting Code” post. In addition to Cédric Beust’s initial comments, the following people had something to say on the topic:

John Wilger asked on Twitter why I didn’t use “file:” (rather than “http:” and a local web server). Unfortunately, Keynote will not do a web view from a “file:” style URL.

Luke Kanies reports that he does something similar. He uses Vim (rather than Ruby + the Syntax gem) to generate the highlighted HTML. He also adds:

In general, this method works out great, but the one thing I would say is that you should always uncheck “automatic update”. Otherwise, you’ll find that it tries to update 10 seconds before your presentation starts and your web server isn’t available.

Ok, that’s good advice. BTW, I would be very interested in a script (AppleScript or Ruby+OSA) that would iterate over the pages in a Keynote presentation and refresh all the WebViews. Any takers?

James Edward Gray II and Mike Clark mentioned the HTML output bundle. James gives the following details:

  • Select Bundles → TextMate → Create HTML From Document (or Create HTML From Document With Line Numbers, if you prefer)
  • Preview the document in TextMate with Window ⇢ Show Web Preview
  • Highlight and Edit → Copy the content you want from the HTML window
  • Switch to Keynote and Edit → Paste

Mike (who credits Bruce Williams as his source for this tip) also provided a video.

Couple of items on the above:

  1. When creating the HTML from the document, convert the whole document. Once in Web Preview mode you can cut and paste only what you want.
  2. Choose a TextMate theme with a background that matches the background in your presenetation to get the best effect for your colors.

Dr. Nic also mentions a “Copy as RTF” TextMate bundle. (I’m not sure if this is the same as James and Mike’s hint above or something different).

Finally, Chris Nelson confirms (via Twitter): “AFAIK there is no equivalent of web views in OpenOffice :(“


add to del.icio.us add to del.icio.us. look up in del.icio.us.   add to furl.net add to furl
Click here to bookmark this link.Channel Image03:44 Tales of Mere Existence ...» Projectionist

Tales of Mere Existence – “Subtext”


add to del.icio.us add to del.icio.us. look up in del.icio.us.   add to furl.net add to furl

Mon 24 March, 2008

Click here to bookmark this link.Channel Image19:51 Off to Seelbach» chris blogs

Tomorrow I’m going to leave early for Seelbach deep in the Black Forest where I’ll spend the rest of the week educating myself on civil service (which I finished for two thirds already, but hey, who cares).

Anarchaia and chris blogs will resume publishing Saturday, March 29.

Please notice that this means I will not be able to attend Euruko 2008 in Prague this year. That’s sad, but I can’t help it (not that I’d have anything to talk about). Enjoy the program.

Regarding conferences, I am planning to go to the Workshop on Self-sustaining Systems in May and RailsConf Europe in September (I hope there will be a CabooseConf Europe, really).

I expect to have occasional Internet access in Seelbach, else mail will have to wait. It’s my first travel with the EEE.

NP: Grateful Dead—Promised Land


add to del.icio.us add to del.icio.us. look up in del.icio.us.   add to furl.net add to furl
Click here to bookmark this link.Channel Image15:08 Twitter Updates for 2008-03-23» halostatue
Finally going to see There Will Be Blood # How in the hell did anyone like "There Will Be Blood"? # @rubyist because it’s a trainwreck? because DDL was chewing the scenery in a pointless nihilistic exercise of nonsense? # Powered by Twitter Tools.
add to del.icio.us add to del.icio.us. look up in del.icio.us.   add to furl.net add to furl
Click here to bookmark this link.Channel Image06:33 软件命令行解说:解决GnuWin32在Windows Vista上的问题» 道喜技术日记

软件命令行解说:解决GnuWin32在Windows Vista上的问题


add to del.icio.us add to del.icio.us. look up in del.icio.us.   add to furl.net add to furl

Sun 23 March, 2008

Click here to bookmark this link.Channel Image15:12 Twitter Updates for 2008-03-22» halostatue
Wow. The Spring "One of a Kind Show and Sale" is much easier to navigate than the winter one. Lots of fun, lots of stuff bought. # IKEA home deliveries are amazingly efficient # @bryanl yeah. I haven’t been able to take the time to import everything into Eagle Filer yet, but I’m in the process of [...]
add to del.icio.us add to del.icio.us. look up in del.icio.us.   add to furl.net add to furl
Click here to bookmark this link.Channel Image15:12 Twitter Updates for 2008-03-22» halostatue
Wow. The Spring "One of a Kind Show and Sale" is much easier to navigate than the winter one. Lots of fun, lots of stuff bought. # IKEA home deliveries are amazingly efficient # @bryanl yeah. I haven’t been able to take the time to import everything into Eagle Filer yet, but I’m in the process of [...]
add to del.icio.us add to del.icio.us. look up in del.icio.us.   add to furl.net add to furl
Click here to bookmark this link.Channel Image15:12 Presenting Code» { |one, step, back| }

This exchange on twitter got me thinking…

Twittering …

I noticed the following twitter conversation this evening between objo and superchris:

superchris: any good recommendations on showing code samples in OpenOffice Impress?

objo: @superchris yeah, get a mac and use Keynote

objo: otherwise, I would screenshot emacs

superchris: @objo.. ya know, i almost added “And I’ll smack anyone who says get a Mac” but ran out of space

superchris: @objo… but actually your idea of using NetBeans screenshots is pretty good

objo: @superchris you never listen …. EMACS not netbeans. Come on man.

superchris: @objo just being helpful by translating for you.. :)

superchris: planning to code with NetBeans on linux forever for no other reason but to annoy @objo

ScreenShots … Yuck!

The problem Chris is trying to solve is putting code snippets into a presentation. There just isn’t a good way to do this in modern presentation programs.

In the old days, I would generate my presentation completely in HTML from a simple text markup file. The generation process was controlled by rake. This allowed me to changed the code, run the unit tests and rebuild the presentation all with a simple rake command. Eventually, I got up to speed with CSS and could make some really nice looking presentations, all from HTML.

Although I could get nice looking slides with CSS, it was a lot of work getting it to work just so. Eventually, I abandoned that approach and swithed to a modern slide presentation program (Keynote in my case).

Although generating the slides is a bit easier in Keynote (or PowerPoint, or Open Office Impress), reproducing code for technical talks is much harder. You generally have two choices:

  1. Cut and paste the code text into Keynote losing any syntax highlighting you might have had, or
  2. Take a screen shot of the code in your fancy editor, preserving the syntax highlighting but losing the “text” nature of the code.

Neither option is pleasant. The former punishes the audience by making the code harder to read, the latter punishes you making the presentation hard to change. (I once saw Dave Thomas giving a Ruby talk and he noticed that he had a minor typo in the code. He switched to edit mode in Keynote with the intent of fixing it on the spot, then he realized that the code was in a graphic image and was uneditable).

Of the two options, I’ve been using the text cut’n’paste technique for most things. In the twitter conversation above, Chris is considering the edit snapshot technique.

Other Options?

I’ve heard rumors of someone working on a script that will insert code snippets into the Keynote data file directly. Unfortunately, as far as I know, they are still rumors at this time.

But here’s another idea. I’ve prototyped this, and think it will work. But be warned I haven’t tried this on a really presentation yet.

Presenting Code … A Proof of Concept

While perusing the options in Keynote, I noticed an insert option called “Web View”

It turns out that this option allows you to include a web page in your presentation. For example, here is my blog inserted directly into the presentation. Clicking on the “web view” object will show an “update” button that will refresh that page from the web.

So, all I have to do is get the code onto a web page, formatted nicely with syntax highlighting, and Keynote will suck it into the presentation, more or less automatically for me. Cool.

Getting it formatted is easy. That’s just a small little Rake task with a good syntax highlighting library. I used Syntax (its a gem, docs on Rubyforge), but there are other options out there.

Here’s the rakefile:

#!/usr/bin/env ruby

require "rake/clean" 

CLOBBER.include('*.html')

task :default => :extract
task :extract => "hello.html" 

file "hello.html" => "hello.rb" do
  extract "hello.html", "hello.rb" 
end

and here is the rakelib/extract.rake library:

#!/usr/bin/env ruby

require 'syntax/convertors/html'

def extract(outfile, infile)
  open(outfile, "w") do |out|
    out.puts "<html>" 
    out.puts "  <head>" 
    out.puts "    <style type=\"text/css\">" 
    out.puts %(
.ruby { font-size: 24pt; font-weight: bold; }
.ruby .normal {}
.ruby .comment { color: #888; font-style: italic; }
.ruby .keyword { color: #A00; font-weight: bold; }
.ruby .method { color: #077; }
.ruby .class { color: #074; }
.ruby .module { color: #050; }
.ruby .punct { color: #447; font-weight: bold; }
.ruby .symbol { color: #099; }
.ruby .string { color: #944; }
.ruby .char { color: #F07; }
.ruby .ident { color: #004; }
.ruby .constant { color: #07F; }
.ruby .regex { color: #B66; }
.ruby .number { color: #D55; }
.ruby .attribute { color: #377; }
.ruby .global { color: #3B7; }
.ruby .expr { color: #227; })
    out.puts "    </style>" 
    out.puts "  </head>" 
    out.puts "  <body>" 
    out.puts "    <pre class=\"ruby\">" 
    code = open(infile) { |f| f.read }
    convertor = Syntax::Convertors::HTML.for_syntax("ruby")
    html = convertor.convert(code)
    out.puts html
    out.puts "    </pre>" 
    out.puts "  </body>" 
    out.puts "</html>" 
  end
end

Edit the CSS styles above to tweek the output to exactly the colors you want. I’ve added a large font-size line to make the code big enough for teh presentation (I hate small code fonts in presentations, you can ask objo about my rants on that topic.)

Now we need to get the code on a web page. No need to get fancy here. I have a script called servefiles that will start a webrick process that serves files from the current directory. Just start it up with “servefiles 3333” (the 3333 is the port to use). Servefiles will display its URL in its startup message, like so:

$ servefiles 3333
URL: http://tardis.local:3333
[2008-03-23 00:47:37] INFO  WEBrick 1.3.1
[2008-03-23 00:47:37] INFO  ruby 1.8.6 (2008-03-03) [i686-darwin9.2.0]
[2008-03-23 00:47:37] INFO  WEBrick::HTTPServer#start: pid=874 port=3333

Here’s the code for servefiles:

#!/usr/bin/env ruby
require 'webrick'
include WEBrick

dir = Dir::pwd
port = (ARGV.first || (12000 + (dir.hash % 1000))).to_i

puts "URL: http://#{Socket.gethostname}:#{port}" 

s = HTTPServer.new(
  :Port            => port,
  :DocumentRoot    => dir
)

trap("INT"){ s.shutdown }
s.start

Now all we have to do is cut and paste the URL given by servefiles into keynote and append the HTML file name we wish to add to our presentation:

Now, to update the code in the presentation, I need to:

  1. Edit the original code base (and run unit tests against it).
  2. Run rake
  3. Press the “Update Now” button in Keynote.

Not bad.

It’s Just a Proof of Concept

Just be warned, I haven’t tried this in a real presentation yet. I’ve just spent an hour or so seeing if all the pieces would work together. There are some obvious things to explore.

  • The extraction code could be enhanced to pull snippets from files based on tags. Or even better, being able to say “Extract Method m from Class C”.
  • I’m using a fixed font size, but extract could easily take the font size as an argument or even calculate the proper font size given the amount of text found in the snippet.
  • I’ve not played with the “Update automatically” checkbox in the Keynote dialog. I’m not sure when it automatically updates, but it is possible that using it might mean you don’t even need step three above.

I will probably experiment some more with then in my next code heavy presentation. Let me know if you try this and how it work for you.

UPDATE

Cédric Beust points out that cutting and pasting from Eclipse to PowerPoint does preserve syntax highlighting. I verified the same is true for Eclipse and Keynote. However all the other IDEs and editors I tried (NetBeans, Coda, TextMate, Emacs) will paste as plain, uncolored text in Keynote. So, if you are going the cut and paste route, you might want to consider using Eclipse for the cut source.

Just for kicks I tried the presentation software in OpenOffice with the same result. Eclipse copies will preserve highlighting, none of the others will.

So, there you have it.


add to del.icio.us add to del.icio.us. look up in del.icio.us.   add to furl.net add to furl
Click here to bookmark this link.Channel Image00:07 Twitter Updates for 2008-03-21» halostatue
@wobblini as far as I understand it, yes. # Neat artisanal travel pouches from http://www.jupiterfreedom.com # Powered by Twitter Tools.
add to del.icio.us add to del.icio.us. look up in del.icio.us.   add to furl.net add to furl

Sat 22 March, 2008

Click here to bookmark this link.Channel Image07:22 MiddleClickClose For Safari 3.1» Joey Gibson's Blog

As I reported two days ago, after I installed Safari 3.1, my MiddleClickClose extension stopped working. Well, I've gotten it working again, but it doesn't load under Safari < 3.1. So, only install this version if you are using Safari 3.1. If you are using an older Safari, use this one.

As before, I'm releasing this under the GPL.


add to del.icio.us add to del.icio.us. look up in del.icio.us.   add to furl.net add to furl
Sources