Skip to content

Instantly share code, notes, and snippets.

def show_lockers(lockers, msg=None):
if msg is not None:
print('\n' + ('-' * 70) + f'\n{msg}\n' + ('-' * 70))
for j in range(0, 20):
targets = [10 * j + i for i in range(1, 11)]
print(' '.join([
f'{i:3d}:{"□" if lockers[i] else "■"}'
for i in targets
]))
print(f'開いているロッカーの数は: {sum(lockers.values())}\n')
@CookieBox26
CookieBox26 / open-with-saku-protocol.user.js
Last active April 9, 2026 02:55
Add a button to open this file with the saku: protocol.
// NOTE: Requires the saku: protocol to be registered.
// ==UserScript==
// @name Open with saku: protocol
// @namespace http://tampermonkey.net/
// @version 2026-04-03
// @description Add a button to open this file with the saku: protocol.
// @author CookieBox26
// @match file:///*.html
// @grant none
@import "/css/theme/evergreen/evergreen.css";
:root {
--cb-steelblue: #4682b4;
--cb-yellow: #f9e18b;
--cb-yellowgreen: #b1eba1;
--cb-font-family-header: 'M PLUS Rounded 1c', sans-serif;
--cb-font-family-text: Armata, 'IBM Plex Sans JP', sans-serif;
--cb-font-family-mono: 'JetBrains Mono', 'M PLUS 1 Code', monospace;
--cb-color-text: #393939;
}
@CookieBox26
CookieBox26 / google-slides-snap-to-grid.user.js
Last active March 22, 2026 13:45
When opening Google Slides, check "View -> Snap to -> Grid".
// NOTE: This script assumes the Google Slides UI is in English or Japanese.
// Do not hover the mouse over the menu until the script finishes running.
// ==UserScript==
// @name Google Slides Snap to Grid
// @namespace http://tampermonkey.net/
// @version 2026-03-22
// @description When opening Google Slides, check "View -> Snap to -> Grid".
// @author CookieBox26
// @match https://docs.google.com/presentation/*
# [必須] mp4 を出力するフォルダを指定します
# パスの最後にはスラッシュを付けてください
# 空文字列にした場合この台本ファイルがあるフォルダに出力します
out_dir = ""
# [任意] BGM を指定します
[bgm_settings]
mp3_path = "" # BGM なしなら空文字列に
adjust = -10 # BGM の音量調整
@CookieBox26
CookieBox26 / cld-ini.sh
Created January 14, 2026 07:25
Creates .claude/settings.local.json and .claude/CLAUDE.md if they do not exist.
#!/usr/bin/bash
# Creates .claude/settings.local.json and .claude/CLAUDE.md if they do not exist.
# Args: target directory, setting file flag, prompt file flag
# Ex. cld-ini.sh "`pwd`" "1Wb" "0"
# Ex. cld-ini.sh "`pwd`" "1WrWb" "0"
# Ex. cld-ini.sh "`pwd`" "1WrWb" "1"
# Setting file flag: one of "0", "1", "1Wb", "1WrWb" ("0" means do not create).
# Prompt file flag: "0" or "1" ("0" means do not create). Currently always generates Python rules.
# Assumes prompt templates are stored under ~/.claude_templates/.
set -euo pipefail # Fail fast on errors, undefined variables, and broken pipelines
@CookieBox26
CookieBox26 / scheduled_task.py
Last active January 13, 2026 06:50
スケジュール実行タスク (schedule ライブラリ使用)
"""
Python の schedule でタスクを定期実行するための便利クラス (遅刻・ダウンタイム・回数上限設定可)
このクラスの使い方: https://qiita.com/CookieBox26/items/9334a4d0e701ebbf0cdb
schedule ライブラリ: https://schedule.readthedocs.io/en/stable/index.html
"""
from abc import ABC, abstractmethod
import schedule
import time
import datetime
@CookieBox26
CookieBox26 / scrape.py
Created January 9, 2026 04:52
気象庁から名古屋と福岡の日時の気圧と気温をスクレイピングするスクリプト
from bs4 import BeautifulSoup
from pathlib import Path
import requests
import numpy as np
import pandas as pd
import time
class JMADataDaily:
def __init__(self, prec_no=51, block_no=47636, year=2025, month=12, suffix='_nagoya'):
@CookieBox26
CookieBox26 / convexts.sh
Created January 9, 2026 03:07
指定ディレクトリ以下の .txt を一斉に .md にリネームする (あるいはその逆をする) スクリプト (混在時はエラー)
#!/usr/bin/bash
# Ex. ./convexts.sh ./Dropbox/obsidian/Mercury/References/
set -euo pipefail # Fail fast on errors, undefined variables, and broken pipelines
[ "$#" -eq 1 ] || { echo "Usage: $0 <target_dir>" >&2; exit 1; }
target_dir=$1
[ -e "$target_dir" ] || { echo "Error: not found: $target_dir" >&2; exit 2; }
cd "$target_dir"
shopt -s nullglob # Make globs expand to empty when no files match
li_txt=( *.txt )
@CookieBox26
CookieBox26 / validate_tasks.py
Last active January 13, 2026 03:25
タスクバリデーションスクリプト
"""タスクバリデーションスクリプト
Usage: python path/to/validate_tasks.py
スクリプトの隣にある README.md 内のタスク一覧と Tasks/ 以下に作成済みのフォルダ一覧を比較して、
以下に該当するタスクがあれば標準出力します。Python 標準モジュールのみ使います。
- README にあるが Tasks/ 以下に未作成
- Tasks/ 以下にあるが README に未管理
- 締切日まで0日を切っているが未完了
- 締切日まで3日を切っているが未着手