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

ruby 388

#Ruby
Ruby 使用 pstore 的简单例子

require "pstore" db = PStore.new("employee.dat") db.transaction do db["params"] = {"name" …

2015-03-27 217

#Ruby
Ruby 使用 Berkeley DB 数据库

require 'dbm' DBM.open('r') do |db| db['t'] ="W" db[23] = "F" end DBM.open('r') do |db| pu…

2015-03-27 416

#Ruby
检查SSH

require 'net/ssh' def test_ssh_connect(address,username,password) begin Net::SSH.start(add…

2015-03-26 705

#Ruby
Ruby 进行 FTP 文件传输时,每传输100k进行提醒

require 'net/ftp' ftp = Net::FTP.new('ftp.domain.com') ftp.passive = true ftp.login ftp.ch…

2015-03-23 650

#Ruby
ruby调用telnet,远程运行命令

require 'net/telnet' # 连接到远程主机 foobar telnet = Net::Telnet.new("Host" => "foobar") {|c|…

2015-03-22 948

#Ruby
Ruby 将哈希数据转成 YAML

require 'yaml' puts ({ 'measurements' => 'metric' }.to_yaml) puts ({ :measurements =>…

2015-03-21 685

#Ruby
Ruby中类的一部分转为单独的类

ClassPart = proc do <copy here code you want to move out of the main class> end

2015-03-20 508

#Ruby
Ruby 设置 Excel 单元格数据并读取

require 'win32ole' excel = WIN32OLE.new("excel.application") excel.Workbooks.Add excel.Ran…

2015-03-20 925

#Ruby
github认证

#coding: utf-8 require 'sinatra' require 'omniauth' require 'omniauth-github' use Rack::Se…

2015-03-19 504

#Ruby
Ruby 连接到 Oracle 数据库并执行SQL查询

require "dbi" URL = "dbi:Oracle:oracle.neumann" dbh = DBI.connect(URL, "scott", "tiger") r…

2015-03-19 378

#Ruby
Ruby GServer 设置允许客户端的同时连接数

require 'gserver' class HelloServer < GServer def serve(io) io.puts("Say something to m…

2015-03-18 630

#Ruby
Ruby:简单的插入排序

#Insertion Sort Method def insertionSort(list) list.each_with_index do |data,i| j = i - 1 …

2015-03-17 428
1 19 20 21 22 23 33