This file contains hidden or 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
require "rubygems" | |
require "nokogiri" | |
require "httpclient" | |
require "uri" | |
require "json" | |
class Pager | |
@@siteinfo_url = "http://wedata.net/databases/AutoPagerize/items.json" | |
attr_accessor :doc |
This file contains hidden or 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
{ | |
name: 'tabundle', | |
domain: 'file:\/\/\/Users\/.+\/Library\/Application%20Support\/Firefox\/Profiles\/.+\/tabundle\/.+\.html', | |
paragraph: '//li', | |
link: './div[@class="url"]/a', | |
stripe: false, | |
} |
This file contains hidden or 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
require "rubygems" | |
require "nokogiri" | |
require "open-uri" | |
require "uri" | |
class SimplePager | |
include Enumerable | |
attr_reader :doc, :original_url, :current_url | |
This file contains hidden or 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
require "rubygems" | |
require "nokogiri" | |
require "open-uri" | |
require "shell" | |
doc = Nokogiri::HTML(open("http://www.stylegala.com/features/bulletmadness/")) | |
sh = Shell.new | |
doc.xpath("//ul[@class='bulletlist']/li/img").each do |img| | |
src = img.attributes["src"].gsub(" ", "%20") |
This file contains hidden or 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
extensions = ["png", "gif", "ico", "bmp", "jpg"] | |
pattern = Regexp.new("(\." + extensions.join("$|\.") + "$)") | |
target = ARGV[0] || "." | |
puts "<html>" | |
puts " <head>" | |
puts " <title>Images</title>" | |
puts " <style>" | |
puts " * {margin:0;padding:5px;}" |
This file contains hidden or 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
require "rubygems" | |
require "open-uri" | |
require "nokogiri" | |
BASE_URL = "http://albertayu773.pixnet.net/album/set/14344750" | |
LINK_XPATH = "//div[@class='thumbList']/ul/li/div/span/a" | |
IMG_XPATH = "id('imageFrame')//img" | |
NEXT_XPATH = "//a[@class='pageNext']" | |
SLEEP_TIME = 3 |
This file contains hidden or 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 String | |
def to_xml | |
self.unpack('U*').collect { |c| | |
if c >= 255 | |
'&#' + c.to_s + ';' | |
elsif c == 165 || c == 92 | |
'\\' | |
else | |
c.chr | |
end |
This file contains hidden or 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
require "iconv" | |
require "nkf" | |
require "kconv" | |
string = "何をするだァーッ" | |
puts string | |
puts Iconv.conv("Shift_JIS", "UTF-8", string) | |
puts NKF.nkf("-e", string) |
This file contains hidden or 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
require "uri" | |
require "rubygems" | |
require "eventmachine" | |
require "em-websocket" | |
require "yajl/http_stream" | |
require "json" | |
require "pit" | |
account = Pit.get("twitter", :require => { | |
"username" => "username", |