Archive for April, 2008

git status in shell prompt

Thursday, April 24th, 2008

When I see the post “Current Git Branch in Bash Prompt” from reddit, I found it really a cool idea. Personally, I use zsh, though that post is about bash, adding similar thing to zsh is pretty easy!

My zsh prompt is already pretty cool in my opinion. I borrowed something from Phil!’s ZSH Prompt, but I prefer a much cleaner style. Here’s what it looks like normally:


It shows the current username and current working directory. I don’t like the full path of cwd shown in the prompt because I don’t care about it most of the time. Note the title bar below is not really irb, it’s the Screen status line. :p

Read the rest of this page »

Google Summer of Code 2008: First Chapter

Wednesday, April 23rd, 2008

Google Summer of Code 2008Finally, I was accepted by Thousand Parsec and will work on Schemepy with Timothy Robert Ansell this summer. I hope this would be an enjoyable summer. :)

It’s been a fairly long time since the announcement of Google Summer of Code 2008. I’ll try to write something about that period. I learned a lot from this and it’s really (some what) by coincidence that I ended up working with Schemepy. :p


It was roughly summer of 2007 when Jack told me about Google Summer of Code. But applying period for GSoC2007 has ended that time. Then when I read the announcement of GSoC2008 this year in the Google Reader in late February, I was excited. I checked the website of GSoC and some projects accepted in year 2007, 2006 and 2005.

Read the rest of this page »


Sunday, April 20th, 2008


但是我想既然这个课是由 CYJJ 来上,应该至少不会无聊到哪里去吧。二十多章的内容被压缩在了 8 周的短学期中,上课又是一百多号人的班级,唯一能吸引人的就是课件里穿插的各种故事(或者说叫做 IT 八卦)了。到最后一周的时候才幡然醒悟:上课似乎没有听进去过几个字。厚厚的一本书,考前看了一遍,也没有记住什么实质性的东西,DFD、ACD、SCD……一堆一堆的概念。当然为了避免这个课变成那种背概念的文科课,配套有几个 project :

  • Software Requirements Specification
  • System Design
  • Test Specification
  • Subsystem Version 1.0
  • Subsystem Version 2.0
  • Web Design
  • Final Integration of System

Read the rest of this page »

YARV (The Official VM for Ruby 1.9) Instruction Set

Friday, April 18th, 2008

YARV is Yet Another Ruby VM. But it is the official Ruby VM since Ruby 1.9. It is a stack-based VM which runs the YARV bytecode, or intcode because each element of the instruction sequence is in fact stored as an int.

There is an instruction table for YARV on the original YARV homepage, but it is out-dated now. So I build a new one and make it publicly available in case some one would be interested in.

Koichi said that the instructions are not stable currently. Something might going to change later. Some instructions that are not used frequently might be modified or even removed. But I guess at least those two instructions will be kept: ;)

  • bitblt: returns "a bit of bacon, lettuce and tomato".
  • answer: the answer to life, the universe, and everything. It returns 42.

Yes, there they are, both in the joke category of the instruction set. :D

Read the rest of this page »

Use git-svn to fork a project and keep tracking of it

Tuesday, April 15th, 2008

gitThe case is that sometimes you want to add some cool feature to an open source project. But you don’t have commit rights to that project. So you checked out a copy of the code and do some local hacking. The problem is that you’ll have to track the updates of the original code and merge the changes to your local copy constantly.

One example is the multi-tty support of GNU Emacs (now officially available in Emacs). While the Emacs code base is rapidly evolving, the author of multi-tty branch should track the changes and merge them to his local copy. Another example is YARV when it is still not part of the official Ruby implementation.

Read the rest of this page »

给 YASnippet 的文档做了 css 主题

Monday, April 14th, 2008

