Fri 25 January, 2008

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
Ruby语言:Ruby程序运行外部程序(一)
(.^.)软件环境- Ruby 1.8.6
- 有用的Windows命令工具集GnuWin32
- Linux系统实例代码
system "rm /tmp/hello.txt" - Windows实例代码
system "cmd /c del ./hello.txt"
system "calc" - 说明
在执行该函数system以后,程序会继续执行之后的代码。
- Linux系统实例代码
system "ls -al /tmp/hello.txt" - Windows实例代码
system "ls -al ./hello.txt" - 说明
在执行该函数exec以后,程序就停止执行之后的代码。
- Windows和Linux系统实例代码
·ls -al .· - 说明
函数·(重音符,在Tab键上面的按钮)能够让我们获得输出结果。
- Windows和Linux系统实例代码
%x(ls -al .) - 说明
注意这里的括号不能省略。
add to del.icio.us. look up in del.icio.us.
add to furl
“ Clutter and overload are not an attribute of information, they are failures of design. ”
Edward Tufte
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
Tip Only use soft bristled tooth brushes
Dentists recommend you only use soft bristled tooth brushes. Medium or hard bristled tooth brushes are apparently marketing ploys and not recommended.
add to del.icio.us. look up in del.icio.us.
add to furlThu 24 January, 2008

add to del.icio.us. look up in del.icio.us.
add to furlWed 23 January, 2008

I love Safari on my shiny Mac Pro, particularly because it's so much faster than Firefox. But one thing I missed from Firefox was being able to do a middle-click on a tab and have it close. After several failed attempts, I finally got some help from Mark Rowe who pointed me to a proper method-swizzling implementation. After switching my code to use that swizzler, everything fell into place. I've been happily using it ever since, I just never released it. I got an email the other day asking for it, so here it is.
Unlike my Export to Archive plugin for iPhoto, I didn't build an installer for this one. It's easy to install, but you still have to do it yourself. And there's a dependency: SIMBL. Now, before Leopard shipped the word was that Input Managers would no longer be supported. After Leopard shipped we saw that wasn't entirely true. So, once you get SIMBL installed and working, using my plugin is easy. This should work on both Tiger and Leopard. I've only tested it recently on Leopard, but I originally wrote it on a Tiger system.
- Get the binary package: MiddleClickClose.zip
- Create ~/Library/Application Support/SIMBL/Plugins if it doesn't exist
- Unzip the MiddleClickClose.zip into this directory. You should end up with a directory called MiddleClickClose.bundle
- Restart Safari
If all goes well, you should now be able to use your middle mouse button to close Safari tabs. It works for me. If it doesn't work for you, run the OSX Console and look for "MiddleClickClose loaded" in the "Console Messages" section.
If you want the source code, download it here.
I should mention that this really is a dirty hack, and may not work with future versions of Leopard. It works for me, but your mileage may vary. I hope it works for you, but it may not.
This code is distributed under the GPL v2.
add to del.icio.us. look up in del.icio.us.
add to furl
http://dpaste.com/hold/31935/
http://news.e-scribe.com/395...
add to del.icio.us. look up in del.icio.us.
add to furl

- 说明
- andLinux 是一个没有虚拟机,但是作为Windows应用程序运行于Windows系统的Linux操作系统。
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程序使用,也可以在Rails框架一样软件中很方便地被使用。
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
2. Botany Without membranous expansions, as a stem.
add to del.icio.us. look up in del.icio.us.
add to furl
“ What are you going to write worthy of me? ”
J. J. Abrams’ Powerbook
add to del.icio.us. look up in del.icio.us.
add to furlTue 22 January, 2008

Well, damn. Just damn. Fred Thompson has thrown in the towel. He no longer had any chance of winning, but it's still sad to see him go. But, if we're really being honest, I don't believe his heart was ever really in the race. As I saw in an article a week or so ago about us "Fred Heads," we wanted him to be president far more than he wanted to be president. I believe that is true.
Now I have no one to vote for. I can't stand McCain. I don't really like Guiliani. Huckabee is less-than-thrilling. Romney is OK, I guess, but nothing exciting. And Ron Paul is insane. Not too many choices left.
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
“ Test cannot be started because it already doesn’t exist. ”
AVG error message
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 furlMon 21 January, 2008

