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

ruby 388

#Ruby
9行代码实现scp

#gem install net-ssh #gem install net-sftp require 'rubygems' require 'net/ssh' require 'n…

2015-08-15 396

#Ruby
共享作用域

def define_methods shared = 0 Kernel.send :define_method, :counter do p shared end Kernel.…

2015-08-15 933

#Ruby
redmine自定义长文本字段显示及导出pdf排版问题临时解决方案

# encoding: utf-8 # # Redmine - project management software # Copyright (C) 2006-2013 Jean…

2015-08-13 276

#Ruby
对ary.product(other_ary, …)方法的一点扩充

def flatten(array, arr) begin unless array[0].flatten.size == array[0].size flatten(array[…

2015-08-12 590

#Ruby
Ruby 编写一个简单的 XML RPC 客户端

require 'xmlrpc/client' server = XMLRPC::Client.new2('http://yourURL') server.call('yourme…

2015-08-12 376

#Ruby
Ruby 打开 Windows 的文件对话框

require "win32ole" cd = WIN32OLE.new("MSComDlg.CommonDialog") cd.filter = "All Files(*.*)|…

2015-08-12 274

#Ruby
Rails 显示随机图片

class HelloController < ApplicationController def show @images = ["image1.jpg", "image2…

2015-08-11 693

#Ruby
平均数/中间数 mean/median

class Array def mean inject(0) {|sum, x| sum += x} / size.to_f end def median sorted = sel…

2015-08-10 446

#Ruby
Ruby解析xls和xlsx文件

desc "转换excel到csv" task :covert_excel_to_csv => :environment do # 读取所有的xls和xlsx文件 excel…

2015-08-08 181

#Ruby
Hpricot 使用 CSS 的类来搜索 HTML 文档中的元素

require 'rubygems' require 'hpricot' require 'open-uri' doc = Hpricot(open('http://www.rub…

2015-08-06 878

#Ruby
Ruby 使用 Win32API 获取函数指针

require "Win32API" def system(cmd) sys = Win32API.new("crtdll", "system", ['P'], 'L') sys.…

2015-08-05 259

#Ruby
Brainfuck 解释器

def parseBF(bf) ptrIndex = 0 i = 0 x = -1 ptr = Array.new(bf.length, 0) #create an array t…

2015-08-03 759
1 9 10 11 12 13 33