graph TD;
subgraph 結果
R0[何もなし]
R1[強化値ダウン]
R2[銀剥がし]
R3[メッキ印消し]
R4[印消し]
end
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| 面白い問題。IEEE 754 binary64の最大値と、iPhoneの計算機アプリの内部処理について考える。 | |
| binary64の最大有限値はDBL_MAXで、これは(2^53 - 1) × 2^(1024-53) = (1 - 2^(-53)) × 2^1024。 | |
| つまり、2^x が表現可能な最大値 DBL_MAX 以下となる最大のxを求めればいい。 | |
| DBL_MAX = (2 - 2^(-52)) × 2^1023 | |
| ここからlog2を取ると、1023 + log2(2 - 2^(-52))になる。さらに分解すると1 + log2(1 - 2^(-53))が加わるので、結果的にlog2(DBL_MAX) = 1024 + log2(1 - 2^(-53))。log2(1 - 2^(-53))は非常に小さい負の値で、約-2^(-53) / ln(2)程度。 | |
| 実際に計算してみると、2^53とln(2)の積で割ると約1.6e-16になる。つまりDBL_MAXのlog2値は1024より約1.6e-16だけ小さいということになる。ただ、iPhoneの計算機がこれをどう処理しているかが問題で、内部的には倍精度浮動小数点ではなく任意精度演算やDecimal型を使っている可能性がある。 | |
| でも結果がオーバーフローで表示されるということは、最終的にはdoubleに変換しているか、あるいは計算自体がdoubleの範囲内で行われているのだろう。iPhoneの計算機の科学計算モードはC言語のpow関数を使っている可能性が高く、2のべき乗がDBL_MAXを超えるとinfになる。ユーザーが入力した「1023.9999999999999999」という値がdoubleでどう丸められるかが重要で、1024に非常に近い数値をdoubleで表現する場合の丸め方が結果を左右する。 | |
| doubleの精度を考えると、1024のすぐ下の値は1024から2^(-42)だけ小さい値になり、この微小な差が指数計算の結果に大きく影響する可能性がある。 | |
| 1023付近では分解能が2^(-43)程度なので、入力値「1023.9999999999999999」がdoubleに丸められる際に1024に変換されてしまい、その結果が計算に反映されているのかもしれない。 | |
| 1024は2のべき乗で区間の境界だから、その直前のdouble値は1024 - 2^(-43)で、入力がこれ以上なら |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| #!/bin/bash | |
| set -euo pipefail; prog=$(realpath -- "$0"); exec claude --add-dir "${prog%/*}" -p "head -10 $prog の手順に従いファイルを更新して" | |
| # | |
| # ファイル更新手順(※チュートリアルを行いたい人はここは読み飛ばして、次に進んでください) | |
| # 1. curl -sLo "${TMPDIR:-/tmp}/hx-tutor.en.txt" https://raw.githubusercontent.com/helix-editor/helix/refs/heads/master/runtime/tutor | |
| # 2. en.txtの日本語版としてこのファイルを上書き再作成してください。その際ファイル冒頭のスクリプトとプロンプトは維持してください。 | |
| # 3. 作成出来たらファイルのフルパスを出力して終了してください。 | |
| # | |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| #!/usr/bin/env bash | |
| usage() { | |
| echo "Usage: $(basename "$0") ...file" >&2 | |
| echo " Randomly select one file and set it as iTerm2 background image" >&2 | |
| echo " -u Unset background image (remove it)" >&2 | |
| echo "Example:" >&2 | |
| echo " iterm2-set-background-image.sh ~/.config/iterm2/images/*.{png,jpg}" >&2 | |
| exit 1 | |
| } |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| // ==UserScript== | |
| // @name GoogleMeet: auto mute / auto join | |
| // @namespace http://tampermonkey.net/ | |
| // @version 2025-04-08 | |
| // @description GoogleMeetにカメラとマイクの自動ミュートや自動参加機能を追加する。 | |
| // @author Yoshiaki Kawazu ( https://x.com/kawaz ) | |
| // @match https://meet.google.com/* | |
| // @icon https://www.google.com/s2/favicons?sz=64&domain=google.com | |
| // @grant none | |
| // ==/UserScript== |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| #!/usr/bin/env bash | |
| # 1Password CLI の op run を、引数でもインジェクション出来るようにするラッパースクリプト。 | |
| # https://gist.github.com/kawaz/a2d0c5bece913a34d2a6d4a02ca6cc3c | |
| op_args=() | |
| while (( 0 < $# )); do | |
| a=$1 | |
| shift | |
| op_args+=("$a") | |
| [[ $a == -- ]] && break |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| # 再起動前のメモ | |
| sudo bash -c "set -x; ps auxf; top -bn1; netstat -anp; mount; docker ps" > reboot2025.txt 2>&1 | |
| # sudo shutdown -r now | |
| # 再起動後に確認 | |
| ## 本当に再起動したか? | |
| uptime | |
| ## netstat の比較 | |
| diff <(cat reboot2025.txt|grep LISTEN|perl -pe's/\d+\///;s/\s\d+\s/ /g;s/[ \t]+/\t/g'|sort -V|perl -pe's/\d+\///;s/[ \t]+/\t/g') <(sudo netstat -anp|grep LISTEN|perl -pe's/\d+\///;s/\s\d+\s/ /g;s/[ \t]+/\t/g'|sort -V) | |
| ## mount 状態の比較 |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| # ローカルで発生したメールを全部SESにリレーして送信する | |
| sender_canonical_maps=regexp:/etc/postfix/sender_canonical_maps.regexp | |
| sender_dependent_relayhost_maps=hash:/etc/postfix/sender_dependent_relayhost_maps regexp:/etc/postfix/sender_dependent_relayhost_maps.regexp | |
| smtp_sasl_auth_enable=yes | |
| smtp_sasl_password_maps=hash:/etc/postfix/smtp_sasl_password_maps regexp:/etc/postfix/smtp_sasl_password_maps.regexp | |
| smtp_sasl_security_options=noanonymous | |
| smtp_sender_dependent_authentication=yes |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| /** | |
| * React等が利用されているサイトでは value プロパティに値をセットしてもWEBアプリに変更が伝わらないことがあるが、それを上手くやる。 | |
| * valueやcheckedプロパティを変更する際はフレームワーク側で差し替えられてるケースの対応として、ネイティブパーツのsetterを直接使って値を書き換えるのが確実 | |
| * | |
| * @param {string | Element | Array<string | Element>} target - 値を設定する対象の要素。文字列(セレクタ)、Element、またはそれらの配列 | |
| * @param {string | boolean} value - 設定する値。input/textareaの場合は文字列、checkboxの場合は真偽値でもOK | |
| * @param {boolean} [immediate=false] - trueの場合は即座に値を更新、falseの場合は次のイベントループで更新(特別な理由がない限りはfalseでOK) | |
| */ | |
| function setValue( | |
| target, |
NewerOlder