ruby 388

#Ruby
Rails 之 Model 简单一例

class Cruncher def crunch return 5 end end

2015-09-22 178

#Ruby
Ruby批量执行Linux安装程序和脚本

require 'find' module Find def match(*paths) matched = [] find(*paths) { |path| matched &l…

2015-09-21 880

#Ruby
Ruby 编写 CGI 脚本

#!/usr/bin/ruby print "Content-type: text/html\r\n\r\n" print "<html><body>Hel…

2015-09-19 733

#Ruby
filter_parameter_logging方法

filter_parameter_logging :password, :password_confirmation

2015-09-17 961

#Ruby
Ruby 抓取 URL 的内容

require 'open-uri' puts open('http://www.oschina.net/').read(200)

2015-09-15 916

#Ruby
ActiveRecord中动态读取表中字段的方法

script/console Loading development environment (Rails 2.3.11) >> p = Package.new =&g…

2015-09-15 141

#Ruby
Ruby 在 Excel 中插入图表并进行旋转

require 'win32ole' ChartTypeVal = 4100; excel = WIN32OLE.new("excel.application") excel['V…

2015-09-15 252

#Ruby
删除目录中重复的文件

require 'find' require 'digest/md5' uniqueFileTable = Hash.new sameFileTable = Hash.new #p…

2015-09-14 688

#Ruby
替换歌词里的时间为空白

f=File.open('M0030002007.lrc') f.each do |line| puts line.gsub(/[\[\d:\.\]]/,'') end

2015-09-13 677

#Ruby
去掉 升级rubygems1.80后的warn

module Deprecate def self.skip # :nodoc: #@skip ||= false #update by jazz 2011-5-6 true en…

2015-09-11 999

#Ruby
Ruby 使用 POST 方法提交数据: set_form_data

require 'net/http' url = URI.parse('http://www.rubyinside.com/test.cgi') Net::HTTP.start(u…

2015-09-11 793

#Ruby
Ruby 使用 HTTPS

require 'net/http' require 'net/https' url = URI.parse('https://example.com/') http = Net:…

2015-09-11 609
1 6 7 8 9 10 33