Skip to content

Instantly share code, notes, and snippets.

@takehiko
takehiko / icosa-drawer.rb
Created January 1, 2019 13:42
Drawing SVG images of a regular icosahedron with "kuku" forms along the sides
#!/usr/bin/env ruby
# icosa-drawer.rb : drawing SVG images of a regular icosahedron
# with "kuku" forms along the sides
# by takehikom
module IcosaDrawer
class Triangle
def initialize(param = {})
@label = param[:label]
@takehiko
takehiko / inome-drawer.rb
Last active June 19, 2018 17:34
Drawing "inome", a traditional Japanese design in the shape of a heart
#!/usr/bin/env ruby
# inome-drawer.rb : drawing "inome", a traditional Japanese design in the shape of a heart
# by takehikom
# See also:
# http://shoujuin.boo.jp/?page_id=466
# http://d.hatena.ne.jp/takehikom/20180619/1529420399
class InomeDrawer
@takehiko
takehiko / trisub.rb
Created June 4, 2018 13:56
A solver of triangular subtraction problem
#!/usr/bin/env ruby
# trisub.rb : a solver of triangular subtraction problem
# by takehikom
# Usage:
# ruby trisub.rb
# ruby trisub.rb 4
# ruby trisub.rb 5
# ruby trisub.rb 6 # no answer
@takehiko
takehiko / colorshow.c
Created April 28, 2018 07:07
colorshow.c
/*
* colorchow.c : ANSIエスケープシーケンスを利用して,
大文字を赤色,小文字を青色で表示する.
* 作成者: 村川猛彦 ([email protected])
* コンパイル方法: cc colorshow.c -o colorshow
* 実行方法: cat report1-cipher.txt | sed -e 'y/ABC/xyz/' | ./colorshow
*/
#include <stdio.h>
#include <ctype.h>
@takehiko
takehiko / dominationgame.svg
Last active February 17, 2018 01:24
A domination game; you can click panels to change the color.
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
@takehiko
takehiko / repeat3.rb
Created January 7, 2018 19:20
An inspector of a string that occurs three times successively, and generators
#!/usr/bin/env ruby
# repeat3.rb : an inspector of a string that occurs three times successively,
# and generators of a string which consists of "a" and "b"
# and has no substring that occurs three times successively
# by takehikom
module Repeat3
class Inspector
def initialize
@takehiko
takehiko / kanji-by-kakusu.rb
Created January 2, 2018 23:44
Print kanji (Chinese characters) within 15 stroke counts
#!/usr/bin/env ruby
# kanji-by-kakusu.rb : print kanji (Chinese characters) within 15 stroke counts
# by takehikom
# 小学校で学習する15画以下の漢字をすべて出力する(他の画数,制限なしにも対応)
# 画数情報は,漢字辞典オンライン http://kanji.jitenon.jp/ にアクセスして取得
require "open-uri"
require "kconv"
@takehiko
takehiko / byoin.rb
Created November 2, 2017 20:08
Wikipedia日本語版「市区町村立病院」から病院名を取り出す
#!/usr/bin/env ruby
# Wikipedia日本語版「市区町村立病院」から病院名を取り出す
require "nokogiri"
require "open-uri"
filename = "byoin.html"
if !test(?f, filename)
html = open("https://ja.wikipedia.org/wiki/%E5%B8%82%E5%8C%BA%E7%94%BA%E6%9D%91%E7%AB%8B%E7%97%85%E9%99%A2").read
@takehiko
takehiko / arrays-2008-2017.bash
Created September 16, 2017 09:23
『小学校学習指導要領解説算数編』のアレイ図比較画像作成
#!/bin/bash
# arrays-2008-2017.bash : 『小学校学習指導要領解説算数編』のアレイ図比較画像作成
# by takehikom
# 使用するコマンド:wget, convert (ImageMagick), unzip
# コマンド中の日本語文字にも注意
# 『小学校学習指導要領解説算数編』(平成20年)からアレイ図を取り出す
if [ ! -f 2008a.pdf ]
@takehiko
takehiko / tomin.rb
Created September 13, 2017 11:39
「都民ファースト」に似た響きの文字列を生成する
#!/usr/bin/env ruby
# tomin.rb by takehikom
# 「都民ファースト」に似た響きの文字列を生成する
require "open-uri"
require "zlib"
require "stringio"
require "kconv"