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

ruby 388

#Ruby
Ruby:最大公因数/最小公倍数

print "Enter one number:" n1 = gets.to_i print "Enter another number:" n2 = gets.to_i gcf …

2015-07-19 293

#Ruby
Ruby/GTK 版本的 "Hello, World" 程序

require 'gtk' window = Gtk::Window::new button = Gtk::Button::new("Hello, World!") button.…

2015-07-18 861

#Ruby
Ruby 对字符串进行转码

require 'iconv' input_encoding = "windows-1252" output_encoding = 'utf-8' converted_doc = …

2015-07-18 467

#Ruby
ruby 16种 hello world 写法

print '1 hello world! ' + "\n" print "2 hello world!\n" print('3 hello world! ' + 10.chr )…

2015-07-16 735

#Ruby
读写yaml文件

require 'yaml' hash = {1 => 'sqlite3', 2 => 'postgresql', 3 => 'mssql', 4 => '…

2015-07-16 253

#Ruby
一行代码让Linux终端下雪

#先运行irb 或 pry C=`stty size`.split[1].to_i;S=[0x2743].pack("U*");a={};puts "\033[2J";loop{a…

2015-07-14 974

#Ruby
Ruby 打开 Word 文档并打印

require "win32ole" docfile = "yourDoc.doc" word = WIN32OLE.new "Word.Application" word.vis…

2015-07-14 527

#Ruby
ruby unit

#!/usr/bin/env ruby #-w # coding:gbk #''' # author: leijming # date :20120701 #''' load 'p…

2015-07-14 565

#Ruby
Ruby将网页中的图片保存到本地

require 'net/http' Net::HTTP.start("www.google.com.hk") { |http| resp = http.get("/images/…

2015-07-14 636

#Ruby
树状结构输出文件目录结构

 require 'find' class Recorder attr_accessor :fileSteam def initialize(outputFilePath) @f…

2015-07-12 696

#Ruby
Ruby 读取 mysql 命令输出

require 'socket' client = TCPSocket.open('127.0.0.1', 'finger') client.send("mysql\n", 0) …

2015-07-10 855

#Ruby
Rails 使用数据库事务 (ActiveRecord)

my_account = Account.find 3 your_account = Account.find 4 Account.transaction do my_accoun…

2015-07-05 138
1 11 12 13 14 15 33