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

ruby 388

#Ruby
数字转换成罗马数字

# Hash holding the roman values # Values above 3999 are not accepted, as numerals with bar…

2014-12-08 382

#Ruby
Windows-1251 转换成 UTF8

function win_to_utf8 ($string) { $in_arr = array ( chr(208), chr(192), chr(193), chr(194),…

2014-12-06 872

#Ruby
服务器本地文件上传

url = 'http://xx' #post到url field_hash = {key: key, token: token} #post数据 request = RestCl…

2014-12-04 292

#Ruby
等级相关系数 Coefficient Of Rank Correlation

puts "Enter Number of Data Set" n=gets.chomp n=n.to_f sum_d=0 i=0 while i<n i=i+1 puts …

2014-12-03 709

#Ruby
热键控制系统音量

#!/usr/bin/env ruby # -*- coding: gb18030 -*- # __FILE__ : ctrlvol.rb # 2012-7 # ruby 1.9.…

2014-12-03 842

#Ruby
Ruby 遍历目录

require 'find' def fileWalk(path) Find.find(path) do |f| type = "File" if File.file?(f) ty…

2014-12-01 896

#Ruby
Rails 显示环境变量

REQUEST_URI: <%= request.env["REQUEST_URI"] %> <br /> SERVER_NAME: <%= requ…

2014-11-30 838

#Ruby
Ruby 查询域名映射的所有IP地址

require 'resolv' Resolv.each_address("http://www.google.com/") do |ip| puts ip end

2014-11-30 127

#Ruby
Ruby 设置 FTP 传输模式为 Passive

require 'net/ftp' ftp = Net::FTP.new('ftp.ruby-lang.org') ftp.passive = true ftp.login(use…

2014-11-29 879

#Ruby
Ruby 管理 GServer 服务器端实例

require 'gserver' class HelloServer < GServer def serve(io) io.puts("To stop this serve…

2014-11-28 791

#Ruby
Project Euler 2

puts (1..Float::INFINITY).lazy.map{|n| (0..n).inject([1,0]) {|(a,b), _| [b, a+b]}[0] }.tak…

2014-11-27 881

#Ruby
使用纯 Ruby 代码来生成 HTML 页面

require 'rubygems' require 'markaby' m = Markaby::Builder.new items = ['Bread', 'Butter', …

2014-11-23 470