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

ruby 388

#Ruby
根据进程名获取进程ID

include Sys require 'win32ole' require 'socket' require 'date' # The Sys module serves as …

2015-07-30 423

#Ruby
Ruby 使用 getname 方法获取 IP 地址对应的主机名

require 'resolv' ip = "192.0.34.166" begin puts Resolv.getname(ip) rescue puts "No hostnam…

2015-07-27 267

#Ruby
“Ruby太慢” ruby真的慢吗?

t1 = Time.now.to_i min = Math.sqrt(1).to_i max = Math.sqrt(10**14).to_i def isH(num) num =…

2015-07-24 911

#Ruby
Ruby 编写 XMLRPC 服务

require "xmlrpc/server" class Num INTERFACE = XMLRPC::interface("num") { meth 'int add(int…

2015-07-24 344

#Ruby
Ruby猜数字游戏

# encoding: UTF-8 class NumberKeeper attr_accessor :number, :userGuessing, :smallerNum, :b…

2015-07-24 126

#Ruby
大白+大白=白胖胖

2.2.0 :011 > (50..99).each{|x| puts "#{x}+#{x}=#{2*x}" if x%10 == 2*x/100 && 2*…

2015-07-23 112

#Ruby
Ruby 处理 XML-RPC 消息

require "xmlrpc/marshal" str = XMLRPC::Marshal.dump( { 'Ruby' => 'is cool' } ) puts str…

2015-07-23 450

#Ruby
fxruby 显示图片,GUI,跨平台,但没有wxruby方便

#--- # Excerpted from "FXRuby: Create Lean and Mean GUIs with Ruby", # published by The Pr…

2015-07-23 442

#Ruby
Ruby线程实现经典的生产者消费者问题

require "thread" puts "ProAndCon" queue = Queue.new #用队列Queue实现线程同步 producer = Thread.new …

2015-07-22 735

#Ruby
Ruby 做 HTTP 请求时定制 Headers

require 'net/http' require 'uri' module Net class HTTP def HTTP.get_with_headers(uri, head…

2015-07-22 907

#Ruby
Ruby 使用 Gzip 和 Tar 对文件进行打包

require 'zlib' file = 'compressed.gz' Zlib::GzipWriter.open(file) do |gzip| gzip << …

2015-07-22 416

#Ruby
命令行查词典

#!/usr/bin/env ruby # encoding: utf-8 require 'net/http' require 'rexml/document' include …

2015-07-20 526
1 10 11 12 13 14 33