Skip to content

Instantly share code, notes, and snippets.

@takehiko
takehiko / colortriangle.svg
Last active December 7, 2023 13:25
Hexagon triangles: you can click triangles 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 / isotri1.svg
Created August 10, 2023 14:42
Creating isosceles triangles given a side
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
@takehiko
takehiko / setsquare1.svg
Created August 9, 2023 13:24
Creating angles using a set square
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
@takehiko
takehiko / mcu.sh
Created April 8, 2023 00:20
Marble color unifier.
#!/bin/bash
# mcu.sh: Marble color unifier.
# (From "four bags with one red, one green, and one blue marble per bag"
# to "four bags with three marbles per bag")
# Downloads: Multiply_4_bags_3_marbles.svg
# Makes: 4x3_1.svg 4x3_1.png 4x3_2.svg 4x3_2.png
# Depends on: wget sed inkscape gm (GraphicsMagick)
@takehiko
takehiko / server.js
Created November 19, 2022 22:26
A tiny HTTP server which accepts GET/POST methods with parameters
// server.js
// パラメータ付きのGET/POSTメソッドを受け付ける小さなHTTPサーバ
// 実行方法
// 適当なディレクトリにこのファイルを置いて
// npm init -y
// npm install express
// node server.js
// 別端末で
// curl -X GET 'http://localhost:8080/?abc=def'
// curl -d ABC=xyz 'http://localhost:8080/'
@takehiko
takehiko / qpr.rb
Created November 29, 2021 10:30
Yet another quadrilateral analyzer & drawer
#!/usr/bin/env ruby
# qpr.rb : 四角形(Quadrilateral)の2辺の関係に基づき平行(Parallel)・
# 垂直(Right angle)の数を求め,2次元平面上に図形を描画する
# by takehikom
# see also:
# 青山尚司「平行だけでなく,垂直も観点に加えた四角形の弁別より」,
# 算数授業研究, Vol.137, pp.58-59 (2021). [isbn:9784491046365]
class QPR
@takehiko
takehiko / polygon-plotter.rb
Created May 14, 2021 21:05
A calculator of polygonal coordinates
#!/usr/bin/env ruby
# polygon-plotter.rb : A calculator of polygonal coordinates
# by takehikom
# see also:
# https://takehikom.hateblo.jp/entry/2021/05/14/073039
# https://takehikom.hateblo.jp/entry/2021/05/15/073040
class PolygonPlotter
def initialize(opt = {})
@takehiko
takehiko / hexdot-generator.rb
Created April 25, 2021 00:48
A dot generator for math education
#!/usr/bin/env ruby
# hexdot-generator.rb : A dot generator for math education
# by takehikom
# see also: https://takehikom.hateblo.jp/entry/2021/04/25/082407
class HexdotGenerator
def initialize(opt = {})
@filename = opt[:file] || "hexdot.svg"
setup
@takehiko
takehiko / insert-timestamp.el
Created February 17, 2021 13:29
Functions for inserting a timestamp in several different ways on Emacs
;; M-x insert-timestamp-default (またはM-x its)で Wed Feb 17 22:18:46 2021
;; M-x insert-timestamp-htmlcomment (またはM-x itsh)で <!-- 2021-02-17 22:18:52 +09:00 --> (と改行)
;; M-x insert-timestamp-unixtime (またはM-x itsu)で 1613567937
;; M-x insert-timestamp-iso (またはM-x itsi)で 2021-02-17T22:19:01+09:00
(defun insert-timestamp-default ()
"Insert the current timestamp"
(interactive)
(insert (current-time-string)))
(defalias 'its 'insert-timestamp-default)
@takehiko
takehiko / radicalfinder.rb
Created April 9, 2020 12:42
MJ文字情報から,部首と同じ字形の漢字を求める
#!/usr/bin/env ruby
# radicalfinder.rb : 部首と同じ字形の漢字を求める
# by takehikom
require "roo" # gem install roo
class Radicalfinder
def initialize(opt = {})
@opt_kyoikukanji_only = opt[:kyoiku]