View gist:469245
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
module Kernel | |
def installed?(cmd) | |
FileTest.executable?(`which #{cmd}`.strip) | |
end | |
end |
View twitter_bot.rb
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 | |
$: << File.expand_path('~/src/net-irc/lib') | |
require 'net/irc' | |
class Bot < Net::IRC::Client | |
include Net::IRC::Constants | |
def on_rpl_welcome(m) |
View remtter.rb
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 | |
# !!!!! OAuth !!!!! | |
require "rubygems" | |
require "logger" | |
require "net/http" | |
require "json" | |
class Remtter |
View sokuho.rb
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 -Ku | |
require 'net/http' | |
require 'rubygems' | |
require 'nokogiri' | |
require 'meow' | |
TOPURL = 'http://baseball.yahoo.co.jp/npb/schedule/' |
View index_holded_list.rb
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
class IndexHoldedList < ::Hash | |
def [](n) | |
raise ArgumentError unless Integer === n | |
self.fetch(n) | |
end | |
def []=(n, value) | |
raise ArgumentError unless Integer === n | |
self.store(n, value) | |
end |
View MyVector.scala
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
class MyVector(val x: Double, val y: Double) { | |
override def toString: String = { | |
"MyVector(" + x + ", " + y + ")" | |
} | |
def length: Double = { | |
Math.sqrt(x * x + y * y) | |
} | |
def direction: Double = { |
View gist:753162
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 | |
tracks = [] << %w(鮮やか な 殺人) << %w(テレキャスター の 真実) << | |
%w(Sadistic Summer) << %w(ターボチャージャー ON) << %w(Acoustic) << | |
%w(O F T) << %w(CRAZY 感情 STYLE) << %w(トルネード G) << %w(傍観) << | |
%w(TK in the 夕景) << %w(想像 の Security) << %w(感覚 UFO) << | |
%w(秋 の 気配 の アルペジオ) << %w(ラスト ダンス レボリューション) << | |
%w(Sergio Echigo) << %w(nakano kill you) << %w(COOL J) << %w(DISCO FLIGHT) << | |
%w(knife vacation) << %w(am 3:45) << %w(赤い 誘惑) << %w(1/f の 誘惑) << | |
%w(i not crazy am you are) << %w(夕景 の 記憶) << %w(Telecastic fake show) << |
View collatz.rb
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 | |
def collatz(n) | |
n == 0 || n == 1 ? n : n.even? ? collatz n / 2 : collatz n * 3 + 1 | |
end | |
1.upto(3 * 2 ** 52).all? {|i| collatz(i) == 1 } # -> true |
View gist:798444
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 'fileutils' | |
# ./src/README | |
# ./dst/ | |
FileUtils::DryRun.copy_entry 'src/', 'dst/' | |
# ./src/README |
View gist:857556
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 | |
# -*- encoding: utf-8 -*- | |
f_numbers = Dir.glob("**/*.jpg").map {|jpg| | |
`jhead #{jpg}`.gsub(%r{Aperture\s*:\s*(?:f/(\d+(?:\.\d+)?))}) { $1 } | |
}.compact.map {|f| f.to_f } | |
f_numbers.group_by {|f| f_numbers.count(f) }.each do |freq, f| | |
puts "#{freq}: #{f.uniq.join(",")}" | |
end |