Thu 27 November, 2008


- 说明
- 在下面资料的逆向循环语句中,do前面多了一个点。
- 参考资料
- http://www.railsrocket.com/articles/looping-backwards-in-ruby
add to del.icio.us. look up in del.icio.us.
add to furl

- 说明
- Cucumber是跨计算机语言的代码测试工具
- Cucumber是使用本地化语言的代码测试工具
- Cucumber是集成多种测试工具于一体的工具
- Cucumber彻底分离测试描述(文字工作者)与描述实现(软件工作者)
- Cucumber更加人性化,更加语言化,更加简单化
- 参考资料
- Cucumber(中文语言描述)基础讲座系列(即将推出)
- Cucumber on Rails基本使用过程
- Cucumber基本概念
- Cucumber on Rails最简单实例
- Cucumber on 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 furlWed 26 November, 2008

心急火燎的结果呢?下面的情景是否会让你有种似曾相识的感觉:
* 费了半天努力修改的bug,仔细想来,其实已经在需求明明白白写好了,只是开发时未曾注意到。
* 好容易写好的一段代码,还没来得及向别人炫耀,却发现原来一个好好的功能出了问题,更糟糕的是,根本看不出这两段代码有什么联系。
* 这个bug让你想骂人,因为它居然是其他人修改另一个bug引入的。
* 这个地方有人改过,不过,修改的代码解决的根本不是真正的问题。
* 客户要的是一个小功能,但是对我们来说,加入它无异于重写整个系统。
……
已经有无数人用无数的事实告诉我们,在软件开发中,要付出就趁早,越晚代价越大。当然,我们能看到的大多数例子是在开发的不同阶段,比如需求比开发便宜,开发比测试便宜,测试比维护便宜等等。其实,在开发之中,也是如此,新鲜出炉的代码绝对比那些陈年旧帐更容易修改,不信的话,找一段自己几个月前写的代码理解一下试试。
前面那些似曾相识的场景,多半都是“急”出来的。可现实是,我们需要在后期用更大的精力为前面的“急”买单,所以,为了不给未来的自己挖坑,我们不妨慢一些:
* 仔细了解一下需求,分析需求是不是合理,而不要低着头就开始堆代码。
* 给出一个解决方案时,考虑一下会对已有的代码造成怎样的影响,打破窗户容易,修补难。
* 多花点时间重构,代码上的臭味越到后期显得越刺激。
* 修改bug时,停下来想想什么才是真正的问题,治标不治本的方案只会让人重回梦境。
* 写测试吧!貌似的浪费会让你在后期遇到bug时感激涕零。
……
软件开发其实是一个跟复杂度做斗争的过程,从某种程度来说,复杂度会一直在增长,我们所能做的就是尽可能降低复杂度增长的速度。我曾经和一些朋友说过,前期所做的一切是让我们在后面有更大空间挥霍。慢下来,让我们有时间思考自己的每一步是否迈得是否稳当,稳当的行进,心里才踏实。
这里的慢,实际上,还是为了快,殊途同归。
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

- 国际化功能问与答(一):国际化文件
- 默认国际化文件在哪里?
$RAILS_ROOT/config/locales - 使用什么样语言写国际化文件?
YAML语言
或者
Ruby语言 - 通常中国大陆中文使用什么国际化文件名称?
zh-CN.yml
或者
zh-CN.rb - 默认国际化文件是定义了什么文字语言?
English - 国际化文件最大特点是什么?
以命名空间为基础结构 - 一个国际化文件是否可以存在几种语言或者方言(zh-CN,zh-HK,zh-TW)呢?
可以 - 一种语言或者一种方言的国际化内容是否可以存放到几个国际化文件呢?
可以 - 一个国际化文件名称是否与文件内容相关呢?
无关
- 默认国际化文件在哪里?
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
MountainWest RubyConf, among the most super cool awesome Ruby gatherings around, is looking for sponsors for the 2009 event in Salt Lake City, UT.
You can read the prospectus here. (PDF)
If you or your company is looking to support the Ruby community, and get some solid advertising in front of some of the best geeks in the world, this is for you.
If you know someone or some company who would be interested in sponsoring the conference, please pass this information on.
add to del.icio.us. look up in del.icio.us.
add to furl

- 重要参考资料
- Rails 2.2: i18n, HTTP validators, thread safety, JRuby/1.9 compatibility, docs
- Ruby on Rails 2.2 Release Notes
- Rails 2.2已经正式发布!
- What’s New in Edge Rails: Rails 2.2 Released – Summary of Features 4
- Demo application to show Rails’ new i18n features
- Rails 2.2 For Me And For You
- Rails 2.2 Released – 27 Links and Resources To Get You Going
- Rails 2.2版本不再推荐使用的功能
- 专题资料
add to del.icio.us. look up in del.icio.us.
add to furlMon 24 November, 2008

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