add to del.icio.us. look up in del.icio.us.
add to furl
The call for participation for RailsConf Europe ‘08 has opened up and we’re now accepting proposals. The conference is returning to Berlin and the conference will happen between the 2nd and 4th of September.
Last year was an absolute blast. There’s such a great diversity of people from all over Europe and beyond. It’s a great addition to the much more US-focused bang of RailsConf in the US.
Also, have in mind that the program for RailsConf Europe is usually pretty much completely different from the US fanfare. So it’s okay to submit your proposal here as well. What might be accepted at RailsConf in the US might not go for RailsConf Europe and vice versa.
Anyway, looking forward to reading about those proposals!
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 furlSun 20 January, 2008

作为一个有理想、有追求的程序员,你成天被各种名词包围着,你对其中一个叫做敏捷的东西特别感兴趣,因为它特别强调人的作用,这听着都让做程序员的你感到舒服。为了让自己早日敏捷起来,你从众多的敏捷实践中选择了一个叫做测试驱动开发(Test Driven Development,TDD)的作为你的起始点。因为它对你周遭的环境要求是最低的:它不像结对那样,要求其他人和你一起合作;也不像采用Story那样改变你所在团队的做事方式……你所需要做的,只是在你编写业务代码之前,把测试先写好。这完全是一种润物细无声的做法,根本无需告诉你之外的任何人。就在别人忙碌的找bug时,你便开始享受敏捷带给你的快乐了。顺便带来的好处是,下次在那里和别人争论敏捷的时候,你可以以一个实践者的姿态出现,而不是在那里信口开河。
你不会打无准备之仗,于是,你通读了Kent Beck的那本薄册子。通读之下,你对TDD更是充满了信心。因为“红——绿——重构”的步骤实在是简单得令人发指。好吧!总而言之,你已经信心十足的准备开始TDD,步入敏捷的康庄大道了。
理想很美好,现实很残酷。
当你着手在实际项目中体验TDD的时候,一切变得并不像最初看起来的那样美好。虽然你努力的坚持着TDD的原则,但你经常就会发现某些东西不好测,比如你遇到了数据库,比如你遇到了GUI,比如你遇到了计时器(Timer)。敏捷并非教条,当某些事不可为的时候,你完全可以不那么坚持。于是,你告诉自己,不好测的东西可以不测,这样,至少从心理上来说,你觉得舒服多了。随着工作的继续,你发现,你不能测的东西越来越多,单元测试的覆盖率随着开发的进行正在逐渐降低,一丝恐惧涌上心头。回过头来,再去看Kent Beck的书,你突然觉得,你似乎被骗了,因为Kent Beck的例子貌似全都是逻辑,如果只是逻辑,当然好测了,但现实从来就不是这样。
难道TDD只是看上去很美?
显然,你不愿意就这样放弃,放弃你苦心学来的软件开发秘籍,那些传说中的高手极力推崇的TDD必然有一定道理,TDD确实能够让你感觉很好:能测试的那部分代码确实极大的增强了你对软件质量的信心,而且出错了也确实好找,每次修改代码之后运行测试出现的绿条也确实让你身心愉悦。
那问题到底出在哪呢?你陷入了沉思。
信马由缰,你翻开了自己写过的代码。看着自己写的这些代码,你忽然意识到一个问题,自己遇到的问题并不属于TDD,而是属于单元测试。正如你之前所想到的那样,TDD做法本身的结果是让你感到快乐的。对,一定是单元测试本身出了问题。那单元测试出了什么问题,很显然,一大堆不能测试的部分让单元测试变得很难写,降低了单元测试的覆盖度。那是不是这会是一个无解的问题呢?你显然不愿意就此放弃,所以,顺着这个思路继续向前。
TDD之所以让你安心,主要是每次编写代码之后,运行测试会出现一个绿条,告诉你测试通过。这样,你可以放心大胆的向前继续,因为你的代码并没有破坏任何东西。究竟是什么让你感到不安,显然是那些测试没有覆盖到的代码。你又仔细翻看了一下那些没有测试覆盖的代码,你的思路一下子清晰起来。之所以这部分让你不安,因为里面除了那些确实不好测试的部分之外,里面还有一些逻辑。如果只是那些真正不好测试的部分没有被测试覆盖到,你会觉得心里还有一些安慰。你确定了,真正使你不安的就是与不好测试的代码共存亡的这些逻辑部分。
如果测试可以覆盖到这些逻辑的部分,至少从感情上来说,就可以接受了。那怎么才能让这些部分被测试覆盖到呢?你仔细观察着那些没有测试的代码,如果这样做,这个部分就可以测试了,如果那样做,那个部分也可以测试了,一来二去,这些貌似不可测试的代码可以分解出许多可以测试的部分。
你的心情一下子好了许多,因为这么做终于可以让测试的覆盖度达到让你心理上可以接受的范围。不过,新的问题也随之而来。我在做什么?拆来分去,这不就是设计吗?怎么走到这里来了。我不是在分析单元测试的问题吗?对了,我最初的问题是TDD,怎么一路跑到设计上来了?
TDD?设计?
你突然发觉自己对TDD的理解有一些偏差。TDD,并不代表不需要设计。读过很多书的你突然想起了Robert Martin那本著名的《敏捷软件开发》,上面有一个关于数据库访问的例子。那个例子里面,前后两个版本的差异正好就是考虑设计的结果。通常,在设计中考虑测试,会很容易找到设计中僵硬的部分,让程序更加灵活。再进一步,如果在开始动手之前,稍微进行一些设计,这些问题还是可能注意得到的。你突然觉得,正是因为TDD本身过于强调测试的价值所在,让你忽略软件开发中很重要的部分:设计。
思路一下子清楚起来,TDD其实不只是“红——绿——重构”,它还是与设计相关的:在动手之前,还是要有一定的设计,而且,在设计中要考虑测试的问题。终于解开了心中的困惑,现在的你,对于TDD有了一个新的认识,虽然这个认识不见得是什么终极真理,但至少是通过自己的思考得来的,这让你更加相信实践出真知的道理。
理清思路后,你更加坚信TDD本身的价值所在,也坚定了在日后开发中继续使用TDD的念头,当然,目光远大的你已经盯上了其它的敏捷实践。
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

