<?xml version="1.0" encoding="utf-8"?>
<?xml-stylesheet type="text/xsl" href="/xslt/rss2.xsl" media="screen"?>
<rss version="2.0"
     xmlns:dc="http://purl.org/dc/elements/1.1/"
     xmlns:content="http://purl.org/rss/1.0/modules/content/">
	<channel>
		<title>Latest from ChinaonRails's Snippets</title>
		<link>http://chinaonrails.com/go/snippets</link>
		<description>ChinaonRails | ChinaonRails are one of the very few China based web consultancies, who specialize in application development using RubyOnRails/Agile/Ajax.</description>
		<category>Technology</category>
		<language>zh_cn</language>
		<item>
			<title>bb-ruby插件转BBCode ... no reply</title>
			<link>http://chinaonrails.com/topic/view/2067.html</link>
			<comments>http://chinaonrails.com/topic/view/2067.html#reply</comments>
			<dc:creator>bd7lx</dc:creator>
			<author>bd7lx</author>
			<!--<enclosure url="http://chinaonrails.com/img/p/9.jpg" type="image/jpeg" />
			<enclosure url="http://chinaonrails.com/img/p/9_s.jpg" type="image/jpeg" />
			<enclosure url="http://chinaonrails.com/img/p/9_n.jpg" type="image/jpeg" />-->
			<category>Snippets</category>
			<description>
			&lt;a href="http://github.com/cpjolicoeur/bb-ruby/tree/master" rel="nofollow external" class="tpc"&gt;http://github.com/cpjolicoeur/bb-ruby/tree/master&lt;/a&gt;&lt;br /&gt;
&lt;br /&gt;
&lt;a href="http://www.inwebwetrust.net/post/2008/08/23/bb-ruby-small-bbcode-to-html-parser-in-ruby" rel="nofollow external" class="tpc"&gt;http://www.inwebwetrust.net/post/2008/08/23/bb-ruby-small-bbcode-to-html-parser-in-ruby&lt;/a&gt;&lt;br /&gt;
&lt;br /&gt;
[color=red]Red[/color]&lt;br /&gt;
&lt;br /&gt;
论坛中常用bbcode，本坛也用但过滤掉了很多&lt;br /&gt;
&lt;br /&gt;
&lt;img class="code" src="http://www.niodesign.com/orlando/images/content/bbcode.png" border="0" /&gt;
			</description>
			<pubDate>Mon, 25 Aug 2008 13:12:46 +0800</pubDate>
			<guid>http://chinaonrails.com/topic/view/2067.html</guid>
		</item>
		<item>
			<title>游戏石头剪子布，送性能最新ruby环境PK的吼叫 ... no reply</title>
			<link>http://chinaonrails.com/topic/view/2018.html</link>
			<comments>http://chinaonrails.com/topic/view/2018.html#reply</comments>
			<dc:creator>bd7lx</dc:creator>
			<author>bd7lx</author>
			<!--<enclosure url="http://chinaonrails.com/img/p/9.jpg" type="image/jpeg" />
			<enclosure url="http://chinaonrails.com/img/p/9_s.jpg" type="image/jpeg" />
			<enclosure url="http://chinaonrails.com/img/p/9_n.jpg" type="image/jpeg" />-->
			<category>Snippets</category>
			<description>
			&lt;a href="http://github.com/wmoxam/rubyrps/tree/master" rel="nofollow external" class="tpc"&gt;http://github.com/wmoxam/rubyrps/tree/master&lt;/a&gt;&lt;br /&gt;
&lt;br /&gt;
&lt;img class="code" src="http://bp2.blogger.com/_CemhPnedxDU/RtViRrYlQzI/AAAAAAAAAN0/f2xlxp0jEZg/s400/Mario+RPS+4.png" border="0" /&gt;&lt;br /&gt;
&lt;br /&gt;
&lt;a href="http://blog.viarails.net/2008/8/11/ruby-vm-shootout" rel="nofollow external" class="tpc"&gt;http://blog.viarails.net/2008/8/11/ruby-vm-shootout&lt;/a&gt;&lt;br /&gt;
&lt;br /&gt;
一点酒领先&lt;br /&gt;
&lt;a href="http://chinaonrails.com/q/shoutout" rel="nofollow external" class="tpc"&gt;http://chinaonrails.com/q/shoutout&lt;/a&gt;
			</description>
			<pubDate>Tue, 12 Aug 2008 13:01:30 +0800</pubDate>
			<guid>http://chinaonrails.com/topic/view/2018.html</guid>
		</item>
		<item>
			<title>批量改文件名的小程序 ... no reply</title>
			<link>http://chinaonrails.com/topic/view/1907.html</link>
			<comments>http://chinaonrails.com/topic/view/1907.html#reply</comments>
			<dc:creator>bd7lx</dc:creator>
			<author>bd7lx</author>
			<!--<enclosure url="http://chinaonrails.com/img/p/9.jpg" type="image/jpeg" />
			<enclosure url="http://chinaonrails.com/img/p/9_s.jpg" type="image/jpeg" />
			<enclosure url="http://chinaonrails.com/img/p/9_n.jpg" type="image/jpeg" />-->
			<category>Snippets</category>
			<description>
			&lt;a href="http://www.prodevtips.com/2008/07/16/ruby-file-renamer/" rel="nofollow external" class="tpc"&gt;http://www.prodevtips.com/2008/07/16/ruby-file-renamer/&lt;/a&gt;&lt;br /&gt;
