ruby 388

#Ruby
Rails 之 find_by_sql 一例

drop database Contact; create database Contact; use Contact; CREATE TABLE Employee ( id in…

2015-11-08 339

#Ruby
ruby 自动对时器 Windows

#! rubyw.exe # encoding: gbk require 'socket' require 'time' require 'cstruct/win32struct'…

2015-11-08 473

#Ruby
Ruby 使用 Hpricot 进行 HTML 文档解析

require 'hpricot' html = <<END_OF_HTML <html> <head> <title>This i…

2015-11-08 822

#Ruby
水仙花数(narcissus number)

#method1 puts (10**2...10**6).select{|n| n.to_s.bytes.map{|x| x-48}.map{|x| x**n.to_s.size…

2015-11-07 561

#Ruby
Ruby 用 Ping 来检查机器和服务的状态

require 'ping' puts "Pong!" if Ping.pingecho('localhost', 5)

2015-11-06 513

#Ruby
用 Ruby 进行简单的 lisp 表达式的解析

def parse(line) s = line.scan(/\(|\)|"(?:\\.|[^"])*"|[^()" \n]+/) f = ->(t=nil){ case x…

2015-11-05 443

#Ruby
疯狂代码zz–ruby一段代码生成11种语言

ruby 1.8.7-p72 Python 2.5.2 perl v5.10.0 Lua 5.0.3 OCaml 3.10.2 ghc-6.8.2 gcc 4.3.2 java "…

2015-11-05 136

#Ruby
Ruby 取出两数列中相同元素后,形成新的数列

array1 = [1, 3, 5, 6, 7, 9] array2 = [1, 4, 5, 6, 8, 9, 10, 20] p array1 & array2

2015-11-05 483

#Ruby
Ruby 使用 FeedTools 解析 RSS

require 'rubygems' require 'feed_tools' feed = FeedTools::Feed.open('http://www.rubyinside…

2015-11-04 359

#Ruby
模糊查找一个对象的方法

"a".methods.grep /case/

2015-11-02 467

#Ruby
Rails的加权平均计算器

class AveController < ApplicationController def index end def calculate @i=0 @course_nu…

2015-11-02 373