This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
#!/usr/bin/env ruby | |
require 'rubygems' | |
require 'tw' | |
require 'json' | |
data = {} | |
data['type'] = 'df' | |
data['time'] = Time.now | |
percent = 0 |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
require 'rubygems' | |
require 'nokogiri' | |
require 'open-uri' | |
doc = Nokogiri::HTML(open('http://enoshima-yacht-harbor.jp/kishou.htm')) | |
tds=doc.xpath("//td") | |
as = tds[16].xpath(".//b").text.sub(/[^\d\.].*$/,'') | |
ad = tds[19].xpath(".//b").text | |
ms = tds[22].xpath(".//b").text.sub(/[^\d\.].*$/,'') |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
require 'rubygems' | |
require 'active_record' | |
# | |
# infinite-wave-43 (Crane) | |
# | |
ActiveRecord::Base.establish_connection( | |
:adapter => 'postgresql', | |
:encoding => 'unicode', | |
:pool => '5', | |
:database => 'd7kfs1aexxxxxx', |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
require 'rubygems' | |
require 're_expand' | |
'(ab)+'.expand { |a| | |
puts a[0] | |
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
require 'rubygems' | |
require 're_expand' | |
'(1|2|3|4)*'.expand(' 222 ',1) { |a| | |
puts a[0] | |
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
require 'rubygems' | |
require 're_expand' | |
"(月|火|水|木|金)曜(1|2|3|4|5|6)限".expand { |a| | |
puts "#{a[0]} #{a[1]} #{a[2]}" | |
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
# 3の倍数にマッチする正規表現 | |
require 'rubygems' | |
require 're_expand' | |
pat = "(0|1(0|1(0)*2)*(2|1(0)*1)|2(0|2(0)*1)*(1|2(0)*2))+" | |
pat.gsub!(/0/,'(0|3|6|9)') | |
pat.gsub!(/1/,'(1|4|7)') | |
pat.gsub!(/2/,'(2|5|8)') | |
pat.expand { |a| | |
puts a[0] | |
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
#!/usr/bin/ruby | |
# | |
# フィボナッチ数列を生成してブロックを渡す | |
# | |
class Fib | |
def self.calc | |
fib = [1,1] | |
loop do | |
yield fib[0] | |
fib.push fib.shift + fib[0] |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
#!/usr/bin/ruby | |
# | |
# フィボナッチ数列を出力 | |
# | |
fib = [1,1] | |
loop do | |
puts fib[0] | |
fib.push fib.shift + fib[0] | |
end |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
def fact(n) | |
n > 1 ? n * fact(n-1) : 1 | |
end | |
puts fact(10000000) |