- 安装说明
- 下载: http://fit.coollittlethings.com/down.php?v=1.9.3_intel
- 解压文件即双击该文件: FunInputToy_v1.9.3_intel.zip
- 双击文件: FunInputToy_v1.9.3_intel.pkg
- 自动重新启动计算机
- 系统偏好设置 >> 多语言环境 >> 输入法菜单 >> 如上图所示
- 致谢
- 非常感谢 kyle 所提供的信息.
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
“ Autumn, the year’s last, loveliest smile. ”
William Cullen Bryant
add to del.icio.us. look up in del.icio.us.
add to furlSun 23 November, 2008


- 什么是消息队列(Messaging Queue)
- 有哪些队列服务器(Queue Server)软件
- 同步与异步概念
- HTTP是同步的,Queue是异步的,但是目的是一样的
- http://en.wikipedia.org/wiki/Message_Queue
- 服务器与客户端概念
- 在HTTP概念中,存在浏览器(Client)与网络服务器(Server);
- 在Queue概念中,也存在客户端软件与服务器软件概念;
- 如何在Ruby和Rails中使用基于Beanstalk的消息队列(Messaging Queue)
- Beanstalk Messaging Queue http://tinyurl.com/24zfv7
- Ruby Beanstalkd distributed worker basics http://tinyurl.com/5nehld
- Ruby Beanstalkd distributed worker intermediate lessons http://tinyurl.com/6hz6p3
- http://async-observer.rubyforge.org/
- 参考资料
- https://computing.llnl.gov/tutorials/parallel_comp/
add to del.icio.us. look up in del.icio.us.
add to furl
There’s a nice write-up about recent events at Ruby Manor that describes a talk involving Monkeybars.
I want add a few comments. First, while it is true that using JRuby means some gems do not work, the upside is that you have at your disposal the hojillion1 Java libraries. While it is a goal that all Ruby code, gem or not, work with JRuby (with some caveats about native code), the ability to call into Java libs is a major win. The post mentions that a particualr gem for using Twitter could not be used; I’m fairly sure this is the exact situation Logan Barnett encountered when he started on Twit-and-Twitter for the Java One Script Bowl.
Logan was able to use a Java lib for Twitter, one that (as I recall) offered a more robust API. Big win. So, not to diminish the problem JRuby may have with certain gems, but there are two ways of looking at this: Some gems don’t run (glass 99/100 empty), vs. full use of Java libs (glass overflowing onto the floor and out the door).
Second, Monkeybars was compared (so to speak) with Shoes. No mention was made of Shoes having stability issues (something I’ve seen for myself), but even were it rock-solid there is no way one would want to build a serious app of any complexity. (To fair, I don’t think Shoes was created for that purpose, though some enthusiasts mistake the ease of use as demonstrated in demo apps as something that scales to commercial-grade desktop applications. If and when there is a WYSIWYG editor for Shoes that might change.) I’m deeply skeptical that, for example, JotBot could have been made in Shoes, if only because of the lack of sophisticated components.
However, for those who really REALLY want to build GUI apps that way, good news: Work is afoot to add this to Monkeybars. We hope before too long to allow Monkeybars to offer the best of both worlds.
1 This is a really big number. Really. Big.
add to del.icio.us. look up in del.icio.us.
add to furl

- 安装说明
- 点击链接: http://tinyurl.com/6g8nd9
- 把下载的文件NetNewsWire.app移到应用软件目录下
- 点击该文件NetNewsWire.app,就可以启动该软件
- 注册一下用户
- 在所有的Mac OS X机器上,只要有该软件并且有相同的用户,相互间就可以同步本地RSS信息。
add to del.icio.us. look up in del.icio.us.
add to furlSat 22 November, 2008

