Skip to content

Instantly share code, notes, and snippets.

@misebox
misebox / gist-sync.sh
Last active August 11, 2025 12:21
Check if a file is unique in your Gist and update it if necessary.
#!/bin/bash -e
if [ "$1" = "" ]
then
echo "usage: $0 {filename}"
exit 1
fi
filepath=$1
filename=$(basename $filepath)
@misebox
misebox / extract_from_notes.scpt
Last active June 29, 2025 15:56
Macのメモアプリの内容を選択したフォルダに書き出すAppleScript
set saveFolder to choose folder with prompt "Select output folder"
tell application "Notes" to activate
delay 1
tell application "Notes"
set allNotes to every note
end tell
repeat with n in allNotes
@misebox
misebox / CLAUDE.md
Last active August 11, 2025 12:19
CLAUDE.md for user

Core Principles

  • Honesty: Definitely never lie, exaggerate, or use unnecessary performative language. Don’t trick users into impossible actions or fake agreement when unsure—explain why instead.
  • Clarity: Be concise and direct; avoid unnecessary complexity
  • Delegation: Use agent-concise-tech-writer for all writing tasks (commits, PRs, issues, documents, plans)
  • Security: Never commit confidential data or modify/remove .env without permission

Code Philosophy

  • Minimal: Write only what's necessary - every line is potential debt
  • Naming: Great names improve everything (productivity, architecture, bug prevention)
  • Simple: Keep code simple, safe, maintainable, and testable
def now_in_tz() -> datetime.datetime:
tz_str = os.environ.get('TZ', None)
tz = zoneinfo.ZoneInfo(tz_str) if tz_str else None
return datetime.datetime.now(tz=tz)
@misebox
misebox / mapEntries.ts
Created July 30, 2024 04:36
オブジェクト変換コードの見た目の複雑さを少し減らす関数
type Mapper<K, V, NK, NV> = (entry: [K, V]) => [NK, NV];
function mapEntries<K extends string, V, NK extends string, NV>(
obj: Record<K, V>,
mapper: Mapper<K, V, NK, NV>
): Record<NK, NV> {
return Object.fromEntries(
Object.entries(obj).map(mapper)
) as Record<NK, NV>;
}
@misebox
misebox / gist:50a7cf988cab3bc329954c64a8b8dc62
Created April 11, 2024 11:39
openapi.jsonからapiclientを生成する
#!/bin/bash -xe
# リポジトリルートへ移動
cd $(dirname $0)/..
# up API server
docker compose up -d --build --wait --quiet-pull api
# openapi.jsonの保存先
@misebox
misebox / utils.ts
Last active April 9, 2024 17:12
TypeScript array utilities
/**
* オブジェクトの配列を辞書化
*/
const indexBy = <T, K extends T[keyof T] & (string | number | symbol)>(arr: T[], getKey: ((t: T) => K)): Record<K, T> => {
return arr.reduce((acc, cur) => {
const key = getKey(cur);
acc[key] = cur;
return acc;
}, {} as Record<K, T>);
};
@misebox
misebox / gist:b110dd38e75418fc2329a744f59dc4a5
Last active October 2, 2023 09:28
/:(.*株式会社.*)/ というテキストを含む h3 要素を探して、: **********に置換する
// /:(.*株式会社.*)/ というテキストを含む h3 要素を探して、: **********に置換する
[...document.querySelectorAll("h3")].forEach(h3 => {h3.innerText?.includes("株式会社") && (h3.innerHTML = h3.innerText.replace(/:.+/, ": **********")) && console.log(h3.innerText)});
[...document.querySelectorAll("p")].forEach(p => {p.innerText?.includes("氏名:") && (p.innerHTML = p.innerText.replace(/氏名:.+/, "氏名:********"))});
[...document.querySelectorAll("a")].forEach(a => {a.href.includes("misebox") && a.remove()});
[...document.querySelectorAll("script")].forEach(s => { s.remove()});
@misebox
misebox / mov2gif.sh
Created June 21, 2023 03:29
The tool that converts a movie file to a compact animation GIF with ffmpeg
#!/bin/bash
if [ $# -lt 1 ]
then
echo "usage: $0 <input video file>"
fi
INPUT_FILE="$1"
OUTPUT_FILE=`echo ${INPUT_FILE} | sed -E 's/\.[^\.]*$//'`.gif
@misebox
misebox / geechs_project_list_parser.py
Last active May 3, 2023 07:36
Parse the text file of the item list from geechs and output TSV
import sys
import pathlib
def parse_project_data(file_path):
with open(file_path, 'r', encoding='utf-8') as f:
content = f.read()
parts = content.split('=============================')
projects = []
for i in range(0, len(parts)-2, 2):
projects.append(parts[i] + parts[i+1])