<?xml version="1.0" encoding="UTF-8"?>
<rss version="2.0"
	xmlns:content="http://purl.org/rss/1.0/modules/content/"
	xmlns:wfw="http://wellformedweb.org/CommentAPI/"
	xmlns:dc="http://purl.org/dc/elements/1.1/"
	xmlns:atom="http://www.w3.org/2005/Atom"
	xmlns:sy="http://purl.org/rss/1.0/modules/syndication/"
	xmlns:slash="http://purl.org/rss/1.0/modules/slash/"
	>

<channel>
	<title>O!Hacker Blog &#187; Ruby</title>
	<atom:link href="http://ohacker.com/tag/ruby/feed/" rel="self" type="application/rss+xml" />
	<link>http://ohacker.com</link>
	<description>anything to hack</description>
	<lastBuildDate>Thu, 12 Aug 2010 05:17:18 +0000</lastBuildDate>
	<language>en</language>
	<sy:updatePeriod>hourly</sy:updatePeriod>
	<sy:updateFrequency>1</sy:updateFrequency>
	<generator>http://wordpress.org/?v=3.0</generator>
		<item>
		<title>Ruby:Timezone synchronization function(跨时区同步时间方法)</title>
		<link>http://ohacker.com/2009/04/30/rubytimezone-synchronization-function%e8%b7%a8%e6%97%b6%e5%8c%ba%e5%90%8c%e6%ad%a5%e6%97%b6%e9%97%b4%e6%96%b9%e6%b3%95/</link>
		<comments>http://ohacker.com/2009/04/30/rubytimezone-synchronization-function%e8%b7%a8%e6%97%b6%e5%8c%ba%e5%90%8c%e6%ad%a5%e6%97%b6%e9%97%b4%e6%96%b9%e6%b3%95/#comments</comments>
		<pubDate>Thu, 30 Apr 2009 08:49:00 +0000</pubDate>
		<dc:creator>Tony</dc:creator>
				<category><![CDATA[Ruby]]></category>

		<guid isPermaLink="false">http://ohacker.com/2009/04/30/rubytimezone-synchronization-function%e8%b7%a8%e6%97%b6%e5%8c%ba%e5%90%8c%e6%ad%a5%e6%97%b6%e9%97%b4%e6%96%b9%e6%b3%95/</guid>
		<description><![CDATA[方法是：首先取得客户端的时区，之后得到服务器的本地时区，之后取得两个时区的差值，计算出相应的时间。输入：服务器时间输出：相应的客户端对应的时间上代码： #时间同步方法 #clint_timezone:client timezone def formate_date_to_client_time_zone&#40;clint_timezone,time&#41; diff=&#40;clint_timezone-get_server_time_zone&#41; unless&#40;clint_timezone.nil?&#41; time=time+diff*3600 end return time end #获得本地时区 #return the server timezone def get_server_time_zone return Time.now.gmtoff/3600 end 相关日志Ruby:string to date Or date to stringJRuby On Spring在spring框架中使用JrubyJRuby的性能优化(update)用ruby写的一个网络爬虫程序Ruby 递归删除文件目录Ruby on Rails单元测试(Unit Test)Eclipse3.4的Ruby支持]]></description>
		<wfw:commentRss>http://ohacker.com/2009/04/30/rubytimezone-synchronization-function%e8%b7%a8%e6%97%b6%e5%8c%ba%e5%90%8c%e6%ad%a5%e6%97%b6%e9%97%b4%e6%96%b9%e6%b3%95/feed/</wfw:commentRss>
		<slash:comments>0</slash:comments>
		</item>
		<item>
		<title>Ruby:string to date Or date to string</title>
		<link>http://ohacker.com/2009/04/29/rubystring-to-date-or-date-to-string/</link>
		<comments>http://ohacker.com/2009/04/29/rubystring-to-date-or-date-to-string/#comments</comments>
		<pubDate>Wed, 29 Apr 2009 09:03:00 +0000</pubDate>
		<dc:creator>Tony</dc:creator>
				<category><![CDATA[Ruby]]></category>

		<guid isPermaLink="false">http://ohacker.com/2009/04/29/rubystring-to-date-or-date-to-string/</guid>
		<description><![CDATA[Ruby:string to date Or date to string #string to date str=&#34;2009-02-02&#34; date=Date.strptime&#40;str,&#34;%Y-%m-%d&#34;&#41; #date to string:&#60;br /&#62;date=Date.new(2009,2,2) str=date.strftime&#40;&#34;%Y-%m-%d&#34;&#41; 相关日志Ruby:Timezone synchronization function(跨时区同步时间方法)JRuby On Spring在spring框架中使用JrubyJRuby的性能优化(update)用ruby写的一个网络爬虫程序Ruby 递归删除文件目录Ruby on Rails单元测试(Unit Test)Eclipse3.4的Ruby支持]]></description>
		<wfw:commentRss>http://ohacker.com/2009/04/29/rubystring-to-date-or-date-to-string/feed/</wfw:commentRss>
		<slash:comments>0</slash:comments>
		</item>
		<item>
		<title>JRuby On Spring在spring框架中使用Jruby</title>
		<link>http://ohacker.com/2009/04/23/jruby-on-spring%e5%9c%a8spring%e6%a1%86%e6%9e%b6%e4%b8%ad%e4%bd%bf%e7%94%a8jruby/</link>
		<comments>http://ohacker.com/2009/04/23/jruby-on-spring%e5%9c%a8spring%e6%a1%86%e6%9e%b6%e4%b8%ad%e4%bd%bf%e7%94%a8jruby/#comments</comments>
		<pubDate>Fri, 24 Apr 2009 05:14:00 +0000</pubDate>
		<dc:creator>Tony</dc:creator>
				<category><![CDATA[Ruby]]></category>
		<category><![CDATA[Jruby]]></category>
		<category><![CDATA[spring]]></category>

		<guid isPermaLink="false">http://ohacker.com/2009/04/23/jruby-on-spring%e5%9c%a8spring%e6%a1%86%e6%9e%b6%e4%b8%ad%e4%bd%bf%e7%94%a8jruby/</guid>
		<description><![CDATA[昨天尝试在Spring中使用脚本语言，比如jruby，发现非常不方便，最主要的一点就是ruby class必须继承某一个java的接口，而其他bean调用时也是调用这个接口类型的对象。jruby的动态性基本丧失了。唉！ 相关日志JRuby的性能优化(update)Why is Spring So Important?Spring包结构以及各个包之间引用关系说明Spring Annotation(IOC篇)Spring Annotation(AOP篇)Ruby:Timezone synchronization function(跨时区同步时间方法)Ruby:string to date Or date to string用ruby写的一个网络爬虫程序Ruby 递归删除文件目录Ruby on Rails单元测试(Unit Test)]]></description>
		<wfw:commentRss>http://ohacker.com/2009/04/23/jruby-on-spring%e5%9c%a8spring%e6%a1%86%e6%9e%b6%e4%b8%ad%e4%bd%bf%e7%94%a8jruby/feed/</wfw:commentRss>
		<slash:comments>0</slash:comments>
		</item>
		<item>
		<title>JRuby的性能优化(update)</title>
		<link>http://ohacker.com/2009/04/23/jruby%e7%9a%84%e6%80%a7%e8%83%bd%e4%bc%98%e5%8c%96update/</link>
		<comments>http://ohacker.com/2009/04/23/jruby%e7%9a%84%e6%80%a7%e8%83%bd%e4%bc%98%e5%8c%96update/#comments</comments>
		<pubDate>Thu, 23 Apr 2009 15:56:00 +0000</pubDate>
		<dc:creator>Tony</dc:creator>
				<category><![CDATA[Ruby]]></category>
		<category><![CDATA[Jruby]]></category>

		<guid isPermaLink="false">http://ohacker.com/2009/04/23/jruby%e7%9a%84%e6%80%a7%e8%83%bd%e4%bc%98%e5%8c%96update/</guid>
		<description><![CDATA[JRuby wiki上列出了性能优化的四条建议：1、调优编译器，JRuby早就弃暗投明跟随XRuby走上了编译这条牛B的道路，将Ruby Script编译成字节码，因此这个环节是断断不能忽略的。两种编译方式：AOT模式：直接生成class文件，脱了Ruby这层皮，咱就是人见人“爱”的java了。JIT模式：充分利用成熟的jit技术，咱不全脱，朦胧美才是真的美。默认从0.9.9版本开始就是开启的，关闭的话（要我说还不如全脱）jruby -J-Djruby.jit.enabled=false2、关闭ObjectSpaceObjectSpace是Ruby用来操作所有运行时对象的模块，这个功能相当牛x。这个的实现在c ruby里是比较容易的，但是对于JRuby代价就比较昂贵了，其实就大部分情况下你基本用不到这个东东，那么最好就是关闭它，JRuby提供了jruby -J-Djruby.objectspace.enabled=false选项来关闭它。3、开启线程池我们知道，在c ruby中的线程是绿色的轻量级线程，因此运行时就动不动开个百来十个“线程”跑一跑充下款爷；然而在JRuby中，线程的实现那可是实打实的本地线程（也就是Ruby线程与java线程一比一），你这么动不动上百个线程那不慢才怪了。因此JRuby提供了线程池选项，运行时尽可能地满足你的要求开线程，但是当短命的Ruby线程重复创建的时候，这些线程将被复用，这在大多数情况下能提高性能表现，特别是在每次调用都启动一个线程的情况下。不过具体效果还是要测试的实际数据说话。jruby -J-Djruby.thread.pooling=true 4、使用Java &#8220;server&#8221;模式虚拟机，地球淫都知道jruby -J-server myscript.rb5、尽量使用最新的jdk，在我的测试中，jdk6跑jruby是效率最高的。 相关日志JRuby On Spring在spring框架中使用JrubyRuby:Timezone synchronization function(跨时区同步时间方法)Ruby:string to date Or date to string用ruby写的一个网络爬虫程序Ruby 递归删除文件目录Ruby on Rails单元测试(Unit Test)Eclipse3.4的Ruby支持]]></description>
		<wfw:commentRss>http://ohacker.com/2009/04/23/jruby%e7%9a%84%e6%80%a7%e8%83%bd%e4%bc%98%e5%8c%96update/feed/</wfw:commentRss>
		<slash:comments>0</slash:comments>
		</item>
		<item>
		<title>用ruby写的一个网络爬虫程序</title>
		<link>http://ohacker.com/2009/04/22/ruby-web-crawed/</link>
		<comments>http://ohacker.com/2009/04/22/ruby-web-crawed/#comments</comments>
		<pubDate>Wed, 22 Apr 2009 16:21:00 +0000</pubDate>
		<dc:creator>Tony</dc:creator>
				<category><![CDATA[Ruby]]></category>

		<guid isPermaLink="false">http://ohacker.com/2009/04/22/%e7%94%a8ruby%e5%86%99%e7%9a%84%e4%b8%80%e4%b8%aa%e7%bd%91%e7%bb%9c%e7%88%ac%e8%99%ab%e7%a8%8b%e5%ba%8f/</guid>
		<description><![CDATA[前几天写的一个ruby爬虫，专抓指定网站的Email require 'net/http' module EmailSpider EMAIL=/\w+&#40;&#91;-+.&#93;\w+&#41;*@\w+&#40;&#91;-.&#93;\w+&#41;*\.\w+&#40;&#91;-.&#93;\w+&#41;*/i #the fullest uri like this #http://www.sina.com.cn:80/abc?query='123'&#38;page='http://eee.sss.vv:8080' URL=/http:\/\/\w+&#40;\.\w+&#41;*&#40;&#91;:&#93;?\d*&#41;?&#91;\/&#93;?&#91;0-9a-zA-Z\/=\?%#\-\&#38;_~\`@\[\]\':\+!\.]*/i NON_HTML_URL=/&#40;\.dtd&#41;&#124;&#40;\.css&#41;&#124;&#40;\.js&#41;&#124;&#40;\.pdf&#41;&#124;&#40;\.png&#41;&#124;&#40;\.jpg&#41;&#124;&#40;\.ps&#41;&#124;&#40;\&#40;.*\&#41;&#91;;&#93;?&#91; &#93;*&#41;$/i GOOGLE_URL=/http:\/\/\w+\.google\./i DOMAIN=/http:\/\/\w+&#40;\.\w+&#41;*&#40;&#91;:&#93;?\d*&#41;?&#91;\/&#93;?/i class EmailSet attr_accessor :emails,:url def initialize&#40;emails,url&#41; @emails,@url=emails,url end end def self.query_by_url&#40;url&#41; url+=&#34;/&#34; if &#40;not url=~/&#91;\/&#93;$/&#41;and&#40;not url=~/&#40;\.htm.?&#41;&#124;&#40;\.jsp&#41;&#124;&#40;\.asp&#41;&#124;&#40;\.php&#41;$/i&#41; url.strip! begin if url=~URL content=Net::HTTP.get&#40;URI.parse&#40;url.strip&#41;&#41;; content.gsub!&#40;/&#60;.?frame .*src=&#34;(.+)&#34;.*&#62;/i&#41; do &#124;match&#124; sub_url=match.scan&#40;/src=&#91;\\'](.+)[\\'&#93;/i&#41; if sub_url=~URL and not url=~GOOGLE_URL query_by_url sub_url else query_by_url &#34;#{url}#{sub_url}&#34; end end [...]]]></description>
		<wfw:commentRss>http://ohacker.com/2009/04/22/ruby-web-crawed/feed/</wfw:commentRss>
		<slash:comments>0</slash:comments>
		</item>
		<item>
		<title>Ruby 递归删除文件目录</title>
		<link>http://ohacker.com/2009/04/22/ruby-%e9%80%92%e5%bd%92%e5%88%a0%e9%99%a4%e6%96%87%e4%bb%b6%e7%9b%ae%e5%bd%95/</link>
		<comments>http://ohacker.com/2009/04/22/ruby-%e9%80%92%e5%bd%92%e5%88%a0%e9%99%a4%e6%96%87%e4%bb%b6%e7%9b%ae%e5%bd%95/#comments</comments>
		<pubDate>Wed, 22 Apr 2009 16:07:00 +0000</pubDate>
		<dc:creator>Tony</dc:creator>
				<category><![CDATA[Ruby]]></category>

		<guid isPermaLink="false">http://ohacker.com/2009/04/22/ruby-%e9%80%92%e5%bd%92%e5%88%a0%e9%99%a4%e6%96%87%e4%bb%b6%e7%9b%ae%e5%bd%95/</guid>
		<description><![CDATA[递归删除文件目录：require 'pathname'dir=Pathname.new("/home/poole/")dir.rmtree #or require 'fileutils'FileUtils.rm_r("/home/poole") 相关日志Ruby:Timezone synchronization function(跨时区同步时间方法)Ruby:string to date Or date to stringJRuby On Spring在spring框架中使用JrubyJRuby的性能优化(update)用ruby写的一个网络爬虫程序Ruby on Rails单元测试(Unit Test)Eclipse3.4的Ruby支持]]></description>
		<wfw:commentRss>http://ohacker.com/2009/04/22/ruby-%e9%80%92%e5%bd%92%e5%88%a0%e9%99%a4%e6%96%87%e4%bb%b6%e7%9b%ae%e5%bd%95/feed/</wfw:commentRss>
		<slash:comments>0</slash:comments>
		</item>
		<item>
		<title>Ruby on Rails单元测试(Unit Test)</title>
		<link>http://ohacker.com/2009/04/20/ruby-on-rails-and-unit-test/</link>
		<comments>http://ohacker.com/2009/04/20/ruby-on-rails-and-unit-test/#comments</comments>
		<pubDate>Mon, 20 Apr 2009 08:05:00 +0000</pubDate>
		<dc:creator>Tony</dc:creator>
				<category><![CDATA[Ruby]]></category>
		<category><![CDATA[Ruby on Rails]]></category>

		<guid isPermaLink="false">http://ohacker.com/2009/04/20/ruby-on-rails%e5%8d%95%e5%85%83%e6%b5%8b%e8%af%95unit-test/</guid>
		<description><![CDATA[Ruby on Rails 单元测试(Unit Test)步骤 （MySQL环境）#首先建立测试数据库mysqladmin -u root create db_test#建立数据库结构rake db:test:prepare#运行测试ruby test/unit/product_test.rb 相关日志ruby on rails 上安装及使用rspecRuby:Timezone synchronization function(跨时区同步时间方法)Ruby:string to date Or date to stringJRuby On Spring在spring框架中使用JrubyJRuby的性能优化(update)用ruby写的一个网络爬虫程序Ruby 递归删除文件目录Ruby on Rails ActiveRecord中Has_many的参数说明Ruby on Rails单元测试(Unit Test)的数据准备Eclipse3.4的Ruby支持]]></description>
		<wfw:commentRss>http://ohacker.com/2009/04/20/ruby-on-rails-and-unit-test/feed/</wfw:commentRss>
		<slash:comments>0</slash:comments>
		</item>
		<item>
		<title>Eclipse3.4的Ruby支持</title>
		<link>http://ohacker.com/2009/04/15/eclipse3-4-ruby-support/</link>
		<comments>http://ohacker.com/2009/04/15/eclipse3-4-ruby-support/#comments</comments>
		<pubDate>Thu, 16 Apr 2009 01:31:00 +0000</pubDate>
		<dc:creator>Tony</dc:creator>
				<category><![CDATA[Other]]></category>
		<category><![CDATA[Ruby]]></category>
		<category><![CDATA[Eclipse]]></category>

		<guid isPermaLink="false">http://ohacker.com/2009/04/15/eclipse3-4%e7%9a%84ruby%e6%94%af%e6%8c%81/</guid>
		<description><![CDATA[再Eclipse3.4之前的版本，我们可以用Aptana来编辑Ruby，但是升级到Eclipse3.4以后，还没有找到一个合适的plugin来写Ruby代码。今天再Eclipse Plugin Center终于找到了一个不错的Ruby Editor，但是目前还不支持Rails。Eclipse Update site为：http://download.eclipse.org/technology/dltk/updates/这个工具距离NetBeans还有不小的差距，但是终于也算有的用了，单元Aptana能快点更新。 相关日志Ruby:Timezone synchronization function(跨时区同步时间方法)Ruby:string to date Or date to stringJRuby On Spring在spring框架中使用JrubyJRuby的性能优化(update)用ruby写的一个网络爬虫程序Ruby 递归删除文件目录Ruby on Rails单元测试(Unit Test)Eclipse快捷键]]></description>
		<wfw:commentRss>http://ohacker.com/2009/04/15/eclipse3-4-ruby-support/feed/</wfw:commentRss>
		<slash:comments>0</slash:comments>
		</item>
	</channel>
</rss>
