require "rubygems" require "activerecord" ActiveRecord::Base.establish_connection( :adapte…
# parse ruby log message # customize as needed LOG_EXPRESSION = /([\w]+),\s+\[([^\]\s]+)\s…
def prime?(num) res = [1] res << num if num == 0 || num == 1 return false end 2.upto…
require 'win32api' class KeyBoardHelper attr_reader :ctrl, :shift, :alt, :win def initiali…
attr_accessor :tag_list
# CStruct Examples require 'cstruct' # example: # struct Point in C\C++ (32-bit platform):…
class Formatter def output_report title, text raise 'can not call Abstract method' end end…
require 'rubygems' require 'net/ssh' Net::SSH.start('example.com', :username=>'yourName…
def factorial(n) if n==0 return 1 else return n*factorial(n-1) end end def combination(x,y…
#!/usr/bin/ruby require 'cgi' cgi = CGI.new text = cgi['text'] puts cgi.header puts "<h…
#encoding: utf-8 arr = ['石头', '剪刀', '布'] win_arr = [['石头', '剪刀'], ['剪刀', '布'], ['布', '石头']…
#!/usr/bin/env ruby # wxRuby2 Sample Code. Copyright (c) 2004-2008 wxRuby development team…
使用Ruby和Nokogiri的网页爬虫例子,导出RSS种子