This file contains 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
def get_toc_source | |
toc_url = @setting["toc_url"] | |
return nil unless toc_url | |
max_retry = 5 | |
toc_source = "" | |
cookie = @setting["cookie"] || "" | |
proxy = ["http://YOUR_PROXY_IP:PORT", "user", "password"] | |
open_uri_options = make_open_uri_options("Cookie" => cookie, allow_redirections: :safe, proxy_http_basic_authentication: proxy) | |
begin | |
open(toc_url, open_uri_options) do |toc_fp| |
This file contains 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 "yaml" | |
require "ostruct" | |
require "time" | |
require "pp" | |
database = {} | |
def date_string_to_time(date) | |
date.is_a?(Time) ? date : Time.parse(date.sub(/[\((].+?[\))]/, "").tr("年月日時分秒@;", "///::: :")) | |
end |
This file contains 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
ranking_org = (0..46).to_a | |
require 'benchmark' | |
Benchmark.bm 12 do |r| | |
r.report "top3: range" do | |
10000000.times do | |
ranking = ranking_org.dup | |
top3 = ranking[0..2] |
This file contains 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
# -*- coding: utf-8 -*- | |
# | |
# Copyright 2013 whiteleaf. All rights reserved. | |
# | |
module Device::Kobo | |
PHYSICAL_SUPPORT = true | |
VOLUME_NAME = "KOBOeReader" | |
DOCUMENTS_PATH_LIST = ["/"] | |
EBOOK_FILE_EXT = ".kepub.epub" |
This file contains 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
converter "test_convert_numbers.txt" do | |
def _stash_number_cache(match) | |
@_number_string_cache ||= {} | |
index = convert_numbers(@_number_string_cache.size.to_s) | |
@_number_string_cache[index] = match | |
"[#数字キャッシュ=#{index}]" | |
end | |
def _rebuild_number_cache(io) |
This file contains 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
var amazon_url_regexp = /(http:\/\/www\.amazon\.(?:com|co\.jp))\/(.+)/; | |
var shell = new ActiveXObject("WScript.Shell"); | |
function short_amazon_link(text) { | |
if (!text.split(/%3F|\?/i)[0].match(amazon_url_regexp)) return null; | |
var matches = [RegExp.$1]; | |
var elements = RegExp.$2.split("/"); | |
for (var i = 0; i < elements.length; i++) { | |
if (elements[i].match(/^\w+$/)) { | |
matches.push(elements[i]); |
This file contains 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
function AmazonLinker() { | |
this.initialize(); | |
} | |
AmazonLinker.prototype = { | |
amazon_url_regexp: /(http:\/\/www\.amazon\.(?:com|co\.jp))\/(.+)/, | |
active_mode_interval: 500, | |
inactive_mode_interval: 10 * 1000, | |
shift_to_inactive_mode_timeout: 10 * 60 * 1000, |
This file contains 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 NilClass | |
def method_missing(args) | |
nil | |
end | |
end | |
module Optional | |
def method_missing(method_name, *args) | |
if method_name =~ /\?$/ |
This file contains 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
<%# -*- coding: utf-8 -*- -%> | |
<% Template.target_binary_version(1.0) -%> | |
<%= toc["title"] %> | |
<%= toc["author"] %> | |
<%= cover_chuki %> | |
[#区切り線] | |
<% if toc["story"] != "" -%> | |
あらすじ: | |
<%= toc["story"] %> |
This file contains 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
# -*- coding: utf-8 -*- | |
# | |
# Copyright 2014 whiteleaf. All rights reserved. | |
# | |
require_relative "winapi" | |
module Clipboard | |
class NotOpenClipboardError < StandardError; end |
NewerOlder