Skip to content

Instantly share code, notes, and snippets.

@takehiko
takehiko / paapi5search.js
Last active March 14, 2020 05:39
Product search using PA-API v5
// paapi5search.js - Product search using PA-API v5
// by takehikom
// npm install paapi5-nodejs-sdk
// npm install optparse
// npm install bitly
// node search.js 'Harry Potter'
// node search.js 9784791628889
// node search.js -t 9784393376034 -j
@takehiko
takehiko / foureights.rb
Last active January 11, 2020 01:28
Four-8 Puzzle
#!/usr/bin/env ruby
# foureights.rb : "8-((8+8)/8)" Puzzle
# by takehikom
# see also: https://takehikom.hateblo.jp/entry/2020/01/11/062120
# 環境変数LANGの値がja_JP.UTF-8などのときは,
# 日本語文字で出力する(実行時オプションで変更可能)
$option_zenkaku = /jp/i === ENV["LANG"]
@takehiko
takehiko / iidxum-versionpicker.rb
Last active December 9, 2019 20:48
Version extractor for beatmania IIDX ULTIMATE MOBILE
#!/usr/bin/env ruby
require "kconv"
# iidxum-versionpicker.rb : Version extractor for beatmania IIDX ULTIMATE MOBILE
# by takehikom
# see also: https://takehikom.hateblo.jp/entry/2019/12/10/000000
# 通信せず、27.0(という名前)のファイルを読み出して、
# game_idの値とバージョン名を見つけ、カンマ区切りで出力する
@takehiko
takehiko / iidxum-extractor.rb
Last active December 9, 2019 20:45
Free song extractor for beatmania IIDX ULTIMATE MOBILE
#!/usr/bin/env ruby
require "kconv"
# iidxum-extractor.rb : Free song extractor for beatmania IIDX ULTIMATE MOBILE
# by takehikom
# see also: https://takehikom.hateblo.jp/entry/2019/12/10/000000
# beatmania IIDX ULTIMATE MOBILEの楽曲一覧
# (https://p.eagate.573.jp/game/2dx/mobile/music/game.html?game_id=27.0 など)
@takehiko
takehiko / dotcircle.rb
Created November 10, 2019 20:27
Drawing circles connecting four points
#!/usr/bin/env ruby
# dotcircle.rb : Drawing circles connecting four points
# by takehikom
# This program invokes ImageMagick's "convert" command.
class DotcircleDrawer
def initialize
@bgcolor = "#f0fff0"
@takehiko
takehiko / quadrilateral-drawer.rb
Created September 7, 2019 03:08
Quadrilateral shape decider and drawer
#!/usr/bin/env ruby
# quadrilateral-drawer.rb : Quadrilateral shape decider and drawer
# by takehikom
# This program invokes ImageMagick's "convert" command.
class QuadrilateralDrawer
def initialize(opt = {})
@margin = (opt[:margin] || 10).to_i
@takehiko
takehiko / waza.rb
Created June 14, 2019 21:08
組体操の2冊の本からの技調査
#!/usr/bin/env ruby
# waza.rb : 組体操の2冊の本からの技調査
# by takehikom
def waza_key(w, indent = 0)
" " * indent + w[2] + "(#{w[3]}人技)"
end
waza2014 = []
@takehiko
takehiko / gf-20190611.rb
Created June 10, 2019 21:01
ワントップでないピラミッドの荷重計算
#!/usr/bin/env ruby
# gf-20190611.rb : ワントップでないピラミッドの荷重計算
# by takehikom
# git clone https://github.com/takehiko/gf.git
# ruby gf-20190611.rb
# gem install rubyXL
# ruby gf-20190611.rb -e
# ls -l gf1.xlsx gf1a.xlsx gf2.xlsx gf3.xlsx
@takehiko
takehiko / kukuniketa.rb
Last active March 11, 2019 09:54
Make 2-digit numbers that appear on the "kuku" table
#!/usr/bin/env ruby
# kukuniketa.rb : 「九九2桁」ソルバ
# by takehikom
# [0, 1, 2, 3, 4, 5, 6, 7, 8, 9]といった配列を入力にとり,
# 2個ずつ組み合わせて2桁の数を作って,いずれも九九の答えに出現する
# ものを求める.
# see also: https://takehikom.hateblo.jp/entry/2019/03/11/054444
@takehiko
takehiko / junjo-detector.rb
Created January 31, 2019 14:37
"Junjo" detector (designed for Order-of-Multiplication Dispute)
#!/usr/bin/env ruby
# junjo-detector.rb : 「かけ算の順序」(表記ゆれを含む)を見つける
# by takehikom
# ruby junjo-detector.rb
# ruby junjo-detector.rb file ...
# ruby junjo-detector.rb directory
def find_junjo(io, filename = nil)