Skip to content

Instantly share code, notes, and snippets.

View kakutani's full-sized avatar

Kakutani Shintaro kakutani

View GitHub Profile
#!/usr/bin/env ruby
# -*- coding: utf-8 -*-
require 'rubygems'
require 'hpricot'
require 'open-uri'
require 'nkf'
$KCODE = "u" if VERSION < "1.9.0"
class AmazonItem
attr_accessor :asin
@kakutani
kakutani / screen.rb
Created August 28, 2008 16:55 — forked from yoshuki/screen.rb
##
# Autotest::Screen is test result notify GNU Screen's statusline.
#
# === screenshots
# * <img src="http://f.hatena.ne.jp/images/fotolife/s/secondlife/20061109/20061109015543.png" />
# * <img src="http://f.hatena.ne.jp/images/fotolife/s/secondlife/20061109/20061109015522.png" />
#
# == SYNOPSIS
# require 'autotest/screen'
# # Autotest::Screen.statusline = '%H %`%-w%{=b bw}%n %t%{-}%+w (your statusline)'
@kakutani
kakutani / gist:8408
Created September 2, 2008 13:38 — forked from walf443/gist:8407
# benchmarking yaml_waml converting string.
require 'benchmark'
require 'yaml'
class String
def is_binary_data?
false
end
end
require 'date'
a = Date.new(2008,10,2)
b = Date.new(2008,10,2)
a == b # true
a.eql? # true
a.equal? b # false
require 'date'
a = Date.new(2008,10,2)
b = Date.new(2008,10,2)
a == b # true
a.eql? # true
a.equal? b # false
diff --git a/spec/yaml_compatible_spec.rb b/spec/yaml_compatible_spec.rb
index 82d4293..d613253 100644
--- a/spec/yaml_compatible_spec.rb
+++ b/spec/yaml_compatible_spec.rb
@@ -127,5 +127,9 @@ EOF_TEST_DATA
end
end
rescue LoadError => e
- warn "this spec require rspec-fixture."
+ describe "rspec-fixture gem" do
javascript:var%20asin=document.getElementById('ASIN').value;location.href='http://amazon.jp/o/ASIN/'+asin%20+%20'/kakutani-22';
ruby191 -e '([-> v {"Ruby #{v[:n]}!\n"}.(n: "1.9.1")] * 100).each(&:display)'
require 'fileutils'
require 'action_controller/test_process'
module UploadedDataHelper
def uploaded_data_of(path, mime_type = :auto)
mime_type = detect_mimetype_of(File.basename(path)) if mime_type == :auto
use_temppath(path) do |temppath|
return ActionController::TestUploadedFile.new(temppath, mime_type)
end
end
#!/usr/bin/env ruby
require 'rubygems'
require 'ruby-debug'
Debugger.start
def pow(x, n)
debugger if n == 1 # start debugger when n == 1
raise if n < 0
if n == 0
return 1