ruby 388

#Ruby
ruby 实现了杨辉三角

class Sanjiao def initialize(row) @row = row end def sanjiaoxing(temp) number = temp.lengt…

2015-10-30 471

#Ruby
对比两个目录中的文件改动

#!/usr/bin/ruby require 'set' def rdiff (src_path, dst_path) if (File.exist?(src_path)) th…

2015-10-29 431

#Ruby
Ruby 解析域名对应的 IP 地址

require 'resolv' puts Resolv.getaddress("http://www.google.com/")

2015-10-26 562

#Ruby
Ruby 连接到 Ruby的Web服务器

require 'socket' socket = TCPSocket.new("www.ruby-lang.org", 80) socket.puts "GET /en/inde…

2015-10-26 511

#Ruby
Ruby 获取所有可用的 DBI 数据库驱动

require 'dbi' DBI.available_drivers.each do |driver| puts "Driver: " + driver DBI.data_sou…

2015-10-25 309

#Ruby
在ruby使用ssh连接linux服务器

require 'net/ssh' host = hostip username = username password = pwd ##显示文件和系统版本 server_cmd1…

2015-10-25 928

#Ruby
Ruby 继承 Gtk::Window

require "gtk" class SampleWindow < Gtk::Window def initialize super set_title("Ruby/GTK…

2015-10-24 175

#Ruby
最强大的which whereis 命令

# which.rb xxx # name = ARGV[0] inc = ENV['INCLUDE'].split(/;/) rescue [] lib = ENV['LIB']…

2015-10-24 129

#Ruby
Ruby 抽取 HTML 文档中的所有 URL 地址

require 'uri' text = %{"test <a href="http://www.a.com/">http://www.a.com/</a>…

2015-10-23 570

#Ruby
Ruby策略模式

class Hero def kill(bug, skill) skill.do(bug) end end class Skill def do(bug="bug") raise …

2015-10-22 639

#Ruby
ruby rot13加密

class String def rot13 self.tr "A-Za-z", "N-ZA-Mn-za-m" end end #用法: #str="abc" #print str…

2015-10-22 793

#Ruby
多线程端口扫描

#!/usr/bin/ruby # -*- coding: utf-8 -*- require 'socket' include Socket::Constants require…

2015-10-19 764
1 3 4 5 6 7 33