2025年は趣味開発環境の変化が大きかったので備忘録として残しておく。
前提:
- 趣味開発はほぼ毎日している
- 開発するのはコマンドラインツールやライブラリが多い
- 言語はほぼRust
- 開発はほぼAndroid上
| #!/usr/bin/env bash | |
| for i in {0..255}; do | |
| printf "\x1b[48;5;%sm%3d\e[0m " "$i" "$i" | |
| if (( i == 15 )) || (( i > 15 )) && (( (i-15) % 6 == 0 )); then | |
| printf "\n" | |
| fi | |
| done |
| # this makes debugging such a breeze with autocomplete available and such. | |
| # requires ipython to be installed of course : pip install IPython | |
| def breakpoint(): | |
| """breakpoint() replacement, which uses IPython instead of plain pdb""" | |
| import sys | |
| from IPython.terminal.debugger import set_trace | |
| set_trace(sys._getframe(1)) |
This is a living document. Everything in this document is made in good faith of being accurate, but like I just said; we don't yet know everything about what's going on.
Update: I've disabled comments as of 2025-01-26 to avoid everyone having notifications for something a year on if someone wants to suggest a correction. Folks are free to email to suggest corrections still, of course.
| // Dump all NSApplication’s class methods | |
| let dump = NSApplication.perform(NSSelectorFromString("fp_methodDescription")).takeUnretainedValue() as? String | |
| // Dump all NSApplication’s instance methods | |
| let dump = NSApp.perform(NSSelectorFromString("fp_methodDescription")).takeUnretainedValue() as? String | |
| // or | |
| print(NSApplication.value(forKey: "fp_methodDescription")) | |
| print(NSApp.value(forKey: "fp_methodDescription")) |
| // | |
| // NSApplication+NSResponderDebug.swift | |
| // | |
| // Created by Stephan Casas on 3/18/24. | |
| // | |
| import Cocoa; | |
| extension NSApplication { | |
DOMの扱い方はよく忘れそうになるので、備忘録がてら書いてみる。MDNから引用するようにしているが、もしかしたら理解が間違っているかもしれない。 DenoでHTMLドキュメントをパースするには、deno-dom-wasmを使う。
deno-dom-wasmはDenoのためのDOMおよびHTML parserの実装。Rust (WASMコンパイル)とTypeScriptで書かれている。
parseFromStringメソッドを使ってHTMLドキュメントをパースする。
| # Usage | |
| # ===== | |
| # | |
| # ## Prerequisite | |
| # | |
| # Prepare Python 3, for exmaple, install Homebrew and `brew install python`. | |
| # | |
| # ## Install dependencies | |
| # | |
| # $ python3 -m venv .venv |
| import gzip | |
| def gzip_search(query: str, candidate_chunks: list[str], top_k: int=1): | |
| """ | |
| 文字列ベースで類似したテキストチャンクを推定するアルゴリズム. | |
| `query`, `chunk`, および`query + " " + chunk`をそれぞれgzipで圧縮し、編集距離のようなものをベースに評価する. | |
| Parameters: | |
| query (str): 検索クエリとして使用する文字列. | |
| top_k (int, optional): 返される類似チャンクの上位k個を指定する (default: 1). |