Skip to content

Instantly share code, notes, and snippets.

View naoranger's full-sized avatar

Naoyuki Mitsuboshi naoranger

View GitHub Profile
@naoranger
naoranger / .tm_properties
Created August 22, 2012 21:20
.tm_properties sample
fontName = "Menlo"
fontSize = 12
myExtraIncludes = ".tm_properties,.htaccess,.git*,.env"
fileBrowserGlob = "{*,$myExtraIncludes}"
include = "{$include,$myExtraIncludes}"
myExtraExcludes = "log,vendor,tmp,*sqlite3,.sass-cache,.DS_Store"
excludeInFileChooser = "{$excludeInFileChooser,$myExtraExcludes}"
excludeInFolderSearch = "{$excludeInFolderSearch,$myExtraExcludes}"
@naoranger
naoranger / horikoji.rb
Created August 18, 2012 03:18
horikoji sample
require 'nokogiri'
require 'open-uri'
url = "https://dl.dropbox.com/u/11503045/rbsmp1.html"
doc = Nokogiri::HTML(open(url).read, nil, 'Shift_JIS')
doc.xpath('//body').children.each_with_index do |item, i|
p "#{i}:#{item.text}"
p item.text.scan(/\w+/)[0]
end
@naoranger
naoranger / google.rb
Created August 9, 2012 03:08
mechanize sample google
require 'mechanize'
agent = Mechanize.new
agent.user_agent_alias = 'Mac Safari'
uri = URI.parse('http://google.com/')
page = agent.get(uri)
sbox = page.form_with(name: 'gbqf')
sbox.q = 'crucial ssd'
result = agent.submit(sbox)
@naoranger
naoranger / tenki.rb
Created August 9, 2012 02:52
nokogiri sample tenki
require 'nokogiri'
require 'open-uri'
url = "http://tenki.jp/"
doc = Nokogiri::HTML(open(url).read)
doc.xpath('//ul[@class="localList"]//li').each do |item|
# u = item.xpath('.//a').attribute('href')
puts item.xpath('.//a').text
# puts item.xpath('.//a/attribute::href').first
# puts item.search('a').attribute('href')
@naoranger
naoranger / kakaku.rb
Created August 9, 2012 02:51
nokogiri sample kakaku
require 'nokogiri'
require 'open-uri'
keyword = "crucial+ssd"
page = open("http://kakaku.com/search_results/#{keyword}/?sort=priceb")
html = Nokogiri::HTML(page.read, nil, 'Shift_JIS')
puts html.xpath('//p[@class="itemnameN"]//a').text
puts html.xpath('//span[@class="yen"]//a').text