首页 软件开发 代码片段 ruby ( Page 28 )

ruby 388

#Ruby
Ruby+Erlang抓取贴吧图片

#coding utf-8 #!/usr/bin/env ruby -w require "open-uri" require "nokogiri" require "thread…

2015-01-02 894

#Ruby
Ruby 判断字符串是否对称

#分两种情况 #第一种是奇数位字符串 def method str p str == str.reverse ? "Yes" : "No" end #另一种是偶数位字符串 def …

2015-01-01 877

#Ruby
Ruby运算符重载

class String def - str self.gsub(str, "") end end puts "Hello" - "H"

2015-01-01 248

#Ruby
ruby编写的乘法口诀代码

TEST_FILE_NAME = '乘法口诀.txt' #创建文件 File.open(TEST_FILE_NAME, 'w+') do |file| for x in 1..9 …

2014-12-31 332

#Ruby
用 Ruby scrAPI 做数据采集

<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xh…

2014-12-30 932

#Ruby
Rails 在 Controller 中选择要显示的 View

class HelloController < ApplicationController def there if Time.now.hour == 12 render(:…

2014-12-28 178

#Ruby
Rails 对 Model 的数据库配置 set_table_name

drop database Contact; create database Contact; use Contact; CREATE TABLE Employee ( id in…

2014-12-28 803

#Ruby
10行代码实现coffeescript全自动编译成js(linux/mac os)

require 'fssm' FILE_PATH = '/home/yourpath/' def compile(path) system "coffee -c #{path}" …

2014-12-28 933

#Ruby
三角形的面积

def triangle(x,y,z) angleX=Math.acos((y**2+z**2-x**2)*3.14/(360*y*z)) #angleX is the angle…

2014-12-28 916

#Ruby
Ruby多进程并行抓取网页

#!/usr/bin/env ruby #encoding: UTF-8 # 抓取每一个站点的首页链接数量 # require 'rubygems' # 1.8.7 require…

2014-12-27 185

#Ruby
Ruby 使用 TkRadioButton

require 'Tk' top = TkRoot.new{title "Radio Button"} radioVar=TkVariable.new r1 = TkRadioBu…

2014-12-23 798
1 26 27 28 29 30 33