Skip to content

Instantly share code, notes, and snippets.

@takehiko
takehiko / aozora-picker.rb
Created October 23, 2015 21:17
Intro Extractor for Articles in Aozora Bunko
#!/usr/bin/env ruby
# aozora-picker.rb : 青空文庫収録作品のイントロ収集
# by takehikom
# usage:
# ruby aozora-picker.rb
# ruby aozora-picker.rb wa
# ruby aozora-picker.rb /path/to/github/aozorabunko/index_pages/sakuhin_wa?.html
# see also:
# http://www.aozora.gr.jp/
@takehiko
takehiko / gf_build.rb
Last active October 18, 2015 17:06
How to Build Trigonal Human Pyramids
#!/usr/bin/env ruby
# gf_build.rb - How to Build Trigonal Human Pyramids
# by takehikom
# see also:
# https://gist.github.com/takehiko/a32f51e2eabba4f821d8
# http://d.hatena.ne.jp/takehikom/20151020/1445266800
# usage:
# ruby gf_build.rb
# ruby gf_build.rb -p 11
@takehiko
takehiko / gfload_est.rb
Last active October 18, 2015 17:07
Load Estimator of Trigonal Human Pyramids
#!/usr/bin/env ruby
# gfload_est.rb - Load Estimator of Trigonal Human Pyramids
# by takehikom
# see also:
# https://gist.github.com/takehiko/a32f51e2eabba4f821d8
# http://d.hatena.ne.jp/takehikom/20151019/1445266799
# usage:
# ruby gfload_est.rb
# ruby gfload_est.rb -p 7 -m 0
@takehiko
takehiko / gfload+.rb
Last active October 16, 2015 21:19
Load Estimation of Trigonal Human Pyramids
#!/usr/bin/env ruby
# gfload+.rb : Load Estimation of Trigonal Human Pyramids
# by takehikom
# see also:
# https://gist.github.com/takehiko/a32f51e2eabba4f821d8
# http://d.hatena.ne.jp/takehikom/20151016/1444941800
# http://d.hatena.ne.jp/takehikom/20151018/1445094000
require_relative "gfload.rb"
@takehiko
takehiko / gfload.rb
Created October 15, 2015 20:30
Load Calculator for Gymnastic Formation
#!/usr/bin/env ruby
# gfload.rb : Load Calculator for Gymnastic Formation
# by takehikom
require 'optparse'
module GFLoad
module Helper
SEPARATOR = "."
@takehiko
takehiko / kanatrie.rb
Created August 13, 2015 22:34
Romanization Rule into Trie
#!/usr/bin/env ruby
# kanatrie.rb : ローマ字の綴りをトライ木に(ヘボン式・訓令式・日本式に対応)
# by takehikom
# required: KAKASI, Graphviz
def create_romaji_kana_hash(option = {})
if option[:label]
puts "==== #{option[:label]} ===="
@takehiko
takehiko / n-win-m-match.rb
Created May 19, 2015 12:00
Winning ratios
#!/usr/bin/env ruby
# n-win-m-match.rb : じゃんけんをm回やって,そのうちn回以上勝つ確率
# by takehikom
require "rational"
class NWinMMatch
def initialize(opt = {})
@choose = {} # 2項係数
@takehiko
takehiko / tatami.rb
Created May 7, 2015 21:07
A solver of tatami mat arrangement problem
#!/usr/bin/env ruby
# tatami.rb : A solver of tatami mat arrangement problem
# by takehikom
module Tatami
class Arranger
def initialize(w = 4, h = 4, opt = {})
@width = w
@height = h
@takehiko
takehiko / assocchecker.rb
Created April 29, 2015 21:04
Associativity checker for well-known logical operations
#!/usr/bin/env ruby
# assocchecker.rb : associativity checker for well-known logical operations
# by takehikom
class AssociativityChecker
def initialize
end
def and(*param)
@takehiko
takehiko / isilx.rb
Created April 27, 2015 20:30
ISIL extractor
#!/usr/bin/env ruby
# isilx.rb : ISIL extractor
# by takehikom
# see also: http://www.ndl.go.jp/jp/aboutus/standards/opendataset.html
require 'rexml/document'
class IsilExtractor