&lt;br /&gt;
&lt;div class="code"&gt;require 'find' &lt;br /&gt;
require 'fileutils' &lt;br /&gt;
 &lt;br /&gt;
def finder( start_dir, look_for, replace_with ) &lt;br /&gt;
   Find.find( start_dir ) do |path| &lt;br /&gt;
    if FileTest.file?( path ) &lt;br /&gt;
      if path =~ look_for &lt;br /&gt;
        old_name = File.basename( path ) &lt;br /&gt;
        new_name = old_name.gsub( look_for, replace_with ) &lt;br /&gt;
        dir = path.gsub( /#{old_name}/, '' ) &lt;br /&gt;
        if File.exists?( dir + old_name ) &lt;br /&gt;
          puts "#{dir + old_name} to #{dir + new_name}\n" &lt;br /&gt;
          FileUtils.mv(dir + old_name, dir + new_name) &lt;br /&gt;
        end &lt;br /&gt;
      end &lt;br /&gt;
    end &lt;br /&gt;
  end &lt;br /&gt;
end &lt;br /&gt;
 &lt;br /&gt;
finder( '/some/dir/', /\.html$/, '.htm' )&lt;/div&gt;
&lt;br /&gt;
把特定路径下的html改成htm&lt;br /&gt;
&lt;br /&gt;
&lt;img class="code" src="http://webtoolsandtips.com/wp-content/uploads/2007/10/renaming-files.png" border="0" /&gt;
			</description>
			<pubDate>Fri, 18 Jul 2008 09:38:55 +0800</pubDate>
			<guid>http://chinaonrails.com/topic/view/1907.html</guid>
		</item>
		<item>
			<title>functor函数式编程插件 ... 1 reply</title>
			<link>http://chinaonrails.com/topic/view/1737.html</link>
			<comments>http://chinaonrails.com/topic/view/1737.html#reply</comments>
			<dc:creator>bd7lx</dc:creator>
			<author>bd7lx</author>
			<!--<enclosure url="http://chinaonrails.com/img/p/9.jpg" type="image/jpeg" />
			<enclosure url="http://chinaonrails.com/img/p/9_s.jpg" type="image/jpeg" />
			<enclosure url="http://chinaonrails.com/img/p/9_n.jpg" type="image/jpeg" />-->
			<category>Snippets</category>
			<description>
			http://functor.rubyforge.org/&lt;br /&gt;
&lt;br /&gt;
提供像是erlang之风的pattern-based function and method dispatch for Ruby&lt;br /&gt;
&lt;br /&gt;
&lt;div class="code"&gt;fib = Functor.new do&lt;br /&gt;
    given( 0 ) { 0 }&lt;br /&gt;
    given( 1 ) { 1 }&lt;br /&gt;
    given( Integer ) { |n| self.call( n - 1 ) + self.call( n - 2 ) }&lt;br /&gt;
  end&lt;/div&gt;
&lt;br /&gt;
&lt;div class="code"&gt;[ *0..10 ].map( &amp;fib )  # =&amp;gt; [0, 1, 1, 2, 3, 5, 8, 13, 21, 34, 55]&lt;/div&gt;
&lt;br /&gt;
&lt;a href="http://chinaonrails.com/topic/view/979.html" rel="nofollow external" class="tpc"&gt;http://chinaonrails.com/topic/view/979.html&lt;/a&gt;
			</description>
			<pubDate>Wed, 18 Jun 2008 16:33:40 +0800</pubDate>
			<guid>http://chinaonrails.com/topic/view/1737.html</guid>
		</item>
		<item>
			<title>单引号和双引号，哪个更快 ... 6 replies</title>
			<link>http://chinaonrails.com/topic/view/1708.html</link>
			<comments>http://chinaonrails.com/topic/view/1708.html#reply</comments>
			<dc:creator>bd7lx</dc:creator>
			<author>bd7lx</author>
			<!--<enclosure url="http://chinaonrails.com/img/p/9.jpg" type="image/jpeg" />
			<enclosure url="http://chinaonrails.com/img/p/9_s.jpg" type="image/jpeg" />
			<enclosure url="http://chinaonrails.com/img/p/9_n.jpg" type="image/jpeg" />-->
			<category>Snippets</category>
			<description>
			&lt;a href="http://blog.cbciweb.com/articles/2008/06/10/ruby-performance-use-double-quotes-vs-single-quotes" rel="nofollow external" class="tpc"&gt;http://blog.cbciweb.com/articles/2008/06/10/ruby-performance-use-double-quotes-vs-single-quotes&lt;/a&gt;
			</description>
			<pubDate>Wed, 11 Jun 2008 09:43:37 +0800</pubDate>
			<guid>http://chinaonrails.com/topic/view/1708.html</guid>
		</item>
		<item>
			<title>Ruby TMTOWTDI 第一集 ... no reply</title>
			<link>http://chinaonrails.com/topic/view/1683.html</link>
			<comments>http://chinaonrails.com/topic/view/1683.html#reply</comments>
			<dc:creator>bd7lx</dc:creator>
			<author>bd7lx</author>
			<!--<enclosure url="http://chinaonrails.com/img/p/9.jpg" type="image/jpeg" />
			<enclosure url="http://chinaonrails.com/img/p/9_s.jpg" type="image/jpeg" />
			<enclosure url="http://chinaonrails.com/img/p/9_n.jpg" type="image/jpeg" />-->
			<category>Snippets</category>
			<description>
			&lt;a href="http://blog.citrusbyte.com/2008/6/2/ruby-tmtowtdi-episode-1" rel="nofollow external" class="tpc"&gt;http://blog.citrusbyte.com/2008/6/2/ruby-tmtowtdi-episode-1&lt;/a&gt;&lt;br /&gt;
&lt;br /&gt;
Tim Toady&lt;br /&gt;
&lt;br /&gt;
提问-回答-对比&lt;br /&gt;
&lt;br /&gt;
小结-修整&lt;br /&gt;
&lt;br /&gt;
开拓新思路&lt;br /&gt;
&lt;br /&gt;
There is more than one way to do it&lt;br /&gt;
&lt;br /&gt;
举例&lt;br /&gt;
http://chinaonrails.com/topic/view/365.html
			</description>
			<pubDate>Tue, 03 Jun 2008 08:30:47 +0800</pubDate>
			<guid>http://chinaonrails.com/topic/view/1683.html</guid>
		</item>
		<item>
			<title>节约能耗，写几行ruby程序把电脑变得更加“绿” ... no reply</title>
			<link>http://chinaonrails.com/topic/view/1680.html</link>
			<comments>http://chinaonrails.com/topic/view/1680.html#reply</comments>
			<dc:creator>bd7lx</dc:creator>
			<author>bd7lx</author>
			<!--<enclosure url="http://chinaonrails.com/img/p/9.jpg" type="image/jpeg" />
			<enclosure url="http://chinaonrails.com/img/p/9_s.jpg" type="image/jpeg" />
			<enclosure url="http://chinaonrails.com/img/p/9_n.jpg" type="image/jpeg" />-->
			<category>Snippets</category>
			<description>
			&lt;a href="http://www.pluginaweek.org/2008/05/21/go-green-with-5-lines-of-ruby/" rel="nofollow external" class="tpc"&gt;http://www.pluginaweek.org/2008/05/21/go-green-with-5-lines-of-ruby/&lt;/a&gt;&lt;br /&gt;
&lt;br /&gt;
&lt;img class="code" src="http://www.pluginaweek.org/wp-content/uploads/2008/05/green_tree.jpg" border="0" /&gt;
			</description>
			<pubDate>Mon, 02 Jun 2008 09:58:43 +0800</pubDate>
			<guid>http://chinaonrails.com/topic/view/1680.html</guid>
		</item>
		<item>
			<title>hashslice 肉末也能切片 ... no reply</title>
			<link>http://chinaonrails.com/topic/view/1678.html</link>
			<comments>http://chinaonrails.com/topic/view/1678.html#reply</comments>
			<dc:creator>bd7lx</dc:creator>
			<author>bd7lx</author>
			<!--<enclosure url="http://chinaonrails.com/img/p/9.jpg" type="image/jpeg" />
			<enclosure url="http://chinaonrails.com/img/p/9_s.jpg" type="image/jpeg" />
			<enclosure url="http://chinaonrails.com/img/p/9_n.jpg" type="image/jpeg" />-->
			<category>Snippets</category>
			<description>
			Slicing? 当然可以啦，Array能切分（IT称呼阵列，编程的叫数组），连我们搞石油的都能分层开采，况hash乎，发扬石油工人有条件上，没条件也上，切&lt;br /&gt;
&lt;br /&gt;
&lt;a href="http://raa.ruby-lang.org/project/hashslice/" rel="nofollow external" class="tpc"&gt;http://raa.ruby-lang.org/project/hashslice/&lt;/a&gt;&lt;br /&gt;
&lt;br /&gt;
RAA 没有rubyforge铸造车间诞生之前就有了，&lt;br /&gt;
说HashSlice是个老插件，你可以这么看&lt;br /&gt;
&lt;br /&gt;
它可以看做是 Ruby module 模块&lt;br /&gt;
能改变Hash类添上新彩&lt;img class="code" src="http://imagecache2.allposters.com/images/pic/GLOP/P907~Hash-Posters.jpg" border="0" /&gt;&lt;br /&gt;
&lt;br /&gt;
Slicing 方便对超过一个以上的 key-value pair（键值对）进行赋值和取出&lt;br /&gt;
&lt;br /&gt;
存取的方法：&lt;br /&gt;
&lt;br /&gt;
require 'hashslice'&lt;br /&gt;
&lt;br /&gt;
hash = {'a' =&amp;gt; 1, 'b' =&amp;gt; 2, 'c' =&amp;gt; 3}&lt;br /&gt;
&lt;br /&gt;
# Slice reference&lt;br /&gt;
hash['a', 'b'] # -&amp;gt; [1, 2]&lt;br /&gt;
hash['a'] # -&amp;gt; 1&lt;br /&gt;
&lt;br /&gt;
# Slice assignment&lt;br /&gt;
hash['a', 'b'] = 7, 8&lt;br /&gt;
&lt;br /&gt;
hash # -&amp;gt; {'a' =&amp;gt; 7, 'b' =&amp;gt; 8, 'c' =&amp;gt; 3}&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
Versions: 	[1.0.4 (2008-05-28)] [1.03 (2008-05-23)]
			</description>
			<pubDate>Fri, 30 May 2008 13:17:50 +0800</pubDate>
			<guid>http://chinaonrails.com/topic/view/1678.html</guid>
		</item>
		<item>
			<title>小程序路由追踪图示化TraceViz ... no reply</title>
			<link>http://chinaonrails.com/topic/view/1673.html</link>
			<comments>http://chinaonrails.com/topic/view/1673.html#reply</comments>
			<dc:creator>bd7lx</dc:creator>
			<author>bd7lx</author>
			<!--<enclosure url="http://chinaonrails.com/img/p/9.jpg" type="image/jpeg" />
			<enclosure url="http://chinaonrails.com/img/p/9_s.jpg" type="image/jpeg" />
			<enclosure url="http://chinaonrails.com/img/p/9_n.jpg" type="image/jpeg" />-->
			<category>Snippets</category>
			<description>
			http://www.hokstad.com/traceviz-visualizing-traceroute-output-with-graphivz.html&lt;br /&gt;
&lt;br /&gt;
&lt;img class="code" src="http://www.hokstad.com/static/traceviz.png" border="0" /&gt;&lt;br /&gt;
&lt;br /&gt;
问其中关键技术是？&lt;br /&gt;
&lt;br /&gt;
你用过类似的程序吗？指图形显示的traceroute非命令行
			</description>
			<pubDate>Thu, 29 May 2008 20:49:22 +0800</pubDate>
			<guid>http://chinaonrails.com/topic/view/1673.html</guid>
		</item>
		<item>
			<title>Symbol.to_i 一点酒 就没有了 ... 2 replies</title>
			<link>http://chinaonrails.com/topic/view/1621.html</link>
			<comments>http://chinaonrails.com/topic/view/1621.html#reply</comments>
			<dc:creator>bd7lx</dc:creator>
			<author>bd7lx</author>
			<!--<enclosure url="http://chinaonrails.com/img/p/9.jpg" type="image/jpeg" />
			<enclosure url="http://chinaonrails.com/img/p/9_s.jpg" type="image/jpeg" />
			<enclosure url="http://chinaonrails.com/img/p/9_n.jpg" type="image/jpeg" />-->
			<category>Snippets</category>
			<description>
			Ruby Symbols in 1.9—End of an Era (and a good thing, too)&lt;br /&gt;
&lt;br /&gt;
&lt;img class="code" src="http://pragdave.pragprog.com/dave.gif" border="0" /&gt;说&lt;br /&gt;
&lt;br /&gt;
&lt;div class="code"&gt;Ruby 1.9 point to the transition away from symbols being immediate objects. &lt;br /&gt;
&lt;br /&gt;
In particular, they lose their integer representation, and hence the&lt;br /&gt;
methods Fixnum.id2name, Fixnum.to_sym, and Symbol.to_i have been removed.&lt;br /&gt;
&lt;br /&gt;
 I'm expecting to see symbols migrate to the heap as 1.9 continues to evolve.&lt;/div&gt;
&lt;br /&gt;
Symbol做成直接对象（text有对应的整数放在解释器内部查询表里）效率高，存取快，但是容易受到攻击DOS，被坏人灌入乱七八糟的整数，影响垃圾回收&lt;br /&gt;
&lt;br /&gt;
Symbol不再用整数表示，他希望往heap里面迁&lt;br /&gt;
&lt;br /&gt;
********************&lt;br /&gt;
&lt;br /&gt;
any？ 以后也没有了，反过来问empty？乎更好的执行效率
			</description>
			<pubDate>Wed, 14 May 2008 10:46:34 +0800</pubDate>
			<guid>http://chinaonrails.com/topic/view/1621.html</guid>
		</item>
		<item>
			<title>看书学不到的技巧：解析带引号字符串 shellwords ... no reply</title>
			<link>http://chinaonrails.com/topic/view/1581.html</link>
			<comments>http://chinaonrails.com/topic/view/1581.html#reply</comments>
			<dc:creator>bd7lx</dc:creator>
			<author>bd7lx</author>
			<!--<enclosure url="http://chinaonrails.com/img/p/9.jpg" type="image/jpeg" />
			<enclosure url="http://chinaonrails.com/img/p/9_s.jpg" type="image/jpeg" />
			<enclosure url="http://chinaonrails.com/img/p/9_n.jpg" type="image/jpeg" />-->
			<category>Snippets</category>
			<description>
			Split text into an array of tokens in the same way the UNIX Bourne shell does&lt;br /&gt;
&lt;br /&gt;
http://ruby-doc.org/core/classes/Shellwords.html&lt;br /&gt;
&lt;br /&gt;
&lt;a href="http://mikenaberezny.com/2008/04/28/parsing-quoted-strings-in-ruby/" rel="nofollow external" class="tpc"&gt;http://mikenaberezny.com/2008/04/28/parsing-quoted-strings-in-ruby/&lt;/a&gt;&lt;br /&gt;
&lt;br /&gt;
&lt;div class="code"&gt;&amp;gt;&amp;gt; require 'shellwords'&lt;br /&gt;
=&amp;gt; true&lt;br /&gt;
&amp;gt;&amp;gt; Shellwords::shellwords('foo "bar baz" qux')&lt;br /&gt;
=&amp;gt; ["foo", "bar baz", "qux"]&lt;/div&gt;
&lt;br /&gt;
perl的shellwords库解析被双引号封装的元素&lt;br /&gt;
&lt;br /&gt;
python里叫shlex&lt;br /&gt;
&lt;br /&gt;
数据分析过程就是用专用的分析器程序处理某一特定的、极为有限的格式,&lt;br /&gt;
python常用shlex做字元转换器（tokenizer），分析一些语法简单的语言，用于创建具有可读性的配置文件，&lt;br /&gt;
以及支持用户借以输入命令的交互式命令行环境。&lt;br /&gt;
&lt;br /&gt;
这里示例中作者的ruby应用shellwords，要做的是DSL简单的自定义查询语句&lt;br /&gt;
&lt;br /&gt;
&lt;img class="code" src="http://pics.bestpicever.com/pics/pic_478003001189476910.jpg" border="0" /&gt;
			</description>
			<pubDate>Mon, 05 May 2008 16:22:12 +0800</pubDate>
			<guid>http://chinaonrails.com/topic/view/1581.html</guid>
		</item>
		<item>
			<title>上海自来水来自海上-颠三倒四，检查“回文”小程序 ... 2 replies</title>
			<link>http://chinaonrails.com/topic/view/1509.html</link>
			<comments>http://chinaonrails.com/topic/view/1509.html#reply</comments>
			<dc:creator>bd7lx</dc:creator>
			<author>bd7lx</author>
			<!--<enclosure url="http://chinaonrails.com/img/p/9.jpg" type="image/jpeg" />
			<enclosure url="http://chinaonrails.com/img/p/9_s.jpg" type="image/jpeg" />
			<enclosure url="http://chinaonrails.com/img/p/9_n.jpg" type="image/jpeg" />-->
			<category>Snippets</category>
			<description>
			&lt;a href="http://icfun.blogspot.com/2008/04/ruby-determination-of-palindrome.html" rel="nofollow external" class="tpc"&gt;http://icfun.blogspot.com/2008/04/ruby-determination-of-palindrome.html&lt;/a&gt;&lt;br /&gt;
&lt;br /&gt;
palindrome&lt;br /&gt;
&lt;br /&gt;
&lt;img class="code" src="http://www.tourism.holdfast.sa.gov.au/webdata/resources/images/palindrome1.jpg" border="0" /&gt;
			</description>
			<pubDate>Wed, 16 Apr 2008 11:09:41 +0800</pubDate>
			<guid>http://chinaonrails.com/topic/view/1509.html</guid>
		</item>
		<item>
			<title>捣鼓Mash - Mocking Hash for total poser objects ... no reply</title>
			<link>http://chinaonrails.com/topic/view/1499.html</link>
			<comments>http://chinaonrails.com/topic/view/1499.html#reply</comments>
			<dc:creator>bd7lx</dc:creator>
			<author>bd7lx</author>
			<!--<enclosure url="http://chinaonrails.com/img/p/9.jpg" type="image/jpeg" />
			<enclosure url="http://chinaonrails.com/img/p/9_s.jpg" type="image/jpeg" />
			<enclosure url="http://chinaonrails.com/img/p/9_n.jpg" type="image/jpeg" />-->
			<category>Snippets</category>
			<description>
			&lt;a href="http://www.intridea.com/2008/4/13/mash-mocking-hash-for-total-poser-objects" rel="nofollow external" class="tpc"&gt;http://www.intridea.com/2008/4/13/mash-mocking-hash-for-total-poser-objects&lt;/a&gt;&lt;br /&gt;
&lt;br /&gt;
author = Mash.new&lt;br /&gt;
author.name # =&amp;gt; nil&lt;br /&gt;
author.name = "Michael Bleigh" &lt;br /&gt;
author.name # =&amp;gt; "Michael Bleigh" &lt;br /&gt;
author.email = "michael@intridea.com" &lt;br /&gt;
author.inspect # =&amp;gt; &amp;lt;Mock name="Michael Bleigh" email="michael@intridea.com"&amp;gt;&lt;br /&gt;
&lt;br /&gt;
让Hash能更加对象化的行为表现&lt;br /&gt;
&lt;br /&gt;
安装个插件，做个捣蒜缸子&lt;br /&gt;
&lt;br /&gt;
gem install mash&lt;br /&gt;
&lt;br /&gt;
当然目前阶段git更流行更潮&lt;br /&gt;
&lt;br /&gt;
git clone git://github.com/mbleigh/mash.git&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
&lt;img class="code" src="http://myhusbandhatesveggies.files.wordpress.com/2007/03/mash.JPG" border="0" /&gt;
			</description>
			<pubDate>Tue, 15 Apr 2008 11:17:05 +0800</pubDate>
			<guid>http://chinaonrails.com/topic/view/1499.html</guid>
		</item>
		<item>
			<title>《学习Ruby》Ruby学习的经典入门之作 ... no reply</title>
			<link>http://chinaonrails.com/topic/view/1483.html</link>
			<comments>http://chinaonrails.com/topic/view/1483.html#reply</comments>
			<dc:creator>snakeguang</dc:creator>
			<author>snakeguang</author>
			<!--<enclosure url="http://chinaonrails.com/img/p_1.gif" type="image/jpeg" />
			<enclosure url="http://chinaonrails.com/img/p_1_s.gif" type="image/jpeg" />
			<enclosure url="http://chinaonrails.com/img/p_1_n.gif" type="image/jpeg" />-->
			<category>Snippets</category>
			<description>
			开车上路前，其实不用巨细匪遗地了解整辆车的构造，使用Ruby程序语言也是如此，用Ruby设计程序时，其实不需对它了如指掌。本书同时献给程序设计老手与新手，它就像帮助人们快速开车上路的驾驶指南。书中提供了很多Ruby程序范例，并说明运行方式与原因，刚好足以让我们自己设计出Ruby程序。.&lt;br /&gt;
人们对于Ruby的兴趣，源自Rails网站开发架构的流行，这也吸引了来自Java和PHP的开发者。不过，Ruby的灵活性还有非常多的用途。最佳的学习方式，莫过于自己动手做!本书几乎每页都有范例，可以让大家动手玩个够。本书内容包括：&lt;br /&gt;
·介绍Ruby最重要的特色。&lt;br /&gt;
·示范Ruby中如何利用条件与操作字符串。&lt;br /&gt;
·讨论正则表达式。&lt;br /&gt;
·操作符、Math模块提供的基本数学函数、有理数等的使用方式。..&lt;br /&gt;
·详细说明并示范Ruby的数组与哈希。&lt;br /&gt;
·解释Ruby用于文件处理的工具。&lt;br /&gt;
·详细讨论Ruby的类别与模块(或称“混成”)，还包括关于面向对象语言的简介&lt;br /&gt;
·介绍XML处理、Tk、RubyGems、反射、RDoc、嵌入式Ruby、元编程、异常处理等众多主题。&lt;br /&gt;
·让读者熟悉Rails的本质，并简短地介绍Rails&lt;br /&gt;
每一章都附有随堂练习，附录则是一份Ruby术语表和本书的参考资源。如果你想动手使用Ruby，本书是快速上手的最佳选择&lt;br /&gt;
&lt;br /&gt;
互动网购买：http://www.china-pub.com/39509&lt;br /&gt;
更多图书信息，敬请访问：http://blog.csdn.net/hzbooks
			</description>
			<pubDate>Wed, 09 Apr 2008 09:57:08 +0800</pubDate>
			<guid>http://chinaonrails.com/topic/view/1483.html</guid>
		</item>
		<item>
			<title>Ruby Learning （一） ... no reply</title>
			<link>http://chinaonrails.com/topic/view/1463.html</link>
			<comments>http://chinaonrails.com/topic/view/1463.html#reply</comments>
			<dc:creator>marshluca</dc:creator>
			<author>marshluca</author>
			<!--<enclosure url="http://chinaonrails.com/img/p/722.jpg" type="image/jpeg" />
			<enclosure url="http://chinaonrails.com/img/p/722_s.jpg" type="image/jpeg" />
			<enclosure url="http://chinaonrails.com/img/p/722_n.jpg" type="image/jpeg" />-->
			<category>Snippets</category>
			<description>
			一名在校本科生，凭借一点C语言的基础+看过一些java方面的书，目前正处在ruby学习中！&lt;br /&gt;
    学习教材—— 《Programming Ruby 2》+《Agile web development with rails 2》&lt;br /&gt;
    操作环境——  netbeans&lt;br /&gt;
    很幸运地收到了Satish Talim的ruby-learning上的e-book， 花了将近一周多的课余时间结束了Ruby第一部分的基本语法：类，对象，变量，Blocks，迭代器，表达式及控制结构，模块，方法，正则表达式，输入、输出，异常，线程...&lt;br /&gt;
   只能说是很模糊的把它跑了一遍,这一部分有很多和Java相象的地方，基本能看明白。 有点张无忌练太极的感觉，‘招式’都似曾相识，但感觉又变了。最苦恼的地方莫过于“方法”那个模块了！每次碰到新的方法，都要把它当作既成的约定，至于它为什么这样工作就不得而知了。 这本书有几乎一半的内容是介绍ruby的参考库，而这些参考库则是以一些方法和模块为主导。要把这些方法都能很熟练的从脑子里不断的调出，对初学者来说，我想这必定是一件很严峻的‘工程’。虽然netbeans在输入这些代码方法时都有提示版块，但至少我必须要知道它们的存在，各自有些什么特点，起着什么样的作用，我想这是必须要了解的！&lt;br /&gt;
重点记录一下方法的使用（尽管学了几遍，但仍然有种很不着地的感觉）&lt;br /&gt;
一、方法定义&lt;br /&gt;
定义方法使用关键字def，而方法名应该以小写字母开始。一般来说，用于请求的方法以?结尾，如instance_of?；对于要修改变量的“危险”方法，需要以!结尾，例如，String提供chop和chop!两种方法。第一个方法返回改变后的字符串，而后面一个方法将直接改变该字符串。另外，!和?是Ruby方法中唯一允许的两个特殊符号。当然，定义的方法可以使用多个参数，只需要在括号中声明即可，参数也可以使用默认值，这与其他语言的差别不大。例：&lt;br /&gt;
 def coolDude(arg1="Miles", arg2="Coltrane", arg3="Roach")  &lt;br /&gt;
   "#{arg1}, #{arg2}, #{arg3}."  &lt;br /&gt;
 end  &lt;br /&gt;
  &lt;br /&gt;
 coolDude  » "Miles, Coltrane, Roach."  &lt;br /&gt;
 coolDude("Bart")  » "Bart, Coltrane, Roach."  &lt;br /&gt;
 coolDude("Bart", "Elwood")  » "Bart, Elwood, Roach."  &lt;br /&gt;
 coolDude("Bart", "Elwood", "Linus")  » "Bart, Elwood, Linus."  &lt;br /&gt;
 &lt;br /&gt;
•个数不定的参数组：如果 一个方法传入多个参数，但是，参数的个数又不能确定，那该怎么办呢？只需要使用两个参数，第一个正常，第二个参数前加*，这样，后面无论多少参数都会转化成数组类型。如：&lt;br /&gt;
 def varargs(arg1, *rest)  &lt;br /&gt;
   "Got #{arg1} and #{rest.join(', ')}"  &lt;br /&gt;
 end  &lt;br /&gt;
  &lt;br /&gt;
 varargs("one")  » "Got one and "  &lt;br /&gt;
 varargs("one", "two")  » "Got one and two"  &lt;br /&gt;
 varargs "one", "two", "three"  » "Got one and two, three"  &lt;br /&gt;
 &lt;br /&gt;
 &lt;br /&gt;
方法与块可以联系起来一起用。例如&lt;br /&gt;
 def takeBlock(p1)&lt;br /&gt;
   if block_given?&lt;br /&gt;
     yield(p1)&lt;br /&gt;
   else&lt;br /&gt;
     p1&lt;br /&gt;
   end&lt;br /&gt;
 end&lt;br /&gt;
 &lt;br /&gt;
 takeBlock("no block")  » "no block"  &lt;br /&gt;
  takeBlock("no block") { |s| s.sub(/no /, '') }  » "block"  &lt;br /&gt;
 &lt;br /&gt;
也可以把块作为参数传入，只需要在相应参数前加&amp;即可。&lt;br /&gt;
二、方法的调用&lt;br /&gt;
方法的调用于其他语言一样，但是，它可以省略括号。另外，如果省略了当前的方法调用者，那么，Ruby默认是由当前的对象所调用的。&lt;br /&gt;
 要展开数组，可以在数组的前面加*号，跟定义方法差不多，那么，在进入方法后，Ruby将自动将数组展开，例如：&lt;br /&gt;
 def five(a, b, c, d, e)  &lt;br /&gt;
   "I was passed #{a} #{b} #{c} #{d} #{e}"  &lt;br /&gt;
 end  &lt;br /&gt;
  &lt;br /&gt;
five(1, 2, 3, 4, 5 )  » "I was passed 1 2 3 4 5"  &lt;br /&gt;
 five(1, 2, 3, *['a', 'b'])  » "I was passed 1 2 3 a b"  &lt;br /&gt;
 five(*(10..14).to_a)  » "I was passed 10 11 12 13 14"  &lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
这一部分的内容都很基本，而且是必须掌握的，它几乎贯穿于ruby的所有程序代码中，所以有很多不是很深刻的地方有待于加强理解~~
			</description>
			<pubDate>Sun, 30 Mar 2008 22:24:17 +0800</pubDate>
			<guid>http://chinaonrails.com/topic/view/1463.html</guid>
		</item>
		<item>
			<title>让页脚自动显示一年又一年 ... no reply</title>
			<link>http://chinaonrails.com/topic/view/1443.html</link>
			<comments>http://chinaonrails.com/topic/view/1443.html#reply</comments>
			<dc:creator>bd7lx</dc:creator>
			<author>bd7lx</author>
			<!--<enclosure url="http://chinaonrails.com/img/p/9.jpg" type="image/jpeg" />
			<enclosure url="http://chinaonrails.com/img/p/9_s.jpg" type="image/jpeg" />
			<enclosure url="http://chinaonrails.com/img/p/9_n.jpg" type="image/jpeg" />-->
			<category>Snippets</category>
			<description>
			&lt;a href="http://www.robbyonrails.com/articles/2008/03/24/dry-a-year-after-year" rel="nofollow external" class="tpc"&gt;http://www.robbyonrails.com/articles/2008/03/24/dry-a-year-after-year&lt;/a&gt;&lt;br /&gt;
&lt;br /&gt;
&lt;img class="code" src="http://img.lumra.com/67/39/fbfb92c9bbec78e547480829fcaa_612.jpg" border="0" /&gt;&lt;br /&gt;
&lt;br /&gt;
简单的事情常常不想干，干的都是从简的事情
			</description>
			<pubDate>Tue, 25 Mar 2008 13:17:20 +0800</pubDate>
			<guid>http://chinaonrails.com/topic/view/1443.html</guid>
		</item>
		<item>
			<title>让ruby弹钢琴Ruby MIDI generator ... no reply</title>
			<link>http://chinaonrails.com/topic/view/1431.html</link>
			<comments>http://chinaonrails.com/topic/view/1431.html#reply</comments>
			<dc:creator>bd7lx</dc:creator>
			<author>bd7lx</author>
			<!--<enclosure url="http://chinaonrails.com/img/p/9.jpg" type="image/jpeg" />
			<enclosure url="http://chinaonrails.com/img/p/9_s.jpg" type="image/jpeg" />
			<enclosure url="http://chinaonrails.com/img/p/9_n.jpg" type="image/jpeg" />-->
			<category>Snippets</category>
			<description>
			Archaeopteryx始祖鸟歌唱&lt;br /&gt;
&lt;img class="code" src="http://s3.amazonaws.com/giles/propellerhead_reason4_thor.jpg" border="0" /&gt;&lt;br /&gt;
&lt;br /&gt;
http://gilesbowkett.blogspot.com/2008/02/archaeopteryx-ruby-midi-generator.html&lt;br /&gt;
&lt;br /&gt;
有视频介绍
			</description>
			<pubDate>Wed, 19 Mar 2008 12:05:47 +0800</pubDate>
			<guid>http://chinaonrails.com/topic/view/1431.html</guid>
		</item>
		<item>
			<title>试用canhaschat插件，实现web即时通讯 ... 1 reply</title>
			<link>http://chinaonrails.com/topic/view/1404.html</link>
			<comments>http://chinaonrails.com/topic/view/1404.html#reply</comments>
			<dc:creator>magicgod</dc:creator>
			<author>magicgod</author>
			<!--<enclosure url="http://chinaonrails.com/img/p_1.gif" type="image/jpeg" />
			<enclosure url="http://chinaonrails.com/img/p_1_s.gif" type="image/jpeg" />
			<enclosure url="http://chinaonrails.com/img/p_1_n.gif" type="image/jpeg" />-->
			<category>Snippets</category>
			<description>
			试用参见：http://magicgod.javaeye.com/blog/168845&lt;br /&gt;
&lt;br /&gt;
算是挺不错的web 即时通讯插件。没有用flash，但是用 mongrel handle。&lt;br /&gt;
&lt;br /&gt;
使用轮询+长连接（30s）的方式接受消息。drb server与jabber  server交互。
			</description>
			<pubDate>Thu, 06 Mar 2008 18:34:26 +0800</pubDate>
			<guid>http://chinaonrails.com/topic/view/1404.html</guid>
		</item>
		<item>
			<title>msn和 gtalk小机器人 ... 13 replies</title>
			<link>http://chinaonrails.com/topic/view/1385.html</link>
			<comments>http://chinaonrails.com/topic/view/1385.html#reply</comments>
			<dc:creator>magicgod</dc:creator>
			<author>magicgod</author>
			<!--<enclosure url="http://chinaonrails.com/img/p_1.gif" type="image/jpeg" />
			<enclosure url="http://chinaonrails.com/img/p_1_s.gif" type="image/jpeg" />
			<enclosure url="http://chinaonrails.com/img/p_1_n.gif" type="image/jpeg" />-->
			<category>Snippets</category>
			<description>
			实际上也使用了activerecord，还有xmpp4r。&lt;br /&gt;
&lt;br /&gt;
是一个可以接收部分命令的机器人。&lt;br /&gt;
&lt;br /&gt;
命令和源码请查看：&lt;br /&gt;
&lt;br /&gt;
http://code.google.com/p/whereisitcn/
			</description>
			<pubDate>Tue, 04 Mar 2008 10:27:44 +0800</pubDate>
			<guid>http://chinaonrails.com/topic/view/1385.html</guid>
		</item>
		<item>
			<title>若闲置时间过长，保存数据就会出错 ... 7 replies</title>
			<link>http://chinaonrails.com/topic/view/1374.html</link>
			<comments>http://chinaonrails.com/topic/view/1374.html#reply</comments>
			<dc:creator>zbage</dc:creator>
			<author>zbage</author>
			<!--<enclosure url="http://chinaonrails.com/img/p_1.gif" type="image/jpeg" />
			<enclosure url="http://chinaonrails.com/img/p_1_s.gif" type="image/jpeg" />
			<enclosure url="http://chinaonrails.com/img/p_1_n.gif" type="image/jpeg" />-->
			<category>Snippets</category>
			<description>
			用ruby写了一段监控代码，用activerecord保存数据，若闲置时间过长，保存数据就会出错，如何解决？
			</description>
			<pubDate>Sun, 02 Mar 2008 12:39:11 +0800</pubDate>
			<guid>http://chinaonrails.com/topic/view/1374.html</guid>
		</item>
	</channel>
</rss>