ruby 388

#Ruby
Rails 连接到 MySQL 数据库

require "rubygems" require "activerecord" ActiveRecord::Base.establish_connection( :adapte…

2015-09-10 242

#Ruby
正则表达式来解析Ruby的日志消息

# parse ruby log message # customize as needed LOG_EXPRESSION = /([\w]+),\s+\[([^\]\s]+)\s…

2015-09-08 638

#Ruby
判断一个数是否为质数

def prime?(num) res = [1] res << num if num == 0 || num == 1 return false end 2.upto…

2015-09-07 611

#Ruby
Ruby调用WindowsAPI模拟按键

require 'win32api' class KeyBoardHelper attr_reader :ctrl, :shift, :alt, :win def initiali…

2015-09-06 533

#Ruby
Android Tips

attr_accessor :tag_list

2015-09-06 217

#Ruby
Ruby 仿 C 结构体:CStruct 的一些例子

# CStruct Examples require 'cstruct' # example: # struct Point in C\C++ (32-bit platform):…

2015-09-05 179

#Ruby
Ruby策略模式2

class Formatter def output_report title, text raise 'can not call Abstract method' end end…

2015-09-04 610

#Ruby
Ruby 改变 SSH 上的当前目录

require 'rubygems' require 'net/ssh' Net::SSH.start('example.com', :username=>'yourName…

2015-09-03 820

#Ruby
Combination Finder

def factorial(n) if n==0 return 1 else return n*factorial(n-1) end end def combination(x,y…

2015-08-31 307

#Ruby
Ruby 访问 CGI 变量

#!/usr/bin/ruby require 'cgi' cgi = CGI.new text = cgi['text'] puts cgi.header puts "<h…

2015-08-30 512

#Ruby
石头剪刀布ruby版

#encoding: utf-8 arr = ['石头', '剪刀', '布'] win_arr = [['石头', '剪刀'], ['剪刀', '布'], ['布', '石头']…

2015-08-30 790

#Ruby
wxruby 显示图片, GUI,跨平台

#!/usr/bin/env ruby # wxRuby2 Sample Code. Copyright (c) 2004-2008 wxRuby development team…

2015-08-28 261
1 7 8 9 10 11 33