Skip to content

Instantly share code, notes, and snippets.

@hokuto
hokuto / scrape.rb
Created April 10, 2012 14:08
web scraping
require 'net/http'
require 'fileutils'
USER_AGENT = "Mozilla/5.0 (Macintosh; Intel Mac OS X 10_7_3) AppleWebKit/535.19 (KHTML, like Gecko) Chrome/18.0.1025.151 Safari/535.19"
def getHtml(host, dir_path, file_name)
out_dir_path = "out" + dir_path
FileUtils.mkdir_p(out_dir_path) unless FileTest.exist?(out_dir_path)
http = Net::HTTP.new(host)
@hokuto
hokuto / get_cardinal_direction.rb
Created November 5, 2011 14:12
get cardinal direction
require "complex"
DIRECTION_LIST = [
"西",
"南西",
"南",
"南東",
"東",
"北東",
"北",
"北西",
create table digit as
select 0 n
union select 1
union select 2
union select 3
union select 4
union select 5
union select 6
union select 7
union select 8