ruby 388

#Ruby
使用mechanize分析并批量下载校内网相册照片

#encoding: utf-8 require 'rubygems' require 'mechanize' class Renren def initialize(e,p) @…

2015-10-09 202

#Ruby
Ruby :编写一个 XML-RPC 程序

require 'xmlrpc/server' server = XMLRPC::Server.new(1234) server.add_handler("sample.sumAn…

2015-10-05 920

#Ruby
ruby使用Win32API操作鼠标

#要求ruby1.8.x require 'Win32API' #定义API GetCursorPos和SetCursorPos的接口 get_cursor_pos = Win32…

2015-10-05 320

#Ruby
Rails 实现页面的基本认证 (Basic Authentication)

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

2015-10-04 352

#Ruby
Ruby Socket编程实例

require "socket" def testTCPServer server = TCPServer.new 2000 # Server bound to port 2000…

2015-10-02 135

#Ruby
Ruby 使用 HTTP 代理的例子

require 'net/http' web_proxy = Net::HTTP::Proxy('your.proxy.hostname.or.ip', 8080) url = U…

2015-10-02 150

#Ruby
Ruby 使用 gserver 创建一个简单的网络服务程序

require 'gserver' class HelloServer < GServer def serve(io) io.puts("Hello!") end end s…

2015-10-01 626

#Ruby
Linux 一键静音脚本

#!/usr/bin/env ruby #alsactl -F init # if can't unmute s = `amixer get Master` val = s.sca…

2015-09-29 895

#Ruby
莱布尼茨公式 估算PI

#The Leibniz formula: 1-(1/3)+(1/5)-(1/7)+(1/9)... def pi(prec) denom = 3.0 mod = -1.0 res…

2015-09-27 975

#Ruby
Ruby 在 Windows 下读取键盘输入

require 'Win32API' def getch @getch ||= Win32API.new('crtdll', '_getch', [], 'L') @getch.c…

2015-09-26 685

#Ruby
判断一组数字是否是Pythagorean Triple/Quadruple

def isPyTri?(a, b, c) if (a**2 + b**2 == c**2) return true else return false end end def i…

2015-09-24 234

#Ruby
爬取指定页面链连

require 'rubygems' require 'open-uri' url_hash = {} open('http://www.cnblogs.com/TomXu/arc…

2015-09-23 487
1 5 6 7 8 9 33