add to del.icio.us. look up in del.icio.us.
add to furl
Rails 2.2 is finally done after we cleared the last issues from the release candidate program. This release contains an long list of fixes, improvements, and additions that’ll make everything Rails smoother and better, but we also have a number of star player features to parade this time.
Internationalization by default
The most important is that Rails now includes a full-on internationalization framework and that it’s pre-wired from start. The work of the i18n group has been very impressive and it’s great to see that Rails finally ships with a solution in the box that’s both simple and extensible. Great job, guys!
Stronger etag and last-modified support
We’ve also added much better support for HTTP validators in the form of etag and last-modified. Making it so much easier to skip expensive procesesing if the client already has the latest stuff. This also makes it even easier to use Rails with gateway proxies.
Thread safety and a connection pool
Josh Peek has added thread safety to Rails and Nick Sieger from JRuby worked on getting Active Record a proper connection pool. So now all elements of Rails are thread safe, which is a big boon for the JRuby guys in particular. For C Ruby, we still need a bunch of dependent libraries to go non-blocking before it’ll make much of a difference, but work on that is forth coming.
Ruby 1.9 and JRuby compatibility
Jeremy Kemper has been rocking on both Ruby 1.9 and JRuby compatibility. Rails 2.2 is fully compatible with both, but again, there might be supporting libraries and gems that are not. Again, lots of work is going into making everything else fully compatible as well.
Better API docs, great guides
Finally, the last big push has been with the documentation of Rails. Pratik’s docrails project has made immense progress. Not only are the API docs much improved, but we also have a whole new guides section generated from documentation that now lives with the source. A true community project with lots of contributors. I’m sure both those new and old to Rails will greatly appreciate the strong focus on documentation.
To read about all these features and more in details, checkout the Rails 2.2 release notes—another one of those guides from the docrails project.
How to install
As always, you can install Rails 2.2 through RubyGems. We now require RubyGems 1.3.1, so be sure to update that first: gem update --system
Then you can install Rails: gem install rails
If you’re updating an existing application, you can run rake rails:update to get the latest JavaScript files and scripts.
From all of us to all of you, we hope you enjoy this release. It’s a true pleasure to see Rails make such big steps forward once again. Dig in, have fun, and we’ll be back with Rails 2.3 with even more before you know it.
add to del.icio.us. look up in del.icio.us.
add to furl
- 相关链接
- Ruby和Rails应用软件有多少? http://www.railsforall.org/apps
- Ruby和Rails资料有多少? http://www.railsforall.org/resources
add to del.icio.us. look up in del.icio.us.
add to furl
First up this week, a warning for those who don’t closely follow the state of the Rails repository – “edge” really means edge now. The bits for 2.2 are getting locked down for release, and the repository has been forked; for the moment, edge Rails is being identified as 2.3 , though that projected version number might change later. If you’re trying to install almost-released 2.2 bits on your machine, make sure you’re using the 2-2-stable branch, and not edge, which is currently seeing some major changes.
The 2-2-stable code is still seeing changes, but they’re either bug fixes or very small things. This week, that includes fixing a bug in assignment to has_one :through associations , some further tuning of CSRF protection , a fix to handling of checkboxes for Boolean attributes , updating the bundled copies of TZInfo, Prototype, and script.aculo.us, and some Ruby 1.9 compatibility work (though currently full Ruby 1.9 compatibility is targeted for Rails 2.3).
The biggest feature change in the 2.2 branch is the addition of explicit I18n support to newly-generated Rails projects, including a sample locale file, auto-loading all locales in config/locales, and sample settings in config/environment.rb. commit
Also worth noting in 2.2 is a chunk of code removal: a whole mess of special case tests for the SQL Server adapter have been chopped out of the Active Record test cases. That’s because Ken Collins has done tremendous work in making the SQL Server adapter work the way that Rails expects data adapters to work, giving us a big step in the area of backend portability. commit
On the actual edge code (the master branch in the repository), there’s a lot more action. With that branch just opened, some pent-up code has been checked in, and some big changes are being made. It’s an exciting time, and edge is definitely worth checking out. Here are some of the most notable changes in the past week.
One big set of changes has come from Jeremy Kemper, who has been overhauling the internal Rails testing to switch from Test::Unit::TestCase to ActiveSupport::TestCase. This work also includes requiring Mocha to test Rails (in the 2.2 code, some tests are skipped if you don’t have Mocha installed) and generally making the Rails testing strategy (both within core and for generated applications) more consistent moving forward.
If you’re one of the people who has always been bothered by the special-case naming of application.rb, rejoice! It’s been reworked to be application_controller.rb in the edge code. More info here and here . commit
Rails 2.3 will introduce the notion of default scopes : similar to named scopes, but applying to all named scopes or find methods within the class. For example, you can write default_scope :order => 'name ASC' and any time you retrieve records from that class they’ll come out sorted by name (unless you override the option, of course). commit
A lot of folks have adopted the notion of using try() to attempt operations on objects – Here’s Chris Wanstrath’s blog post introducing it. It’s especially helpful in views where you can avoid nil-checking by writing code like <%= @person.try(:name) %>. Well, now it’s baked right into Rails. commit
Also new on the syntactic sugar front is Enumerable#none? to check that none of the elements match the supplied block. commit
The render method has been getting smarter over the years, and it’s going to be even smarter in 2.3. If you have an object or a collection and the naming matches up, you can now just do <% render @article %> or <% render @articles %> and things will just work. Ryan Daigle has some more examples on this. commit
On a somewhat similar note, render_component goes from “deprecated” to “nonexistent” in 2.3. If you still need it, you can install the plugin . commit
The autolink helper has been refactored to make it a bit less messy and more intuitive. commit commit
There’s a fix to a memory leak connected to thread safety and asset tags, that could bite sites that were referencing a lot of external images. Aaron Batalion contributed the fix, as well as a blog post explaining the issue. commit and commit
Finally, it’s worth mentioning that some controversy has erupted over a change made to the 2.2 code five months ago – the addition of Array#second through Array#tenth as aliases for Array#[1] through Array#[9]. Without taking a stand on the controversy (I’ve done that elsewhere), I’ll just note that the most recent edge checkin as I write this trims this down to only support Array#second through Array#fifth – and uses the savings in overhead to implement Array#forty-two. commit
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 November, 2008