- 说明
- 不错的创意网站;
- 所有asp文件都是执行命令,其实就是网站菜单;
- 要是能够使用Tab键和方向键就更好。
add to del.icio.us. look up in del.icio.us.
add to furlSat 19 January, 2008

It's snowing in Georgia right now. Big, fat flakes falling fast. None sticking to the streets, but cars, grass and houses are collecting lots of it. We're only expecting a few more hours of falling flakes, but it sure is pretty to look at now. It will all be either solid ice or gone tomorrow, but we're enjoying it while it's here. View the entire set.
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
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 on Rails Enterprise Application Development
by Elliot Smith and Rob Nichols.
Packt Publishing, Birmington 2007.
[Full disclosure: I have received a copy of the book in exchange for this review.]
The book targets Rails beginners that have a little prior knowledge of Ruby and Ruby on Rails and aims to accompany them on their way to Rails mastership. It focuses on the iterative and stepwise development of a small CRM system for a small company. Since the chapters don’t anticipate, it can be read straight forward, while the reader continuously learns and refines his skills.
It starts with a general introduction on why to use a web-based client-server architecture for business applications, and then recommends Rails to implement them, last but not the least because it is open source and enables easy testing.
Next, the reader is introduced to basic database design, elementary normalization and how Rails’ ORM works. Then, it discusses Rails naming conventions and includes a list of reserved words in Ruby. A list of reserved class names is unfortunately not included, it would have been very helpful since Ruby already claims some very generic class names (Date, Thread, etc.).
Contradictory to the introduction, now nevertheless follows a tutorial on how to setup and install Rails. The book was written before Rails 2 and generally speaks of outdated versions, however, most of the content is not affected by this—still, there may be some traps if one tries to follow it with more recent Rails versions. After setting up Rails, the installation of a database (MySQL throughout the book) and a revision control system (Subversion) is explained.
After these preliminaries, a Rails project is created and the book explains the Rails directory structure. Tables are set up, migrations introduced, and the reader learns about the essential ActiveRecord API with finds and relationships. Validations are addressed as well; the regular expression for email checking is broken. After a quick overview of unit testing and Test::Unit (TDD is discussed but not used), the reader can check in the code for the first time.
Now, they generate controllers, introduce ERB and pagination (using
the built-in paginate), how to do links and layout and furthermore
how to use partials and flash. The chapter also shows how to write
functional tests.
The application is ready for a first deployment. After an overview of the typical Rails hardware requirements, the book explains how to set up Mongrel.
The next chapter focuses on user experience. The authors introduce routes for better bookmarking, show how to add search and input validation and finally give examples of using AJAX for autocompletion. They also point out that AJAX should be used sparingly and only when it makes sense. The chapter also makes an excursion on how to setup Instiki as a help system.
After this, the book deals with improving error handling,
authentication (for which they use unsalted password hashing) and file
uploads. After displaying a primitive version of file uploads, it is
shown how to install plugins and how to use acts_as_attachment.
Then, more serious deployment gets addressed. They introduce Capistrano, explain how to set it up and then use it for upgrading, downgrading and database-related tasks. A list of common problems is provided to help fix likely issues. The authors also explain how to install automatic start-up scripts, session cleaning and log rotation. The rest of the chapter deals with optimizing the Rails application: how to find and identify the bottlenecks with profiling and how to speed up Rails with the different kinds of caching available or by using eager loading. Finally, they also address scaling by using multiple Mongrels and Apache as a reverse proxy and static file server.
The last chapter, “Down the Track” tries to school the reader when it’s okay to break Rails’ conventions. They give situations where the use of custom SQL or using multiple databases is required or advantageous. The chapter also outlines general virtues of a business application developer, such as the importance of understanding the business processes, that successful applications primarily need to yield profit, that automation is good, and reporting important.
The book is concluded by an appendix showing how to setup your own Gem server.
Conclusion: The book does not satisfy the introductory claims: it is often too detailed on the basics and too shallow on the crucial things and sidetracks the reader into unimportant issues. The writing is occasionally clumsy and sometimes overuses the passive voice to incomprehensibility. Some code examples are syntactically invalid and a few Ruby-related commentary plainly wrong. Throughout the text, replace all occurrences of “property” by “attribute” and of “ampersand” by “commercial at”. Various other mistakes sprinkle the book, occasional typos, random font changes and weird spacing suggest the book was produced in a hurry. People with typographic sense will be shocked by the table of contents and complete and the utter lack of typographical quotes. The few illustrations are reproduced in a very low resolution.
Still, the book may be useful for Rails beginners that are interested in the development of an “enterprise application” and would like to know what else there is to keep track of. The complete Rails newbie however will stumble due to the preknowledge of Ruby, whilst the slightly advanced Rails developer will hardly learn anything new and would be better off with specific books on deployment or system administration to extend his knowledge.
Rating: 3 of 5 points.
NP: Minutemen—Love Dance
add to del.icio.us. look up in del.icio.us.
add to furl
“ Were I to choose an auspicious image for the new millennium, I would choose this one: The sudden agile leap of the poet-philosopher who raises himself above the weight of the world, showing that with all his gravity he has the secret of lightness, and that what many consider to be the vitality of the times-noisy, aggressive, revving and roaring- belongs to the realm of death, like a cemetary for rusty, old cars. ”
Italo Calvino
add to del.icio.us. look up in del.icio.us.
add to furlFri 18 January, 2008

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


