Skip to content

Instantly share code, notes, and snippets.

Avatar

Kakutani Shintaro kakutani

View GitHub Profile
View amazon_sales_rank.rb
#!/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
View 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)'
View gist:8408
# benchmarking yaml_waml converting string.
require 'benchmark'
require 'yaml'
class String
def is_binary_data?
false
end
end
View gist:17682
require 'date'
a = Date.new(2008,10,2)
b = Date.new(2008,10,2)
a == b # true
a.eql? # true
a.equal? b # false
View gist:17683
require 'date'
a = Date.new(2008,10,2)
b = Date.new(2008,10,2)
a == b # true
a.eql? # true
a.equal? b # false
View yaml_compatible_spec.rb.patch
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
View amzbm.js
javascript:var%20asin=document.getElementById('ASIN').value;location.href='http://amazon.jp/o/ASIN/'+asin%20+%20'/kakutani-22';
View gist:62091
ruby191 -e '([-> v {"Ruby #{v[:n]}!\n"}.(n: "1.9.1")] * 100).each(&:display)'
View gist:119162
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
View debugee.rb
#!/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