Skip to content

Instantly share code, notes, and snippets.

@tekihei2317
tekihei2317 / init.lua
Last active May 18, 2025 00:20
月配列2-263でローマ字のタイピングゲームを遊べるようにする設定(Mac, hammerspoon)
local keymap = {
q = { default = "so", shift = "la", side = "left" },
w = { default = "ko", shift = "hi", side = "left" },
e = { default = "si", shift = "ho", side = "left" },
r = { default = "te", shift = "hu", side = "left" },
t = { default = "lyo", shift = "me", side = "left" },
a = { default = "ha", shift = "li", side = "left" },
s = { default = "ka", shift = "wo", side = "left" },
d = { default = "", shift = "ra", side = "left" },
@tekihei2317
tekihei2317 / generate.rb
Last active May 1, 2025 08:18
WTの公式ワードファイルから、特定の文字数のフレーズのみを抽出するスクリプト
require 'rexml/document'
include REXML
# --- 設定 ---
TARGET_LENGTH = 5
SOURCE_FILE = "word2jp.xml"
OUTPUT_FILE = "word2jp_len#{TARGET_LENGTH}.xml"
SIGNATURE = "word2-len#{TARGET_LENGTH}"
# ------------
@tekihei2317
tekihei2317 / README.md
Created August 7, 2023 00:26
my-first-gistpad

gistpad

@tekihei2317
tekihei2317 / realworld-select-statements-pickup.sql
Last active August 26, 2021 12:36
Realworldを作るために対応するクエリ一覧
-- 対応するクエリ一覧
-- select句(優先度: 3)
--- 全カラムのselect
select * from `articles` where `id` = 1\G
--- カラムを指定するselect
select `article_id` from `articles` inner join `article_tag` on `articles`.`id` = `article_tag`.`article_id` where `article_tag`.`tag_id` = 2 order by `created_at` desc\G
--- 集約関数のselect(selectRaw?)
@tekihei2317
tekihei2317 / realworld-select-statements.sql
Last active August 25, 2021 23:24
laravel-realworld-example-appのテストで実行されていた、select文の一覧(pt-query-digestの解析結果から抽出)
-- select * from `migrations` where `migration` = '2017_04_27_200850_create_follows_table'\G
-- select * from `migrations` where `batch` = 1 order by `migration` desc\G
-- select * from information_schema.tables where table_schema = 'realworld_test' and table_name = 'migrations'\G
-- select `migration` from `migrations` order by `batch` asc, `migration` asc\G
select `slug` = 'new-title', `title` = 'new title', `description` = 'new description', `body` = 'new body with random text', `updated_at` = '2021-08-25 12:22:27' from `articles` where `id` = 1\G
select `username` = 'test12345', `email` = 'test12345@test.com', `password` = 'test12345', `bio` = 'hello', `image` = 'http://test.com/test.jpg', `updated_at` = '2021-08-25 12:22:40' from `users` where `id` = 1\G
select * from `articles` where `id` = 1\G
select * from `comments` where `id` = 1\G
select * from `favorites` where `user_id` = 2 and `article_id` in (1)\G
select * from `follows` where `follower_id` = 1 and `followed_id` in (2)\G
@tekihei2317
tekihei2317 / DSU.rb
Last active November 3, 2020 06:25
DisjointSetUnion(Ruby)
class DisjointSetUnion
def initialize(size)
@nodes = Array.new(size) { |i| TreeNode.new(i) }
end
def unite(i, j)
@nodes[i].unite(@nodes[j])
end
def same_group?(i, j)
@tekihei2317
tekihei2317 / dfs.rb
Created November 3, 2020 02:54
Rubyで深さ優先探索
def solve
n, m, g = gets.split(' ').map(&:to_i)
graph = Array.new(n) { Array.new }
m.times do
a, b = gets.split(' ').map(&:to_i)
graph[b - 1] << a - 1
end
visited = Array.new(n, false)
dfs = ->(crt) do