比方说我给你举个例子,最近我一个朋友讲到四万亿眼睛都发红,可是,那些做企业的吧,
比方说他是生产服装的,他说他只花很少的精力很少的钱去关心这个服装做的怎么样,
他说你做的怎么样做什么服装是他考虑的十分之一都不到的事情,
那重要的是什么呢,因为你的服装不能去卖给老百姓,因为赚不了钱的,那你也不能出国的,因为外国人都是很抠的,
他整天要检查你,所以最好的赚钱的方法就是卖给,比方说,你是一个国营的大饭店,你一订订5000套,
那我只要搞定那个订货的人,那我这5000套怎么做,价钱可以高,东西又可以做的次。
所以他最大的精力就用在建立一个关系网,就是什么人可以给我订单,
他不需要科研费,生产费是压到最低。什么东西都弄到最低,最大的费用就是关系费。
我关键只要订单,你可以从这样一个小的case你就可以知道事情是怎么在运作,
那么这些负责国营企业,各种各样官员,他随便都可以做,你们十个工厂都在做衣服,
我明明知道你们做的好啊,可是他给我好处了,我为什么要订你的衣服,至于衣服怎么样不是随便穿嘛,
所以他们之间的这种合作关系就使得质量问题变得完全不重要,这在衣服是没危险性哦,这到地铁就有危险性了。
文道:
所以在中国呢,很多人都知道,很多商人都知道,要赚钱,最好赚的是什么钱,就是项目,而且是公家的项目。
你跟外国人做买卖,那是市场竞争,你跟中国老百姓做买卖,就像你讲的,老百姓没多少钱让你赚,
但是你赚政府的钱,那是多大的一笔钱啊,而且政府的钱赚的就比较容易,
我们想想所谓贪污是什么概念,贪污其实是一个做生意的人他必须要面对的一个诱惑,
而且那个诱惑实在太大了,因为你想想看,如果就像你刚才讲的那个例子,我如果花心思做好这个衣服,
去研究这个市场,去做好风险的计算,怎么样去跟人家竞争,那是一个很困难的事情,
但如果反过来,我天天想着,负责这个项目的领导他爱什么,李书记我该给他个什么。
我天天琢磨这事,相比之下要容易多了,那你相对来讲,你好像一下子表面付出了要来贿赂的款项,
但是你耗费的各种精力什么加起来,你是划算多了。
所以中国现在我担心的就是贪污变成一种路径依赖,他是惯性的,从人性的角度来讲,
他是一个最容易赚钱,最容易做生意的方法,如果我们说资本主义相信理性的话,没有一个理性的人不会不想去贪污。
文涛:
所以有的时候就出现一个两难,就是本身照那种纯粹的市场论来讲,政府应该管的越少越好......
,balabalabala,貌似有些不和谐,开始转移话题...懂的


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 furlThu 20 November, 2008

With king of the hill Rails chugging along, and up-and-comer Merb picking up steam, why bother with Ramaze?
The number one thing that makes Ramaze stand out from the crowd is that you write very little code and you write it all yourself. No generators.
...
Before Rails, people wrote lots and lots of code when making a web app, and they did it over and over as they did web app after web app. With each new app, they would spend time “ramping up” with just the base application before they got into the real meat of the matter, the core functionality which varied from client to client, application to application. Rails and Merb and their ilk try to make your life easier by generating this “lots and lots of code” for you, so you don’t have to spend time repeating the motions of getting the skeleton of your application coded.
Ramaze takes a different approach. It asks: How about we dump the “lots and lots of code” part altogether? This way, you get the benefit of nearly nil ramp up time, without the gaping jaw effect that hits you after you run a code generator script and sit staring at the big filetree that just sprouted out of the ground (think Jack and the Beanstalk).
add to del.icio.us. look up in del.icio.us.
add to furl