YASnippet文档是用 reStructuredText 生成的,感觉 reStructuredText 虽然很强大,但是自带的那个 HTML Writer 的可定制性实在是不太好,而且文档不好找,许多地方都只能根据固定好的输出结构来做 css ,而 Muse 在这方面要好弄一些,主要是 Muse 比较简单,许多地方可以方便的控制了。下面是一个截图:

Document of YASnippet

还不错吧!可以点过去看看。 :) 其实是借用了 Drupal 6 的默认主题里的不少东西。

[ANN] YASnippet 0.5.0 Released

Thursday, April 10th, 2008

EmacsI know the problem from the very beginning: if you delete (use something like C-w or C-k) the region of the snippet you just expanded, things will get weird. I thought people will never want to delete the snippet after expanded it; and if he really want to, he can use undo, which works perfectly. But I realized that I was wrong when the Nth people report this bug to me.

So, though I’m busy preparing for my final exam, I decide to sit down and fix the problem. And I’m glad to announce the release of YASnippet 0.5.0 with this annoying problem fixed.

There are also other enhancements (especially the hippie-expand integration that many people requested). Here’s the ChangeLog for 0.5.0:

  • Integrate with hippie-expand. Just add yas/hippie-try-expand to hippie-expand-try-functions-list.
  • If you set yas/fall-back-behavior to 'return-nil, YASnippet will return nil when it can’t find a snippet to expand.
  • Defect fix: the condition of a snippet was evaluated twice in earlier version.
  • Deleting snippet (using C-w or C-k) won’t cause serious problem now.
  • Several complex snippet for python-mode from Yasser included in the distribution.

I wish you enjoy it. :)

BleakHouse 4! Find memory leak in your Ruby program!

Sunday, April 6th, 2008

今天看到 BleakHouse 发布了第 4 版的消息:采用了全新的实现:

…there is no framing necessary, and the analysis task runs in seconds instead of hours.

我在“内存泄漏分析工具的尴尬”这篇文章中曾经介绍过 BleakHouse ,不过那个时候用
BleakHouse 会产生出无比巨大的 dump 文件,并且分析过程需要花费非常多的内存和时间,有时基本成了不可能完成的任务。现在看到 v4 发布消息里提到了新的实现,实在是大喜!因为这本身是一个非常不错的工具。如果你有发现你的 Ruby 程序性能低下,一定要试一试这个工具:

Read the rest of this page »

Ruby on Crack: yet another web framework

Wednesday, April 2nd, 2008

:D 愚人节里各个社区里的气氛都活跃了许多,在 Ruby-talk 的邮件列表里发现了 N 个 Ruby fork 要发布了,还有用 PHP 写的 Ruby 。其他社区也很活跃,Java 似乎是今年的一个主角:各种各样的项目都要迁移到 Java 了。 :D

不过令我敬佩的是虽然只是愚人节的玩笑,许多人都很细心地去做,比如前面的这个叫做 Brobinius 的 Ruby fork 还专门做了一个网站。还有 Antonio Cangiano 的 Ruby on Crack ,他最后一段描述的不同的人对 Ruby on Crack 的反馈:

“Those who use Crack can really appreciate the beauty of Ruby.” — Matz

“Fuck You” — DHH

“Incredible framework. I plan to publish a book about it ASAP, and I’m sure that it’ll be the first in a long series of books that I’ll write while using Crack.” — Dave Thomas

“Crack is what we really needed at Engine Yard.” — Ezra Zygmuntowicz

“Wow, what an eye opener. Crack made web programming fun again.” — Obie Fernandez

“You ass#$!@ m0#@#!@&%$” — Zed Shaw

“Once you have tried Crack for the first time, you realize how addictive it is. I simply can’t go back to Rails anymore.” — April Pesce

“Web 3.0 will belong to those on Crack.” — Tim O’Reilly

“If there is something that the Ruby community got right it’s Crack. I wish Python programmers were on Crack too!” — Guido van Rossum

“This is truly innovative and a godsend for startups. Give us about 6 years and we’ll have Arc on Crack too.”- Paul Graham

也是写得相当生动啊! :D