<?xml version="1.0" encoding="utf-8" standalone="yes"?><rss version="2.0" xmlns:atom="http://www.w3.org/2005/Atom"><channel><title>suer TIL</title><link>https://atsum.in/</link><description>Recent content on suer TIL</description><generator>Hugo -- gohugo.io</generator><language>ja</language><copyright>&amp;copy; 2022 suer</copyright><lastBuildDate>Sat, 12 Sep 2026 05:34:30 +0900</lastBuildDate><atom:link href="https://atsum.in/index.xml" rel="self" type="application/rss+xml"/><item><title>【mise】mise bootstrap mise-shell-activateでシェル起動ファイルへの組み込みを宣言的に管理する</title><link>https://atsum.in/linux/mise-bootstrap-mise-shell-activate/</link><pubDate>Sat, 12 Sep 2026 05:34:30 +0900</pubDate><guid>https://atsum.in/linux/mise-bootstrap-mise-shell-activate/</guid><description>&lt;h2 id="mise-activateの設定を複数のシェル起動ファイルに手で書きたくない">mise activateの設定を複数のシェル起動ファイルに手で書きたくない&lt;/h2>
&lt;p>&lt;a href="https://atsum.in/linux/mise-activate" target="_blank" rel="noopener">【mise】mise activateでシェルにmiseを組み込む&lt;/a>
を使うには、&lt;code>eval &amp;quot;$(mise activate bash)&amp;quot;&lt;/code>のような行を&lt;code>.bashrc&lt;/code>等に自分で追記する必要がある。複数マシンやシェルの組み合わせで同じ設定を揃えたい場合、手作業では抜け漏れが出やすい。&lt;code>mise bootstrap mise-shell-activate&lt;/code>は、&lt;code>[bootstrap.mise_shell_activate]&lt;/code>の宣言に基づいて、シェルの起動ファイルへの組み込みを冪等に管理するコマンドである。&lt;/p></description><enclosure url="https://atsum.in/linux/mise-bootstrap-mise-shell-activate/img/thumbnail.png" type="image/png"/></item><item><title>【mise】mise bootstrap secretsでシークレット入力の有無を確認する</title><link>https://atsum.in/linux/mise-bootstrap-secrets/</link><pubDate>Sat, 12 Sep 2026 05:20:32 +0900</pubDate><guid>https://atsum.in/linux/mise-bootstrap-secrets/</guid><description>&lt;h2 id="bootstrapの設定にapiトークンを埋め込みたいがmisetomlには書きたくない">bootstrapの設定にAPIトークンを埋め込みたいがmise.tomlには書きたくない&lt;/h2>
&lt;p>&lt;a href="https://atsum.in/linux/mise-bootstrap-files" target="_blank" rel="noopener">【mise】mise bootstrap filesでシステムファイルを宣言的に配置する&lt;/a>
のようなbootstrap設定で、配置するファイルにAPIトークンやパスワードを含めたい場合がある。&lt;code>[bootstrap.secrets]&lt;/code>は、こうした機密情報の「入力」を宣言するためのセクションで、値そのものは&lt;code>mise.toml&lt;/code>に書かず、環境変数から供給する。&lt;code>mise bootstrap secrets&lt;/code>は、宣言した入力が実際に利用可能かどうかを、値を表示せずに確認するコマンドである。&lt;/p></description><enclosure url="https://atsum.in/linux/mise-bootstrap-secrets/img/thumbnail.png" type="image/png"/></item><item><title>【mise】mise bootstrap packagesでシステムパッケージを宣言的に管理する</title><link>https://atsum.in/linux/mise-bootstrap-packages/</link><pubDate>Sat, 12 Sep 2026 04:59:28 +0900</pubDate><guid>https://atsum.in/linux/mise-bootstrap-packages/</guid><description>&lt;h2 id="aptbrewでインストールしたパッケージをmisetomlで管理したい">apt/brewでインストールしたパッケージをmise.tomlで管理したい&lt;/h2>
&lt;p>開発機のセットアップでは、mise管理下のツール以外に&lt;code>apt&lt;/code>や&lt;code>brew&lt;/code>で入れるシステムパッケージも必要になる。&lt;code>mise bootstrap packages&lt;/code>は、&lt;code>[bootstrap.packages]&lt;/code>にシステムパッケージを宣言し、&lt;code>apt&lt;/code>/&lt;code>brew&lt;/code>など複数のパッケージマネージャを横断してインストール・管理するコマンドである。&lt;/p></description><enclosure url="https://atsum.in/linux/mise-bootstrap-packages/img/thumbnail.png" type="image/png"/></item><item><title>【mise】mise bootstrap planで適用前に変更内容を確認する</title><link>https://atsum.in/linux/mise-bootstrap-plan/</link><pubDate>Sat, 12 Sep 2026 04:21:27 +0900</pubDate><guid>https://atsum.in/linux/mise-bootstrap-plan/</guid><description>&lt;h2 id="bootstrapの変更を適用する前に内容を確認したい">bootstrapの変更を適用する前に内容を確認したい&lt;/h2>
&lt;p>&lt;a href="https://atsum.in/linux/mise-bootstrap-files" target="_blank" rel="noopener">【mise】mise bootstrap filesでシステムファイルを宣言的に配置する&lt;/a>
のような&lt;code>mise bootstrap&lt;/code>配下のサブコマンドは、ファイルの配置やパッケージのインストールなど、マシンに実際に変更を加える。適用前にどんな変更が行われるかを確認したい場合、&lt;code>mise bootstrap plan&lt;/code>を使う。実行してもマシンには一切変更を加えない、読み取り専用のコマンドである。&lt;/p></description><enclosure url="https://atsum.in/linux/mise-bootstrap-plan/img/thumbnail.png" type="image/png"/></item><item><title>【mise】mise config setでmise.tomlに値を書き込む</title><link>https://atsum.in/linux/mise-config-set/</link><pubDate>Sat, 12 Sep 2026 04:07:58 +0900</pubDate><guid>https://atsum.in/linux/mise-config-set/</guid><description>&lt;h2 id="misetomlの任意のキーをコマンドラインから書き換えたい">mise.tomlの任意のキーをコマンドラインから書き換えたい&lt;/h2>
&lt;p>&lt;a href="https://atsum.in/linux/mise-config-get" target="_blank" rel="noopener">【mise】mise config getでmise.tomlの値を取得する&lt;/a>
の対になるコマンドが&lt;code>mise config set&lt;/code>である。&lt;code>mise.toml&lt;/code>の任意のキーに、ドット区切りのパスを指定して値を書き込める。&lt;/p></description><enclosure url="https://atsum.in/linux/mise-config-set/img/thumbnail.png" type="image/png"/></item><item><title>【mise】mise config getでmise.tomlの値を取得する</title><link>https://atsum.in/linux/mise-config-get/</link><pubDate>Fri, 11 Sep 2026 23:43:48 +0900</pubDate><guid>https://atsum.in/linux/mise-config-get/</guid><description>&lt;h2 id="misetomlの値をスクリプトから取得したい">mise.tomlの値をスクリプトから取得したい&lt;/h2>
&lt;p>&lt;code>mise.toml&lt;/code>の特定の値をシェルスクリプトから取得したい場合、&lt;code>cat&lt;/code>して&lt;code>grep&lt;/code>や&lt;code>awk&lt;/code>で抜き出すのは手間である。&lt;code>mise config get&lt;/code>は、&lt;code>mise.toml&lt;/code>の任意のキーの値をドット区切りのパスで取得するコマンドである。&lt;a href="https://atsum.in/linux/mise-set" target="_blank" rel="noopener">【mise】mise setでmise.tomlに環境変数を設定する&lt;/a>
が&lt;code>[env]&lt;/code>専用なのに対し、&lt;code>mise config get&lt;/code>は&lt;code>mise.toml&lt;/code>のどのセクションのキーでも取得できる。&lt;/p></description><enclosure url="https://atsum.in/linux/mise-config-get/img/thumbnail.png" type="image/png"/></item><item><title>【mise】mise tasks graphでモノレポのプロジェクトグラフを確認する</title><link>https://atsum.in/linux/mise-tasks-graph/</link><pubDate>Fri, 11 Sep 2026 23:33:43 +0900</pubDate><guid>https://atsum.in/linux/mise-tasks-graph/</guid><description>&lt;h2 id="モノレポ内のサブプロジェクト同士の依存関係を把握したい">モノレポ内のサブプロジェクト同士の依存関係を把握したい&lt;/h2>
&lt;p>npm workspacesやCargo workspaceでモノレポを組んでいると、どのサブプロジェクトがどのサブプロジェクトに依存しているか把握しづらくなる。&lt;code>mise tasks graph&lt;/code>は、モノレポ内のサブプロジェクトとその依存関係を可視化するコマンドである。2026年9月時点では実験的機能に位置づけられている。&lt;/p></description><enclosure url="https://atsum.in/linux/mise-tasks-graph/img/thumbnail.png" type="image/png"/></item><item><title>【mise】mise tasks validateでタスク定義の誤りを検証する</title><link>https://atsum.in/linux/mise-tasks-validate/</link><pubDate>Fri, 11 Sep 2026 23:27:01 +0900</pubDate><guid>https://atsum.in/linux/mise-tasks-validate/</guid><description>&lt;h2 id="タスクの設定ミスは実行するまで気づきにくい">タスクの設定ミスは実行するまで気づきにくい&lt;/h2>
&lt;p>&lt;code>mise.toml&lt;/code>のタスク定義で、存在しないタスク名を&lt;code>depends&lt;/code>に書き間違えたり、&lt;code>alias&lt;/code>が別のタスクと重複したりしても、&lt;code>mise run&lt;/code>で実際に実行するまで気づきにくい。&lt;code>mise tasks validate&lt;/code>は、こうしたタスク定義の問題を実行せずにまとめて検出するコマンドである。&lt;/p></description><enclosure url="https://atsum.in/linux/mise-tasks-validate/img/thumbnail.png" type="image/png"/></item><item><title>【mise】mise tasks depsでタスクの依存関係をツリー表示する</title><link>https://atsum.in/linux/mise-tasks-deps/</link><pubDate>Fri, 11 Sep 2026 23:15:54 +0900</pubDate><guid>https://atsum.in/linux/mise-tasks-deps/</guid><description>&lt;h2 id="タスクが増えると依存関係を把握しづらい">タスクが増えると依存関係を把握しづらい&lt;/h2>
&lt;p>&lt;a href="https://atsum.in/linux/mise-tasks-ls" target="_blank" rel="noopener">【mise】mise tasks lsでタスク一覧を詳しく確認する&lt;/a>
では各タスクの一覧は分かるが、どのタスクがどのタスクに依存しているかまでは分からない。&lt;code>mise tasks deps&lt;/code>は、タスクの依存関係をツリー形式で可視化するコマンドである。&lt;/p></description><enclosure url="https://atsum.in/linux/mise-tasks-deps/img/thumbnail.png" type="image/png"/></item><item><title>【mise】mise tasks infoでタスク1件の詳細情報を確認する</title><link>https://atsum.in/linux/mise-tasks-info/</link><pubDate>Fri, 11 Sep 2026 22:44:52 +0900</pubDate><guid>https://atsum.in/linux/mise-tasks-info/</guid><description>&lt;h2 id="タスク一覧だけでは中身まで分からない">タスク一覧だけでは中身まで分からない&lt;/h2>
&lt;p>&lt;a href="https://atsum.in/linux/mise-tasks-ls" target="_blank" rel="noopener">【mise】mise tasks lsでタスク一覧を詳しく確認する&lt;/a>
でタスクの一覧は確認できるが、1件のタスクが具体的にどんなコマンドを実行し、何に依存しているかまでは分からない。&lt;code>mise tasks info&lt;/code>は、指定した1件のタスクの詳細情報を表示するコマンドである。&lt;/p></description><enclosure url="https://atsum.in/linux/mise-tasks-info/img/thumbnail.png" type="image/png"/></item><item><title>【mise】mise tasks editで$EDITORを使ってタスクを編集する</title><link>https://atsum.in/linux/mise-tasks-edit/</link><pubDate>Fri, 11 Sep 2026 22:38:22 +0900</pubDate><guid>https://atsum.in/linux/mise-tasks-edit/</guid><description>&lt;h2 id="タスクの中身を編集するたびにファイルパスを調べるのが面倒">タスクの中身を編集するたびにファイルパスを調べるのが面倒&lt;/h2>
&lt;p>&lt;a href="https://atsum.in/linux/mise-tasks-add" target="_blank" rel="noopener">【mise】mise tasks addでmise.tomlにタスクを追加する&lt;/a>
で追加したタスクを後から編集する際、&lt;code>mise.toml&lt;/code>のどこにあるか、あるいは&lt;code>mise-tasks/&lt;/code>のどのファイルかを探すのは手間である。&lt;code>mise tasks edit&lt;/code>は、タスク名を指定するだけで環境変数&lt;code>$EDITOR&lt;/code>にそのタスクを開くコマンドである。&lt;/p></description><enclosure url="https://atsum.in/linux/mise-tasks-edit/img/thumbnail.png" type="image/png"/></item><item><title>【mise】mise tasks addでmise.tomlにタスクを追加する</title><link>https://atsum.in/linux/mise-tasks-add/</link><pubDate>Fri, 11 Sep 2026 20:33:23 +0900</pubDate><guid>https://atsum.in/linux/mise-tasks-add/</guid><description>&lt;h2 id="タスクを追加するたびにmisetomlを手で編集するのが面倒">タスクを追加するたびにmise.tomlを手で編集するのが面倒&lt;/h2>
&lt;p>&lt;a href="https://atsum.in/linux/mise-run" target="_blank" rel="noopener">【mise】mise runでタスクを定義して実行する&lt;/a>
でタスクを実行できるが、新しいタスクを追加するたびに&lt;code>mise.toml&lt;/code>の&lt;code>[tasks.*]&lt;/code>セクションをTOMLの文法通り手で書くのは手間である。&lt;code>mise tasks add&lt;/code>は、コマンドラインからタスクを追加できるコマンドである。&lt;/p></description><enclosure url="https://atsum.in/linux/mise-tasks-add/img/thumbnail.png" type="image/png"/></item><item><title>【mise】mise ociでmise.tomlからOCIコンテナイメージをビルドする</title><link>https://atsum.in/linux/mise-oci/</link><pubDate>Fri, 11 Sep 2026 19:35:16 +0900</pubDate><guid>https://atsum.in/linux/mise-oci/</guid><description>&lt;h2 id="ツール1つのバージョンを変えるだけでdockerのレイヤーが全部作り直しになる">ツール1つのバージョンを変えるだけでDockerのレイヤーが全部作り直しになる&lt;/h2>
&lt;p>Dockerfileでツールをインストールすると、途中の&lt;code>RUN&lt;/code>命令でバージョンを1つ変えただけでも、それより上のレイヤーがすべて無効化されてビルドし直しになる。&lt;code>mise oci&lt;/code>は、&lt;code>mise.toml&lt;/code>に書いたツールをそれぞれ独立したOCIレイヤーとしてビルドするコマンドである。ツール1つのバージョンを変えても、そのツールのレイヤーだけが再構築され、他のツールやベースイメージのレイヤーはそのまま再利用される。2026年9月時点では実験的機能に位置づけられている。&lt;/p></description><enclosure url="https://atsum.in/linux/mise-oci/img/thumbnail.png" type="image/png"/></item><item><title>【mise】mise depsでロックファイルの更新を検知して依存関係を自動インストールする</title><link>https://atsum.in/linux/mise-deps/</link><pubDate>Fri, 11 Sep 2026 06:02:01 +0900</pubDate><guid>https://atsum.in/linux/mise-deps/</guid><description>&lt;h2 id="npm-installを忘れてタスクを実行してしまう">npm installを忘れてタスクを実行してしまう&lt;/h2>
&lt;p>&lt;code>package-lock.json&lt;/code>が更新されているのに&lt;code>npm install&lt;/code>を忘れたまま&lt;code>mise run&lt;/code>でタスクを実行し、依存関係の不足でエラーになった経験がある。&lt;code>mise deps&lt;/code>は、ロックファイルがインストール済みの出力(&lt;code>node_modules&lt;/code>など)より新しいかどうかを検知し、必要な場合だけ依存関係のインストールコマンドを実行するコマンドである。2026年9月時点では実験的機能に位置づけられている。&lt;/p></description><enclosure url="https://atsum.in/linux/mise-deps/img/thumbnail.png" type="image/png"/></item><item><title>【mise】mise generate task-stubsでタスクを直接実行できるシムを生成する</title><link>https://atsum.in/linux/mise-generate-task-stubs/</link><pubDate>Tue, 08 Sep 2026 07:29:08 +0900</pubDate><guid>https://atsum.in/linux/mise-generate-task-stubs/</guid><description>&lt;h2 id="mise-runを省略してタスクを直接実行したい">mise runを省略してタスクを直接実行したい&lt;/h2>
&lt;p>&lt;code>mise.toml&lt;/code>にタスクを定義すると&lt;code>mise run &amp;lt;task&amp;gt;&lt;/code>で実行できるが、プロジェクトのcontributorに&lt;code>./bin/test&lt;/code>のような見慣れたコマンドとして使わせたい場合がある。&lt;code>mise generate task-stubs&lt;/code>は、定義済みの各タスクに対応する実行ファイル(シム)を生成するコマンドである。&lt;/p></description><enclosure url="https://atsum.in/linux/mise-generate-task-stubs/img/thumbnail.png" type="image/png"/></item><item><title>【mise】mise generate install-scriptでmiseを自動インストールするスクリプトを生成する</title><link>https://atsum.in/linux/mise-generate-install-script/</link><pubDate>Mon, 07 Sep 2026 08:42:52 +0900</pubDate><guid>https://atsum.in/linux/mise-generate-install-script/</guid><description>&lt;h2 id="miseを未インストールのcontributorにも同じ手順でツールを使わせたい">miseを未インストールのcontributorにも同じ手順でツールを使わせたい&lt;/h2>
&lt;p>&lt;code>mise.toml&lt;/code>を使うプロジェクトでは、contributorが先に&lt;code>mise&lt;/code>自体をインストールしておく必要がある。&lt;code>mise generate install-script&lt;/code>は、実行するとmiseが未インストールなら自動的にダウンロード・インストールしてから、そのままmiseコマンドとして動作するラッパースクリプトを生成するコマンドである。&lt;/p></description><enclosure url="https://atsum.in/linux/mise-generate-install-script/img/thumbnail.png" type="image/png"/></item><item><title>【mise】mise install-intoでmise管理外のディレクトリにツールをインストールする</title><link>https://atsum.in/linux/mise-install-into/</link><pubDate>Mon, 07 Sep 2026 08:06:36 +0900</pubDate><guid>https://atsum.in/linux/mise-install-into/</guid><description>&lt;h2 id="ツールの実体だけをmise管理外に取り出したい">ツールの実体だけをmise管理外に取り出したい&lt;/h2>
&lt;p>Dockerイメージのビルドなどで、mise自体を組み込まずにツールの実行ファイルだけを特定のディレクトリに配置したい場合がある。&lt;code>mise install-into&lt;/code>は、&lt;code>mise.toml&lt;/code>やmiseのインストール先ディレクトリを経由せず、指定したパスに直接ツールをダウンロード・展開するコマンドである。&lt;/p></description><enclosure url="https://atsum.in/linux/mise-install-into/img/thumbnail.png" type="image/png"/></item><item><title>【mise】mise deactivateでシェルセッション内のmiseを無効化する</title><link>https://atsum.in/linux/mise-deactivate/</link><pubDate>Sun, 06 Sep 2026 21:32:16 +0900</pubDate><guid>https://atsum.in/linux/mise-deactivate/</guid><description>&lt;h2 id="activateしたmiseを一時的に無効化したい">activateしたmiseを一時的に無効化したい&lt;/h2>
&lt;p>&lt;a href="https://atsum.in/linux/mise-activate" target="_blank" rel="noopener">【mise】mise activateでシェルにmiseを組み込む&lt;/a>
でシェルにmiseを組み込んだ後、一時的に無効化したい場合がある。&lt;code>mise deactivate&lt;/code>は、&lt;code>mise activate&lt;/code>済みのシェルセッション内でmiseを無効化するコマンドである。&lt;/p></description><enclosure url="https://atsum.in/linux/mise-deactivate/img/thumbnail.png" type="image/png"/></item><item><title>【mise】mise bootstrap reposで複数のgitリポジトリをまとめて管理する</title><link>https://atsum.in/linux/mise-bootstrap-repos/</link><pubDate>Sun, 06 Sep 2026 20:09:13 +0900</pubDate><guid>https://atsum.in/linux/mise-bootstrap-repos/</guid><description>&lt;h2 id="開発機に必要なリポジトリをまとめてcloneしたい">開発機に必要なリポジトリをまとめてcloneしたい&lt;/h2>
&lt;p>&lt;a href="https://atsum.in/linux/mise-bootstrap-basic" target="_blank" rel="noopener">【mise】mise bootstrapで開発機のセットアップを宣言的に管理する&lt;/a>
で紹介した&lt;code>mise bootstrap&lt;/code>のうち、gitリポジトリのcloneと更新を担当するのが&lt;code>mise bootstrap repos&lt;/code>である。&lt;code>mise.toml&lt;/code>の&lt;code>[bootstrap.repos]&lt;/code>に必要なリポジトリを列挙しておくと、新しい開発機でもまとめてcloneできる。&lt;/p></description><enclosure url="https://atsum.in/linux/mise-bootstrap-repos/img/thumbnail.png" type="image/png"/></item><item><title>【mise】mise bootstrap dotfilesで複数マシンのdotfilesを同期する</title><link>https://atsum.in/linux/mise-bootstrap-dotfiles/</link><pubDate>Sun, 06 Sep 2026 19:54:52 +0900</pubDate><guid>https://atsum.in/linux/mise-bootstrap-dotfiles/</guid><description>&lt;h2 id="dotfilesを複数の開発機で同期させたい">dotfilesを複数の開発機で同期させたい&lt;/h2>
&lt;p>&lt;a href="https://atsum.in/linux/mise-bootstrap-basic" target="_blank" rel="noopener">【mise】mise bootstrapで開発機のセットアップを宣言的に管理する&lt;/a>
で紹介した&lt;code>mise bootstrap&lt;/code>のうち、&lt;code>.zshrc&lt;/code>や&lt;code>.gitconfig&lt;/code>のようなdotfilesの配置を担当するのが&lt;code>mise bootstrap dotfiles&lt;/code>である。&lt;code>mise.toml&lt;/code>の&lt;code>[dotfiles]&lt;/code>セクションに管理対象を登録しておくと、別の開発機でも同じ内容を再現できる。&lt;/p></description><enclosure url="https://atsum.in/linux/mise-bootstrap-dotfiles/img/thumbnail.png" type="image/png"/></item><item><title>【mise】mise bootstrap filesでシステムファイルを宣言的に配置する</title><link>https://atsum.in/linux/mise-bootstrap-files/</link><pubDate>Sun, 06 Sep 2026 19:18:31 +0900</pubDate><guid>https://atsum.in/linux/mise-bootstrap-files/</guid><description>&lt;h2 id="etc配下のファイルもmisetomlで管理したい">/etc配下のファイルもmise.tomlで管理したい&lt;/h2>
&lt;p>&lt;a href="https://atsum.in/linux/mise-bootstrap-basic" target="_blank" rel="noopener">【mise】mise bootstrapで開発機のセットアップを宣言的に管理する&lt;/a>
で紹介した&lt;code>mise bootstrap&lt;/code>のうち、&lt;code>/etc&lt;/code>配下の設定ファイルやディレクトリの配置だけを担当するのが&lt;code>mise bootstrap files&lt;/code>である。&lt;code>[bootstrap.files]&lt;/code>と&lt;code>[bootstrap.directories]&lt;/code>に書いた内容を、実際のファイルシステムの状態に反映する。&lt;/p></description><enclosure url="https://atsum.in/linux/mise-bootstrap-files/img/thumbnail.png" type="image/png"/></item><item><title>【mise】mise bootstrapで開発機のセットアップを宣言的に管理する</title><link>https://atsum.in/linux/mise-bootstrap-basic/</link><pubDate>Sun, 06 Sep 2026 16:35:58 +0900</pubDate><guid>https://atsum.in/linux/mise-bootstrap-basic/</guid><description>&lt;h2 id="開発機のセットアップをmisetomlにまとめたい">開発機のセットアップをmise.tomlにまとめたい&lt;/h2>
&lt;p>新しい開発機をセットアップするたびに、ツールのインストールや設定ファイルの配置を手作業でやり直すのは手間がかかる。&lt;code>mise bootstrap&lt;/code>は、&lt;code>mise.toml&lt;/code>の&lt;code>[bootstrap.*]&lt;/code>セクションに書いた内容を基に、開発機のセットアップを一括で実行するコマンドである。&lt;/p></description><enclosure url="https://atsum.in/linux/mise-bootstrap-basic/img/thumbnail.png" type="image/png"/></item><item><title>【mise】mise generate configで新規にmise.tomlを生成する</title><link>https://atsum.in/linux/mise-generate-config/</link><pubDate>Sun, 06 Sep 2026 15:55:57 +0900</pubDate><guid>https://atsum.in/linux/mise-generate-config/</guid><description>&lt;h2 id="新規プロジェクトにmisetomlを作りたい">新規プロジェクトにmise.tomlを作りたい&lt;/h2>
&lt;p>新しいプロジェクトでmiseを使い始める際、コメント付きの雛形から&lt;code>mise.toml&lt;/code>を作りたい場合がある。&lt;code>mise generate config&lt;/code>は、新規の設定ファイルを生成するコマンドである。&lt;/p></description><enclosure url="https://atsum.in/linux/mise-generate-config/img/thumbnail.png" type="image/png"/></item><item><title>【mise】mise generate devcontainerでdevcontainer設定を生成する</title><link>https://atsum.in/linux/mise-generate-devcontainer/</link><pubDate>Sun, 06 Sep 2026 15:45:00 +0900</pubDate><guid>https://atsum.in/linux/mise-generate-devcontainer/</guid><description>&lt;h2 id="devcontainer上でもmiseのツールをそのまま使いたい">devcontainer上でもmiseのツールをそのまま使いたい&lt;/h2>
&lt;p>VSCodeのdevcontainerを使う場合、コンテナ内にも&lt;code>mise.toml&lt;/code>で定義したツールをインストールする仕組みが必要になる。&lt;code>mise generate devcontainer&lt;/code>は、mise向けのdevcontainer featureを組み込んだ&lt;code>devcontainer.json&lt;/code>を生成するコマンドである。&lt;/p></description><enclosure url="https://atsum.in/linux/mise-generate-devcontainer/img/thumbnail.png" type="image/png"/></item><item><title>【mise】mise generate task-docsでタスクのドキュメントを生成する</title><link>https://atsum.in/linux/mise-generate-task-docs/</link><pubDate>Sun, 06 Sep 2026 15:33:12 +0900</pubDate><guid>https://atsum.in/linux/mise-generate-task-docs/</guid><description>&lt;h2 id="misetomlのタスク一覧をドキュメント化したい">mise.tomlのタスク一覧をドキュメント化したい&lt;/h2>
&lt;p>&lt;code>mise.toml&lt;/code>にタスクを増やしていくと、README等に手動でタスクの説明を書き足すのは手間になる。&lt;code>mise generate task-docs&lt;/code>は、タスクの&lt;code>description&lt;/code>や&lt;code>usage&lt;/code>からMarkdown形式のドキュメントを自動生成するコマンドである。&lt;/p></description><enclosure url="https://atsum.in/linux/mise-generate-task-docs/img/thumbnail.png" type="image/png"/></item><item><title>【mise】mise implodeでmiseを完全にアンインストールする</title><link>https://atsum.in/linux/mise-implode/</link><pubDate>Sun, 06 Sep 2026 15:06:31 +0900</pubDate><guid>https://atsum.in/linux/mise-implode/</guid><description>&lt;h2 id="miseを丸ごとアンインストールしたい">miseを丸ごとアンインストールしたい&lt;/h2>
&lt;p>miseが不要になった、あるいは環境を作り直したい場合、&lt;code>mise implode&lt;/code>でmise本体とインストール済みツール・キャッシュなどの関連データを一括削除できる。&lt;/p></description><enclosure url="https://atsum.in/linux/mise-implode/img/thumbnail.png" type="image/png"/></item><item><title>【mise】mise cacheでmiseのキャッシュを管理する</title><link>https://atsum.in/linux/mise-cache/</link><pubDate>Sun, 06 Sep 2026 14:47:47 +0900</pubDate><guid>https://atsum.in/linux/mise-cache/</guid><description>&lt;h2 id="miseが溜め込むキャッシュを整理したい">miseが溜め込むキャッシュを整理したい&lt;/h2>
&lt;p>miseは&lt;code>mise ls-remote&lt;/code>などでツールのリモートバージョン一覧を取得するたびに、その結果をローカルにキャッシュする。このキャッシュを確認・削除するコマンドが&lt;code>mise cache&lt;/code>である。&lt;/p></description><enclosure url="https://atsum.in/linux/mise-cache/img/thumbnail.png" type="image/png"/></item><item><title>【mise】mise completionでシェル補完を生成する</title><link>https://atsum.in/linux/mise-completion/</link><pubDate>Sun, 06 Sep 2026 14:30:24 +0900</pubDate><guid>https://atsum.in/linux/mise-completion/</guid><description>&lt;h2 id="miseのシェル補完を有効にしたい">miseのシェル補完を有効にしたい&lt;/h2>
&lt;p>miseはサブコマンドやツール名の補完スクリプトを&lt;code>mise completion&lt;/code>で生成できる。生成したスクリプトを配置すれば、&lt;code>mise us&lt;/code>まで打って&lt;code>Tab&lt;/code>キーを押すと&lt;code>mise use&lt;/code>が補完されるようになる。&lt;/p></description><enclosure url="https://atsum.in/linux/mise-completion/img/thumbnail.png" type="image/png"/></item><item><title>【mise】mise fmtでmise.tomlを整形する</title><link>https://atsum.in/linux/mise-fmt/</link><pubDate>Sun, 06 Sep 2026 09:55:51 +0900</pubDate><guid>https://atsum.in/linux/mise-fmt/</guid><description>&lt;h2 id="misetomlの空白がバラバラになる">mise.tomlの空白がバラバラになる&lt;/h2>
&lt;p>複数人で&lt;code>mise.toml&lt;/code>を編集していると、&lt;code>=&lt;/code>の前後のスペースの数や空行の入れ方が人によってバラバラになりがちである。&lt;code>mise fmt&lt;/code>を使うと、&lt;code>mise.toml&lt;/code>の空白を統一した形式に整形できる。&lt;/p></description><enclosure url="https://atsum.in/linux/mise-fmt/img/thumbnail.png" type="image/png"/></item><item><title>【mise】mise untrustで設定ファイルの信頼を解除する</title><link>https://atsum.in/linux/mise-untrust/</link><pubDate>Sun, 06 Sep 2026 09:55:51 +0900</pubDate><guid>https://atsum.in/linux/mise-untrust/</guid><description>&lt;h2 id="一度信頼した設定ファイルの信頼を取り消したい">一度信頼した設定ファイルの信頼を取り消したい&lt;/h2>
&lt;p>&lt;a href="https://atsum.in/linux/mise-trust" target="_blank" rel="noopener">【mise】mise trustで設定ファイルを信頼する&lt;/a>
で紹介した&lt;code>mise trust&lt;/code>は、&lt;code>[env]&lt;/code>や&lt;code>[tasks]&lt;/code>を含む&lt;code>mise.toml&lt;/code>を明示的に信頼するコマンドである。信頼済みの設定ファイルを未信頼の状態に戻したい場合は&lt;code>mise untrust&lt;/code>を使う。&lt;/p></description><enclosure url="https://atsum.in/linux/mise-untrust/img/thumbnail.png" type="image/png"/></item><item><title>【mise】mise backendsで対応バックエンドの一覧を確認する</title><link>https://atsum.in/linux/mise-backends/</link><pubDate>Sun, 06 Sep 2026 09:44:41 +0900</pubDate><guid>https://atsum.in/linux/mise-backends/</guid><description>&lt;h2 id="miseが対応しているインストール元の種類を知りたい">miseが対応しているインストール元の種類を知りたい&lt;/h2>
&lt;p>&lt;a href="https://atsum.in/linux/mise-registry" target="_blank" rel="noopener">【mise】mise registryでツール名とバックエンドの対応を確認する&lt;/a>
などで触れてきた「バックエンド」は、ツールをどこからインストールするかを表す区分である。&lt;a href="https://atsum.in/linux/mise-plugins" target="_blank" rel="noopener">【mise】mise pluginsでプラグインを管理する&lt;/a>
でも&lt;code>asdf&lt;/code>というバックエンド名が登場した。&lt;/p></description><enclosure url="https://atsum.in/linux/mise-backends/img/thumbnail.png" type="image/png"/></item><item><title>【mise】mise toolでツールの詳細情報をまとめて確認する</title><link>https://atsum.in/linux/mise-tool/</link><pubDate>Sun, 06 Sep 2026 09:34:49 +0900</pubDate><guid>https://atsum.in/linux/mise-tool/</guid><description>&lt;h2 id="ツールの状態をあちこちのコマンドで確認するのが面倒">ツールの状態をあちこちのコマンドで確認するのが面倒&lt;/h2>
&lt;p>特定のツールについて「どのバックエンドから入っているか」「インストール済みのバージョンは何か」「どの設定ファイルで解決されているか」を知りたいときがある。従来は&lt;a href="https://atsum.in/linux/mise-registry" target="_blank" rel="noopener">【mise】mise registryでツール名とバックエンドの対応を確認する&lt;/a>
や&lt;a href="https://atsum.in/linux/mise-ls" target="_blank" rel="noopener">【mise】mise lsでインストール済みツールの一覧を確認する&lt;/a>
などを使い分ける必要があった。&lt;/p></description><enclosure url="https://atsum.in/linux/mise-tool/img/thumbnail.png" type="image/png"/></item><item><title>【mise】mise editでmise.tomlを対話的に編集する</title><link>https://atsum.in/linux/mise-edit/</link><pubDate>Sun, 06 Sep 2026 09:04:13 +0900</pubDate><guid>https://atsum.in/linux/mise-edit/</guid><description>&lt;h2 id="misetomlを手で編集するとタイポや構文ミスが心配">mise.tomlを手で編集するとタイポや構文ミスが心配&lt;/h2>
&lt;p>&lt;code>mise.toml&lt;/code>はテキストファイルなので直接編集できるが、TOMLの構文やツール名を手で打つとタイポしやすい。&lt;code>mise edit&lt;/code>を使うと、既存の&lt;code>mise.toml&lt;/code>の内容をツリー形式で表示しながら対話的に編集できる。&lt;/p></description><enclosure url="https://atsum.in/linux/mise-edit/img/thumbnail.png" type="image/png"/></item><item><title>【mise】mise shell-aliasでシェルコマンドのエイリアスを管理する</title><link>https://atsum.in/linux/mise-shell-alias/</link><pubDate>Sun, 06 Sep 2026 08:54:03 +0900</pubDate><guid>https://atsum.in/linux/mise-shell-alias/</guid><description>&lt;h2 id="プロジェクトごとにシェルコマンドのエイリアスを切り替えたい">プロジェクトごとにシェルコマンドのエイリアスを切り替えたい&lt;/h2>
&lt;p>&lt;code>.bashrc&lt;/code>や&lt;code>.zshrc&lt;/code>に書くシェルエイリアスはどのディレクトリでも同じものが使えるが、プロジェクトによって使いたいエイリアスが変わる場合もある。&lt;code>mise shell-alias&lt;/code>を使うと、&lt;code>mise.toml&lt;/code>の&lt;code>[shell_alias]&lt;/code>セクションにエイリアスを定義でき、&lt;code>mise activate&lt;/code>を組み込んだシェルでプロジェクトディレクトリに入ったときだけ有効になる。&lt;a href="https://atsum.in/linux/mise-tool-alias" target="_blank" rel="noopener">【mise】mise tool-aliasでツールバージョンにエイリアスを定義する&lt;/a>
で紹介した&lt;code>mise tool-alias&lt;/code>とは名前が似ているが別物で、こちらはツールバージョンではなくシェルコマンドのエイリアスを扱う。&lt;/p></description><enclosure url="https://atsum.in/linux/mise-shell-alias/img/thumbnail.png" type="image/png"/></item><item><title>【mise】mise searchでレジストリのツールをキーワード検索する</title><link>https://atsum.in/linux/mise-search/</link><pubDate>Sun, 06 Sep 2026 06:47:09 +0900</pubDate><guid>https://atsum.in/linux/mise-search/</guid><description>&lt;h2 id="ツール名がうろ覚えのとき候補を探したい">ツール名がうろ覚えのとき候補を探したい&lt;/h2>
&lt;p>&lt;code>jq&lt;/code>のようにインストールしたいツールの正確な名前が分かっていれば&lt;a href="https://atsum.in/linux/mise-use" target="_blank" rel="noopener">【mise】mise useでプロジェクトにツールバージョンを設定する&lt;/a>
で済む。ツール名がうろ覚えの場合や、似た用途のツールを見比べたい場合は&lt;code>mise search&lt;/code>でキーワード検索できる。&lt;/p></description><enclosure url="https://atsum.in/linux/mise-search/img/thumbnail.png" type="image/png"/></item><item><title>【mise】mise syncで他のバージョンマネージャのインストール済みバージョンを取り込む</title><link>https://atsum.in/linux/mise-sync/</link><pubDate>Sun, 06 Sep 2026 06:31:23 +0900</pubDate><guid>https://atsum.in/linux/mise-sync/</guid><description>&lt;h2 id="homebrewやnvmで既にインストールしたバージョンをmiseでも使いたい">Homebrewやnvmで既にインストールしたバージョンをmiseでも使いたい&lt;/h2>
&lt;p>nvmやpyenv、Homebrewで既にインストール済みのNode.jsやPythonがある状態でmiseを導入する場合、同じバージョンを二重にダウンロードし直すのは無駄である。&lt;code>mise sync&lt;/code>を使うと、他のバージョンマネージャがインストール済みのバージョンをmise管理下にシンボリックリンクとして取り込める。&lt;/p></description><enclosure url="https://atsum.in/linux/mise-sync/img/thumbnail.png" type="image/png"/></item><item><title>【mise】mise generate tool-stubでHTTP配布ツールのスタブを生成する</title><link>https://atsum.in/linux/mise-tool-stub/</link><pubDate>Sat, 05 Sep 2026 23:07:18 +0900</pubDate><guid>https://atsum.in/linux/mise-tool-stub/</guid><description>&lt;h2 id="レジストリに登録されていないツールをリポジトリに同梱して配布したい">レジストリに登録されていないツールをリポジトリに同梱して配布したい&lt;/h2>
&lt;p>&lt;a href="https://atsum.in/linux/mise-registry" target="_blank" rel="noopener">【mise】mise registryでツール名とバックエンド確認をする&lt;/a>
で紹介したツールの探し方は、&lt;code>mise.toml&lt;/code>の&lt;code>[tools]&lt;/code>にツール名を書く前提である。&lt;/p></description><enclosure url="https://atsum.in/linux/mise-tool-stub/img/thumbnail.png" type="image/png"/></item><item><title>【mise】mise tokenでmiseが使うトークンの解決元を確認する</title><link>https://atsum.in/linux/mise-token/</link><pubDate>Sat, 05 Sep 2026 22:57:20 +0900</pubDate><guid>https://atsum.in/linux/mise-token/</guid><description>&lt;h2 id="どの環境変数のトークンが使われているか分かりにくい">どの環境変数のトークンが使われているか分かりにくい&lt;/h2>
&lt;p>miseはツールのインストール時に、GitHubなどのgitプロバイダーAPIへ認証付きでリクエストするため、環境変数からトークンを読み取る。しかし複数のトークン系環境変数が定義されていると、実際にどれが使われているのか分かりにくい。&lt;code>mise token&lt;/code>を使うと、miseが実際に使うトークンとその解決元(環境変数名)を確認できる。&lt;/p></description><enclosure url="https://atsum.in/linux/mise-token/img/thumbnail.png" type="image/png"/></item><item><title>【mise】mise generate git-pre-commitでコミット前フックを生成する</title><link>https://atsum.in/linux/mise-generate-git-pre-commit/</link><pubDate>Sat, 05 Sep 2026 22:45:55 +0900</pubDate><guid>https://atsum.in/linux/mise-generate-git-pre-commit/</guid><description>&lt;h2 id="コミット前のlintやテストを毎回手動で実行するのは忘れがち">コミット前のlintやテストを毎回手動で実行するのは忘れがち&lt;/h2>
&lt;p>&lt;code>mise.toml&lt;/code>にlintやテストを実行するタスクを定義していても、コミット前に毎回自分で実行するのは忘れがちである。&lt;code>mise generate git-pre-commit&lt;/code>を使うと、コミット時に&lt;code>mise run &amp;lt;タスク名&amp;gt;&lt;/code>を自動実行するgit pre-commitフックを生成できる。&lt;/p></description><enclosure url="https://atsum.in/linux/mise-generate-git-pre-commit/img/thumbnail.png" type="image/png"/></item><item><title>【mise】mise generate github-actionでCIワークフローの雛形を生成する</title><link>https://atsum.in/linux/mise-generate-github-action/</link><pubDate>Sat, 05 Sep 2026 22:27:59 +0900</pubDate><guid>https://atsum.in/linux/mise-generate-github-action/</guid><description>&lt;h2 id="ci用ワークフローを毎回手書きするのは手間">CI用ワークフローを毎回手書きするのは手間&lt;/h2>
&lt;p>&lt;a href="https://atsum.in/linux/mise-action-basic" target="_blank" rel="noopener">【mise】mise-actionの基本的な使い方&lt;/a>
では&lt;code>jdx/mise-action&lt;/code>のセットアップ方法を紹介した。&lt;/p>
&lt;p>&lt;a href="https://atsum.in/linux/mise-action-run" target="_blank" rel="noopener">【mise】mise-actionのセットアップ後にmise runでタスクを実行する&lt;/a>
では、セットアップ後に&lt;code>mise run&lt;/code>でタスクを実行する方法を紹介した。&lt;/p></description><enclosure url="https://atsum.in/linux/mise-generate-github-action/img/thumbnail.png" type="image/png"/></item><item><title>【mise】tracked-configsで参照されている設定ファイルを確認する</title><link>https://atsum.in/linux/mise-tracked-configs/</link><pubDate>Sat, 05 Sep 2026 21:59:26 +0900</pubDate><guid>https://atsum.in/linux/mise-tracked-configs/</guid><description>&lt;h2 id="mise-pruneはどうやって使用中のバージョンを判定しているか">mise pruneはどうやって使用中のバージョンを判定しているか&lt;/h2>
&lt;p>&lt;a href="https://atsum.in/linux/mise-prune" target="_blank" rel="noopener">【mise】mise pruneで使われていないバージョンをまとめて削除する&lt;/a>
は、どの設定ファイルからも参照されなくなったバージョンを自動で検出する。この判定の元になっているのが&lt;code>~/.local/state/mise/tracked-configs&lt;/code>というディレクトリで、これまでに&lt;code>mise install&lt;/code>や&lt;code>mise use&lt;/code>を実行したプロジェクトの設定ファイルが記録されている。&lt;/p></description><enclosure url="https://atsum.in/linux/mise-tracked-configs/img/thumbnail.png" type="image/png"/></item><item><title>【GitHub CLI】複数のDependabot PRを連続マージする前にmergeable/mergeStateStatusでコンフリクトを確認する</title><link>https://atsum.in/linux/gh-pr-mergeable-check/</link><pubDate>Sat, 05 Sep 2026 20:54:58 +0900</pubDate><guid>https://atsum.in/linux/gh-pr-mergeable-check/</guid><description>&lt;h2 id="複数のdependabot-prを連続マージすると事故が怖い">複数のDependabot PRを連続マージすると事故が怖い&lt;/h2>
&lt;p>同一リポジトリでDependabotが作成した複数のPull Requestを&lt;code>gh pr merge&lt;/code>で連続マージすると、後続のPRが直前のマージの影響でコンフリクトを起こすことがある。&lt;/p></description><enclosure url="https://atsum.in/linux/gh-pr-mergeable-check/img/thumbnail.png" type="image/png"/></item><item><title>【mise】mise.lockで解決済みバージョンを固定する</title><link>https://atsum.in/linux/mise-lock/</link><pubDate>Sat, 05 Sep 2026 20:34:25 +0900</pubDate><guid>https://atsum.in/linux/mise-lock/</guid><description>&lt;h2 id="バージョン範囲指定は環境によって解決結果が変わる">バージョン範囲指定は環境によって解決結果が変わる&lt;/h2>
&lt;p>&lt;code>mise.toml&lt;/code>に&lt;code>jq = &amp;quot;1.8&amp;quot;&lt;/code>のようにバージョン範囲を指定すると、実行環境やタイミングによって解決される具体的なバージョンが変わりうる。&lt;a href="https://atsum.in/linux/mise-use-pin" target="_blank" rel="noopener">【mise】mise use --pinで解決済みのバージョンをmise.tomlに保存する&lt;/a>
では、&lt;code>--pin&lt;/code>で&lt;code>mise.toml&lt;/code>自体に具体的なバージョンを書き込む方法を紹介した。&lt;code>mise.lock&lt;/code>は&lt;code>mise.toml&lt;/code>の範囲指定を変更せずに、解決結果だけを別ファイルに記録する仕組みで、mise公式ドキュメントでは&lt;code>--pin&lt;/code>よりもこちらが推奨されている。&lt;/p></description><enclosure url="https://atsum.in/linux/mise-lock/img/thumbnail.png" type="image/png"/></item><item><title>【mise】mise unuseでmise.tomlからツールの記述を削除する</title><link>https://atsum.in/linux/mise-unuse/</link><pubDate>Sat, 05 Sep 2026 19:58:53 +0900</pubDate><guid>https://atsum.in/linux/mise-unuse/</guid><description>&lt;h2 id="misetomlからツールの記述だけを削除したい">mise.tomlからツールの記述だけを削除したい&lt;/h2>
&lt;p>&lt;a href="https://atsum.in/linux/mise-uninstall" target="_blank" rel="noopener">【mise】mise uninstallでインストール済みツールを削除する&lt;/a>
は、ディスク上のツールの実体を削除するコマンドである。それに対して&lt;code>mise unuse&lt;/code>は、&lt;code>mise.toml&lt;/code>からツールの記述を削除するコマンドであり、他の設定ファイルから参照されなくなったバージョンは、あわせてディスクからも削除される。&lt;/p></description><enclosure url="https://atsum.in/linux/mise-unuse/img/thumbnail.png" type="image/png"/></item><item><title>【mise】mise linkでインストール済みツールをmise管理下に登録する</title><link>https://atsum.in/linux/mise-link/</link><pubDate>Sat, 05 Sep 2026 19:45:54 +0900</pubDate><guid>https://atsum.in/linux/mise-link/</guid><description>&lt;h2 id="mise管理外のツールをmisetomlから参照したい">mise管理外のツールをmise.tomlから参照したい&lt;/h2>
&lt;p>Homebrewや自前のビルドスクリプトなど、mise管理外の方法でインストールしたツールがある場合、&lt;code>mise link&lt;/code>を使うとそのツールをmise管理下のバージョンとしてシンボリックリンクで登録できる。登録後は&lt;code>mise.toml&lt;/code>や&lt;code>mise use&lt;/code>から通常のバージョンと同じように参照できる。&lt;/p></description><enclosure url="https://atsum.in/linux/mise-link/img/thumbnail.png" type="image/png"/></item><item><title>【mise】mise enでmiseの環境が有効なシェルを起動する</title><link>https://atsum.in/linux/mise-en/</link><pubDate>Sat, 05 Sep 2026 18:30:00 +0900</pubDate><guid>https://atsum.in/linux/mise-en/</guid><description>&lt;h2 id="misetomlのツールがすぐ使えるシェルを起動したい">mise.tomlのツールがすぐ使えるシェルを起動したい&lt;/h2>
&lt;p>&lt;a href="https://atsum.in/linux/mise-env" target="_blank" rel="noopener">【mise】mise envでmiseが設定する環境変数を出力する&lt;/a>
で紹介した&lt;code>mise env&lt;/code>は、export文を出力するだけで、現在のシェルに反映するには&lt;code>eval&lt;/code>が必要になる。&lt;code>mise en&lt;/code>を使うと、&lt;code>eval&lt;/code>を挟まずに、mise環境が最初から有効なシェルをその場で起動できる。&lt;/p></description><enclosure url="https://atsum.in/linux/mise-en/img/thumbnail.png" type="image/png"/></item><item><title>【mise】mise bin-pathsでアクティブなツールの実行ファイルディレクトリを確認する</title><link>https://atsum.in/linux/mise-bin-paths/</link><pubDate>Sat, 05 Sep 2026 18:15:38 +0900</pubDate><guid>https://atsum.in/linux/mise-bin-paths/</guid><description>&lt;h2 id="pathに追加すべきディレクトリを直接知りたい">PATHに追加すべきディレクトリを直接知りたい&lt;/h2>
&lt;p>&lt;a href="https://atsum.in/linux/mise-where" target="_blank" rel="noopener">【mise】mise whereでツールのインストールパスを確認する&lt;/a>
で紹介した&lt;code>mise where&lt;/code>は、ツールのインストールディレクトリそのものを返す。ただしツールによっては、実行ファイルはインストールディレクトリ直下ではなく&lt;code>bin/&lt;/code>のようなサブディレクトリにある。&lt;code>mise bin-paths&lt;/code>を使うと、実際に実行ファイルが置かれているディレクトリを直接確認できる。&lt;/p></description><enclosure url="https://atsum.in/linux/mise-bin-paths/img/thumbnail.png" type="image/png"/></item><item><title>【mise】mise watchでファイル変更を監視してタスクを自動再実行する</title><link>https://atsum.in/linux/mise-watch/</link><pubDate>Sat, 05 Sep 2026 17:30:14 +0900</pubDate><guid>https://atsum.in/linux/mise-watch/</guid><description>&lt;h2 id="ファイルを保存するたびにタスクを再実行したい">ファイルを保存するたびにタスクを再実行したい&lt;/h2>
&lt;p>&lt;a href="https://atsum.in/linux/mise-run" target="_blank" rel="noopener">【mise】mise runでタスクを定義して実行する&lt;/a>
で紹介した&lt;code>mise run&lt;/code>は、実行するたびに手動でコマンドを打つ必要がある。&lt;code>mise watch&lt;/code>を使うと、ソースファイルの変更を検知して自動的にタスクを再実行できる。&lt;/p></description><enclosure url="https://atsum.in/linux/mise-watch/img/thumbnail.png" type="image/png"/></item><item><title>【mise】mise mcpでAIアシスタントからmiseを操作する</title><link>https://atsum.in/linux/mise-mcp/</link><pubDate>Sat, 05 Sep 2026 17:13:46 +0900</pubDate><guid>https://atsum.in/linux/mise-mcp/</guid><description>&lt;h2 id="aiアシスタントにmiseの情報を渡したい">AIアシスタントにmiseの情報を渡したい&lt;/h2>
&lt;p>Claude DesktopやCursorのようなMCP(Model Context Protocol)対応のAIアシスタントに、プロジェクトで使っているツールやタスクの情報を渡したい場合がある。&lt;code>mise mcp&lt;/code>を使うと、mise自体をMCPサーバーとして起動し、標準入出力を経由したJSON-RPCでmiseの情報を扱えるようにできる。&lt;/p></description><enclosure url="https://atsum.in/linux/mise-mcp/img/thumbnail.png" type="image/png"/></item><item><title>【mise】mise unsetでmise.tomlの環境変数を削除する</title><link>https://atsum.in/linux/mise-unset/</link><pubDate>Sat, 05 Sep 2026 17:04:19 +0900</pubDate><guid>https://atsum.in/linux/mise-unset/</guid><description>&lt;h2 id="mise-setで設定した環境変数を削除したい">mise setで設定した環境変数を削除したい&lt;/h2>
&lt;p>&lt;a href="https://atsum.in/linux/mise-set" target="_blank" rel="noopener">【mise】mise setでmise.tomlに環境変数を設定する&lt;/a>
で設定した環境変数が不要になったら、&lt;code>mise unset&lt;/code>で削除する。&lt;/p></description><enclosure url="https://atsum.in/linux/mise-unset/img/thumbnail.png" type="image/png"/></item><item><title>【mise】mise setでmise.tomlに環境変数を設定する</title><link>https://atsum.in/linux/mise-set/</link><pubDate>Sat, 05 Sep 2026 16:55:32 +0900</pubDate><guid>https://atsum.in/linux/mise-set/</guid><description>&lt;h2 id="プロジェクトごとの環境変数をmisetomlで管理したい">プロジェクトごとの環境変数をmise.tomlで管理したい&lt;/h2>
&lt;p>&lt;code>MISE_DATA_DIR&lt;/code>のような&lt;code>MISE_*&lt;/code>環境変数はmise自体の動作を制御するものだが、&lt;code>mise set&lt;/code>で設定するのはそれとは別に、プロジェクトで使う任意の環境変数である。&lt;code>mise.toml&lt;/code>の&lt;code>[env]&lt;/code>セクションに書いておくと、&lt;code>mise activate&lt;/code>済みのシェルやタスク実行時に自動的に反映される。&lt;/p></description><enclosure url="https://atsum.in/linux/mise-set/img/thumbnail.png" type="image/png"/></item><item><title>【mise】mise tool-aliasでツールバージョンにエイリアスを定義する</title><link>https://atsum.in/linux/mise-tool-alias/</link><pubDate>Sat, 05 Sep 2026 16:47:53 +0900</pubDate><guid>https://atsum.in/linux/mise-tool-alias/</guid><description>&lt;h2 id="独自の名前でバージョンを指定したい">独自の名前でバージョンを指定したい&lt;/h2>
&lt;p>miseは&lt;code>node&lt;/code>の&lt;code>lts-jod&lt;/code>のように、一部のツールでLTSバージョンなどのエイリアスをあらかじめ用意している。&lt;code>mise tool-alias&lt;/code>を使うと、自分で任意のエイリアス名を定義できる。設定は&lt;code>~/.config/mise/config.toml&lt;/code>(グローバル設定ファイル)に保存され、プロジェクトを問わず使える。&lt;/p></description><enclosure url="https://atsum.in/linux/mise-tool-alias/img/thumbnail.png" type="image/png"/></item><item><title>【mise】mise registryでツール名とバックエンドの対応を確認する</title><link>https://atsum.in/linux/mise-registry/</link><pubDate>Sat, 05 Sep 2026 16:40:21 +0900</pubDate><guid>https://atsum.in/linux/mise-registry/</guid><description>&lt;h2 id="ツール名がどのバックエンドで解決されているか確認したい">ツール名がどのバックエンドで解決されているか確認したい&lt;/h2>
&lt;p>&lt;code>mise use jq&lt;/code>のように短いツール名を指定すると、miseは内部のレジストリを参照して、実際にどのバックエンド(aqua、asdf、cargo、goなど)からインストールするかを自動的に決める。&lt;code>mise registry&lt;/code>を使うと、この対応関係を確認できる。&lt;/p></description><enclosure url="https://atsum.in/linux/mise-registry/img/thumbnail.png" type="image/png"/></item><item><title>【mise】mise-actionを使わず手動でセットアップする場合との違い</title><link>https://atsum.in/linux/mise-action-manual-setup/</link><pubDate>Sat, 05 Sep 2026 15:16:10 +0900</pubDate><guid>https://atsum.in/linux/mise-action-manual-setup/</guid><description>&lt;h2 id="mise-actionなしでもmiseをセットアップできる">mise-actionなしでもmiseをセットアップできる&lt;/h2>
&lt;p>&lt;code>jdx/mise-action&lt;/code>を使わなくても、mise公式のインストールスクリプトを使えばGitHub Actions上でmiseをセットアップできる。mise-actionが内部で何を自動化しているかを知るために、手動セットアップと比較する。&lt;/p></description><enclosure url="https://atsum.in/linux/mise-action-manual-setup/img/thumbnail.png" type="image/png"/></item><item><title>【mise】mise-actionのworking_directory入力でmise.tomlの場所を指定する</title><link>https://atsum.in/linux/mise-action-working-directory/</link><pubDate>Sat, 05 Sep 2026 15:06:48 +0900</pubDate><guid>https://atsum.in/linux/mise-action-working-directory/</guid><description>&lt;h2 id="モノレポのサブディレクトリにあるmisetomlを読み込みたい">モノレポのサブディレクトリにあるmise.tomlを読み込みたい&lt;/h2>
&lt;p>&lt;code>jdx/mise-action&lt;/code>は既定でリポジトリのルートディレクトリで&lt;code>mise install&lt;/code>を実行する。モノレポ構成で&lt;code>mise.toml&lt;/code>がサブディレクトリにある場合、ルートディレクトリには&lt;code>mise.toml&lt;/code>が存在しないため、そのままでは目的のツールがインストールされない。&lt;code>working_directory&lt;/code>入力を使うと、&lt;code>mise-action&lt;/code>が&lt;code>mise install&lt;/code>などを実行するディレクトリを指定できる。&lt;/p></description><enclosure url="https://atsum.in/linux/mise-action-working-directory/img/thumbnail.png" type="image/png"/></item><item><title>【mise】mise-actionのinstall_args入力でインストール対象を絞り込む</title><link>https://atsum.in/linux/mise-action-install-args/</link><pubDate>Sat, 05 Sep 2026 14:55:08 +0900</pubDate><guid>https://atsum.in/linux/mise-action-install-args/</guid><description>&lt;h2 id="misetomlの一部のツールだけインストールしたい">mise.tomlの一部のツールだけインストールしたい&lt;/h2>
&lt;p>&lt;code>jdx/mise-action&lt;/code>は既定で&lt;code>mise install&lt;/code>を実行し、&lt;code>mise.toml&lt;/code>に定義した全ツールをインストールする。ジョブによって使うツールが異なるモノレポなどでは、ジョブごとに一部のツールだけインストールしたい場合がある。&lt;code>install_args&lt;/code>入力を使うと、&lt;code>mise install&lt;/code>に渡す引数を指定し、インストール対象を絞り込める。&lt;/p></description><enclosure url="https://atsum.in/linux/mise-action-install-args/img/thumbnail.png" type="image/png"/></item><item><title>【mise】mise-actionのgithub_token入力でAPIレート制限を回避する</title><link>https://atsum.in/linux/mise-action-github-token/</link><pubDate>Sat, 05 Sep 2026 12:28:56 +0900</pubDate><guid>https://atsum.in/linux/mise-action-github-token/</guid><description>&lt;h2 id="github-apiのレート制限でツールのインストールに失敗する">GitHub APIのレート制限でツールのインストールに失敗する&lt;/h2>
&lt;p>&lt;code>jdx/mise-action&lt;/code>は、ツールの最新バージョン確認やリリースアセットのダウンロードにGitHubのAPIを使う。GitHub APIは未認証のアクセスに対して低いレート制限がかかっている。多くのワークフローを同時に実行する環境ではこの制限に引っかかり、インストールに失敗する場合がある。&lt;code>github_token&lt;/code>入力を使うと、GitHubの認証情報でAPIリクエストを認証し、レート制限を緩和できる。&lt;/p></description><enclosure url="https://atsum.in/linux/mise-action-github-token/img/thumbnail.png" type="image/png"/></item><item><title>【mise】mise-actionのセットアップ後にmise runでタスクを実行する</title><link>https://atsum.in/linux/mise-action-run/</link><pubDate>Sat, 05 Sep 2026 12:11:47 +0900</pubDate><guid>https://atsum.in/linux/mise-action-run/</guid><description>&lt;h2 id="ciでもmisetomlに定義したタスクをそのまま使いたい">CIでもmise.tomlに定義したタスクをそのまま使いたい&lt;/h2>
&lt;p>&lt;a href="https://atsum.in/linux/mise-run" target="_blank" rel="noopener">【mise】mise runでタスクを定義して実行する&lt;/a>
で紹介した&lt;code>mise run&lt;/code>は、ローカルでもCIでも同じ&lt;code>mise.toml&lt;/code>のタスク定義をそのまま実行できる。&lt;code>jdx/mise-action&lt;/code>でセットアップした後に&lt;code>mise run&lt;/code>を実行するだけで、ビルドやテストといったタスクをGitHub Actions上でも実行できる。&lt;/p></description><enclosure url="https://atsum.in/linux/mise-action-run/img/thumbnail.png" type="image/png"/></item><item><title>【mise】mise pluginsでプラグインを管理する</title><link>https://atsum.in/linux/mise-plugins/</link><pubDate>Sat, 05 Sep 2026 10:25:20 +0900</pubDate><guid>https://atsum.in/linux/mise-plugins/</guid><description>&lt;h2 id="レジストリに無いツールをasdf互換プラグインで使いたい">レジストリに無いツールをasdf互換プラグインで使いたい&lt;/h2>
&lt;p>miseはツールごとにコアやaquaなど複数のバックエンドを内蔵しており、&lt;code>mise use&lt;/code>でツール名を指定すると、レジストリに登録された優先順位に従って自動的にバックエンドが選ばれる。ただし&lt;a href="https://dev.classmethod.jp/articles/mise-tool-version-management-20260418/" target="_blank" rel="noopener nofollow">セキュリティ上の懸念から&lt;/a>
、レジストリへの新規ツール登録ではasdfやvfoxのバックエンドは受け付けられなくなっており、新規に対応させたいツールはaquaバックエンドへの登録が推奨されている。レジストリに登録されていないツールをどうしても使いたい場合は、&lt;code>mise plugins&lt;/code>でasdf互換の外部プラグインを自分で追加して管理する。&lt;/p></description><enclosure url="https://atsum.in/linux/mise-plugins/img/thumbnail.png" type="image/png"/></item><item><title>【mise】mise self-updateでmise自体をアップデートする</title><link>https://atsum.in/linux/mise-self-update/</link><pubDate>Sat, 05 Sep 2026 10:16:20 +0900</pubDate><guid>https://atsum.in/linux/mise-self-update/</guid><description>&lt;h2 id="mise本体を最新バージョンに更新したい">mise本体を最新バージョンに更新したい&lt;/h2>
&lt;p>&lt;code>mise install&lt;/code>や&lt;code>mise use&lt;/code>でインストールするのはmise管理下のツールのバージョンで、mise自体のバージョンは別に管理されている。mise自体を最新版に更新するには&lt;code>mise self-update&lt;/code>を使う。&lt;/p></description><enclosure url="https://atsum.in/linux/mise-self-update/img/thumbnail.png" type="image/png"/></item><item><title>【mise】mise configで設定ファイル一覧・階層を確認する</title><link>https://atsum.in/linux/mise-config/</link><pubDate>Sat, 05 Sep 2026 10:06:03 +0900</pubDate><guid>https://atsum.in/linux/mise-config/</guid><description>&lt;h2 id="どの設定ファイルが読み込まれているか分かりにくい">どの設定ファイルが読み込まれているか分かりにくい&lt;/h2>
&lt;p>グローバル設定ファイル(&lt;code>~/.config/mise/config.toml&lt;/code>)とプロジェクトの&lt;code>mise.toml&lt;/code>など、miseは複数の設定ファイルを階層的に読み込む。ツールのバージョンが想定と違う場合、どの設定ファイルの記述が効いているのか分かりにくいことがある。&lt;code>mise config&lt;/code>を使うと、現在のディレクトリで読み込まれている設定ファイルの一覧と、それぞれに定義されているツールを確認できる。&lt;/p></description><enclosure url="https://atsum.in/linux/mise-config/img/thumbnail.png" type="image/png"/></item><item><title>【mise】mise settingsでmise自体の設定を変更する</title><link>https://atsum.in/linux/mise-settings/</link><pubDate>Sat, 05 Sep 2026 09:43:11 +0900</pubDate><guid>https://atsum.in/linux/mise-settings/</guid><description>&lt;h2 id="mise自体の設定を恒久的に変更したい">mise自体の設定を恒久的に変更したい&lt;/h2>
&lt;p>&lt;a href="https://atsum.in/linux/mise-jobs" target="_blank" rel="noopener">【mise】MISE_JOBSで並列インストール数を変更する&lt;/a>
のように、mise自体の挙動は環境変数でも変更できるが、環境変数はシェルの起動ファイルやCIの設定に書く必要があり、設定ファイルとして一元管理しづらい。&lt;code>mise settings&lt;/code>を使うと、同じ設定を&lt;code>mise.toml&lt;/code>やグローバル設定ファイルに恒久的に書き込める。&lt;/p></description><enclosure url="https://atsum.in/linux/mise-settings/img/thumbnail.png" type="image/png"/></item><item><title>【mise】mise envでmiseが設定する環境変数を出力する</title><link>https://atsum.in/linux/mise-env/</link><pubDate>Sat, 05 Sep 2026 09:32:29 +0900</pubDate><guid>https://atsum.in/linux/mise-env/</guid><description>&lt;h2 id="mise-activateを恒久的に組み込まずにmiseを使いたい">mise activateを恒久的に組み込まずにmiseを使いたい&lt;/h2>
&lt;p>&lt;a href="https://atsum.in/linux/mise-activate" target="_blank" rel="noopener">【mise】mise activateでシェルにmiseを組み込む&lt;/a>
はシェルの設定ファイルに追記して恒久的にmiseを有効化する方法である。CIの1回のジョブ実行時など、シェルの設定ファイルを恒久的に変更したくない場面もある。&lt;code>mise env&lt;/code>を使うと、&lt;code>mise.toml&lt;/code>に応じてmiseが設定するPATHや環境変数を出力し、その場だけ有効化できる。&lt;/p></description><enclosure url="https://atsum.in/linux/mise-env/img/thumbnail.png" type="image/png"/></item><item><title>【mise】mise shellでシェルセッションの間だけバージョンを切り替える</title><link>https://atsum.in/linux/mise-shell/</link><pubDate>Sat, 05 Sep 2026 09:17:20 +0900</pubDate><guid>https://atsum.in/linux/mise-shell/</guid><description>&lt;h2 id="複数のコマンドにまたがって一時的にバージョンを切り替えたい">複数のコマンドにまたがって一時的にバージョンを切り替えたい&lt;/h2>
&lt;p>&lt;a href="https://atsum.in/linux/mise-exec" target="_blank" rel="noopener">【mise】mise execで一時的にツールバージョンを切り替えてコマンド実行する&lt;/a>
は1回のコマンド実行だけ別バージョンを使う場合に向いている。複数のコマンドを続けて実行したい場合は、毎回&lt;code>mise exec&lt;/code>を付けるのは手間がかかる。&lt;code>mise shell&lt;/code>を使うと、現在のシェルセッションが続く間だけ一時的にバージョンを切り替えられる。&lt;/p></description><enclosure url="https://atsum.in/linux/mise-shell/img/thumbnail.png" type="image/png"/></item><item><title>【mise】mise pruneで使われていないバージョンをまとめて削除する</title><link>https://atsum.in/linux/mise-prune/</link><pubDate>Sat, 05 Sep 2026 09:01:42 +0900</pubDate><guid>https://atsum.in/linux/mise-prune/</guid><description>&lt;h2 id="使われなくなった古いバージョンが溜まっていく">使われなくなった古いバージョンが溜まっていく&lt;/h2>
&lt;p>&lt;a href="https://atsum.in/linux/mise-uninstall" target="_blank" rel="noopener">【mise】mise uninstallでインストール済みツールを削除する&lt;/a>
は削除したいツールとバージョンを自分で指定する必要がある。&lt;code>mise use&lt;/code>でバージョンを切り替えるたびに、古いバージョンを手動で&lt;code>mise uninstall&lt;/code>するのは手間がかかる。&lt;code>mise prune&lt;/code>を使うと、どの設定ファイルからも参照されなくなったバージョンをまとめて削除できる。&lt;/p></description><enclosure url="https://atsum.in/linux/mise-prune/img/thumbnail.png" type="image/png"/></item><item><title>【mise】mise latestで最新バージョンを確認する</title><link>https://atsum.in/linux/mise-latest/</link><pubDate>Sat, 05 Sep 2026 08:23:09 +0900</pubDate><guid>https://atsum.in/linux/mise-latest/</guid><description>&lt;h2 id="最新バージョンだけを手早く確認したい">最新バージョンだけを手早く確認したい&lt;/h2>
&lt;p>&lt;a href="https://atsum.in/linux/mise-ls-remote" target="_blank" rel="noopener">【mise】mise ls-remoteでインストール可能なバージョン一覧を確認する&lt;/a>
はツールの全バージョンを一覧表示するが、最新バージョンだけを知りたい場合は一覧から目視で探す手間がかかる。&lt;code>mise latest&lt;/code>を使うと、最新バージョンだけを1行で確認できる。&lt;/p></description><enclosure url="https://atsum.in/linux/mise-latest/img/thumbnail.png" type="image/png"/></item><item><title>【mise】mise ls-remoteでインストール可能なバージョン一覧を確認する</title><link>https://atsum.in/linux/mise-ls-remote/</link><pubDate>Sat, 05 Sep 2026 08:18:32 +0900</pubDate><guid>https://atsum.in/linux/mise-ls-remote/</guid><description>&lt;h2 id="ツールにどんなバージョンが存在するか確認したい">ツールにどんなバージョンが存在するか確認したい&lt;/h2>
&lt;p>&lt;code>mise use&lt;/code>や&lt;code>mise install&lt;/code>でバージョンを指定するには、そのツールにどんなバージョンが存在するかを事前に知りたい場合がある。&lt;code>mise ls-remote&lt;/code>を使うと、インストール可能なバージョンの一覧をリモートから取得して確認できる。&lt;a href="https://atsum.in/linux/mise-ls" target="_blank" rel="noopener">【mise】mise lsでインストール済みツールの一覧を確認する&lt;/a>
とは対象が異なる点に注意する。&lt;/p></description><enclosure url="https://atsum.in/linux/mise-ls-remote/img/thumbnail.png" type="image/png"/></item><item><title>【mise】mise use --pinで解決済みのバージョンをmise.tomlに保存する</title><link>https://atsum.in/linux/mise-use-pin/</link><pubDate>Sat, 05 Sep 2026 08:06:49 +0900</pubDate><guid>https://atsum.in/linux/mise-use-pin/</guid><description>&lt;h2 id="バージョン範囲を指定すると実行環境によって解決されるバージョンが変わる">バージョン範囲を指定すると、実行環境によって解決されるバージョンが変わる&lt;/h2>
&lt;p>&lt;code>mise use jq@1&lt;/code>のようにメジャーバージョンだけを指定すると、&lt;code>mise.toml&lt;/code>には範囲を示す文字列がそのまま書き込まれる。この状態でメンバーや実行環境が異なると、&lt;code>mise install&lt;/code>で解決する具体的なバージョンも変わる可能性がある。&lt;code>mise use --pin&lt;/code>を使うと、実際に解決した具体的なバージョンを&lt;code>mise.toml&lt;/code>に書き込める。&lt;/p></description><enclosure url="https://atsum.in/linux/mise-use-pin/img/thumbnail.png" type="image/png"/></item><item><title>【mise】mise-actionのversion入力でmise自体のバージョンを固定する</title><link>https://atsum.in/linux/mise-action-version/</link><pubDate>Sat, 05 Sep 2026 07:46:54 +0900</pubDate><guid>https://atsum.in/linux/mise-action-version/</guid><description>&lt;h2 id="mise-actionのワークフロー間でmise本体のバージョンを揃えたい">mise-actionのワークフロー間でmise本体のバージョンを揃えたい&lt;/h2>
&lt;p>&lt;code>jdx/mise-action&lt;/code>は&lt;code>version&lt;/code>を指定しない場合、実行のたびにmise本体の最新リリースをダウンロードする。miseの新しいリリースで挙動が変わった場合、あるワークフローの実行だけ結果が変わってしまう可能性がある。&lt;code>jdx/mise-action&lt;/code>の&lt;code>version&lt;/code>入力を使うと、mise本体のバージョンをワークフロー間で固定できる。&lt;/p></description><enclosure url="https://atsum.in/linux/mise-action-version/img/thumbnail.png" type="image/png"/></item><item><title>【mise】MISE_VERBOSE/MISE_DEBUGでログ出力レベルを変更する</title><link>https://atsum.in/linux/mise-verbose-debug/</link><pubDate>Sat, 05 Sep 2026 07:28:59 +0900</pubDate><guid>https://atsum.in/linux/mise-verbose-debug/</guid><description>&lt;h2 id="ツールのインストールが失敗する原因を調べたい">ツールのインストールが失敗する原因を調べたい&lt;/h2>
&lt;p>miseの既定の出力は、どのツールをどこまでインストールしたかという最小限の情報だけを表示する。ダウンロードURLが正しいか、どのAPIにアクセスしているかなど、失敗の原因を調べたいときには情報が足りない。環境変数&lt;code>MISE_VERBOSE&lt;/code>や&lt;code>MISE_DEBUG&lt;/code>を設定すると、より詳細なログを出力させられる。&lt;/p></description><enclosure url="https://atsum.in/linux/mise-verbose-debug/img/thumbnail.png" type="image/png"/></item><item><title>【mise】MISE_JOBSで並列インストール数を変更する</title><link>https://atsum.in/linux/mise-jobs/</link><pubDate>Sat, 05 Sep 2026 07:14:02 +0900</pubDate><guid>https://atsum.in/linux/mise-jobs/</guid><description>&lt;h2 id="インストールログが並列に混ざって読みにくい">インストールログが並列に混ざって読みにくい&lt;/h2>
&lt;p>&lt;a href="https://atsum.in/linux/mise-install" target="_blank" rel="noopener">【mise】mise installで設定ファイルに書いたツールをインストールする&lt;/a>
で紹介した&lt;code>mise install&lt;/code>は、&lt;code>mise.toml&lt;/code>に複数のツールが書かれている場合、既定で複数のツールを並行してインストールする。速度面では有利だが、複数のツールのダウンロード・インストールログが入り交じって、どのツールでエラーが起きたか分かりにくくなる場合がある。環境変数&lt;code>MISE_JOBS&lt;/code>を設定すると、同時に実行するインストール処理の数を変更できる。&lt;/p></description><enclosure url="https://atsum.in/linux/mise-jobs/img/thumbnail.png" type="image/png"/></item><item><title>【mise】MISE_NOT_FOUND_AUTO_INSTALLで未インストールツールの自動インストールを無効化する</title><link>https://atsum.in/linux/mise-not-found-auto-install/</link><pubDate>Sat, 05 Sep 2026 07:05:00 +0900</pubDate><guid>https://atsum.in/linux/mise-not-found-auto-install/</guid><description>&lt;h2 id="コマンド実行時に意図せずツールがインストールされる">コマンド実行時に意図せずツールがインストールされる&lt;/h2>
&lt;p>miseは&lt;code>mise.toml&lt;/code>にツールを書いておくと、&lt;a href="https://atsum.in/linux/mise-install" target="_blank" rel="noopener">【mise】mise installで設定ファイルに書いたツールをインストールする&lt;/a>
で紹介した&lt;code>mise install&lt;/code>を実行しなくても、そのコマンドを初めて実行したタイミングで自動的にインストールしてくれる。便利な機能である一方、シェルの挙動を調べているときにこの自動インストールが割り込んでくると、原因の切り分けを難しくする場合がある。環境変数&lt;code>MISE_NOT_FOUND_AUTO_INSTALL&lt;/code>を設定すると、この自動インストール機能を無効化できる。&lt;/p></description><enclosure url="https://atsum.in/linux/mise-not-found-auto-install/img/thumbnail.png" type="image/png"/></item><item><title>【mise】MISE_TRUSTED_CONFIG_PATHSで信頼済み設定ファイルのパスを指定する</title><link>https://atsum.in/linux/mise-trusted-config-paths/</link><pubDate>Fri, 04 Sep 2026 23:30:00 +0900</pubDate><guid>https://atsum.in/linux/mise-trusted-config-paths/</guid><description>&lt;h2 id="毎回mise-trustを実行するのが手間">毎回mise trustを実行するのが手間&lt;/h2>
&lt;p>&lt;a href="https://atsum.in/linux/mise-trust" target="_blank" rel="noopener">【mise】mise trustで設定ファイルを信頼する&lt;/a>
で紹介したとおり、&lt;code>[env]&lt;/code>や&lt;code>[tasks]&lt;/code>を含む&lt;code>mise.toml&lt;/code>は&lt;code>mise trust&lt;/code>を実行するまで読み込めない。CI環境など対話的に&lt;code>mise trust&lt;/code>を実行できない場所や、決まったディレクトリ配下のプロジェクトをまとめて信頼済みにしたい場合には不便である。環境変数&lt;code>MISE_TRUSTED_CONFIG_PATHS&lt;/code>にパスを指定すると、&lt;code>mise trust&lt;/code>を実行しなくても、そのパス配下の設定ファイルを信頼済みとして扱える。&lt;/p></description><enclosure url="https://atsum.in/linux/mise-trusted-config-paths/img/thumbnail.png" type="image/png"/></item><item><title>【mise】MISE_DATA_DIRでツールのインストール先ディレクトリを変更する</title><link>https://atsum.in/linux/mise-data-dir/</link><pubDate>Fri, 04 Sep 2026 23:05:16 +0900</pubDate><guid>https://atsum.in/linux/mise-data-dir/</guid><description>&lt;h2 id="ツールのインストール先を別のディスクに置きたい">ツールのインストール先を別のディスクに置きたい&lt;/h2>
&lt;p>miseがインストールするツール本体は、既定で&lt;code>~/.local/share/mise&lt;/code>配下に保存される。ディスク容量の大きい別ボリュームにインストール先をまとめたい、コンテナのビルドキャッシュ層としてインストール先を分離したいなど、既定のパス以外を使いたい場合がある。環境変数&lt;code>MISE_DATA_DIR&lt;/code>を設定すると、ツールのインストール先ディレクトリを変更できる。&lt;/p></description><enclosure url="https://atsum.in/linux/mise-data-dir/img/thumbnail.png" type="image/png"/></item><item><title>【mise】MISE_GLOBAL_CONFIG_FILEでグローバル設定ファイルの場所を変更する</title><link>https://atsum.in/linux/mise-global-config-file/</link><pubDate>Fri, 04 Sep 2026 21:00:00 +0900</pubDate><guid>https://atsum.in/linux/mise-global-config-file/</guid><description>&lt;h2 id="グローバル設定ファイルを別の場所に置きたい">グローバル設定ファイルを別の場所に置きたい&lt;/h2>
&lt;p>&lt;a href="https://atsum.in/linux/mise-use-global" target="_blank" rel="noopener">【mise】mise use --globalで全体的に使うツールのバージョンを設定する&lt;/a>
で紹介したグローバル設定ファイルは、既定で&lt;code>~/.config/mise/config.toml&lt;/code>に置かれる。dotfilesリポジトリの中で設定ファイルを一括管理したい、複数のマシンで共有したいディレクトリに置きたいなど、既定のパス以外を使いたい場合がある。環境変数&lt;code>MISE_GLOBAL_CONFIG_FILE&lt;/code>を設定すると、グローバル設定ファイルとして読み書きするパスそのものを変更できる。&lt;/p></description><enclosure url="https://atsum.in/linux/mise-global-config-file/img/thumbnail.png" type="image/png"/></item><item><title>【mise】MISE_DEFAULT_CONFIG_FILENAMEで作成される設定ファイル名を変更する</title><link>https://atsum.in/linux/mise-default-config-filename/</link><pubDate>Fri, 04 Sep 2026 20:44:36 +0900</pubDate><guid>https://atsum.in/linux/mise-default-config-filename/</guid><description>&lt;h2 id="misetomlではなく別のファイル名で設定を管理したい">mise.tomlではなく別のファイル名で設定を管理したい&lt;/h2>
&lt;p>&lt;a href="https://atsum.in/linux/mise-toml" target="_blank" rel="noopener">【mise】mise.tomlの書き方の基本&lt;/a>
で紹介したとおり、miseは既定で&lt;code>mise.toml&lt;/code>という設定ファイルを読み書きする。プロジェクトの命名規則に合わせてドットファイル形式にしたい、既存の設定ファイル名と統一したいなど、&lt;code>mise.toml&lt;/code>以外の名前を使いたい場合がある。環境変数&lt;code>MISE_DEFAULT_CONFIG_FILENAME&lt;/code>を設定すると、&lt;code>mise use&lt;/code>や&lt;code>mise set&lt;/code>が新規に設定ファイルを作成する際のファイル名を変更できる。&lt;/p></description><enclosure url="https://atsum.in/linux/mise-default-config-filename/img/thumbnail.png" type="image/png"/></item><item><title>【mise】タスクのusageフィールドでCLI引数を定義する</title><link>https://atsum.in/linux/mise-task-usage/</link><pubDate>Fri, 04 Sep 2026 20:29:46 +0900</pubDate><guid>https://atsum.in/linux/mise-task-usage/</guid><description>&lt;h2 id="タスクに実行時のオプションを渡したい">タスクに実行時のオプションを渡したい&lt;/h2>
&lt;p>&lt;a href="https://atsum.in/linux/mise-run" target="_blank" rel="noopener">【mise】mise runでタスクを定義して実行する&lt;/a>
で紹介したタスクは、&lt;code>run&lt;/code>に書いたコマンドをそのまま実行するだけである。デプロイ先の環境名や詳細ログの有無など、実行のたびに変わる値をタスクに渡したい場合がある。&lt;/p></description><enclosure url="https://atsum.in/linux/mise-task-usage/img/thumbnail.png" type="image/png"/></item><item><title>【mise】mise tasks ls でタスク一覧を詳しく確認する</title><link>https://atsum.in/linux/mise-tasks-ls/</link><pubDate>Fri, 04 Sep 2026 20:09:54 +0900</pubDate><guid>https://atsum.in/linux/mise-tasks-ls/</guid><description>&lt;h2 id="misetomlに定義したタスクの詳細を確認したい">mise.tomlに定義したタスクの詳細を確認したい&lt;/h2>
&lt;p>&lt;a href="https://atsum.in/linux/mise-run" target="_blank" rel="noopener">【mise】mise runでタスクを定義して実行する&lt;/a>
で紹介した&lt;code>mise tasks&lt;/code>は、タスク名と&lt;code>description&lt;/code>だけを表示するシンプルな一覧である。タスクの数が増えてくると、定義元の設定ファイルや隠しタスクの有無、グローバルとプロジェクト固有の区別など、絞り込んで確認したくなる場合がある。&lt;code>mise tasks ls&lt;/code>は一覧表示に特化したサブコマンドで、これらのオプションを備えている。&lt;code>mise tasks&lt;/code>は&lt;code>mise tasks ls&lt;/code>のショートハンドであり、両者の結果は同じである。&lt;/p></description><enclosure url="https://atsum.in/linux/mise-tasks-ls/img/thumbnail.png" type="image/png"/></item><item><title>【mise】MISE_ENVで環境別の設定ファイルを切り替える</title><link>https://atsum.in/linux/mise-env-toml/</link><pubDate>Fri, 04 Sep 2026 19:44:32 +0900</pubDate><guid>https://atsum.in/linux/mise-env-toml/</guid><description>&lt;h2 id="開発環境と本番環境でツールのバージョンや環境変数を切り替えたい">開発環境と本番環境でツールのバージョンや環境変数を切り替えたい&lt;/h2>
&lt;p>同じプロジェクトでも、開発環境と本番環境で使うツールのバージョンや環境変数を変えたい場合がある。環境変数&lt;code>MISE_ENV&lt;/code>を指定すると、&lt;code>mise.&amp;lt;環境名&amp;gt;.toml&lt;/code>という命名の設定ファイルを追加で読み込ませられる。&lt;/p></description><enclosure url="https://atsum.in/linux/mise-env-toml/img/thumbnail.png" type="image/png"/></item><item><title>【mise】mise-actionでツールのキャッシュを有効にする</title><link>https://atsum.in/linux/mise-action-cache/</link><pubDate>Thu, 03 Sep 2026 23:58:40 +0900</pubDate><guid>https://atsum.in/linux/mise-action-cache/</guid><description>&lt;h2 id="ワークフローを実行するたびにツールのダウンロードで時間がかかる">ワークフローを実行するたびにツールのダウンロードで時間がかかる&lt;/h2>
&lt;p>&lt;code>jdx/mise-action&lt;/code>は毎回のワークフロー実行で&lt;code>mise install&lt;/code>を実行するため、キャッシュがなければ実行のたびにツールをダウンロードし直すことになる。&lt;code>jdx/mise-action&lt;/code>にはキャッシュ機能が備わっており、2回目以降の実行を高速化できる。&lt;/p></description><enclosure url="https://atsum.in/linux/mise-action-cache/img/thumbnail.png" type="image/png"/></item><item><title>【mise】mise execで一時的にツールバージョンを切り替えてコマンド実行する</title><link>https://atsum.in/linux/mise-exec/</link><pubDate>Thu, 03 Sep 2026 23:50:09 +0900</pubDate><guid>https://atsum.in/linux/mise-exec/</guid><description>&lt;h2 id="misetomlを書き換えずに別バージョンで動作確認したい">mise.tomlを書き換えずに別バージョンで動作確認したい&lt;/h2>
&lt;p>古いバージョンでの挙動を確認したいときなど、&lt;code>mise.toml&lt;/code>を書き換えずにその場限り別バージョンのツールを使いたい場面がある。&lt;code>mise exec&lt;/code>を使うと、&lt;code>mise.toml&lt;/code>を変更せずに指定したバージョンでコマンドを実行できる。&lt;/p></description><enclosure url="https://atsum.in/linux/mise-exec/img/thumbnail.png" type="image/png"/></item><item><title>【mise】mise reshimでshimを再生成する</title><link>https://atsum.in/linux/mise-reshim/</link><pubDate>Thu, 03 Sep 2026 23:22:17 +0900</pubDate><guid>https://atsum.in/linux/mise-reshim/</guid><description>&lt;h2 id="npmのグローバルインストールなどで追加したコマンドが実行できない">npmのグローバルインストールなどで追加したコマンドが実行できない&lt;/h2>
&lt;p>miseはインストールしたツールごとに、実体を呼び出す小さな仲介役(shim)を&lt;code>~/.local/share/mise/shims&lt;/code>に生成する。&lt;code>mise install&lt;/code>でインストールした直後はshimも自動生成されるが、miseの管理外の方法でツール本体のディレクトリに新しい実行ファイルを追加した場合、shimは自動的には作られない。&lt;code>mise reshim&lt;/code>を実行すると、インストール済みツールの実体を再スキャンし、不足しているshimをまとめて生成する。&lt;/p></description><enclosure url="https://atsum.in/linux/mise-reshim/img/thumbnail.png" type="image/png"/></item><item><title>【mise】mise outdated / mise upgrade でツールをアップグレードする</title><link>https://atsum.in/linux/mise-upgrade/</link><pubDate>Thu, 03 Sep 2026 23:10:39 +0900</pubDate><guid>https://atsum.in/linux/mise-upgrade/</guid><description>&lt;h2 id="misetomlのバージョン範囲内で新しいバージョンが出ていないか確認したい">mise.tomlのバージョン範囲内で新しいバージョンが出ていないか確認したい&lt;/h2>
&lt;p>&lt;code>mise.toml&lt;/code>に&lt;code>jq = &amp;quot;1.8&amp;quot;&lt;/code>のようにバージョンを範囲指定していると、その範囲内でより新しいパッチバージョンが出ていても自動では切り替わらない。&lt;code>mise outdated&lt;/code>で更新可能なバージョンを確認し、&lt;code>mise upgrade&lt;/code>でアップグレードできる。&lt;/p></description><enclosure url="https://atsum.in/linux/mise-upgrade/img/thumbnail.png" type="image/png"/></item><item><title>【mise】mise-actionの基本的な使い方</title><link>https://atsum.in/linux/mise-action-basic/</link><pubDate>Thu, 03 Sep 2026 22:59:16 +0900</pubDate><guid>https://atsum.in/linux/mise-action-basic/</guid><description>&lt;h2 id="github-actionsのワークフローでmisetomlに書いたツールを使いたい">GitHub Actionsのワークフローでmise.tomlに書いたツールを使いたい&lt;/h2>
&lt;p>ローカルでは&lt;code>mise install&lt;/code>を実行すればよいが、GitHub Actionsのワークフロー上でも同じように&lt;code>mise.toml&lt;/code>に書いたツールをセットアップしたい。&lt;a href="https://github.com/jdx/mise-action" target="_blank" rel="noopener nofollow">jdx/mise-action&lt;/a>
を使うと、ワークフロー上にmiseをインストールし、リポジトリの&lt;code>mise.toml&lt;/code>に書かれたツールをそのまま使えるようになる。&lt;/p></description><enclosure url="https://atsum.in/linux/mise-action-basic/img/thumbnail.png" type="image/png"/></item><item><title>【mise】mise uninstallでインストール済みツールを削除する</title><link>https://atsum.in/linux/mise-uninstall/</link><pubDate>Thu, 03 Sep 2026 22:49:15 +0900</pubDate><guid>https://atsum.in/linux/mise-uninstall/</guid><description>&lt;h2 id="使わなくなったツールのバージョンをディスクから消したい">使わなくなったツールのバージョンをディスクから消したい&lt;/h2>
&lt;p>&lt;code>mise install &amp;lt;tool&amp;gt;@&amp;lt;version&amp;gt;&lt;/code>でバージョンを指定してインストールを繰り返していると、使わなくなった古いバージョンがディスクに残り続ける。&lt;code>mise uninstall&lt;/code>を使うと、インストール済みのツールを個別に削除できる。&lt;/p></description><enclosure url="https://atsum.in/linux/mise-uninstall/img/thumbnail.png" type="image/png"/></item><item><title>【mise】mise activate でシェルにmiseを組み込む</title><link>https://atsum.in/linux/mise-activate/</link><pubDate>Thu, 03 Sep 2026 22:30:49 +0900</pubDate><guid>https://atsum.in/linux/mise-activate/</guid><description>&lt;h2 id="mise-installしてもコマンドの実体が切り替わらない">mise installしてもコマンドの実体が切り替わらない&lt;/h2>
&lt;p>&lt;code>mise.toml&lt;/code>にツールを記述して&lt;code>mise install&lt;/code>を実行しても、シェルで直接コマンド名を打ったときに使われる実体は自動的には切り替わらない。&lt;code>jq&lt;/code>のようにシステムにも同名のコマンドがインストール済みの場合、そちらが優先されたままになる。&lt;code>mise activate&lt;/code>をシェルに組み込むと、ディレクトリごとに&lt;code>mise.toml&lt;/code>で指定したバージョンへコマンドの解決先が自動的に切り替わる。&lt;/p></description><enclosure url="https://atsum.in/linux/mise-activate/img/thumbnail.png" type="image/png"/></item><item><title>【mise】.tool-versions との互換性</title><link>https://atsum.in/linux/mise-tool-versions/</link><pubDate>Thu, 03 Sep 2026 22:21:25 +0900</pubDate><guid>https://atsum.in/linux/mise-tool-versions/</guid><description>&lt;h2 id="asdfから移行するときにtool-versionsを書き換えたくない">asdfから移行するときに.tool-versionsを書き換えたくない&lt;/h2>
&lt;p>&lt;code>asdf&lt;/code>はプロジェクトで使うツールのバージョンを&lt;code>.tool-versions&lt;/code>というファイルで管理する。&lt;code>mise&lt;/code>は&lt;code>.tool-versions&lt;/code>をそのまま読み込めるため、&lt;code>asdf&lt;/code>から&lt;code>mise&lt;/code>へ移行する際に&lt;code>.tool-versions&lt;/code>を書き換える必要はない。&lt;/p></description><enclosure url="https://atsum.in/linux/mise-tool-versions/img/thumbnail.png" type="image/png"/></item><item><title>【mise】mise.toml の書き方の基本</title><link>https://atsum.in/linux/mise-toml/</link><pubDate>Thu, 03 Sep 2026 21:12:43 +0900</pubDate><guid>https://atsum.in/linux/mise-toml/</guid><description>&lt;h2 id="misetomlに何を書けるのか把握したい">mise.tomlに何を書けるのか把握したい&lt;/h2>
&lt;p>&lt;code>mise&lt;/code>はプロジェクトで使うツールのバージョンや環境変数、タスクを&lt;code>mise.toml&lt;/code>という設定ファイルで管理する。&lt;code>mise.toml&lt;/code>には[tools]以外にもいくつかのセクションがあり、書ける内容やファイルの置き場所にはルールがある。&lt;/p></description><enclosure url="https://atsum.in/linux/mise-toml/img/thumbnail.png" type="image/png"/></item><item><title>【mise】miseコマンドまとめ</title><link>https://atsum.in/linux/mise/</link><pubDate>Thu, 03 Sep 2026 20:40:32 +0900</pubDate><guid>https://atsum.in/linux/mise/</guid><description>&lt;p>&lt;code>mise&lt;/code>は、プロジェクトごとに使うツールのバージョンを&lt;code>mise.toml&lt;/code>で管理するツールである。1つのコマンドが担う役割は小さく分かれているため、目的に応じたコマンドを個別に把握しておくと使いやすい。ここではmiseの主要なコマンドを目的別に整理し、それぞれの使い方を解説した記事へリンクする。&lt;/p></description><enclosure url="https://atsum.in/linux/mise/img/thumbnail.png" type="image/png"/></item><item><title>【mise】mise run でタスクを定義して実行する</title><link>https://atsum.in/linux/mise-run/</link><pubDate>Thu, 03 Sep 2026 20:34:45 +0900</pubDate><guid>https://atsum.in/linux/mise-run/</guid><description>&lt;h2 id="ビルドやテストのコマンドをmisetomlにまとめて管理したい">ビルドやテストのコマンドをmise.tomlにまとめて管理したい&lt;/h2>
&lt;p>プロジェクトごとに使う&lt;code>npm run build&lt;/code>や&lt;code>make test&lt;/code>のようなコマンドを、READMEやシェルスクリプトへ散らばらせず&lt;code>mise.toml&lt;/code>にまとめて定義しておきたい場合がある。miseは&lt;code>mise.toml&lt;/code>にタスクを定義し、&lt;code>mise run&lt;/code>で実行できるタスクランナー機能を備えている。&lt;/p></description><enclosure url="https://atsum.in/linux/mise-run/img/thumbnail.png" type="image/png"/></item><item><title>【mise】mise trust で設定ファイルを信頼する</title><link>https://atsum.in/linux/mise-trust/</link><pubDate>Thu, 03 Sep 2026 20:20:26 +0900</pubDate><guid>https://atsum.in/linux/mise-trust/</guid><description>&lt;h2 id="初めて開いたプロジェクトでmiseコマンドがエラーになる">初めて開いたプロジェクトでmiseコマンドがエラーになる&lt;/h2>
&lt;p>&lt;code>mise.toml&lt;/code>は環境変数の設定やタスクの定義など、コードの実行や環境に影響する内容を含められる。知らないリポジトリの&lt;code>mise.toml&lt;/code>をそのまま読み込んでしまうと、意図しないコードの実行につながるおそれがある。そのためmiseはこのような設定ファイルを未信頼(untrusted)として扱い、読み込む前に&lt;code>mise trust&lt;/code>による明示的な信頼を求める。&lt;/p></description><enclosure url="https://atsum.in/linux/mise-trust/img/thumbnail.png" type="image/png"/></item><item><title>【mise】mise doctor で環境の問題を診断する</title><link>https://atsum.in/linux/mise-doctor/</link><pubDate>Thu, 03 Sep 2026 19:46:59 +0900</pubDate><guid>https://atsum.in/linux/mise-doctor/</guid><description>&lt;h2 id="miseが正しく動作しているか確認したい">miseが正しく動作しているか確認したい&lt;/h2>
&lt;p>&lt;code>mise use&lt;/code>や&lt;code>mise install&lt;/code>を実行したのに意図したバージョンが使われない、といった場合、miseの設定やPATHの状態を1つずつ確認するのは手間がかかる。&lt;code>mise doctor&lt;/code>を実行すると、miseの動作状況をまとめて確認でき、問題があれば警告として教えてくれる。&lt;/p></description><enclosure url="https://atsum.in/linux/mise-doctor/img/thumbnail.png" type="image/png"/></item><item><title>【mise】mise which で実行ファイルの実体パスを確認する</title><link>https://atsum.in/linux/mise-which/</link><pubDate>Thu, 03 Sep 2026 18:30:50 +0900</pubDate><guid>https://atsum.in/linux/mise-which/</guid><description>&lt;h2 id="miseが管理するコマンドの実行ファイルがどこにあるか確認したい">miseが管理するコマンドの実行ファイルがどこにあるか確認したい&lt;/h2>
&lt;p>ターミナルでOSの&lt;code>which&lt;/code>コマンドを使っても、PATHの設定状況によっては、mise管理下のバージョンとは別の場所にインストールされた同名のコマンドを指す場合がある。&lt;code>mise which&lt;/code>を使うと、mise管理下で実際に使われる実行ファイルのパスを確実に確認できる。&lt;/p></description><enclosure url="https://atsum.in/linux/mise-which/img/thumbnail.png" type="image/png"/></item><item><title>【mise】mise where でツールのインストールパスを確認する</title><link>https://atsum.in/linux/mise-where/</link><pubDate>Thu, 03 Sep 2026 08:50:14 +0900</pubDate><guid>https://atsum.in/linux/mise-where/</guid><description>&lt;h2 id="miseがインストールしたツールの実体がどこにあるか確認したい">miseがインストールしたツールの実体がどこにあるか確認したい&lt;/h2>
&lt;p>miseは&lt;code>mise install&lt;/code>でツールをダウンロードすると、独自の管理ディレクトリ配下でバージョンごとにインストールする。インストール先のパスを直接知りたい場合、&lt;code>mise where&lt;/code>を使うとツールのインストールディレクトリを確認できる。&lt;/p></description><enclosure url="https://atsum.in/linux/mise-where/img/thumbnail.png" type="image/png"/></item><item><title>【mise】mise current で現在有効なツールのバージョンを確認する</title><link>https://atsum.in/linux/mise-current/</link><pubDate>Thu, 03 Sep 2026 08:45:36 +0900</pubDate><guid>https://atsum.in/linux/mise-current/</guid><description>&lt;h2 id="カレントディレクトリで実際に使われているバージョンだけを確認したい">カレントディレクトリで実際に使われているバージョンだけを確認したい&lt;/h2>
&lt;p>&lt;code>mise ls&lt;/code>は設定ファイルの場所やインストール状況まで含めた一覧を表示するが、単純に「今このディレクトリで有効なバージョンは何か」だけを知りたい場合は情報が多すぎる。&lt;code>mise current&lt;/code>を使うと、カレントディレクトリで現在有効なツールとバージョンだけをシンプルに表示できる。&lt;/p></description><enclosure url="https://atsum.in/linux/mise-current/img/thumbnail.png" type="image/png"/></item><item><title>【mise】mise ls でインストール済みツールの一覧を確認する</title><link>https://atsum.in/linux/mise-ls/</link><pubDate>Thu, 03 Sep 2026 08:26:15 +0900</pubDate><guid>https://atsum.in/linux/mise-ls/</guid><description>&lt;h2 id="misetomlに書いたツールが実際にインストールされているか確認したい">mise.tomlに書いたツールが実際にインストールされているか確認したい&lt;/h2>
&lt;p>&lt;code>mise use&lt;/code>や&lt;code>mise install&lt;/code>でツールを追加した後、実際にどのツールがインストールされていて、どのバージョンが有効になっているかを確認したい場合がある。&lt;code>mise ls&lt;/code>を使うと、mise管理下のツールとバージョンの一覧を確認できる。&lt;code>mise list&lt;/code>は&lt;code>mise ls&lt;/code>のエイリアスであり、同じ結果を得られる。&lt;/p></description><enclosure url="https://atsum.in/linux/mise-ls/img/thumbnail.png" type="image/png"/></item><item><title>【mise】mise use --global で全体的に使うツールのバージョンを設定する</title><link>https://atsum.in/linux/mise-use-global/</link><pubDate>Thu, 03 Sep 2026 08:13:50 +0900</pubDate><guid>https://atsum.in/linux/mise-use-global/</guid><description>&lt;h2 id="プロジェクトを問わず使うツールのバージョンを設定したい">プロジェクトを問わず使うツールのバージョンを設定したい&lt;/h2>
&lt;p>&lt;code>mise use&lt;/code>は、実行したディレクトリの&lt;code>mise.toml&lt;/code>にツールとバージョンを書き込む。プロジェクトごとにバージョンを揃えるにはこれで十分だが、&lt;code>fzf&lt;/code>や&lt;code>ripgrep&lt;/code>のように特定のプロジェクトに紐付かず、どこでも同じバージョンを使いたいツールもある。&lt;code>mise use --global&lt;/code>を使うと、ディレクトリに関係なく共通で使うツールのバージョンを設定できる。&lt;/p></description><enclosure url="https://atsum.in/linux/mise-use-global/img/thumbnail.png" type="image/png"/></item><item><title>【mise】mise use でプロジェクトに使うツールのバージョンを設定する</title><link>https://atsum.in/linux/mise-use/</link><pubDate>Thu, 03 Sep 2026 08:06:53 +0900</pubDate><guid>https://atsum.in/linux/mise-use/</guid><description>&lt;h2 id="misetomlへのツール追加とインストールを一度に済ませたい">mise.tomlへのツール追加とインストールを一度に済ませたい&lt;/h2>
&lt;p>プロジェクトで新しいツールを使い始めたい場合、&lt;code>mise.toml&lt;/code>を直接編集してツールとバージョンを追記し、その後&lt;code>mise install&lt;/code>でインストールするという手順を踏める。&lt;code>mise use&lt;/code>コマンドを使うと、&lt;code>mise.toml&lt;/code>への追記とインストールを1つのコマンドで行える。&lt;/p></description><enclosure url="https://atsum.in/linux/mise-use/img/thumbnail.png" type="image/png"/></item><item><title>【mise】mise install で設定ファイルに書いたツールをインストールする</title><link>https://atsum.in/linux/mise-install/</link><pubDate>Thu, 03 Sep 2026 07:59:03 +0900</pubDate><guid>https://atsum.in/linux/mise-install/</guid><description>&lt;h2 id="misetomlに書いたツールを実際にインストールしたい">mise.tomlに書いたツールを実際にインストールしたい&lt;/h2>
&lt;p>&lt;code>mise&lt;/code>はプロジェクトごとに使うツールのバージョンを&lt;code>mise.toml&lt;/code>で管理する。&lt;code>mise.toml&lt;/code>にツールとバージョンを記述しただけでは、そのバージョンの実体はまだダウンロードされていない。&lt;code>mise install&lt;/code>を実行すると、設定ファイルに書かれたツールを実際にダウンロード・インストールする。&lt;/p></description><enclosure url="https://atsum.in/linux/mise-install/img/thumbnail.png" type="image/png"/></item><item><title>【GitHub Actions】ログをグループ化して見やすくする</title><link>https://atsum.in/linux/github-actions-log-grouping/</link><pubDate>Mon, 31 Aug 2026 20:02:50 +0900</pubDate><guid>https://atsum.in/linux/github-actions-log-grouping/</guid><description>&lt;h2 id="ログをグループ化する">ログをグループ化する&lt;/h2>
&lt;p>GitHub Actionsのログは実行内容が多いと縦に長くなり、目的の箇所を探しづらい。&lt;/p>
&lt;p>&lt;code>::group::&lt;/code>と&lt;code>::endgroup::&lt;/code>のワークフローコマンドを使うと、ログを折りたたみ可能なブロックにまとめられる。&lt;/p></description><enclosure url="https://atsum.in/linux/github-actions-log-grouping/img/thumbnail.png" type="image/png"/></item><item><title>【find -iname】大文字・小文字を区別せずファイル名で検索する</title><link>https://atsum.in/linux/find-iname/</link><pubDate>Mon, 31 Aug 2026 19:50:05 +0900</pubDate><guid>https://atsum.in/linux/find-iname/</guid><description>&lt;h2 id="大文字小文字を区別せずファイルを検索したい">大文字・小文字を区別せずファイルを検索したい&lt;/h2>
&lt;p>&lt;code>find&lt;/code>コマンドの&lt;code>-name&lt;/code>オプションは、大文字・小文字を区別してファイル名を検索する。&lt;code>README.md&lt;/code>と&lt;code>readme.txt&lt;/code>のように表記が揺れているファイルをまとめて検索したい場合、&lt;code>-iname&lt;/code>オプションを使う。&lt;/p></description><enclosure url="https://atsum.in/linux/find-iname/img/thumbnail.png" type="image/png"/></item><item><title>【MySQL】EXPLAIN ANALYZEで実測値を確認する</title><link>https://atsum.in/database/mysql-explain-analyze/</link><pubDate>Sun, 23 Aug 2026 11:25:18 +0900</pubDate><guid>https://atsum.in/database/mysql-explain-analyze/</guid><description>&lt;p>MySQLでクエリの実行計画とあわせて実際の実行時間を確認するには&lt;code>EXPLAIN ANALYZE&lt;/code>を使う。MySQL 8.0.18以降で利用できる。&lt;/p></description><enclosure url="https://atsum.in/database/mysql-explain-analyze/img/thumbnail.png" type="image/png"/></item><item><title>【MySQL】EXPLAINの読み方の基本</title><link>https://atsum.in/database/mysql-explain-basics/</link><pubDate>Sun, 23 Aug 2026 09:03:13 +0900</pubDate><guid>https://atsum.in/database/mysql-explain-basics/</guid><description>&lt;p>MySQLでクエリの実行計画を確認するには&lt;code>EXPLAIN&lt;/code>を使う。&lt;br>
&lt;code>type&lt;/code>・&lt;code>key&lt;/code>・&lt;code>rows&lt;/code>・&lt;code>Extra&lt;/code>の意味を理解すると、インデックスが効いているかどうかを判断できる。&lt;/p></description><enclosure url="https://atsum.in/database/mysql-explain-basics/img/thumbnail.png" type="image/png"/></item><item><title>【MySQL】デッドロックのログの読み方</title><link>https://atsum.in/database/mysql-deadlock-log/</link><pubDate>Sun, 23 Aug 2026 08:47:23 +0900</pubDate><guid>https://atsum.in/database/mysql-deadlock-log/</guid><description>&lt;p>MySQLでデッドロックが発生すると、&lt;code>SHOW ENGINE INNODB STATUS&lt;/code>の&lt;code>LATEST DETECTED DEADLOCK&lt;/code>に直近の詳細が記録される。&lt;br>
継続的に記録するには&lt;code>innodb_print_all_deadlocks&lt;/code>を有効にし、エラーログに全件を残す。&lt;/p></description><enclosure url="https://atsum.in/database/mysql-deadlock-log/img/thumbnail.png" type="image/png"/></item><item><title>【MySQL】SHOW PROCESSLISTで実行中クエリとロック待ちを確認する</title><link>https://atsum.in/database/mysql-show-processlist/</link><pubDate>Sat, 22 Aug 2026 16:12:16 +0900</pubDate><guid>https://atsum.in/database/mysql-show-processlist/</guid><description>&lt;p>MySQLで実行中のクエリを確認するには&lt;code>SHOW PROCESSLIST&lt;/code>を使う。&lt;br>
ロック待ちの詳細を調べるには&lt;code>information_schema.innodb_trx&lt;/code>や&lt;code>sys.innodb_lock_waits&lt;/code>とあわせて確認する。&lt;/p></description><enclosure url="https://atsum.in/database/mysql-show-processlist/img/thumbnail.png" type="image/png"/></item><item><title>【MySQL】performance_schemaで重いクエリを特定する</title><link>https://atsum.in/database/mysql-statement-digest/</link><pubDate>Fri, 21 Aug 2026 20:22:26 +0900</pubDate><guid>https://atsum.in/database/mysql-statement-digest/</guid><description>&lt;p>MySQLで実行されたSQL文ごとの実行回数・実行時間を集計するには、&lt;code>performance_schema.events_statements_summary_by_digest&lt;/code>を使う。&lt;br>
&lt;code>sys.statement_analysis&lt;/code>を使うと、単位が読みやすく整形された形で同様の情報を確認できる。&lt;/p></description><enclosure url="https://atsum.in/database/mysql-statement-digest/img/thumbnail.png" type="image/png"/></item><item><title>【MySQL】スロークエリをログに出力する</title><link>https://atsum.in/database/mysql-slow-query-log/</link><pubDate>Fri, 21 Aug 2026 08:47:51 +0900</pubDate><guid>https://atsum.in/database/mysql-slow-query-log/</guid><description>&lt;p>MySQLで実行時間の長いSQL文をログに出力するには、&lt;code>slow_query_log&lt;/code>・&lt;code>long_query_time&lt;/code>を設定する。&lt;br>
インデックスを使わないクエリまで対象を広げる場合は&lt;code>log_queries_not_using_indexes&lt;/code>もあわせて使う。&lt;/p></description><enclosure url="https://atsum.in/database/mysql-slow-query-log/img/thumbnail.png" type="image/png"/></item><item><title>【MySQL】innodb_buffer_pool_sizeと各種バッファの役割・確認方法</title><link>https://atsum.in/database/mysql-buffer-pool-size/</link><pubDate>Fri, 21 Aug 2026 08:31:50 +0900</pubDate><guid>https://atsum.in/database/mysql-buffer-pool-size/</guid><description>&lt;p>MySQLのメモリも、PostgreSQLと同様に全接続で共有する領域と、接続ごとに確保する領域へ大別できる。&lt;br>
&lt;code>innodb_buffer_pool_size&lt;/code>は前者、&lt;code>sort_buffer_size&lt;/code>・&lt;code>join_buffer_size&lt;/code>は後者を制御するパラメータである。&lt;/p></description><enclosure url="https://atsum.in/database/mysql-buffer-pool-size/img/thumbnail.png" type="image/png"/></item><item><title>【MySQL】接続数の上限と現在の接続数を確認する</title><link>https://atsum.in/database/mysql-max-connections/</link><pubDate>Fri, 21 Aug 2026 00:04:57 +0900</pubDate><guid>https://atsum.in/database/mysql-max-connections/</guid><description>&lt;p>MySQLで同時接続数の上限や現在の接続状況を確認するには、&lt;code>max_connections&lt;/code>・&lt;code>Threads_connected&lt;/code>・&lt;code>Max_used_connections&lt;/code>を使う。&lt;/p></description><enclosure url="https://atsum.in/database/mysql-max-connections/img/thumbnail.png" type="image/png"/></item><item><title>【MySQL】各データベースのサイズを確認する</title><link>https://atsum.in/database/mysql-database-size/</link><pubDate>Thu, 20 Aug 2026 23:52:42 +0900</pubDate><guid>https://atsum.in/database/mysql-database-size/</guid><description>&lt;p>MySQLには、PostgreSQLの&lt;code>pg_database_size&lt;/code>関数のようにデータベースのサイズを直接返す関数はない。&lt;br>
&lt;code>information_schema.tables&lt;/code>の&lt;code>DATA_LENGTH&lt;/code>・&lt;code>INDEX_LENGTH&lt;/code>カラムを集計してサイズを求める。&lt;/p></description><enclosure url="https://atsum.in/database/mysql-database-size/img/thumbnail.png" type="image/png"/></item><item><title>【MySQL】my.cnfの場所を探す</title><link>https://atsum.in/database/mysql-my-cnf-location/</link><pubDate>Thu, 20 Aug 2026 23:36:16 +0900</pubDate><guid>https://atsum.in/database/mysql-my-cnf-location/</guid><description>&lt;p>MySQLの設定ファイル&lt;code>my.cnf&lt;/code>はOSやインストール方法によって場所が異なる。&lt;br>
PostgreSQLの&lt;code>show config_file;&lt;/code>のように設定ファイルの場所を直接返すSQL文はなく、&lt;code>SHOW VARIABLES&lt;/code>にも該当する項目はない。&lt;br>
稼働しているMySQLの設定ファイルの場所を確認するには、&lt;code>mysqld&lt;/code>コマンドの探索順表示や&lt;code>--print-defaults&lt;/code>オプションを使う。&lt;/p></description><enclosure url="https://atsum.in/database/mysql-my-cnf-location/img/thumbnail.png" type="image/png"/></item><item><title>【sar】CPUやメモリの使用状況を確認する</title><link>https://atsum.in/linux/sar/</link><pubDate>Thu, 20 Aug 2026 08:12:34 +0900</pubDate><guid>https://atsum.in/linux/sar/</guid><description>&lt;h2 id="sarとは">sarとは&lt;/h2>
&lt;p>&lt;code>sar&lt;/code>はCPU、メモリ、ディスクI/Oなどシステム全体の統計情報を表示するコマンドである。
&lt;code>-r&lt;/code>や&lt;code>-d&lt;/code>などのオプションで表示する統計の種類を切り替えられる。&lt;/p></description><enclosure url="https://atsum.in/linux/sar/img/thumbnail.png" type="image/png"/></item><item><title>【mpstat】CPUコアごとの使用率を確認する</title><link>https://atsum.in/linux/mpstat/</link><pubDate>Wed, 19 Aug 2026 23:05:12 +0900</pubDate><guid>https://atsum.in/linux/mpstat/</guid><description>&lt;h2 id="mpstatとは">mpstatとは&lt;/h2>
&lt;p>&lt;code>mpstat&lt;/code>はCPU全体、またはCPUコアごとの使用率を表示するコマンドである。&lt;/p>
&lt;p>&lt;code>sysstat&lt;/code>パッケージに含まれており、Debian/Ubuntu系では以下でインストールする。&lt;/p></description><enclosure url="https://atsum.in/linux/mpstat/img/thumbnail.png" type="image/png"/></item><item><title>【Linux】pidstatでプロセスごとのCPU使用率を確認する</title><link>https://atsum.in/linux/pidstat/</link><pubDate>Wed, 19 Aug 2026 22:17:56 +0900</pubDate><guid>https://atsum.in/linux/pidstat/</guid><description>&lt;h2 id="pidstatとは">pidstatとは&lt;/h2>
&lt;p>&lt;code>pidstat&lt;/code>はプロセス単位でCPU使用率を表示するコマンドである。
&lt;code>top&lt;/code>と異なり、指定したプロセスの推移をログのように出力できる。&lt;/p>
&lt;p>&lt;code>sysstat&lt;/code>パッケージに含まれており、Debian/Ubuntu系では以下でインストールする。&lt;/p></description><enclosure url="https://atsum.in/linux/pidstat/img/thumbnail.png" type="image/png"/></item><item><title>jqコマンドの-cオプションでJSON Lines形式に出力し1行ずつ処理する</title><link>https://atsum.in/linux/jq-jsonlines/</link><pubDate>Tue, 18 Aug 2026 20:37:24 +0900</pubDate><guid>https://atsum.in/linux/jq-jsonlines/</guid><description>&lt;h2 id="pretty-printのままだと1行1レコードで扱えない">pretty printのままだと1行1レコードで扱えない&lt;/h2>
&lt;p>jqはデフォルトで出力を整形（pretty print）するため、1件のオブジェクトが複数行にまたがる。&lt;/p></description><enclosure url="https://atsum.in/linux/jq-jsonlines/img/thumbnail.png" type="image/png"/></item><item><title>【MySQL】--batchオプションでタブ区切り出力にする</title><link>https://atsum.in/database/mysql-batch/</link><pubDate>Sun, 16 Aug 2026 18:35:18 +0900</pubDate><guid>https://atsum.in/database/mysql-batch/</guid><description>&lt;h2 id="batchオプション">&amp;ndash;batchオプション&lt;/h2>
&lt;p>&lt;code>mysql&lt;/code>コマンドの&lt;code>--batch&lt;/code>(&lt;code>-B&lt;/code>)オプションは、クエリ結果の出力形式を罫線付きのテーブル形式からタブ区切り形式に変える。&lt;/p>
&lt;p>対話端末で&lt;code>mysql&lt;/code>を実行すると、通常は罫線付きのテーブル形式で結果が表示される。&lt;/p></description><enclosure url="https://atsum.in/database/mysql-batch/img/thumbnail.png" type="image/png"/></item><item><title>mysqldumpslowでMySQLのスロークエリを集計する</title><link>https://atsum.in/database/mysqldumpslow/</link><pubDate>Sun, 16 Aug 2026 14:06:20 +0900</pubDate><guid>https://atsum.in/database/mysqldumpslow/</guid><description>&lt;h2 id="mysqldumpslow">mysqldumpslow&lt;/h2>
&lt;p>mysqldumpslowはMySQLのスロークエリログを集計するツール。MySQL本体に同梱されており、追加のソフトウェアなしで利用できる。&lt;/p></description><enclosure url="https://atsum.in/database/mysqldumpslow/img/thumbnail.png" type="image/png"/></item><item><title>【diff -q】終了コードだけでファイルの差分有無を判定する</title><link>https://atsum.in/linux/diff-q/</link><pubDate>Sun, 16 Aug 2026 10:50:56 +0900</pubDate><guid>https://atsum.in/linux/diff-q/</guid><description>&lt;h2 id="ファイルの差分有無だけを知りたい">ファイルの差分有無だけを知りたい&lt;/h2>
&lt;p>&lt;code>diff&lt;/code>コマンドは差分箇所を出力するが、シェルスクリプトなどで差分の有無だけを判定したい場合、差分箇所の出力は不要である。&lt;code>-q&lt;/code>オプションを付けると、差分箇所を出力せず「ファイルが異なるかどうか」のみを終了コードで返す。&lt;/p></description><enclosure url="https://atsum.in/linux/diff-q/img/thumbnail.png" type="image/png"/></item><item><title>【Linux】ss -tlnpでリッスン中のポートとプロセスをまとめて確認する</title><link>https://atsum.in/linux/ss-tlnp/</link><pubDate>Sun, 16 Aug 2026 09:54:13 +0900</pubDate><guid>https://atsum.in/linux/ss-tlnp/</guid><description>&lt;p>サーバでどのプロセスがどのポートをリッスンしているか、まとめて確認したい場合がある。&lt;code>ss&lt;/code>コマンドに&lt;code>-tlnp&lt;/code>オプションを付けると、TCPのLISTEN状態のソケットをポート番号とプロセス情報つきで一覧表示できる。&lt;/p></description><enclosure url="https://atsum.in/linux/ss-tlnp/img/thumbnail.png" type="image/png"/></item><item><title>installコマンドでパーミッションと所有者を指定してファイルをコピーする</title><link>https://atsum.in/linux/install-copy-owner-mode/</link><pubDate>Sun, 16 Aug 2026 09:36:51 +0900</pubDate><guid>https://atsum.in/linux/install-copy-owner-mode/</guid><description>&lt;h2 id="install-コマンド">install コマンド&lt;/h2>
&lt;p>&lt;code>install&lt;/code>コマンドはファイルのコピーと同時にパーミッションや所有者を設定するコマンド。&lt;code>-m&lt;/code>オプションでパーミッション、&lt;code>-o&lt;/code>オプションで所有者、&lt;code>-g&lt;/code>オプションでグループを指定してコピーできる。&lt;code>cp&lt;/code>、&lt;code>chown&lt;/code>、&lt;code>chmod&lt;/code>を組み合わせるより1コマンドで簡潔に記述できる。&lt;/p></description><enclosure url="https://atsum.in/linux/install-copy-owner-mode/img/thumbnail.png" type="image/png"/></item><item><title>【curl】-o /dev/nullと-wでステータスコードと所要時間だけ取得する</title><link>https://atsum.in/linux/curl-status-code-time-total/</link><pubDate>Sun, 16 Aug 2026 08:17:14 +0900</pubDate><guid>https://atsum.in/linux/curl-status-code-time-total/</guid><description>&lt;p>&lt;code>curl&lt;/code>はデフォルトでレスポンスボディを標準出力に表示する。ステータスコードと所要時間だけ知りたい場合、ボディの表示は不要である。&lt;code>-o /dev/null&lt;/code>でボディを破棄し、&lt;code>-w&lt;/code>オプションで必要な値だけを出力する。&lt;/p></description><enclosure url="https://atsum.in/linux/curl-status-code-time-total/img/thumbnail.png" type="image/png"/></item><item><title>【gzip】-k で元ファイルを消さずに圧縮ファイルを作る</title><link>https://atsum.in/linux/gzip-keep-original/</link><pubDate>Sun, 16 Aug 2026 08:07:00 +0900</pubDate><guid>https://atsum.in/linux/gzip-keep-original/</guid><description>&lt;p>&lt;code>gzip&lt;/code>はデフォルトで圧縮と同時に元ファイルを削除する。元ファイルを残したまま圧縮ファイルだけを作りたい場合は&lt;code>-k&lt;/code>(&lt;code>--keep&lt;/code>)オプションを使う。&lt;/p></description><enclosure url="https://atsum.in/linux/gzip-keep-original/img/thumbnail.png" type="image/png"/></item><item><title>【MySQL】再起動が必要な設定を見分ける</title><link>https://atsum.in/database/mysql-dynamic-variables/</link><pubDate>Sat, 15 Aug 2026 18:00:00 +0900</pubDate><guid>https://atsum.in/database/mysql-dynamic-variables/</guid><description>&lt;p>MySQLの設定には、&lt;code>SET GLOBAL&lt;/code>で即座に変更できる動的変数と、&lt;code>my.cnf&lt;/code>を書き換えてサーバーを再起動しないと変更できない静的変数がある。&lt;br>
&lt;code>SHOW VARIABLES&lt;/code>の結果だけではどちらか判別できないため、他の方法で見分ける必要がある。&lt;/p></description><enclosure url="https://atsum.in/database/mysql-dynamic-variables/img/thumbnail.png" type="image/png"/></item><item><title>【MySQL】設定値を一覧・検索する</title><link>https://atsum.in/database/mysql-show-variables/</link><pubDate>Sat, 15 Aug 2026 17:00:00 +0900</pubDate><guid>https://atsum.in/database/mysql-show-variables/</guid><description>&lt;h2 id="show-variablesで設定値を一覧検索する">SHOW VARIABLESで設定値を一覧・検索する&lt;/h2>
&lt;p>MySQLの全設定値を一覧するには&lt;code>SHOW VARIABLES&lt;/code>文を実行する。&lt;/p>
&lt;div class="highlight">&lt;pre tabindex="0" class="chroma">&lt;code class="language-sql" data-lang="sql">&lt;span class="line">&lt;span class="cl">&lt;span class="k">SHOW&lt;/span>&lt;span class="w"> &lt;/span>&lt;span class="n">VARIABLES&lt;/span>&lt;span class="p">;&lt;/span>&lt;span class="w">
&lt;/span>&lt;/span>&lt;/span>&lt;/code>&lt;/pre>&lt;/div>&lt;p>設定項目数は600件を超え(バージョンによって異なる)、&lt;code>Variable_name&lt;/code>と&lt;code>Value&lt;/code>の2カラムのみが表示される。&lt;/p></description><enclosure url="https://atsum.in/database/mysql-show-variables/img/thumbnail.png" type="image/png"/></item><item><title>【MySQL】ユーザー・ロール・権限一覧を確認する</title><link>https://atsum.in/database/mysql-show-grants/</link><pubDate>Sat, 15 Aug 2026 16:00:00 +0900</pubDate><guid>https://atsum.in/database/mysql-show-grants/</guid><description>&lt;h2 id="show-grantsで権限を確認する">SHOW GRANTSで権限を確認する&lt;/h2>
&lt;p>MySQLで指定したユーザーに付与されている権限を確認するには&lt;code>SHOW GRANTS&lt;/code>文を使う。&lt;/p>
&lt;div class="highlight">&lt;pre tabindex="0" class="chroma">&lt;code class="language-sql" data-lang="sql">&lt;span class="line">&lt;span class="cl">&lt;span class="k">SHOW&lt;/span>&lt;span class="w"> &lt;/span>&lt;span class="n">GRANTS&lt;/span>&lt;span class="w"> &lt;/span>&lt;span class="k">FOR&lt;/span>&lt;span class="w"> &lt;/span>&lt;span class="s1">&amp;#39;ユーザー名&amp;#39;&lt;/span>&lt;span class="o">@&lt;/span>&lt;span class="s1">&amp;#39;ホスト名&amp;#39;&lt;/span>&lt;span class="p">;&lt;/span>&lt;span class="w">
&lt;/span>&lt;/span>&lt;/span>&lt;/code>&lt;/pre>&lt;/div>&lt;p>例えば&lt;code>app_user&lt;/code>ユーザーの権限を確認するには以下のように実行する。&lt;/p></description><enclosure url="https://atsum.in/database/mysql-show-grants/img/thumbnail.png" type="image/png"/></item><item><title>【MySQL】指定したテーブルのインデックスを確認する</title><link>https://atsum.in/database/mysql-show-index/</link><pubDate>Sat, 15 Aug 2026 15:00:00 +0900</pubDate><guid>https://atsum.in/database/mysql-show-index/</guid><description>&lt;h2 id="show-indexでインデックスを確認する">SHOW INDEXでインデックスを確認する&lt;/h2>
&lt;p>MySQLで指定したテーブルのインデックスを確認するには&lt;code>SHOW INDEX&lt;/code>文を使う。&lt;/p>
&lt;div class="highlight">&lt;pre tabindex="0" class="chroma">&lt;code class="language-sql" data-lang="sql">&lt;span class="line">&lt;span class="cl">&lt;span class="k">SHOW&lt;/span>&lt;span class="w"> &lt;/span>&lt;span class="k">INDEX&lt;/span>&lt;span class="w"> &lt;/span>&lt;span class="k">FROM&lt;/span>&lt;span class="w"> &lt;/span>&lt;span class="err">テーブル名&lt;/span>&lt;span class="p">;&lt;/span>&lt;span class="w">
&lt;/span>&lt;/span>&lt;/span>&lt;/code>&lt;/pre>&lt;/div>&lt;p>例えば&lt;code>users&lt;/code>テーブルのインデックスを確認するには以下のように実行する。&lt;/p></description><enclosure url="https://atsum.in/database/mysql-show-index/img/thumbnail.png" type="image/png"/></item><item><title>【MySQL】テーブル定義とカラム一覧を確認する</title><link>https://atsum.in/database/mysql-show-columns/</link><pubDate>Sat, 15 Aug 2026 14:00:00 +0900</pubDate><guid>https://atsum.in/database/mysql-show-columns/</guid><description>&lt;p>テーブル定義を確認するには&lt;code>DESC&lt;/code>コマンドを使う。&lt;br>
テーブル作成時のDDLをそのまま確認する場合は&lt;code>SHOW CREATE TABLE&lt;/code>、コメントや文字コードも含めて確認する場合は&lt;code>SHOW FULL COLUMNS&lt;/code>を使う。&lt;br>
SQLで取得する場合は&lt;code>information_schema.columns&lt;/code>を参照する。&lt;/p></description><enclosure url="https://atsum.in/database/mysql-show-columns/img/thumbnail.png" type="image/png"/></item><item><title>【MySQL】テーブル一覧を取得する</title><link>https://atsum.in/database/mysql-show-tables/</link><pubDate>Sat, 15 Aug 2026 13:16:00 +0900</pubDate><guid>https://atsum.in/database/mysql-show-tables/</guid><description>&lt;h2 id="show-tablesでテーブル一覧を確認する">SHOW TABLESでテーブル一覧を確認する&lt;/h2>
&lt;p>MySQLでテーブル一覧を確認するには、&lt;code>SHOW TABLES&lt;/code>文を使う。&lt;/p>
&lt;div class="highlight">&lt;pre tabindex="0" class="chroma">&lt;code class="language-sql" data-lang="sql">&lt;span class="line">&lt;span class="cl">&lt;span class="n">mysql&lt;/span>&lt;span class="o">&amp;gt;&lt;/span>&lt;span class="w"> &lt;/span>&lt;span class="k">SHOW&lt;/span>&lt;span class="w"> &lt;/span>&lt;span class="n">TABLES&lt;/span>&lt;span class="p">;&lt;/span>&lt;span class="w">
&lt;/span>&lt;/span>&lt;/span>&lt;span class="line">&lt;span class="cl">&lt;span class="w">&lt;/span>&lt;span class="o">+&lt;/span>&lt;span class="c1">------------------+
&lt;/span>&lt;/span>&lt;/span>&lt;span class="line">&lt;span class="cl">&lt;span class="c1">&lt;/span>&lt;span class="o">|&lt;/span>&lt;span class="w"> &lt;/span>&lt;span class="n">Tables_in_shopdb&lt;/span>&lt;span class="w"> &lt;/span>&lt;span class="o">|&lt;/span>&lt;span class="w">
&lt;/span>&lt;/span>&lt;/span>&lt;span class="line">&lt;span class="cl">&lt;span class="w">&lt;/span>&lt;span class="o">+&lt;/span>&lt;span class="c1">------------------+
&lt;/span>&lt;/span>&lt;/span>&lt;span class="line">&lt;span class="cl">&lt;span class="c1">&lt;/span>&lt;span class="o">|&lt;/span>&lt;span class="w"> &lt;/span>&lt;span class="n">orders&lt;/span>&lt;span class="w"> &lt;/span>&lt;span class="o">|&lt;/span>&lt;span class="w">
&lt;/span>&lt;/span>&lt;/span>&lt;span class="line">&lt;span class="cl">&lt;span class="w">&lt;/span>&lt;span class="o">|&lt;/span>&lt;span class="w"> &lt;/span>&lt;span class="n">users&lt;/span>&lt;span class="w"> &lt;/span>&lt;span class="o">|&lt;/span>&lt;span class="w">
&lt;/span>&lt;/span>&lt;/span>&lt;span class="line">&lt;span class="cl">&lt;span class="w">&lt;/span>&lt;span class="o">|&lt;/span>&lt;span class="w"> &lt;/span>&lt;span class="n">users_view&lt;/span>&lt;span class="w"> &lt;/span>&lt;span class="o">|&lt;/span>&lt;span class="w">
&lt;/span>&lt;/span>&lt;/span>&lt;span class="line">&lt;span class="cl">&lt;span class="w">&lt;/span>&lt;span class="o">+&lt;/span>&lt;span class="c1">------------------+
&lt;/span>&lt;/span>&lt;/span>&lt;/code>&lt;/pre>&lt;/div>&lt;p>結果の列名は&lt;code>Tables_in_接続中のデータベース名&lt;/code>になる。&lt;br>
テーブルだけでなくビューも表示される。&lt;/p></description><enclosure url="https://atsum.in/database/mysql-show-tables/img/thumbnail.png" type="image/png"/></item><item><title>【MySQL】データベース一覧を確認する</title><link>https://atsum.in/database/mysql-show-databases/</link><pubDate>Sat, 15 Aug 2026 10:14:46 +0900</pubDate><guid>https://atsum.in/database/mysql-show-databases/</guid><description>&lt;h2 id="show-databasesでデータベース一覧を確認する">SHOW DATABASESでデータベース一覧を確認する&lt;/h2>
&lt;p>MySQLでデータベース一覧を確認するには、&lt;code>SHOW DATABASES&lt;/code>文を使う。&lt;/p>
&lt;div class="highlight">&lt;pre tabindex="0" class="chroma">&lt;code class="language-sql" data-lang="sql">&lt;span class="line">&lt;span class="cl">&lt;span class="n">mysql&lt;/span>&lt;span class="o">&amp;gt;&lt;/span>&lt;span class="w"> &lt;/span>&lt;span class="k">SHOW&lt;/span>&lt;span class="w"> &lt;/span>&lt;span class="n">DATABASES&lt;/span>&lt;span class="p">;&lt;/span>&lt;span class="w">
&lt;/span>&lt;/span>&lt;/span>&lt;span class="line">&lt;span class="cl">&lt;span class="w">&lt;/span>&lt;span class="o">+&lt;/span>&lt;span class="c1">--------------------+
&lt;/span>&lt;/span>&lt;/span>&lt;span class="line">&lt;span class="cl">&lt;span class="c1">&lt;/span>&lt;span class="o">|&lt;/span>&lt;span class="w"> &lt;/span>&lt;span class="k">Database&lt;/span>&lt;span class="w"> &lt;/span>&lt;span class="o">|&lt;/span>&lt;span class="w">
&lt;/span>&lt;/span>&lt;/span>&lt;span class="line">&lt;span class="cl">&lt;span class="w">&lt;/span>&lt;span class="o">+&lt;/span>&lt;span class="c1">--------------------+
&lt;/span>&lt;/span>&lt;/span>&lt;span class="line">&lt;span class="cl">&lt;span class="c1">&lt;/span>&lt;span class="o">|&lt;/span>&lt;span class="w"> &lt;/span>&lt;span class="n">analytics&lt;/span>&lt;span class="w"> &lt;/span>&lt;span class="o">|&lt;/span>&lt;span class="w">
&lt;/span>&lt;/span>&lt;/span>&lt;span class="line">&lt;span class="cl">&lt;span class="w">&lt;/span>&lt;span class="o">|&lt;/span>&lt;span class="w"> &lt;/span>&lt;span class="n">information_schema&lt;/span>&lt;span class="w"> &lt;/span>&lt;span class="o">|&lt;/span>&lt;span class="w">
&lt;/span>&lt;/span>&lt;/span>&lt;span class="line">&lt;span class="cl">&lt;span class="w">&lt;/span>&lt;span class="o">|&lt;/span>&lt;span class="w"> &lt;/span>&lt;span class="n">mysql&lt;/span>&lt;span class="w"> &lt;/span>&lt;span class="o">|&lt;/span>&lt;span class="w">
&lt;/span>&lt;/span>&lt;/span>&lt;span class="line">&lt;span class="cl">&lt;span class="w">&lt;/span>&lt;span class="o">|&lt;/span>&lt;span class="w"> &lt;/span>&lt;span class="n">performance_schema&lt;/span>&lt;span class="w"> &lt;/span>&lt;span class="o">|&lt;/span>&lt;span class="w">
&lt;/span>&lt;/span>&lt;/span>&lt;span class="line">&lt;span class="cl">&lt;span class="w">&lt;/span>&lt;span class="o">|&lt;/span>&lt;span class="w"> &lt;/span>&lt;span class="n">reportdb&lt;/span>&lt;span class="w"> &lt;/span>&lt;span class="o">|&lt;/span>&lt;span class="w">
&lt;/span>&lt;/span>&lt;/span>&lt;span class="line">&lt;span class="cl">&lt;span class="w">&lt;/span>&lt;span class="o">|&lt;/span>&lt;span class="w"> &lt;/span>&lt;span class="n">shopdb&lt;/span>&lt;span class="w"> &lt;/span>&lt;span class="o">|&lt;/span>&lt;span class="w">
&lt;/span>&lt;/span>&lt;/span>&lt;span class="line">&lt;span class="cl">&lt;span class="w">&lt;/span>&lt;span class="o">|&lt;/span>&lt;span class="w"> &lt;/span>&lt;span class="n">sys&lt;/span>&lt;span class="w"> &lt;/span>&lt;span class="o">|&lt;/span>&lt;span class="w">
&lt;/span>&lt;/span>&lt;/span>&lt;span class="line">&lt;span class="cl">&lt;span class="w">&lt;/span>&lt;span class="o">+&lt;/span>&lt;span class="c1">--------------------+
&lt;/span>&lt;/span>&lt;/span>&lt;/code>&lt;/pre>&lt;/div>&lt;p>自分で作成したデータベースに加えて、初期状態から存在する&lt;code>information_schema&lt;/code>・&lt;code>mysql&lt;/code>・&lt;code>performance_schema&lt;/code>・&lt;code>sys&lt;/code>も表示される。&lt;br>
それぞれの役割は以下の通り。&lt;/p></description><enclosure url="https://atsum.in/database/mysql-show-databases/img/thumbnail.png" type="image/png"/></item><item><title>【truncate】truncate -s 0 でログをクリアする</title><link>https://atsum.in/linux/truncate-log/</link><pubDate>Sat, 15 Aug 2026 09:46:41 +0900</pubDate><guid>https://atsum.in/linux/truncate-log/</guid><description>&lt;p>肥大化したログファイルを消すときは&lt;code>rm&lt;/code>ではなく&lt;code>truncate -s 0&lt;/code>を使う。ファイルを残したまま中身だけを空にできるため、ディスク容量がすぐに解放され、アプリケーションのログ出力も止まらない。&lt;/p></description><enclosure url="https://atsum.in/linux/truncate-log/img/thumbnail.png" type="image/png"/></item><item><title>【openssl】証明書ファイルの有効期限を確認する</title><link>https://atsum.in/linux/openssl-cert-expiry/</link><pubDate>Sat, 15 Aug 2026 07:12:41 +0900</pubDate><guid>https://atsum.in/linux/openssl-cert-expiry/</guid><description>&lt;h2 id="手元の証明書ファイルの期限を確認したい">手元の証明書ファイルの期限を確認したい&lt;/h2>
&lt;p>サーバに配置した証明書ファイルや、認証局から受け取ったばかりの証明書ファイルについて、有効期限や発行対象を確認したい場面がある。証明書はPEM形式であればテキストファイルだが、中身はBase64でエンコードされているためそのまま読んでも内容は分からない。&lt;/p></description><enclosure url="https://atsum.in/linux/openssl-cert-expiry/img/thumbnail.png" type="image/png"/></item><item><title>【script】ターミナルの操作内容をログに記録する</title><link>https://atsum.in/linux/script-command/</link><pubDate>Wed, 12 Aug 2026 22:45:08 +0900</pubDate><guid>https://atsum.in/linux/script-command/</guid><description>&lt;h2 id="ターミナルでの作業内容をそのまま残したい">ターミナルでの作業内容をそのまま残したい&lt;/h2>
&lt;p>障害対応やサーバの初期構築では、実行したコマンドとその出力をあとから見返したい場面がある。ターミナルのスクロールバックをコピーする方法もあるが、バッファからあふれた分は失われる。&lt;a href="https://atsum.in/linux/tee-stderr" target="_blank" rel="noopener">teeコマンド&lt;/a>
で残せるのは個々のコマンドの出力だけで、入力したコマンド自体は残らない。&lt;/p></description><enclosure url="https://atsum.in/linux/script-command/img/thumbnail.png" type="image/png"/></item><item><title>【Linux】ps --forestでプロセスの親子関係をツリー表示する</title><link>https://atsum.in/linux/ps-forest/</link><pubDate>Tue, 11 Aug 2026 22:05:15 +0900</pubDate><guid>https://atsum.in/linux/ps-forest/</guid><description>&lt;h2 id="ps-forest">ps &amp;ndash;forest&lt;/h2>
&lt;p>&lt;code>ps&lt;/code>に&lt;code>--forest&lt;/code>を付けると、プロセスの一覧を親子関係のツリーとして表示する。&lt;code>ps -ef&lt;/code>の情報量を保ったまま、どのプロセスがどこから起動されたかを確認できる。&lt;/p></description><enclosure url="https://atsum.in/linux/ps-forest/img/thumbnail.png" type="image/png"/></item><item><title>【Linux】pstreeコマンドでプロセスの親子関係をツリー表示する</title><link>https://atsum.in/linux/pstree-command/</link><pubDate>Tue, 11 Aug 2026 21:07:42 +0900</pubDate><guid>https://atsum.in/linux/pstree-command/</guid><description>&lt;h2 id="pstreeコマンド">pstreeコマンド&lt;/h2>
&lt;p>&lt;code>pstree&lt;/code>はプロセスを親子関係のツリーとして表示するコマンド。&lt;code>ps&lt;/code>の一覧では分かりにくい「どのプロセスがどこから起動されたか」をひと目で把握できる。&lt;/p></description><enclosure url="https://atsum.in/linux/pstree-command/img/thumbnail.png" type="image/png"/></item><item><title>【Linux】whoコマンドでログイン中のユーザーを確認する</title><link>https://atsum.in/linux/who-command/</link><pubDate>Tue, 11 Aug 2026 20:16:01 +0900</pubDate><guid>https://atsum.in/linux/who-command/</guid><description>&lt;h2 id="whoコマンド">whoコマンド&lt;/h2>
&lt;p>&lt;code>who&lt;/code>は現在ログイン中のユーザーを表示するコマンド。&lt;code>/var/run/utmp&lt;/code>に記録された現在のセッションを読み取る。&lt;/p>
&lt;div class="highlight">&lt;pre tabindex="0" class="chroma">&lt;code class="language-shell" data-lang="shell">&lt;span class="line">&lt;span class="cl">$ who
&lt;/span>&lt;/span>&lt;/code>&lt;/pre>&lt;/div>&lt;div class="highlight">&lt;pre tabindex="0" class="chroma">&lt;code class="language-text" data-lang="text">&lt;span class="line">&lt;span class="cl">alice pts/0 Aug 11 11:09 (192.168.10.21)
&lt;/span>&lt;/span>&lt;span class="line">&lt;span class="cl">bob pts/1 Aug 11 11:09 (192.168.10.35)
&lt;/span>&lt;/span>&lt;/code>&lt;/pre>&lt;/div>&lt;p>左から、ユーザー名、端末名、ログイン時刻、接続元である。&lt;code>pts/0&lt;/code>はSSHなどの擬似端末を表す。コンソールからのログインは&lt;code>tty1&lt;/code>のように表示され、接続元の欄は空になる。&lt;/p></description><enclosure url="https://atsum.in/linux/who-command/img/thumbnail.png" type="image/png"/></item><item><title>【Linux】wコマンドでログイン中のユーザーと実行中のコマンドを確認する</title><link>https://atsum.in/linux/w-command/</link><pubDate>Tue, 11 Aug 2026 20:02:51 +0900</pubDate><guid>https://atsum.in/linux/w-command/</guid><description>&lt;h2 id="wコマンド">wコマンド&lt;/h2>
&lt;p>&lt;code>w&lt;/code>はログイン中のユーザーと、そのユーザーが何をしているかを表示するコマンド。&lt;code>who&lt;/code>が接続元と時刻を並べるだけなのに対し、&lt;code>w&lt;/code>は実行中のコマンドやCPU時間まで表示する。&lt;/p></description><enclosure url="https://atsum.in/linux/w-command/img/thumbnail.png" type="image/png"/></item><item><title>【Linux】lastコマンドでログイン履歴を確認する</title><link>https://atsum.in/linux/last-command/</link><pubDate>Tue, 11 Aug 2026 19:35:04 +0900</pubDate><guid>https://atsum.in/linux/last-command/</guid><description>&lt;h2 id="lastコマンド">lastコマンド&lt;/h2>
&lt;p>&lt;code>last&lt;/code>は&lt;code>/var/log/wtmp&lt;/code>に記録されたログイン履歴を新しい順に表示するコマンド。誰がいつどこから接続したかを確認できる。現在ログイン中のユーザーを調べる&lt;code>who&lt;/code>や&lt;code>w&lt;/code>と違い、過去のログインとログアウトをさかのぼって追える。&lt;/p></description><enclosure url="https://atsum.in/linux/last-command/img/thumbnail.png" type="image/png"/></item><item><title>【Hugo】hugo listでサーバーを起動せずに記事一覧と件数を確認する</title><link>https://atsum.in/hugo/list-command/</link><pubDate>Tue, 11 Aug 2026 16:00:47 +0900</pubDate><guid>https://atsum.in/hugo/list-command/</guid><description>&lt;h2 id="実現したいこと">実現したいこと&lt;/h2>
&lt;p>ブログの記事数や記事一覧を確認したい。&lt;code>hugo server&lt;/code>を起動して一覧ページを開く方法は手間がかかる。素の&lt;code>hugo&lt;/code>でビルドすると&lt;code>public/&lt;/code>が本番URLの生成物で上書きされ、起動中の開発サーバーの状態を壊してしまう。&lt;/p></description><enclosure url="https://atsum.in/hugo/list-command/img/thumbnail.png" type="image/png"/></item><item><title>【Linux】uptime -sでシステムの起動時刻を表示する</title><link>https://atsum.in/linux/uptime-since/</link><pubDate>Tue, 11 Aug 2026 15:34:04 +0900</pubDate><guid>https://atsum.in/linux/uptime-since/</guid><description>&lt;h2 id="起動時刻を表示する-s">起動時刻を表示する(-s)&lt;/h2>
&lt;p>&lt;code>uptime&lt;/code>は起動からの経過時間を表示する。&lt;/p>
&lt;div class="highlight">&lt;pre tabindex="0" class="chroma">&lt;code class="language-shell" data-lang="shell">&lt;span class="line">&lt;span class="cl">$ uptime
&lt;/span>&lt;/span>&lt;span class="line">&lt;span class="cl"> 15:33:53 up &lt;span class="m">17&lt;/span> days, 9:42, &lt;span class="m">0&lt;/span> user, load average: 0.00, 0.00, 0.00
&lt;/span>&lt;/span>&lt;/code>&lt;/pre>&lt;/div>&lt;p>&lt;code>17 days, 9:42&lt;/code>から起動した日時を逆算するのは手間である。
&lt;code>-s&lt;/code>(&lt;code>--since&lt;/code>)を付けると、起動時刻そのものを表示する。&lt;/p></description><enclosure url="https://atsum.in/linux/uptime-since/img/thumbnail.png" type="image/png"/></item><item><title>【Linux】dmesgのタイムスタンプを日時で表示する(-T)</title><link>https://atsum.in/linux/dmesg-human-readable-timestamp/</link><pubDate>Tue, 11 Aug 2026 14:48:53 +0900</pubDate><guid>https://atsum.in/linux/dmesg-human-readable-timestamp/</guid><description>&lt;h2 id="dmesgのタイムスタンプは起動からの経過秒">dmesgのタイムスタンプは起動からの経過秒&lt;/h2>
&lt;p>&lt;code>dmesg&lt;/code>でカーネルのメッセージを確認すると、行頭の角括弧に数値が並ぶ。&lt;/p>
&lt;div class="highlight">&lt;pre tabindex="0" class="chroma">&lt;code class="language-shell" data-lang="shell">&lt;span class="line">&lt;span class="cl">$ dmesg &lt;span class="p">|&lt;/span> tail -4
&lt;/span>&lt;/span>&lt;span class="line">&lt;span class="cl">&lt;span class="o">[&lt;/span>1500839.421998&lt;span class="o">]&lt;/span> veth63e4340: entered promiscuous mode
&lt;/span>&lt;/span>&lt;span class="line">&lt;span class="cl">&lt;span class="o">[&lt;/span>1500839.498290&lt;span class="o">]&lt;/span> eth0: renamed from vethd6a1e0d
&lt;/span>&lt;/span>&lt;span class="line">&lt;span class="cl">&lt;span class="o">[&lt;/span>1500839.507428&lt;span class="o">]&lt;/span> docker0: port 1&lt;span class="o">(&lt;/span>veth63e4340&lt;span class="o">)&lt;/span> entered blocking state
&lt;/span>&lt;/span>&lt;span class="line">&lt;span class="cl">&lt;span class="o">[&lt;/span>1500839.507434&lt;span class="o">]&lt;/span> docker0: port 1&lt;span class="o">(&lt;/span>veth63e4340&lt;span class="o">)&lt;/span> entered forwarding state
&lt;/span>&lt;/span>&lt;/code>&lt;/pre>&lt;/div>&lt;p>&lt;code>1500839.421998&lt;/code>は起動からの経過秒である。
アプリケーションのログやアラートの発生時刻と突き合わせたい場面では、経過秒のままでは扱いにくい。&lt;/p></description><enclosure url="https://atsum.in/linux/dmesg-human-readable-timestamp/img/thumbnail.png" type="image/png"/></item><item><title>【Linux】free -hのavailableとbuff/cacheの読み方</title><link>https://atsum.in/linux/free-available-buff-cache/</link><pubDate>Tue, 11 Aug 2026 13:29:46 +0900</pubDate><guid>https://atsum.in/linux/free-available-buff-cache/</guid><description>&lt;h2 id="freeが少ないのはメモリ不足ではない">freeが少ないのはメモリ不足ではない&lt;/h2>
&lt;p>&lt;code>free -h&lt;/code>でメモリの状況を確認すると、&lt;code>free&lt;/code>列がほとんど残っていない状態をよく見かける。&lt;/p>
&lt;div class="highlight">&lt;pre tabindex="0" class="chroma">&lt;code class="language-shell" data-lang="shell">&lt;span class="line">&lt;span class="cl">$ free -h
&lt;/span>&lt;/span>&lt;span class="line">&lt;span class="cl"> total used free shared buff/cache available
&lt;/span>&lt;/span>&lt;span class="line">&lt;span class="cl">Mem: 5.8Gi 476Mi 295Mi 700Ki 5.2Gi 5.3Gi
&lt;/span>&lt;/span>&lt;span class="line">&lt;span class="cl">Swap: 0B 0B 0B
&lt;/span>&lt;/span>&lt;/code>&lt;/pre>&lt;/div>&lt;p>&lt;code>free&lt;/code>が295Miしかないため空きメモリが枯渇しているように見えるが、&lt;code>available&lt;/code>は5.3Giある。
Linuxは余ったメモリをディスクキャッシュとして使い切る方針で動くため、稼働時間の長いサーバーほど&lt;code>free&lt;/code>は小さくなる。
メモリの余裕を判断する列は&lt;code>free&lt;/code>ではなく&lt;code>available&lt;/code>である。&lt;/p></description><enclosure url="https://atsum.in/linux/free-available-buff-cache/img/thumbnail.png" type="image/png"/></item><item><title>【Shell Script】bash -xで実行トレースを表示してデバッグする</title><link>https://atsum.in/linux/bash-x-debug/</link><pubDate>Tue, 11 Aug 2026 11:03:00 +0900</pubDate><guid>https://atsum.in/linux/bash-x-debug/</guid><description>&lt;h2 id="シェルスクリプトが意図した動作をしない">シェルスクリプトが意図した動作をしない&lt;/h2>
&lt;p>シェルスクリプトはエラーメッセージを出さずに間違った結果を返す場合がある。&lt;/p>
&lt;p>以下はログファイルが10個を超えたときに警告を出すスクリプトである。&lt;/p></description><enclosure url="https://atsum.in/linux/bash-x-debug/img/thumbnail.png" type="image/png"/></item><item><title>【Shell Script】waitで並列実行したジョブの成否を判定する</title><link>https://atsum.in/linux/wait-parallel-jobs/</link><pubDate>Tue, 11 Aug 2026 10:07:12 +0900</pubDate><guid>https://atsum.in/linux/wait-parallel-jobs/</guid><description>&lt;h2 id="並列実行したジョブの失敗を検知したい">並列実行したジョブの失敗を検知したい&lt;/h2>
&lt;p>複数のホストへのデプロイのような処理は、&lt;code>&amp;amp;&lt;/code>でバックグラウンド実行すれば並列に走らせられる。すべての終了を待つには引数なしの&lt;code>wait&lt;/code>を使う。&lt;/p></description><enclosure url="https://atsum.in/linux/wait-parallel-jobs/img/thumbnail.png" type="image/png"/></item><item><title>【nkf】文字コードを判定して変換する</title><link>https://atsum.in/linux/nkf/</link><pubDate>Tue, 11 Aug 2026 08:33:15 +0900</pubDate><guid>https://atsum.in/linux/nkf/</guid><description>&lt;h2 id="文字コードが分からないファイルを変換したい">文字コードが分からないファイルを変換したい&lt;/h2>
&lt;p>&lt;code>iconv&lt;/code> は変換元の文字コードを &lt;code>-f&lt;/code> で指定する必要がある。手元のファイルがShift_JISとEUC-JPのどちらなのか分からない場合、まず判定してから変換しなければならない。&lt;/p></description><enclosure url="https://atsum.in/linux/nkf/img/thumbnail.png" type="image/png"/></item><item><title>【iconv】ファイルの文字コードを変換する</title><link>https://atsum.in/linux/iconv/</link><pubDate>Tue, 11 Aug 2026 08:12:26 +0900</pubDate><guid>https://atsum.in/linux/iconv/</guid><description>&lt;h2 id="ファイルの文字コードを変換したい">ファイルの文字コードを変換したい&lt;/h2>
&lt;p>Shift_JISで書かれたCSVをUTF-8で読みたい場合や、逆にUTF-8のテキストをWindows向けにShift_JISへ戻したい場合、&lt;code>iconv&lt;/code> コマンドを使う。&lt;/p></description><enclosure url="https://atsum.in/linux/iconv/img/thumbnail.png" type="image/png"/></item><item><title>【Shell Script】プロセス置換 &lt;(command) でコマンド出力をファイルとして渡す</title><link>https://atsum.in/linux/process-substitution/</link><pubDate>Mon, 10 Aug 2026 23:27:48 +0900</pubDate><guid>https://atsum.in/linux/process-substitution/</guid><description>&lt;h2 id="コマンドの出力をファイル名で受け取るコマンドに渡したい">コマンドの出力をファイル名で受け取るコマンドに渡したい&lt;/h2>
&lt;p>&lt;code>diff&lt;/code>や&lt;code>comm&lt;/code>のようにファイル名を引数に取るコマンドへ、別のコマンドの出力を渡したい場面がある。素直に書くと一時ファイルを経由する。&lt;/p>
&lt;div class="highlight">&lt;pre tabindex="0" class="chroma">&lt;code class="language-shell" data-lang="shell">&lt;span class="line">&lt;span class="cl">$ sort a.txt &amp;gt; /tmp/a.sorted
&lt;/span>&lt;/span>&lt;span class="line">&lt;span class="cl">$ sort b.txt &amp;gt; /tmp/b.sorted
&lt;/span>&lt;/span>&lt;span class="line">&lt;span class="cl">$ diff /tmp/a.sorted /tmp/b.sorted
&lt;/span>&lt;/span>&lt;span class="line">&lt;span class="cl">$ rm /tmp/a.sorted /tmp/b.sorted
&lt;/span>&lt;/span>&lt;/code>&lt;/pre>&lt;/div>&lt;p>bashやzshのプロセス置換&lt;code>&amp;lt;(command)&lt;/code>を使うと、一時ファイルなしで1行にまとまる。&lt;/p></description><enclosure url="https://atsum.in/linux/process-substitution/img/thumbnail.png" type="image/png"/></item><item><title>【Shell Script】getoptsでコマンドラインオプションを解析する</title><link>https://atsum.in/linux/getopts/</link><pubDate>Mon, 10 Aug 2026 21:00:34 +0900</pubDate><guid>https://atsum.in/linux/getopts/</guid><description>&lt;h2 id="シェルスクリプトで-vや-f-fileのようなオプションを扱いたい">シェルスクリプトで-vや-f fileのようなオプションを扱いたい&lt;/h2>
&lt;p>シェルスクリプトに&lt;code>-v&lt;/code>や&lt;code>-f file&lt;/code>のようなオプションを渡したい場合、&lt;code>$1&lt;/code>や&lt;code>$2&lt;/code>を自力で判定すると、オプションの順序やまとめ書きへの対応が煩雑になる。シェルのビルトインコマンド&lt;code>getopts&lt;/code>を使うと、UNIXコマンドと同じ形式のオプション解析を簡潔に書ける。&lt;/p></description><enclosure url="https://atsum.in/linux/getopts/img/thumbnail.png" type="image/png"/></item><item><title>【touch -d】任意の日時のファイルを作る</title><link>https://atsum.in/linux/touch-d/</link><pubDate>Mon, 10 Aug 2026 08:44:19 +0900</pubDate><guid>https://atsum.in/linux/touch-d/</guid><description>&lt;h2 id="任意の日時のファイルを作りたい">任意の日時のファイルを作りたい&lt;/h2>
&lt;p>ログのローテーションや&lt;code>find -mtime&lt;/code>による検索の動作を確認したい場合、更新日時が過去や未来のファイルが必要になる。&lt;code>touch&lt;/code>コマンドの&lt;code>-d&lt;/code>オプションを使うと、任意の日時のファイルを作成できる。&lt;/p></description><enclosure url="https://atsum.in/linux/touch-d/img/thumbnail.png" type="image/png"/></item><item><title>【VSCode】Javaのフォーマッターを設定する</title><link>https://atsum.in/vscode/java-formatter/</link><pubDate>Sun, 09 Aug 2026 19:08:45 +0900</pubDate><guid>https://atsum.in/vscode/java-formatter/</guid><description>&lt;h2 id="vscodeのjavaフォーマッター">VSCodeのJavaフォーマッター&lt;/h2>
&lt;p>VSCodeでJavaを書くときのフォーマッターは、Language Support for Java(TM) by Red Hatに含まれるEclipse JDTのフォーマッターである。Eclipse形式のフォーマット設定XMLをそのまま読み込めるため、Eclipseで使っていた設定やチームで共有しているスタイル定義を流用できる。&lt;/p></description><enclosure url="https://atsum.in/vscode/java-formatter/img/thumbnail.png" type="image/png"/></item><item><title>【VSCode】Workspace Trust(信頼するフォルダー)の仕組みと設定</title><link>https://atsum.in/vscode/workspace-trust/</link><pubDate>Sun, 09 Aug 2026 16:14:51 +0900</pubDate><guid>https://atsum.in/vscode/workspace-trust/</guid><description>&lt;h2 id="workspace-trustとは">Workspace Trustとは&lt;/h2>
&lt;p>Workspace TrustはVSCode 1.57で追加されたセキュリティ機能である。フォルダを開いただけでVSCodeや拡張機能がプロジェクト内のコードを勝手に実行してしまう事態を防ぐ。&lt;/p></description><enclosure url="https://atsum.in/vscode/workspace-trust/img/thumbnail.png" type="image/png"/></item><item><title>【VSCode】フォルダ同士を比較する</title><link>https://atsum.in/vscode/compare-folders/</link><pubDate>Sun, 09 Aug 2026 15:00:42 +0900</pubDate><guid>https://atsum.in/vscode/compare-folders/</guid><description>&lt;h2 id="vscodeのフォルダ比較">VSCodeのフォルダ比較&lt;/h2>
&lt;p>VSCodeにはファイル同士を比較する標準機能がある。エクスプローラーで「比較対象の選択」と「選択項目と比較」を使う方法や、&lt;code>code -d file1 file2&lt;/code>で開く方法である。&lt;/p></description><enclosure url="https://atsum.in/vscode/compare-folders/img/thumbnail.png" type="image/png"/></item><item><title>【シェル】echo -e と printf の使い分け（改行の制御）</title><link>https://atsum.in/linux/echo-printf-newline/</link><pubDate>Sun, 09 Aug 2026 13:48:18 +0900</pubDate><guid>https://atsum.in/linux/echo-printf-newline/</guid><description>&lt;p>シェルスクリプトで文字列の途中に改行を入れたい場合、&lt;code>echo -e &amp;quot;a\nb&amp;quot;&lt;/code>と書く方法がある。しかし&lt;code>echo&lt;/code>の&lt;code>-e&lt;/code>は環境によって解釈が異なるため、移植性を求めるなら&lt;code>printf&lt;/code>を使う。&lt;/p></description><enclosure url="https://atsum.in/linux/echo-printf-newline/img/thumbnail.png" type="image/png"/></item><item><title>【iTerm2】画面を分割して複数のシェルを並べる</title><link>https://atsum.in/mac/iterm-split-pane/</link><pubDate>Sun, 09 Aug 2026 12:34:43 +0900</pubDate><guid>https://atsum.in/mac/iterm-split-pane/</guid><description>&lt;p>iTerm2は1つのタブを複数の領域に分割し、それぞれで別のシェルを動かせる。
分割された1つ1つの領域をPaneと呼ぶ。&lt;/p>
&lt;p>サーバのログを流しながら別のPaneでコマンドを実行する、といった使い方ができる。&lt;/p></description><enclosure url="https://atsum.in/mac/iterm-split-pane/img/thumbnail.png" type="image/png"/></item><item><title>【PostgreSQL】データベース一覧を確認する</title><link>https://atsum.in/database/postgresql-show-databases/</link><pubDate>Sun, 09 Aug 2026 11:41:41 +0900</pubDate><guid>https://atsum.in/database/postgresql-show-databases/</guid><description>&lt;h2 id="lコマンドでデータベース一覧を確認する">\lコマンドでデータベース一覧を確認する&lt;/h2>
&lt;p>PostgreSQLでデータベース一覧を確認するには、psqlコマンドラインツールの&lt;code>\l&lt;/code>コマンドを使う。&lt;/p>
&lt;div class="highlight">&lt;pre tabindex="0" class="chroma">&lt;code class="language-sql" data-lang="sql">&lt;span class="line">&lt;span class="cl">&lt;span class="err">\&lt;/span>&lt;span class="n">l&lt;/span>&lt;span class="w">
&lt;/span>&lt;/span>&lt;/span>&lt;span class="line">&lt;span class="cl">&lt;span class="w"> &lt;/span>&lt;span class="n">List&lt;/span>&lt;span class="w"> &lt;/span>&lt;span class="k">of&lt;/span>&lt;span class="w"> &lt;/span>&lt;span class="n">databases&lt;/span>&lt;span class="w">
&lt;/span>&lt;/span>&lt;/span>&lt;span class="line">&lt;span class="cl">&lt;span class="w"> &lt;/span>&lt;span class="n">Name&lt;/span>&lt;span class="w"> &lt;/span>&lt;span class="o">|&lt;/span>&lt;span class="w"> &lt;/span>&lt;span class="k">Owner&lt;/span>&lt;span class="w"> &lt;/span>&lt;span class="o">|&lt;/span>&lt;span class="w"> &lt;/span>&lt;span class="k">Encoding&lt;/span>&lt;span class="w"> &lt;/span>&lt;span class="o">|&lt;/span>&lt;span class="w"> &lt;/span>&lt;span class="n">Locale&lt;/span>&lt;span class="w"> &lt;/span>&lt;span class="n">Provider&lt;/span>&lt;span class="w"> &lt;/span>&lt;span class="o">|&lt;/span>&lt;span class="w"> &lt;/span>&lt;span class="k">Collate&lt;/span>&lt;span class="w"> &lt;/span>&lt;span class="o">|&lt;/span>&lt;span class="w"> &lt;/span>&lt;span class="n">Ctype&lt;/span>&lt;span class="w"> &lt;/span>&lt;span class="o">|&lt;/span>&lt;span class="w"> &lt;/span>&lt;span class="n">Locale&lt;/span>&lt;span class="w"> &lt;/span>&lt;span class="o">|&lt;/span>&lt;span class="w"> &lt;/span>&lt;span class="n">ICU&lt;/span>&lt;span class="w"> &lt;/span>&lt;span class="n">Rules&lt;/span>&lt;span class="w"> &lt;/span>&lt;span class="o">|&lt;/span>&lt;span class="w"> &lt;/span>&lt;span class="k">Access&lt;/span>&lt;span class="w"> &lt;/span>&lt;span class="k">privileges&lt;/span>&lt;span class="w">
&lt;/span>&lt;/span>&lt;/span>&lt;span class="line">&lt;span class="cl">&lt;span class="w">&lt;/span>&lt;span class="c1">-----------+----------+----------+-----------------+------------+------------+--------+-----------+-----------------------
&lt;/span>&lt;/span>&lt;/span>&lt;span class="line">&lt;span class="cl">&lt;span class="c1">&lt;/span>&lt;span class="w"> &lt;/span>&lt;span class="n">analytics&lt;/span>&lt;span class="w"> &lt;/span>&lt;span class="o">|&lt;/span>&lt;span class="w"> &lt;/span>&lt;span class="n">postgres&lt;/span>&lt;span class="w"> &lt;/span>&lt;span class="o">|&lt;/span>&lt;span class="w"> &lt;/span>&lt;span class="n">UTF8&lt;/span>&lt;span class="w"> &lt;/span>&lt;span class="o">|&lt;/span>&lt;span class="w"> &lt;/span>&lt;span class="n">libc&lt;/span>&lt;span class="w"> &lt;/span>&lt;span class="o">|&lt;/span>&lt;span class="w"> &lt;/span>&lt;span class="n">en_US&lt;/span>&lt;span class="p">.&lt;/span>&lt;span class="n">utf8&lt;/span>&lt;span class="w"> &lt;/span>&lt;span class="o">|&lt;/span>&lt;span class="w"> &lt;/span>&lt;span class="n">en_US&lt;/span>&lt;span class="p">.&lt;/span>&lt;span class="n">utf8&lt;/span>&lt;span class="w"> &lt;/span>&lt;span class="o">|&lt;/span>&lt;span class="w"> &lt;/span>&lt;span class="o">|&lt;/span>&lt;span class="w"> &lt;/span>&lt;span class="o">|&lt;/span>&lt;span class="w">
&lt;/span>&lt;/span>&lt;/span>&lt;span class="line">&lt;span class="cl">&lt;span class="w"> &lt;/span>&lt;span class="n">postgres&lt;/span>&lt;span class="w"> &lt;/span>&lt;span class="o">|&lt;/span>&lt;span class="w"> &lt;/span>&lt;span class="n">postgres&lt;/span>&lt;span class="w"> &lt;/span>&lt;span class="o">|&lt;/span>&lt;span class="w"> &lt;/span>&lt;span class="n">UTF8&lt;/span>&lt;span class="w"> &lt;/span>&lt;span class="o">|&lt;/span>&lt;span class="w"> &lt;/span>&lt;span class="n">libc&lt;/span>&lt;span class="w"> &lt;/span>&lt;span class="o">|&lt;/span>&lt;span class="w"> &lt;/span>&lt;span class="n">en_US&lt;/span>&lt;span class="p">.&lt;/span>&lt;span class="n">utf8&lt;/span>&lt;span class="w"> &lt;/span>&lt;span class="o">|&lt;/span>&lt;span class="w"> &lt;/span>&lt;span class="n">en_US&lt;/span>&lt;span class="p">.&lt;/span>&lt;span class="n">utf8&lt;/span>&lt;span class="w"> &lt;/span>&lt;span class="o">|&lt;/span>&lt;span class="w"> &lt;/span>&lt;span class="o">|&lt;/span>&lt;span class="w"> &lt;/span>&lt;span class="o">|&lt;/span>&lt;span class="w">
&lt;/span>&lt;/span>&lt;/span>&lt;span class="line">&lt;span class="cl">&lt;span class="w"> &lt;/span>&lt;span class="n">reportdb&lt;/span>&lt;span class="w"> &lt;/span>&lt;span class="o">|&lt;/span>&lt;span class="w"> &lt;/span>&lt;span class="n">app_user&lt;/span>&lt;span class="w"> &lt;/span>&lt;span class="o">|&lt;/span>&lt;span class="w"> &lt;/span>&lt;span class="n">UTF8&lt;/span>&lt;span class="w"> &lt;/span>&lt;span class="o">|&lt;/span>&lt;span class="w"> &lt;/span>&lt;span class="n">libc&lt;/span>&lt;span class="w"> &lt;/span>&lt;span class="o">|&lt;/span>&lt;span class="w"> &lt;/span>&lt;span class="n">en_US&lt;/span>&lt;span class="p">.&lt;/span>&lt;span class="n">utf8&lt;/span>&lt;span class="w"> &lt;/span>&lt;span class="o">|&lt;/span>&lt;span class="w"> &lt;/span>&lt;span class="n">en_US&lt;/span>&lt;span class="p">.&lt;/span>&lt;span class="n">utf8&lt;/span>&lt;span class="w"> &lt;/span>&lt;span class="o">|&lt;/span>&lt;span class="w"> &lt;/span>&lt;span class="o">|&lt;/span>&lt;span class="w"> &lt;/span>&lt;span class="o">|&lt;/span>&lt;span class="w">
&lt;/span>&lt;/span>&lt;/span>&lt;span class="line">&lt;span class="cl">&lt;span class="w"> &lt;/span>&lt;span class="n">shopdb&lt;/span>&lt;span class="w"> &lt;/span>&lt;span class="o">|&lt;/span>&lt;span class="w"> &lt;/span>&lt;span class="n">postgres&lt;/span>&lt;span class="w"> &lt;/span>&lt;span class="o">|&lt;/span>&lt;span class="w"> &lt;/span>&lt;span class="n">UTF8&lt;/span>&lt;span class="w"> &lt;/span>&lt;span class="o">|&lt;/span>&lt;span class="w"> &lt;/span>&lt;span class="n">libc&lt;/span>&lt;span class="w"> &lt;/span>&lt;span class="o">|&lt;/span>&lt;span class="w"> &lt;/span>&lt;span class="n">en_US&lt;/span>&lt;span class="p">.&lt;/span>&lt;span class="n">utf8&lt;/span>&lt;span class="w"> &lt;/span>&lt;span class="o">|&lt;/span>&lt;span class="w"> &lt;/span>&lt;span class="n">en_US&lt;/span>&lt;span class="p">.&lt;/span>&lt;span class="n">utf8&lt;/span>&lt;span class="w"> &lt;/span>&lt;span class="o">|&lt;/span>&lt;span class="w"> &lt;/span>&lt;span class="o">|&lt;/span>&lt;span class="w"> &lt;/span>&lt;span class="o">|&lt;/span>&lt;span class="w">
&lt;/span>&lt;/span>&lt;/span>&lt;span class="line">&lt;span class="cl">&lt;span class="w"> &lt;/span>&lt;span class="n">template0&lt;/span>&lt;span class="w"> &lt;/span>&lt;span class="o">|&lt;/span>&lt;span class="w"> &lt;/span>&lt;span class="n">postgres&lt;/span>&lt;span class="w"> &lt;/span>&lt;span class="o">|&lt;/span>&lt;span class="w"> &lt;/span>&lt;span class="n">UTF8&lt;/span>&lt;span class="w"> &lt;/span>&lt;span class="o">|&lt;/span>&lt;span class="w"> &lt;/span>&lt;span class="n">libc&lt;/span>&lt;span class="w"> &lt;/span>&lt;span class="o">|&lt;/span>&lt;span class="w"> &lt;/span>&lt;span class="n">en_US&lt;/span>&lt;span class="p">.&lt;/span>&lt;span class="n">utf8&lt;/span>&lt;span class="w"> &lt;/span>&lt;span class="o">|&lt;/span>&lt;span class="w"> &lt;/span>&lt;span class="n">en_US&lt;/span>&lt;span class="p">.&lt;/span>&lt;span class="n">utf8&lt;/span>&lt;span class="w"> &lt;/span>&lt;span class="o">|&lt;/span>&lt;span class="w"> &lt;/span>&lt;span class="o">|&lt;/span>&lt;span class="w"> &lt;/span>&lt;span class="o">|&lt;/span>&lt;span class="w"> &lt;/span>&lt;span class="o">=&lt;/span>&lt;span class="k">c&lt;/span>&lt;span class="o">/&lt;/span>&lt;span class="n">postgres&lt;/span>&lt;span class="w"> &lt;/span>&lt;span class="o">+&lt;/span>&lt;span class="w">
&lt;/span>&lt;/span>&lt;/span>&lt;span class="line">&lt;span class="cl">&lt;span class="w"> &lt;/span>&lt;span class="o">|&lt;/span>&lt;span class="w"> &lt;/span>&lt;span class="o">|&lt;/span>&lt;span class="w"> &lt;/span>&lt;span class="o">|&lt;/span>&lt;span class="w"> &lt;/span>&lt;span class="o">|&lt;/span>&lt;span class="w"> &lt;/span>&lt;span class="o">|&lt;/span>&lt;span class="w"> &lt;/span>&lt;span class="o">|&lt;/span>&lt;span class="w"> &lt;/span>&lt;span class="o">|&lt;/span>&lt;span class="w"> &lt;/span>&lt;span class="o">|&lt;/span>&lt;span class="w"> &lt;/span>&lt;span class="n">postgres&lt;/span>&lt;span class="o">=&lt;/span>&lt;span class="n">CTc&lt;/span>&lt;span class="o">/&lt;/span>&lt;span class="n">postgres&lt;/span>&lt;span class="w">
&lt;/span>&lt;/span>&lt;/span>&lt;span class="line">&lt;span class="cl">&lt;span class="w"> &lt;/span>&lt;span class="n">template1&lt;/span>&lt;span class="w"> &lt;/span>&lt;span class="o">|&lt;/span>&lt;span class="w"> &lt;/span>&lt;span class="n">postgres&lt;/span>&lt;span class="w"> &lt;/span>&lt;span class="o">|&lt;/span>&lt;span class="w"> &lt;/span>&lt;span class="n">UTF8&lt;/span>&lt;span class="w"> &lt;/span>&lt;span class="o">|&lt;/span>&lt;span class="w"> &lt;/span>&lt;span class="n">libc&lt;/span>&lt;span class="w"> &lt;/span>&lt;span class="o">|&lt;/span>&lt;span class="w"> &lt;/span>&lt;span class="n">en_US&lt;/span>&lt;span class="p">.&lt;/span>&lt;span class="n">utf8&lt;/span>&lt;span class="w"> &lt;/span>&lt;span class="o">|&lt;/span>&lt;span class="w"> &lt;/span>&lt;span class="n">en_US&lt;/span>&lt;span class="p">.&lt;/span>&lt;span class="n">utf8&lt;/span>&lt;span class="w"> &lt;/span>&lt;span class="o">|&lt;/span>&lt;span class="w"> &lt;/span>&lt;span class="o">|&lt;/span>&lt;span class="w"> &lt;/span>&lt;span class="o">|&lt;/span>&lt;span class="w"> &lt;/span>&lt;span class="o">=&lt;/span>&lt;span class="k">c&lt;/span>&lt;span class="o">/&lt;/span>&lt;span class="n">postgres&lt;/span>&lt;span class="w"> &lt;/span>&lt;span class="o">+&lt;/span>&lt;span class="w">
&lt;/span>&lt;/span>&lt;/span>&lt;span class="line">&lt;span class="cl">&lt;span class="w"> &lt;/span>&lt;span class="o">|&lt;/span>&lt;span class="w"> &lt;/span>&lt;span class="o">|&lt;/span>&lt;span class="w"> &lt;/span>&lt;span class="o">|&lt;/span>&lt;span class="w"> &lt;/span>&lt;span class="o">|&lt;/span>&lt;span class="w"> &lt;/span>&lt;span class="o">|&lt;/span>&lt;span class="w"> &lt;/span>&lt;span class="o">|&lt;/span>&lt;span class="w"> &lt;/span>&lt;span class="o">|&lt;/span>&lt;span class="w"> &lt;/span>&lt;span class="o">|&lt;/span>&lt;span class="w"> &lt;/span>&lt;span class="n">postgres&lt;/span>&lt;span class="o">=&lt;/span>&lt;span class="n">CTc&lt;/span>&lt;span class="o">/&lt;/span>&lt;span class="n">postgres&lt;/span>&lt;span class="w">
&lt;/span>&lt;/span>&lt;/span>&lt;span class="line">&lt;span class="cl">&lt;span class="w">&lt;/span>&lt;span class="p">(&lt;/span>&lt;span class="mi">6&lt;/span>&lt;span class="w"> &lt;/span>&lt;span class="k">rows&lt;/span>&lt;span class="p">)&lt;/span>&lt;span class="w">
&lt;/span>&lt;/span>&lt;/span>&lt;/code>&lt;/pre>&lt;/div>&lt;p>&lt;code>\list&lt;/code>と入力しても同じ結果になる。&lt;/p></description><enclosure url="https://atsum.in/database/postgresql-show-databases/img/thumbnail.png" type="image/png"/></item><item><title>【PostgreSQL】スキーマ一覧を確認する</title><link>https://atsum.in/database/postgresql-show-schemas/</link><pubDate>Sun, 09 Aug 2026 11:21:09 +0900</pubDate><guid>https://atsum.in/database/postgresql-show-schemas/</guid><description>&lt;h2 id="dnコマンドでスキーマ一覧を確認する">\dnコマンドでスキーマ一覧を確認する&lt;/h2>
&lt;p>PostgreSQLでスキーマ一覧を確認するには、psqlコマンドラインツールの&lt;code>\dn&lt;/code>コマンドを使う。&lt;/p>
&lt;div class="highlight">&lt;pre tabindex="0" class="chroma">&lt;code class="language-sql" data-lang="sql">&lt;span class="line">&lt;span class="cl">&lt;span class="err">\&lt;/span>&lt;span class="n">dn&lt;/span>&lt;span class="w">
&lt;/span>&lt;/span>&lt;/span>&lt;span class="line">&lt;span class="cl">&lt;span class="w"> &lt;/span>&lt;span class="n">List&lt;/span>&lt;span class="w"> &lt;/span>&lt;span class="k">of&lt;/span>&lt;span class="w"> &lt;/span>&lt;span class="n">schemas&lt;/span>&lt;span class="w">
&lt;/span>&lt;/span>&lt;/span>&lt;span class="line">&lt;span class="cl">&lt;span class="w"> &lt;/span>&lt;span class="n">Name&lt;/span>&lt;span class="w"> &lt;/span>&lt;span class="o">|&lt;/span>&lt;span class="w"> &lt;/span>&lt;span class="k">Owner&lt;/span>&lt;span class="w">
&lt;/span>&lt;/span>&lt;/span>&lt;span class="line">&lt;span class="cl">&lt;span class="w">&lt;/span>&lt;span class="c1">--------+-------------------
&lt;/span>&lt;/span>&lt;/span>&lt;span class="line">&lt;span class="cl">&lt;span class="c1">&lt;/span>&lt;span class="w"> &lt;/span>&lt;span class="n">app&lt;/span>&lt;span class="w"> &lt;/span>&lt;span class="o">|&lt;/span>&lt;span class="w"> &lt;/span>&lt;span class="n">postgres&lt;/span>&lt;span class="w">
&lt;/span>&lt;/span>&lt;/span>&lt;span class="line">&lt;span class="cl">&lt;span class="w"> &lt;/span>&lt;span class="k">public&lt;/span>&lt;span class="w"> &lt;/span>&lt;span class="o">|&lt;/span>&lt;span class="w"> &lt;/span>&lt;span class="n">pg_database_owner&lt;/span>&lt;span class="w">
&lt;/span>&lt;/span>&lt;/span>&lt;span class="line">&lt;span class="cl">&lt;span class="w"> &lt;/span>&lt;span class="n">report&lt;/span>&lt;span class="w"> &lt;/span>&lt;span class="o">|&lt;/span>&lt;span class="w"> &lt;/span>&lt;span class="n">app_user&lt;/span>&lt;span class="w">
&lt;/span>&lt;/span>&lt;/span>&lt;span class="line">&lt;span class="cl">&lt;span class="w"> &lt;/span>&lt;span class="n">sales&lt;/span>&lt;span class="w"> &lt;/span>&lt;span class="o">|&lt;/span>&lt;span class="w"> &lt;/span>&lt;span class="n">postgres&lt;/span>&lt;span class="w">
&lt;/span>&lt;/span>&lt;/span>&lt;span class="line">&lt;span class="cl">&lt;span class="w">&lt;/span>&lt;span class="p">(&lt;/span>&lt;span class="mi">4&lt;/span>&lt;span class="w"> &lt;/span>&lt;span class="k">rows&lt;/span>&lt;span class="p">)&lt;/span>&lt;span class="w">
&lt;/span>&lt;/span>&lt;/span>&lt;/code>&lt;/pre>&lt;/div>&lt;p>&lt;code>pg_catalog&lt;/code>や&lt;code>information_schema&lt;/code>などのシステムスキーマは除外され、自分で作成したスキーマと&lt;code>public&lt;/code>スキーマだけが表示される。&lt;/p></description><enclosure url="https://atsum.in/database/postgresql-show-schemas/img/thumbnail.png" type="image/png"/></item><item><title>【Hugo】-Mオプションでディスクへ書かずにビルドする</title><link>https://atsum.in/hugo/render-to-memory/</link><pubDate>Sun, 09 Aug 2026 11:10:00 +0900</pubDate><guid>https://atsum.in/hugo/render-to-memory/</guid><description>&lt;h2 id="実現したいこと">実現したいこと&lt;/h2>
&lt;p>ビルドが通るかどうかだけを確認したい場合、生成物はディスクに残らなくてもよい。むしろ&lt;code>public/&lt;/code>に本番URLの生成物が残ると、&lt;code>hugo server&lt;/code>で起動中の開発サーバーの状態を壊してしまう。&lt;/p></description><enclosure url="https://atsum.in/hugo/render-to-memory/img/thumbnail.png" type="image/png"/></item><item><title>【Hugo】-dオプションでビルド結果を別ディレクトリに出力する</title><link>https://atsum.in/hugo/build-destination-option/</link><pubDate>Sun, 09 Aug 2026 10:53:55 +0900</pubDate><guid>https://atsum.in/hugo/build-destination-option/</guid><description>&lt;h2 id="実現したいこと">実現したいこと&lt;/h2>
&lt;p>&lt;code>hugo server&lt;/code>でローカル開発サーバーを起動したまま、別のターミナルで&lt;code>hugo&lt;/code>を実行してビルドが通るかを確認したい。&lt;/p>
&lt;p>しかし何も指定せずに&lt;code>hugo&lt;/code>を実行すると、開発サーバーが配信しているファイルが本番用のURLで上書きされてしまう。ブラウザで開いているページのリンクが軒並み本番サイトのURLに変わり、クリックすると本番サイトへ飛ばされる。&lt;/p></description><enclosure url="https://atsum.in/hugo/build-destination-option/img/thumbnail.png" type="image/png"/></item><item><title>【PostgreSQL】pg_hba.confの場所を探す(show hba_file)</title><link>https://atsum.in/database/postgresql-hba-conf-location/</link><pubDate>Sun, 09 Aug 2026 10:30:28 +0900</pubDate><guid>https://atsum.in/database/postgresql-hba-conf-location/</guid><description>&lt;h2 id="pg_hbaconfの場所を探すコマンドshow-hba_file">pg_hba.confの場所を探すコマンド(show hba_file)&lt;/h2>
&lt;p>&lt;code>pg_hba.conf&lt;/code>はPostgreSQLのクライアント認証を設定するファイルで、どのホストからどのユーザーがどのデータベースに、どの認証方式で接続できるかを定義する。&lt;br>
&lt;code>postgresql.conf&lt;/code>と同様にOSやインストール方法によって配置場所が異なる。&lt;/p></description><enclosure url="https://atsum.in/database/postgresql-hba-conf-location/img/thumbnail.png" type="image/png"/></item><item><title>【GitHub CLI】gh repo createでリポジトリ作成からpushまでまとめて実行する</title><link>https://atsum.in/linux/gh-repo-create-source-push/</link><pubDate>Sat, 08 Aug 2026 15:55:21 +0900</pubDate><guid>https://atsum.in/linux/gh-repo-create-source-push/</guid><description>&lt;h2 id="ローカルリポジトリからgithubリポジトリを作成してpushする">ローカルリポジトリからGitHubリポジトリを作成してpushする&lt;/h2>
&lt;p>手元で&lt;code>git init&lt;/code>したリポジトリをGitHubに上げる場合、通常はGitHub上でリポジトリを作成し、&lt;code>git remote add&lt;/code>でリモートを登録し、&lt;code>git push&lt;/code>する。
GitHub CLIの&lt;code>gh repo create&lt;/code>に&lt;code>--source&lt;/code>と&lt;code>--push&lt;/code>を指定すると、一連の手順をコマンド1つで完了できる。&lt;/p></description><enclosure url="https://atsum.in/linux/gh-repo-create-source-push/img/thumbnail.png" type="image/png"/></item><item><title>【Maven】-Dtestオプションでテストを1つだけ実行する</title><link>https://atsum.in/java/surefire-run-single-test/</link><pubDate>Sat, 08 Aug 2026 10:23:41 +0900</pubDate><guid>https://atsum.in/java/surefire-run-single-test/</guid><description>&lt;h2 id="概要">概要&lt;/h2>
&lt;p>Mavenでテストを実行すると、通常はプロジェクト内のすべてのテストが対象になる。
修正したクラスのテストだけを確認したい場合、maven-surefire-pluginの &lt;code>-Dtest&lt;/code> オプションで実行対象を絞り込める。&lt;/p></description><enclosure url="https://atsum.in/java/surefire-run-single-test/img/thumbnail.png" type="image/png"/></item><item><title>【AWS CLI】aws iam simulate-principal-policyでIAM権限を実際に試さずに確認する</title><link>https://atsum.in/aws/iam-simulate-principal-policy/</link><pubDate>Thu, 06 Aug 2026 07:37:34 +0900</pubDate><guid>https://atsum.in/aws/iam-simulate-principal-policy/</guid><description>&lt;h2 id="権限が足りているかをapiを呼ばずに確かめる">権限が足りているかをAPIを呼ばずに確かめる&lt;/h2>
&lt;p>IAMユーザーやロールの権限が足りているかは、実際にAPIを呼んで&lt;code>AccessDenied&lt;/code>が返るかどうかで確かめる場合が多い。&lt;br>
ただしリソースの作成や削除を伴うAPIでは、権限確認のためだけに呼ぶわけにはいかない。&lt;/p></description><enclosure url="https://atsum.in/aws/iam-simulate-principal-policy/img/thumbnail.png" type="image/png"/></item><item><title>【dig】DNSの問い合わせ結果を読む</title><link>https://atsum.in/linux/dig-read-output/</link><pubDate>Mon, 03 Aug 2026 08:08:35 +0900</pubDate><guid>https://atsum.in/linux/dig-read-output/</guid><description>&lt;h2 id="digの出力">digの出力&lt;/h2>
&lt;p>&lt;code>dig&lt;/code>はDNSの問い合わせ結果を確認するコマンド。ホスト名を引数に渡すと、応答の全体が表示される。&lt;/p>
&lt;div class="highlight">&lt;pre tabindex="0" class="chroma">&lt;code class="language-shell" data-lang="shell">&lt;span class="line">&lt;span class="cl">$ dig www.example.com
&lt;/span>&lt;/span>&lt;/code>&lt;/pre>&lt;/div>&lt;div class="highlight">&lt;pre tabindex="0" class="chroma">&lt;code class="language-text" data-lang="text">&lt;span class="line">&lt;span class="cl">; &amp;lt;&amp;lt;&amp;gt;&amp;gt; DiG 9.20.26-Debian &amp;lt;&amp;lt;&amp;gt;&amp;gt; www.example.com
&lt;/span>&lt;/span>&lt;span class="line">&lt;span class="cl">;; global options: +cmd
&lt;/span>&lt;/span>&lt;span class="line">&lt;span class="cl">;; Got answer:
&lt;/span>&lt;/span>&lt;span class="line">&lt;span class="cl">;; -&amp;gt;&amp;gt;HEADER&amp;lt;&amp;lt;- opcode: QUERY, status: NOERROR, id: 55790
&lt;/span>&lt;/span>&lt;span class="line">&lt;span class="cl">;; flags: qr rd ra ad; QUERY: 1, ANSWER: 2, AUTHORITY: 0, ADDITIONAL: 1
&lt;/span>&lt;/span>&lt;span class="line">&lt;span class="cl">
&lt;/span>&lt;/span>&lt;span class="line">&lt;span class="cl">;; OPT PSEUDOSECTION:
&lt;/span>&lt;/span>&lt;span class="line">&lt;span class="cl">; EDNS: version: 0, flags:; udp: 512
&lt;/span>&lt;/span>&lt;span class="line">&lt;span class="cl">;; QUESTION SECTION:
&lt;/span>&lt;/span>&lt;span class="line">&lt;span class="cl">;www.example.com. IN A
&lt;/span>&lt;/span>&lt;span class="line">&lt;span class="cl">
&lt;/span>&lt;/span>&lt;span class="line">&lt;span class="cl">;; ANSWER SECTION:
&lt;/span>&lt;/span>&lt;span class="line">&lt;span class="cl">www.example.com. 300 IN A 172.66.147.243
&lt;/span>&lt;/span>&lt;span class="line">&lt;span class="cl">www.example.com. 300 IN A 104.20.23.154
&lt;/span>&lt;/span>&lt;span class="line">&lt;span class="cl">
&lt;/span>&lt;/span>&lt;span class="line">&lt;span class="cl">;; Query time: 19 msec
&lt;/span>&lt;/span>&lt;span class="line">&lt;span class="cl">;; SERVER: 192.168.1.1#53(192.168.1.1) (UDP)
&lt;/span>&lt;/span>&lt;span class="line">&lt;span class="cl">;; WHEN: Mon Aug 03 08:17:28 JST 2026
&lt;/span>&lt;/span>&lt;span class="line">&lt;span class="cl">;; MSG SIZE rcvd: 76
&lt;/span>&lt;/span>&lt;/code>&lt;/pre>&lt;/div>&lt;p>情報量が多いが、普段確認するのは以下の4箇所。&lt;/p></description><enclosure url="https://atsum.in/linux/dig-read-output/img/thumbnail.png" type="image/png"/></item><item><title>【du】ディスクを圧迫しているディレクトリを探す</title><link>https://atsum.in/linux/du-find-large-directories/</link><pubDate>Mon, 03 Aug 2026 07:03:58 +0900</pubDate><guid>https://atsum.in/linux/du-find-large-directories/</guid><description>&lt;h2 id="ディスクの空き容量が減った原因を特定したい">ディスクの空き容量が減った原因を特定したい&lt;/h2>
&lt;p>&lt;code>df -h&lt;/code>でディスクの使用率が上がっていると分かっても、どのディレクトリが容量を占めているかまでは分からない。&lt;/p>
&lt;div class="highlight">&lt;pre tabindex="0" class="chroma">&lt;code class="language-shell" data-lang="shell">&lt;span class="line">&lt;span class="cl">$ df -h /
&lt;/span>&lt;/span>&lt;span class="line">&lt;span class="cl">Filesystem Size Used Avail Use% Mounted on
&lt;/span>&lt;/span>&lt;span class="line">&lt;span class="cl">/dev/sda1 50G 47G 3.0G 94% /
&lt;/span>&lt;/span>&lt;/code>&lt;/pre>&lt;/div>&lt;p>使用量の内訳を調べるには&lt;code>du&lt;/code>(disk usage)コマンドを使う。上の階層から順に大きいディレクトリをたどれば、容量を消費している場所を絞り込める。&lt;/p></description><enclosure url="https://atsum.in/linux/du-find-large-directories/img/thumbnail.png" type="image/png"/></item><item><title>【AWS CLI】S3バケットのバージョニングを有効化・確認する</title><link>https://atsum.in/aws/s3-bucket-versioning/</link><pubDate>Sat, 01 Aug 2026 12:03:49 +0900</pubDate><guid>https://atsum.in/aws/s3-bucket-versioning/</guid><description>&lt;h2 id="バージョニングを有効化する">バージョニングを有効化する&lt;/h2>
&lt;p>&lt;code>--versioning-configuration&lt;/code>に&lt;code>Status=Enabled&lt;/code>を指定する。&lt;/p>
&lt;div class="highlight">&lt;pre tabindex="0" class="chroma">&lt;code class="language-shell" data-lang="shell">&lt;span class="line">&lt;span class="cl">$ aws s3api put-bucket-versioning --bucket example-bucket --versioning-configuration &lt;span class="nv">Status&lt;/span>&lt;span class="o">=&lt;/span>Enabled
&lt;/span>&lt;/span>&lt;/code>&lt;/pre>&lt;/div>&lt;p>成功しても出力はない。&lt;/p>
&lt;p>有効化の直後は設定の伝播に時間がかかる。&lt;br>
伝播中は、有効化後に作成・更新したオブジェクトへのGETリクエストが&lt;code>HTTP 404 NoSuchKey&lt;/code>になる場合がある。&lt;br>
AWSのドキュメントでは、有効化から15分待ってから書き込みや削除に進むよう推奨している。&lt;/p></description><enclosure url="https://atsum.in/aws/s3-bucket-versioning/img/thumbnail.png" type="image/png"/></item><item><title>【AWS CLI】パブリック公開されているS3バケットを探す</title><link>https://atsum.in/aws/find-public-s3-buckets/</link><pubDate>Sat, 01 Aug 2026 11:11:50 +0900</pubDate><guid>https://atsum.in/aws/find-public-s3-buckets/</guid><description>&lt;h2 id="バケットポリシーによる公開を確認する">バケットポリシーによる公開を確認する&lt;/h2>
&lt;p>&lt;code>aws s3api get-bucket-policy-status&lt;/code>は、バケットポリシーの結果としてバケットがパブリック扱いになっているかを返す。&lt;/p>
&lt;div class="highlight">&lt;pre tabindex="0" class="chroma">&lt;code class="language-shell" data-lang="shell">&lt;span class="line">&lt;span class="cl">$ aws s3api get-bucket-policy-status --bucket example-public-bucket
&lt;/span>&lt;/span>&lt;/code>&lt;/pre>&lt;/div>&lt;div class="highlight">&lt;pre tabindex="0" class="chroma">&lt;code class="language-json" data-lang="json">&lt;span class="line">&lt;span class="cl">&lt;span class="p">{&lt;/span>
&lt;/span>&lt;/span>&lt;span class="line">&lt;span class="cl"> &lt;span class="nt">&amp;#34;PolicyStatus&amp;#34;&lt;/span>&lt;span class="p">:&lt;/span> &lt;span class="p">{&lt;/span>
&lt;/span>&lt;/span>&lt;span class="line">&lt;span class="cl"> &lt;span class="nt">&amp;#34;IsPublic&amp;#34;&lt;/span>&lt;span class="p">:&lt;/span> &lt;span class="kc">true&lt;/span>
&lt;/span>&lt;/span>&lt;span class="line">&lt;span class="cl"> &lt;span class="p">}&lt;/span>
&lt;/span>&lt;/span>&lt;span class="line">&lt;span class="cl">&lt;span class="p">}&lt;/span>
&lt;/span>&lt;/span>&lt;/code>&lt;/pre>&lt;/div>&lt;p>ポリシーの中身を読まずに判定できるため、棚卸しの一次判定に向いている。&lt;/p></description><enclosure url="https://atsum.in/aws/find-public-s3-buckets/img/thumbnail.png" type="image/png"/></item><item><title>【AWS CLI】aws s3api get-bucket-policyでS3のバケットポリシーを確認する</title><link>https://atsum.in/aws/s3-get-bucket-policy/</link><pubDate>Sat, 01 Aug 2026 10:29:52 +0900</pubDate><guid>https://atsum.in/aws/s3-get-bucket-policy/</guid><description>&lt;h2 id="基本的な使い方">基本的な使い方&lt;/h2>
&lt;p>&lt;code>--bucket&lt;/code>にバケット名を指定する。&lt;/p>
&lt;div class="highlight">&lt;pre tabindex="0" class="chroma">&lt;code class="language-shell" data-lang="shell">&lt;span class="line">&lt;span class="cl">$ aws s3api get-bucket-policy --bucket &amp;lt;bucket-name&amp;gt;
&lt;/span>&lt;/span>&lt;/code>&lt;/pre>&lt;/div>&lt;p>実行例&lt;/p>
&lt;div class="highlight">&lt;pre tabindex="0" class="chroma">&lt;code class="language-shell" data-lang="shell">&lt;span class="line">&lt;span class="cl">$ aws s3api get-bucket-policy --bucket example-bucket
&lt;/span>&lt;/span>&lt;/code>&lt;/pre>&lt;/div>&lt;div class="highlight">&lt;pre tabindex="0" class="chroma">&lt;code class="language-json" data-lang="json">&lt;span class="line">&lt;span class="cl">&lt;span class="p">{&lt;/span>
&lt;/span>&lt;/span>&lt;span class="line">&lt;span class="cl"> &lt;span class="nt">&amp;#34;Policy&amp;#34;&lt;/span>&lt;span class="p">:&lt;/span> &lt;span class="s2">&amp;#34;{\&amp;#34;Version\&amp;#34;:\&amp;#34;2012-10-17\&amp;#34;,\&amp;#34;Statement\&amp;#34;:[{\&amp;#34;Sid\&amp;#34;:\&amp;#34;\&amp;#34;,\&amp;#34;Effect\&amp;#34;:\&amp;#34;Allow\&amp;#34;,\&amp;#34;Principal\&amp;#34;:{\&amp;#34;Service\&amp;#34;:\&amp;#34;cloudfront.amazonaws.com\&amp;#34;},\&amp;#34;Action\&amp;#34;:\&amp;#34;s3:GetObject\&amp;#34;,\&amp;#34;Resource\&amp;#34;:\&amp;#34;arn:aws:s3:::example-bucket/*\&amp;#34;,\&amp;#34;Condition\&amp;#34;:{\&amp;#34;StringEquals\&amp;#34;:{\&amp;#34;aws:SourceArn\&amp;#34;:\&amp;#34;arn:aws:cloudfront::123456789012:distribution/E1EXAMPLE123ABC\&amp;#34;}}}]}&amp;#34;&lt;/span>
&lt;/span>&lt;/span>&lt;span class="line">&lt;span class="cl">&lt;span class="p">}&lt;/span>
&lt;/span>&lt;/span>&lt;/code>&lt;/pre>&lt;/div>&lt;p>&lt;code>Policy&lt;/code>の値はJSONオブジェクトではなく、エスケープされた文字列である。&lt;br>
そのままでは読みづらいため、次のように整形する。&lt;/p></description><enclosure url="https://atsum.in/aws/s3-get-bucket-policy/img/thumbnail.png" type="image/png"/></item><item><title>【AWS CLI】aws s3 presignで署名付きURLを生成してS3のファイルを一時的に共有する</title><link>https://atsum.in/aws/s3-presign/</link><pubDate>Sat, 01 Aug 2026 07:26:33 +0900</pubDate><guid>https://atsum.in/aws/s3-presign/</guid><description>&lt;p>&lt;code>aws s3 presign&lt;/code>で署名付きURL(presigned URL)を生成すると、期限付きでダウンロードできるURLをその場で作れる。&lt;br>
URLを受け取った相手にAWSアカウントは不要で、期限が過ぎればURLは自動的に使えなくなる。&lt;/p></description><enclosure url="https://atsum.in/aws/s3-presign/img/thumbnail.png" type="image/png"/></item><item><title>【Mac】ncduでディスク使用量の大きいディレクトリを探す</title><link>https://atsum.in/mac/ncdu/</link><pubDate>Tue, 28 Jul 2026 08:18:51 +0900</pubDate><guid>https://atsum.in/mac/ncdu/</guid><description>&lt;h2 id="ncdu">ncdu&lt;/h2>
&lt;p>&lt;a href="https://dev.yorhel.nl/ncdu" target="_blank" rel="noopener nofollow">ncdu&lt;/a>
(NCurses Disk Usage)はディスク使用量をターミナル上のUIで表示するツール。&lt;/p>
&lt;p>&lt;code>du&lt;/code>の出力を読む代わりに、カーソルでディレクトリを掘り下げながら容量の内訳を確認できる。ディスクの空き容量が減ったときに、どのディレクトリが容量を占めているかを短時間で特定できる。&lt;/p></description><enclosure url="https://atsum.in/mac/ncdu/img/thumbnail.png" type="image/png"/></item><item><title>【PostgreSQL】psqlでクエリを定期的に再実行して監視する</title><link>https://atsum.in/database/psql-watch/</link><pubDate>Mon, 27 Jul 2026 23:05:24 +0900</pubDate><guid>https://atsum.in/database/psql-watch/</guid><description>&lt;h2 id="psqlのwatchでクエリを繰り返し実行する">psqlの\watchでクエリを繰り返し実行する&lt;/h2>
&lt;p>psqlの&lt;code>\watch&lt;/code>メタコマンドは、直前に実行したクエリを一定間隔で繰り返し実行する。実行中のクエリやテーブルの件数など、時間とともに変化する値を監視する場合に使う。&lt;/p></description><enclosure url="https://atsum.in/database/psql-watch/img/thumbnail.png" type="image/png"/></item><item><title>【PostgreSQL】デッドロックのログの読み方</title><link>https://atsum.in/database/postgresql-deadlock-log/</link><pubDate>Mon, 27 Jul 2026 00:16:12 +0900</pubDate><guid>https://atsum.in/database/postgresql-deadlock-log/</guid><description>&lt;h2 id="デッドロックとは">デッドロックとは&lt;/h2>
&lt;p>2つ以上のトランザクションが互いの保持するロックの解放を待ち合い、どちらも先に進めなくなった状態である。PostgreSQLは&lt;code>deadlock_timeout&lt;/code>(デフォルト1秒)を超えてロックを待ったときに待ち合わせの循環を検査し、循環を見つけるとトランザクションのひとつを中断する。&lt;/p></description><enclosure url="https://atsum.in/database/postgresql-deadlock-log/img/thumbnail.png" type="image/png"/></item><item><title>【PostgreSQL】SELECT FOR UPDATEで行をロックする</title><link>https://atsum.in/database/postgresql-select-for-update/</link><pubDate>Sun, 26 Jul 2026 23:29:39 +0900</pubDate><guid>https://atsum.in/database/postgresql-select-for-update/</guid><description>&lt;h2 id="select-for-updateとは">SELECT FOR UPDATEとは&lt;/h2>
&lt;p>&lt;code>SELECT ... FOR UPDATE&lt;/code>は、取得した行に対して排他的な行ロックを取得する構文である。ロックはトランザクションの終了まで保持され、他のトランザクションは同じ行に対する&lt;code>UPDATE&lt;/code>や&lt;code>DELETE&lt;/code>、&lt;code>SELECT FOR UPDATE&lt;/code>で待たされる。&lt;/p></description><enclosure url="https://atsum.in/database/postgresql-select-for-update/img/thumbnail.png" type="image/png"/></item><item><title>【PostgreSQL】再起動が必要な設定を見分ける</title><link>https://atsum.in/database/postgresql-restart-required-settings/</link><pubDate>Sun, 26 Jul 2026 19:49:53 +0900</pubDate><guid>https://atsum.in/database/postgresql-restart-required-settings/</guid><description>&lt;h2 id="設定の反映方法は3通り">設定の反映方法は3通り&lt;/h2>
&lt;p>PostgreSQLの設定を変更したあと、変更を反映する操作は設定項目ごとに異なる。&lt;/p>
&lt;pre class="mermaid">graph TD
A[設定を変更] --&amp;gt; B{context}
B --&amp;gt;|internal| C[変更不可]
B --&amp;gt;|postmaster| D[設定ファイル + 再起動]
B --&amp;gt;|sighup| E[&amp;#34;設定ファイル + リロード&amp;#34;]
B --&amp;gt;|superuser-backend / backend| F[&amp;#34;設定ファイル + リロード&amp;lt;br/&amp;gt;反映は新規セッションから&amp;#34;]
B --&amp;gt;|superuser / user| G[&amp;#34;設定ファイル + リロード&amp;lt;br/&amp;gt;またはSETでセッション単位に変更&amp;#34;]
&lt;/pre>
&lt;p>&lt;code>postgresql.conf&lt;/code>を書き換えてリロードしただけでは反映されない設定もあるため、変更前に判別しておく。判別には&lt;code>pg_settings&lt;/code>の&lt;code>context&lt;/code>カラムを使用する。&lt;/p></description><enclosure url="https://atsum.in/database/postgresql-restart-required-settings/img/thumbnail.png" type="image/png"/></item><item><title>【PostgreSQL】pg_stat_user_tablesでSeq ScanとIndex Scanの比率を確認する</title><link>https://atsum.in/database/pg-stat-user-tables-scan-ratio/</link><pubDate>Sun, 26 Jul 2026 16:50:15 +0900</pubDate><guid>https://atsum.in/database/pg-stat-user-tables-scan-ratio/</guid><description>&lt;h2 id="pg_stat_user_tablesとは">pg_stat_user_tablesとは&lt;/h2>
&lt;p>&lt;code>pg_stat_user_tables&lt;/code>は、テーブルごとのアクセス状況を集計するビューである。Seq Scan(全件走査)とIndex Scanのそれぞれの回数を確認できるため、インデックスが不足しているテーブルの発見に使える。&lt;/p></description><enclosure url="https://atsum.in/database/pg-stat-user-tables-scan-ratio/img/thumbnail.png" type="image/png"/></item><item><title>【PostgreSQL】shared_buffersとwork_memの役割と確認方法</title><link>https://atsum.in/database/postgresql-shared-buffers-work-mem/</link><pubDate>Sun, 26 Jul 2026 13:38:17 +0900</pubDate><guid>https://atsum.in/database/postgresql-shared-buffers-work-mem/</guid><description>&lt;h2 id="shared_buffersとwork_memの役割">shared_buffersとwork_memの役割&lt;/h2>
&lt;p>PostgreSQLのメモリは大きく2種類ある。全プロセスで共有する領域と、バックエンドプロセスごとに確保する領域である。&lt;code>shared_buffers&lt;/code>は前者、&lt;code>work_mem&lt;/code>は後者を制御するパラメータである。&lt;/p></description><enclosure url="https://atsum.in/database/postgresql-shared-buffers-work-mem/img/thumbnail.png" type="image/png"/></item><item><title>【PostgreSQL】SHOW ALLやpg_settingsで設定値を一覧・検索する</title><link>https://atsum.in/database/postgresql-show-settings/</link><pubDate>Sun, 26 Jul 2026 13:17:26 +0900</pubDate><guid>https://atsum.in/database/postgresql-show-settings/</guid><description>&lt;h2 id="show-allで設定値を一覧する">SHOW ALLで設定値を一覧する&lt;/h2>
&lt;p>PostgreSQLの全設定値を一覧するには&lt;code>SHOW ALL&lt;/code>コマンドを実行する。&lt;/p>
&lt;div class="highlight">&lt;pre tabindex="0" class="chroma">&lt;code class="language-sql" data-lang="sql">&lt;span class="line">&lt;span class="cl">&lt;span class="k">SHOW&lt;/span>&lt;span class="w"> &lt;/span>&lt;span class="k">ALL&lt;/span>&lt;span class="p">;&lt;/span>&lt;span class="w">
&lt;/span>&lt;/span>&lt;/span>&lt;span class="line">&lt;span class="cl">&lt;span class="w"> &lt;/span>&lt;span class="n">name&lt;/span>&lt;span class="w"> &lt;/span>&lt;span class="o">|&lt;/span>&lt;span class="w"> &lt;/span>&lt;span class="n">setting&lt;/span>&lt;span class="w"> &lt;/span>&lt;span class="o">|&lt;/span>&lt;span class="w"> &lt;/span>&lt;span class="n">description&lt;/span>&lt;span class="w">
&lt;/span>&lt;/span>&lt;/span>&lt;span class="line">&lt;span class="cl">&lt;span class="w">&lt;/span>&lt;span class="c1">---------------------------------+---------+---------------------------------------------------------
&lt;/span>&lt;/span>&lt;/span>&lt;span class="line">&lt;span class="cl">&lt;span class="c1">&lt;/span>&lt;span class="w"> &lt;/span>&lt;span class="n">application_name&lt;/span>&lt;span class="w"> &lt;/span>&lt;span class="o">|&lt;/span>&lt;span class="w"> &lt;/span>&lt;span class="n">psql&lt;/span>&lt;span class="w"> &lt;/span>&lt;span class="o">|&lt;/span>&lt;span class="w"> &lt;/span>&lt;span class="k">Sets&lt;/span>&lt;span class="w"> &lt;/span>&lt;span class="n">the&lt;/span>&lt;span class="w"> &lt;/span>&lt;span class="n">application&lt;/span>&lt;span class="w"> &lt;/span>&lt;span class="n">name&lt;/span>&lt;span class="w"> &lt;/span>&lt;span class="k">to&lt;/span>&lt;span class="w"> &lt;/span>&lt;span class="n">be&lt;/span>&lt;span class="w"> &lt;/span>&lt;span class="n">reported&lt;/span>&lt;span class="w"> &lt;/span>&lt;span class="k">in&lt;/span>&lt;span class="w"> &lt;/span>&lt;span class="k">statistics&lt;/span>&lt;span class="p">...&lt;/span>&lt;span class="w">
&lt;/span>&lt;/span>&lt;/span>&lt;span class="line">&lt;span class="cl">&lt;span class="w"> &lt;/span>&lt;span class="n">archive_mode&lt;/span>&lt;span class="w"> &lt;/span>&lt;span class="o">|&lt;/span>&lt;span class="w"> &lt;/span>&lt;span class="k">off&lt;/span>&lt;span class="w"> &lt;/span>&lt;span class="o">|&lt;/span>&lt;span class="w"> &lt;/span>&lt;span class="n">Allows&lt;/span>&lt;span class="w"> &lt;/span>&lt;span class="n">archiving&lt;/span>&lt;span class="w"> &lt;/span>&lt;span class="k">of&lt;/span>&lt;span class="w"> &lt;/span>&lt;span class="n">WAL&lt;/span>&lt;span class="w"> &lt;/span>&lt;span class="n">files&lt;/span>&lt;span class="w"> &lt;/span>&lt;span class="k">using&lt;/span>&lt;span class="w"> &lt;/span>&lt;span class="n">archive_command&lt;/span>&lt;span class="p">.&lt;/span>&lt;span class="w">
&lt;/span>&lt;/span>&lt;/span>&lt;span class="line">&lt;span class="cl">&lt;span class="w"> &lt;/span>&lt;span class="n">autovacuum&lt;/span>&lt;span class="w"> &lt;/span>&lt;span class="o">|&lt;/span>&lt;span class="w"> &lt;/span>&lt;span class="k">on&lt;/span>&lt;span class="w"> &lt;/span>&lt;span class="o">|&lt;/span>&lt;span class="w"> &lt;/span>&lt;span class="n">Starts&lt;/span>&lt;span class="w"> &lt;/span>&lt;span class="n">the&lt;/span>&lt;span class="w"> &lt;/span>&lt;span class="n">autovacuum&lt;/span>&lt;span class="w"> &lt;/span>&lt;span class="n">subprocess&lt;/span>&lt;span class="p">.&lt;/span>&lt;span class="w">
&lt;/span>&lt;/span>&lt;/span>&lt;span class="line">&lt;span class="cl">&lt;span class="w"> &lt;/span>&lt;span class="n">max_connections&lt;/span>&lt;span class="w"> &lt;/span>&lt;span class="o">|&lt;/span>&lt;span class="w"> &lt;/span>&lt;span class="mi">100&lt;/span>&lt;span class="w"> &lt;/span>&lt;span class="o">|&lt;/span>&lt;span class="w"> &lt;/span>&lt;span class="k">Sets&lt;/span>&lt;span class="w"> &lt;/span>&lt;span class="n">the&lt;/span>&lt;span class="w"> &lt;/span>&lt;span class="n">maximum&lt;/span>&lt;span class="w"> &lt;/span>&lt;span class="nb">number&lt;/span>&lt;span class="w"> &lt;/span>&lt;span class="k">of&lt;/span>&lt;span class="w"> &lt;/span>&lt;span class="n">concurrent&lt;/span>&lt;span class="w"> &lt;/span>&lt;span class="n">connections&lt;/span>&lt;span class="p">.&lt;/span>&lt;span class="w">
&lt;/span>&lt;/span>&lt;/span>&lt;span class="line">&lt;span class="cl">&lt;span class="w"> &lt;/span>&lt;span class="n">shared_buffers&lt;/span>&lt;span class="w"> &lt;/span>&lt;span class="o">|&lt;/span>&lt;span class="w"> &lt;/span>&lt;span class="mi">16384&lt;/span>&lt;span class="w"> &lt;/span>&lt;span class="o">|&lt;/span>&lt;span class="w"> &lt;/span>&lt;span class="k">Sets&lt;/span>&lt;span class="w"> &lt;/span>&lt;span class="n">the&lt;/span>&lt;span class="w"> &lt;/span>&lt;span class="nb">number&lt;/span>&lt;span class="w"> &lt;/span>&lt;span class="k">of&lt;/span>&lt;span class="w"> &lt;/span>&lt;span class="n">shared&lt;/span>&lt;span class="w"> &lt;/span>&lt;span class="n">memory&lt;/span>&lt;span class="w"> &lt;/span>&lt;span class="n">buffers&lt;/span>&lt;span class="w"> &lt;/span>&lt;span class="n">used&lt;/span>&lt;span class="w"> &lt;/span>&lt;span class="k">by&lt;/span>&lt;span class="w"> &lt;/span>&lt;span class="n">the&lt;/span>&lt;span class="w"> &lt;/span>&lt;span class="p">...&lt;/span>&lt;span class="w">
&lt;/span>&lt;/span>&lt;/span>&lt;span class="line">&lt;span class="cl">&lt;span class="w"> &lt;/span>&lt;span class="n">work_mem&lt;/span>&lt;span class="w"> &lt;/span>&lt;span class="o">|&lt;/span>&lt;span class="w"> &lt;/span>&lt;span class="mi">4096&lt;/span>&lt;span class="w"> &lt;/span>&lt;span class="o">|&lt;/span>&lt;span class="w"> &lt;/span>&lt;span class="k">Sets&lt;/span>&lt;span class="w"> &lt;/span>&lt;span class="n">the&lt;/span>&lt;span class="w"> &lt;/span>&lt;span class="n">maximum&lt;/span>&lt;span class="w"> &lt;/span>&lt;span class="n">memory&lt;/span>&lt;span class="w"> &lt;/span>&lt;span class="k">to&lt;/span>&lt;span class="w"> &lt;/span>&lt;span class="n">be&lt;/span>&lt;span class="w"> &lt;/span>&lt;span class="n">used&lt;/span>&lt;span class="w"> &lt;/span>&lt;span class="k">for&lt;/span>&lt;span class="w"> &lt;/span>&lt;span class="n">query&lt;/span>&lt;span class="w"> &lt;/span>&lt;span class="n">workspaces&lt;/span>&lt;span class="p">.&lt;/span>&lt;span class="w">
&lt;/span>&lt;/span>&lt;/span>&lt;span class="line">&lt;span class="cl">&lt;span class="w">&lt;/span>&lt;span class="err">・&lt;/span>&lt;span class="w">
&lt;/span>&lt;/span>&lt;/span>&lt;span class="line">&lt;span class="cl">&lt;span class="w">&lt;/span>&lt;span class="err">・&lt;/span>&lt;span class="w">
&lt;/span>&lt;/span>&lt;/span>&lt;span class="line">&lt;span class="cl">&lt;span class="w">&lt;/span>&lt;span class="err">・&lt;/span>&lt;span class="w">
&lt;/span>&lt;/span>&lt;/span>&lt;span class="line">&lt;span class="cl">&lt;span class="w">&lt;/span>&lt;span class="p">(&lt;/span>&lt;span class="mi">300&lt;/span>&lt;span class="w"> &lt;/span>&lt;span class="k">rows&lt;/span>&lt;span class="p">)&lt;/span>&lt;span class="w">
&lt;/span>&lt;/span>&lt;/span>&lt;/code>&lt;/pre>&lt;/div>&lt;p>設定項目数は300件を超え(バージョンによって異なる)、&lt;code>name&lt;/code>・&lt;code>setting&lt;/code>・&lt;code>description&lt;/code>の3カラムのみが表示される。&lt;/p></description><enclosure url="https://atsum.in/database/postgresql-show-settings/img/thumbnail.png" type="image/png"/></item><item><title>【PostgreSQL】CHECK制約を後から安全に追加する方法</title><link>https://atsum.in/database/postgresql-add-check-constraint-safely/</link><pubDate>Sun, 26 Jul 2026 10:02:02 +0900</pubDate><guid>https://atsum.in/database/postgresql-add-check-constraint-safely/</guid><description>&lt;h2 id="そのままcheck制約を追加する場合の問題">そのままCHECK制約を追加する場合の問題&lt;/h2>
&lt;p>既存のテーブルにCHECK制約を追加するには、&lt;code>ALTER TABLE ... ADD CONSTRAINT ... CHECK&lt;/code>を使用する。&lt;/p>
&lt;div class="highlight">&lt;pre tabindex="0" class="chroma">&lt;code class="language-sql" data-lang="sql">&lt;span class="line">&lt;span class="cl">&lt;span class="k">ALTER&lt;/span>&lt;span class="w"> &lt;/span>&lt;span class="k">TABLE&lt;/span>&lt;span class="w"> &lt;/span>&lt;span class="n">products&lt;/span>&lt;span class="w"> &lt;/span>&lt;span class="k">ADD&lt;/span>&lt;span class="w"> &lt;/span>&lt;span class="k">CONSTRAINT&lt;/span>&lt;span class="w"> &lt;/span>&lt;span class="n">price_positive&lt;/span>&lt;span class="w"> &lt;/span>&lt;span class="k">CHECK&lt;/span>&lt;span class="w"> &lt;/span>&lt;span class="p">(&lt;/span>&lt;span class="n">price&lt;/span>&lt;span class="w"> &lt;/span>&lt;span class="o">&amp;gt;&lt;/span>&lt;span class="w"> &lt;/span>&lt;span class="mi">0&lt;/span>&lt;span class="p">);&lt;/span>&lt;span class="w">
&lt;/span>&lt;/span>&lt;/span>&lt;/code>&lt;/pre>&lt;/div>&lt;p>この方法は、テーブル全体をスキャンして既存の全行が条件を満たすことを検証する。&lt;br>
検証中はテーブルに対して&lt;code>ACCESS EXCLUSIVE&lt;/code>ロックを保持し続けるため、大規模なテーブルでは検証が終わるまでの間、参照・更新を含むすべてのアクセスがブロックされる。&lt;/p></description><enclosure url="https://atsum.in/database/postgresql-add-check-constraint-safely/img/thumbnail.png" type="image/png"/></item><item><title>【PostgreSQL】外部キー制約を後から安全に追加する方法</title><link>https://atsum.in/database/postgresql-add-foreign-key-constraint-safely/</link><pubDate>Sun, 26 Jul 2026 09:46:10 +0900</pubDate><guid>https://atsum.in/database/postgresql-add-foreign-key-constraint-safely/</guid><description>&lt;h2 id="そのまま外部キー制約を追加する場合の問題">そのまま外部キー制約を追加する場合の問題&lt;/h2>
&lt;p>既存のテーブルに外部キー制約を追加するには、&lt;code>ALTER TABLE ... ADD CONSTRAINT ... FOREIGN KEY&lt;/code>を使用する。&lt;/p>
&lt;div class="highlight">&lt;pre tabindex="0" class="chroma">&lt;code class="language-sql" data-lang="sql">&lt;span class="line">&lt;span class="cl">&lt;span class="k">ALTER&lt;/span>&lt;span class="w"> &lt;/span>&lt;span class="k">TABLE&lt;/span>&lt;span class="w"> &lt;/span>&lt;span class="n">orders&lt;/span>&lt;span class="w"> &lt;/span>&lt;span class="k">ADD&lt;/span>&lt;span class="w"> &lt;/span>&lt;span class="k">CONSTRAINT&lt;/span>&lt;span class="w"> &lt;/span>&lt;span class="n">fk_user&lt;/span>&lt;span class="w"> &lt;/span>&lt;span class="k">FOREIGN&lt;/span>&lt;span class="w"> &lt;/span>&lt;span class="k">KEY&lt;/span>&lt;span class="w"> &lt;/span>&lt;span class="p">(&lt;/span>&lt;span class="n">user_id&lt;/span>&lt;span class="p">)&lt;/span>&lt;span class="w"> &lt;/span>&lt;span class="k">REFERENCES&lt;/span>&lt;span class="w"> &lt;/span>&lt;span class="n">users&lt;/span>&lt;span class="p">(&lt;/span>&lt;span class="n">id&lt;/span>&lt;span class="p">);&lt;/span>&lt;span class="w">
&lt;/span>&lt;/span>&lt;/span>&lt;/code>&lt;/pre>&lt;/div>&lt;p>この方法は、参照元テーブルの既存行が参照先テーブルの主キーを正しく参照しているかを検証する。&lt;br>
検証の間、参照元・参照先の両テーブルに対して&lt;code>SHARE ROW EXCLUSIVE&lt;/code>ロックを保持し続ける。&lt;/p></description><enclosure url="https://atsum.in/database/postgresql-add-foreign-key-constraint-safely/img/thumbnail.png" type="image/png"/></item><item><title>【PostgreSQL】NOT NULL制約を後から安全に追加する方法</title><link>https://atsum.in/database/postgresql-add-not-null-constraint-safely/</link><pubDate>Sun, 26 Jul 2026 08:56:23 +0900</pubDate><guid>https://atsum.in/database/postgresql-add-not-null-constraint-safely/</guid><description>&lt;h2 id="そのままnot-null制約を追加する場合の問題">そのままNOT NULL制約を追加する場合の問題&lt;/h2>
&lt;p>既存のカラムにNOT NULL制約を追加するには、&lt;code>ALTER TABLE ... ALTER COLUMN ... SET NOT NULL&lt;/code>を使用する。&lt;/p>
&lt;div class="highlight">&lt;pre tabindex="0" class="chroma">&lt;code class="language-sql" data-lang="sql">&lt;span class="line">&lt;span class="cl">&lt;span class="k">ALTER&lt;/span>&lt;span class="w"> &lt;/span>&lt;span class="k">TABLE&lt;/span>&lt;span class="w"> &lt;/span>&lt;span class="n">big_users&lt;/span>&lt;span class="w"> &lt;/span>&lt;span class="k">ALTER&lt;/span>&lt;span class="w"> &lt;/span>&lt;span class="k">COLUMN&lt;/span>&lt;span class="w"> &lt;/span>&lt;span class="n">email&lt;/span>&lt;span class="w"> &lt;/span>&lt;span class="k">SET&lt;/span>&lt;span class="w"> &lt;/span>&lt;span class="k">NOT&lt;/span>&lt;span class="w"> &lt;/span>&lt;span class="k">NULL&lt;/span>&lt;span class="p">;&lt;/span>&lt;span class="w">
&lt;/span>&lt;/span>&lt;/span>&lt;/code>&lt;/pre>&lt;/div>&lt;p>この方法は、テーブル全体をスキャンして既存の全行がNULLを含まないことを検証する。&lt;br>
検証中はテーブルに対して&lt;code>ACCESS EXCLUSIVE&lt;/code>ロックを保持し続けるため、大規模なテーブルでは検証が終わるまでの間、参照・更新を含むすべてのアクセスがブロックされる。&lt;/p></description><enclosure url="https://atsum.in/database/postgresql-add-not-null-constraint-safely/img/thumbnail.png" type="image/png"/></item><item><title>【PostgreSQL】pg_basebackupで物理バックアップを取得する</title><link>https://atsum.in/database/postgresql-basebackup/</link><pubDate>Sat, 25 Jul 2026 23:24:00 +0900</pubDate><guid>https://atsum.in/database/postgresql-basebackup/</guid><description>&lt;h2 id="pg_basebackupとは">pg_basebackupとは&lt;/h2>
&lt;p>&lt;code>pg_basebackup&lt;/code>は、稼働中のPostgreSQLサーバーからデータベースクラスタ全体の物理バックアップを取得するコマンドである。&lt;br>
取得したバックアップは、レプリカの構築やリストアに使用する。&lt;/p></description><enclosure url="https://atsum.in/database/postgresql-basebackup/img/thumbnail.png" type="image/png"/></item><item><title>【PostgreSQL】log_min_duration_statementでスロークエリをログに出力する</title><link>https://atsum.in/database/postgresql-log-min-duration-statement/</link><pubDate>Sat, 25 Jul 2026 22:46:36 +0900</pubDate><guid>https://atsum.in/database/postgresql-log-min-duration-statement/</guid><description>&lt;h2 id="log_min_duration_statementとは">log_min_duration_statementとは&lt;/h2>
&lt;p>&lt;code>log_min_duration_statement&lt;/code>は、指定した時間（ミリ秒）以上かかったSQL文をログに出力するPostgreSQLのパラメータである。&lt;br>
スロークエリを特定する際に使用する。&lt;/p></description><enclosure url="https://atsum.in/database/postgresql-log-min-duration-statement/img/thumbnail.png" type="image/png"/></item><item><title>【PostgreSQL】シーケンスの現在値を変更する</title><link>https://atsum.in/database/postgresql-setval/</link><pubDate>Sat, 25 Jul 2026 12:39:42 +0900</pubDate><guid>https://atsum.in/database/postgresql-setval/</guid><description>&lt;h2 id="setval関数でシーケンスの現在値を変更する">setval関数でシーケンスの現在値を変更する&lt;/h2>
&lt;p>PostgreSQLでシーケンスの現在値を変更するには、&lt;code>setval&lt;/code>関数を使用する。&lt;/p>
&lt;div class="highlight">&lt;pre tabindex="0" class="chroma">&lt;code class="language-sql" data-lang="sql">&lt;span class="line">&lt;span class="cl">&lt;span class="k">SELECT&lt;/span>&lt;span class="w"> &lt;/span>&lt;span class="n">setval&lt;/span>&lt;span class="p">(&lt;/span>&lt;span class="s1">&amp;#39;シーケンス名&amp;#39;&lt;/span>&lt;span class="p">,&lt;/span>&lt;span class="w"> &lt;/span>&lt;span class="err">値&lt;/span>&lt;span class="p">);&lt;/span>&lt;span class="w">
&lt;/span>&lt;/span>&lt;/span>&lt;/code>&lt;/pre>&lt;/div>&lt;p>たとえば&lt;code>SERIAL&lt;/code>型の&lt;code>id&lt;/code>カラムを持つ&lt;code>items&lt;/code>テーブルのシーケンス&lt;code>items_id_seq&lt;/code>を100に設定する場合は以下のように実行する。&lt;/p></description><enclosure url="https://atsum.in/database/postgresql-setval/img/thumbnail.png" type="image/png"/></item><item><title>【PostgreSQL】接続数の上限と現在の接続数を確認する</title><link>https://atsum.in/database/postgresql-max-connections/</link><pubDate>Sat, 25 Jul 2026 12:29:32 +0900</pubDate><guid>https://atsum.in/database/postgresql-max-connections/</guid><description>&lt;h2 id="max_connectionsで接続数の上限を確認する">max_connectionsで接続数の上限を確認する&lt;/h2>
&lt;p>PostgreSQLで同時接続数の上限を確認するには、&lt;code>max_connections&lt;/code>パラメータを&lt;code>SHOW&lt;/code>コマンドで確認する。&lt;/p>
&lt;div class="highlight">&lt;pre tabindex="0" class="chroma">&lt;code class="language-sql" data-lang="sql">&lt;span class="line">&lt;span class="cl">&lt;span class="k">SHOW&lt;/span>&lt;span class="w"> &lt;/span>&lt;span class="n">max_connections&lt;/span>&lt;span class="p">;&lt;/span>&lt;span class="w">
&lt;/span>&lt;/span>&lt;/span>&lt;span class="line">&lt;span class="cl">&lt;span class="w"> &lt;/span>&lt;span class="n">max_connections&lt;/span>&lt;span class="w">
&lt;/span>&lt;/span>&lt;/span>&lt;span class="line">&lt;span class="cl">&lt;span class="w">&lt;/span>&lt;span class="c1">------------------
&lt;/span>&lt;/span>&lt;/span>&lt;span class="line">&lt;span class="cl">&lt;span class="c1">&lt;/span>&lt;span class="w"> &lt;/span>&lt;span class="mi">100&lt;/span>&lt;span class="w">
&lt;/span>&lt;/span>&lt;/span>&lt;span class="line">&lt;span class="cl">&lt;span class="w">&lt;/span>&lt;span class="p">(&lt;/span>&lt;span class="mi">1&lt;/span>&lt;span class="w"> &lt;/span>&lt;span class="k">row&lt;/span>&lt;span class="p">)&lt;/span>&lt;span class="w">
&lt;/span>&lt;/span>&lt;/span>&lt;/code>&lt;/pre>&lt;/div>&lt;p>&lt;code>pg_settings&lt;/code>システムカタログを参照しても同様に確認できる。&lt;/p></description><enclosure url="https://atsum.in/database/postgresql-max-connections/img/thumbnail.png" type="image/png"/></item><item><title>【PostgreSQL】ロール・権限一覧を確認する</title><link>https://atsum.in/database/postgresql-show-roles/</link><pubDate>Sat, 25 Jul 2026 09:53:58 +0900</pubDate><guid>https://atsum.in/database/postgresql-show-roles/</guid><description>&lt;h2 id="duコマンドでロール一覧を確認する">\duコマンドでロール一覧を確認する&lt;/h2>
&lt;p>PostgreSQLでロール一覧を確認するには、psqlコマンドラインツールの&lt;code>\du&lt;/code>コマンドを使う。&lt;/p>
&lt;div class="highlight">&lt;pre tabindex="0" class="chroma">&lt;code class="language-sql" data-lang="sql">&lt;span class="line">&lt;span class="cl">&lt;span class="err">\&lt;/span>&lt;span class="n">du&lt;/span>&lt;span class="w">
&lt;/span>&lt;/span>&lt;/span>&lt;span class="line">&lt;span class="cl">&lt;span class="w"> &lt;/span>&lt;span class="n">List&lt;/span>&lt;span class="w"> &lt;/span>&lt;span class="k">of&lt;/span>&lt;span class="w"> &lt;/span>&lt;span class="n">roles&lt;/span>&lt;span class="w">
&lt;/span>&lt;/span>&lt;/span>&lt;span class="line">&lt;span class="cl">&lt;span class="w"> &lt;/span>&lt;span class="k">Role&lt;/span>&lt;span class="w"> &lt;/span>&lt;span class="n">name&lt;/span>&lt;span class="w"> &lt;/span>&lt;span class="o">|&lt;/span>&lt;span class="w"> &lt;/span>&lt;span class="n">Attributes&lt;/span>&lt;span class="w">
&lt;/span>&lt;/span>&lt;/span>&lt;span class="line">&lt;span class="cl">&lt;span class="w">&lt;/span>&lt;span class="c1">---------------+------------------------------------------------------------
&lt;/span>&lt;/span>&lt;/span>&lt;span class="line">&lt;span class="cl">&lt;span class="c1">&lt;/span>&lt;span class="w"> &lt;/span>&lt;span class="n">app_admin&lt;/span>&lt;span class="w"> &lt;/span>&lt;span class="o">|&lt;/span>&lt;span class="w"> &lt;/span>&lt;span class="k">Create&lt;/span>&lt;span class="w"> &lt;/span>&lt;span class="k">role&lt;/span>&lt;span class="p">,&lt;/span>&lt;span class="w"> &lt;/span>&lt;span class="k">Create&lt;/span>&lt;span class="w"> &lt;/span>&lt;span class="n">DB&lt;/span>&lt;span class="w">
&lt;/span>&lt;/span>&lt;/span>&lt;span class="line">&lt;span class="cl">&lt;span class="w"> &lt;/span>&lt;span class="n">app_user&lt;/span>&lt;span class="w"> &lt;/span>&lt;span class="o">|&lt;/span>&lt;span class="w">
&lt;/span>&lt;/span>&lt;/span>&lt;span class="line">&lt;span class="cl">&lt;span class="w"> &lt;/span>&lt;span class="n">postgres&lt;/span>&lt;span class="w"> &lt;/span>&lt;span class="o">|&lt;/span>&lt;span class="w"> &lt;/span>&lt;span class="n">Superuser&lt;/span>&lt;span class="p">,&lt;/span>&lt;span class="w"> &lt;/span>&lt;span class="k">Create&lt;/span>&lt;span class="w"> &lt;/span>&lt;span class="k">role&lt;/span>&lt;span class="p">,&lt;/span>&lt;span class="w"> &lt;/span>&lt;span class="k">Create&lt;/span>&lt;span class="w"> &lt;/span>&lt;span class="n">DB&lt;/span>&lt;span class="p">,&lt;/span>&lt;span class="w"> &lt;/span>&lt;span class="n">Replication&lt;/span>&lt;span class="p">,&lt;/span>&lt;span class="w"> &lt;/span>&lt;span class="n">Bypass&lt;/span>&lt;span class="w"> &lt;/span>&lt;span class="n">RLS&lt;/span>&lt;span class="w">
&lt;/span>&lt;/span>&lt;/span>&lt;span class="line">&lt;span class="cl">&lt;span class="w"> &lt;/span>&lt;span class="n">readonly_user&lt;/span>&lt;span class="w"> &lt;/span>&lt;span class="o">|&lt;/span>&lt;span class="w">
&lt;/span>&lt;/span>&lt;/span>&lt;/code>&lt;/pre>&lt;/div>&lt;p>&lt;code>Attributes&lt;/code>列にはロールに付与された属性が表示される。&lt;br>
&lt;code>Superuser&lt;/code>（スーパーユーザー）、&lt;code>Create role&lt;/code>（ロール作成権限）、&lt;code>Create DB&lt;/code>（データベース作成権限）などがあり、属性を持たないロールは空欄になる。&lt;/p></description><enclosure url="https://atsum.in/database/postgresql-show-roles/img/thumbnail.png" type="image/png"/></item><item><title>【PostgreSQL】pg_restoreの-jオプションで並列リストアする</title><link>https://atsum.in/database/pg-restore-parallel-jobs/</link><pubDate>Sat, 25 Jul 2026 09:32:48 +0900</pubDate><guid>https://atsum.in/database/pg-restore-parallel-jobs/</guid><description>&lt;h2 id="-jオプションとは">-jオプションとは&lt;/h2>
&lt;p>&lt;code>pg_dump&lt;/code>の&lt;code>-Fc&lt;/code>（カスタムフォーマット）で取得したダンプは、&lt;code>pg_restore&lt;/code>の&lt;code>-j&lt;/code>（&lt;code>--jobs&lt;/code>）オプションで複数テーブルを並列にリストアできる。ダンプ内のテーブルは互いに独立したエントリとして格納されているため、&lt;code>-j&lt;/code>に指定した数のプロセスで同時にデータロードやインデックス作成を進められる。&lt;/p></description><enclosure url="https://atsum.in/database/pg-restore-parallel-jobs/img/thumbnail.png" type="image/png"/></item><item><title>【PostgreSQL】pg_restoreの--tableオプションで特定のテーブルのみリストアする</title><link>https://atsum.in/database/pg-restore-table/</link><pubDate>Sat, 25 Jul 2026 09:24:18 +0900</pubDate><guid>https://atsum.in/database/pg-restore-table/</guid><description>&lt;h2 id="tableオプションとは">&amp;ndash;tableオプションとは&lt;/h2>
&lt;p>&lt;code>pg_dump&lt;/code>の&lt;code>-Fc&lt;/code>（カスタムフォーマット）で取得したダンプは、&lt;code>pg_restore&lt;/code>の&lt;code>--table&lt;/code>（&lt;code>-t&lt;/code>）オプションで特定のテーブルのみをリストアできる。プレインテキスト形式のダンプは先頭から順にSQL文を実行する仕組みのため、リストア時にテーブルを絞り込むことはできない。カスタムフォーマットであれば、全テーブルを含む1つのダンプファイルを作成しておき、リストアするタイミングで必要なテーブルだけを選べる。&lt;/p></description><enclosure url="https://atsum.in/database/pg-restore-table/img/thumbnail.png" type="image/png"/></item><item><title>【PostgreSQL】pg_dumpの-Fcオプションでカスタムフォーマットのバックアップを取得する</title><link>https://atsum.in/database/pg-dump-custom-format/</link><pubDate>Sat, 25 Jul 2026 08:39:44 +0900</pubDate><guid>https://atsum.in/database/pg-dump-custom-format/</guid><description>&lt;h2 id="pg_dumpの-fcオプションとは">pg_dumpの-Fcオプションとは&lt;/h2>
&lt;p>&lt;code>pg_dump&lt;/code>はデフォルトでSQL文からなるプレインテキスト形式のダンプを出力する。&lt;code>-Fc&lt;/code>（&lt;code>--format=custom&lt;/code>）オプションを指定すると、PostgreSQL独自のバイナリ形式であるカスタムフォーマットでダンプを出力できる。&lt;/p></description><enclosure url="https://atsum.in/database/pg-dump-custom-format/img/thumbnail.png" type="image/png"/></item><item><title>【PostgreSQL】TABLESAMPLEで大きなテーブルからランダムサンプリングする</title><link>https://atsum.in/database/pg-tablesample-random-sampling/</link><pubDate>Fri, 24 Jul 2026 21:51:30 +0900</pubDate><guid>https://atsum.in/database/pg-tablesample-random-sampling/</guid><description>&lt;h2 id="tablesampleとは">TABLESAMPLEとは&lt;/h2>
&lt;p>大きなテーブルからランダムに一部の行だけを抽出したい場合、&lt;code>ORDER BY random() LIMIT&lt;/code>がよく使われるが、全行をスキャンしてソートするため大きなテーブルでは非常に遅くなる。&lt;code>TABLESAMPLE&lt;/code>はテーブルの一部だけを読み取ってサンプリングする句であり、&lt;code>SELECT&lt;/code>の&lt;code>FROM&lt;/code>句に対して指定する。&lt;/p></description><enclosure url="https://atsum.in/database/pg-tablesample-random-sampling/img/thumbnail.png" type="image/png"/></item><item><title>【PostgreSQL】ON CONFLICTでUPSERT（INSERT or UPDATE）を1文で書く</title><link>https://atsum.in/database/pg-upsert-on-conflict/</link><pubDate>Thu, 23 Jul 2026 21:00:00 +0900</pubDate><guid>https://atsum.in/database/pg-upsert-on-conflict/</guid><description>&lt;h2 id="on-conflictとは">ON CONFLICTとは&lt;/h2>
&lt;p>PostgreSQLの&lt;code>INSERT&lt;/code>文には&lt;code>ON CONFLICT&lt;/code>句があり、一意制約や主キー制約に違反した場合の挙動を指定できる。&lt;code>ON CONFLICT&lt;/code>句を使うと、行が存在しなければ&lt;code>INSERT&lt;/code>、既に存在すれば&lt;code>UPDATE&lt;/code>するUPSERT処理を1つの文で記述できる。&lt;/p></description><enclosure url="https://atsum.in/database/pg-upsert-on-conflict/img/thumbnail.png" type="image/png"/></item><item><title>【PostgreSQL】pg_stat_progress_vacuumでVACUUMの進捗を確認する</title><link>https://atsum.in/database/pg-vacuum-progress/</link><pubDate>Thu, 23 Jul 2026 19:15:10 +0900</pubDate><guid>https://atsum.in/database/pg-vacuum-progress/</guid><description>&lt;h2 id="pg_stat_progress_vacuumとは">pg_stat_progress_vacuumとは&lt;/h2>
&lt;p>大きなテーブルに&lt;code>VACUUM&lt;/code>を実行すると、完了まで数分から数時間かかることがある。&lt;code>pg_stat_progress_vacuum&lt;/code>は、現在実行中の&lt;code>VACUUM&lt;/code>がどこまで進んでいるかを確認できるビューである。手動実行の&lt;code>VACUUM&lt;/code>だけでなく、&lt;a href="https://atsum.in/database/pg-autovacuum-check" target="_blank" rel="noopener">【PostgreSQL】autovacuumが実行されているか確認する&lt;/a>
で扱ったautovacuumの進捗も同じビューで確認できる。&lt;/p></description><enclosure url="https://atsum.in/database/pg-vacuum-progress/img/thumbnail.png" type="image/png"/></item><item><title>【PostgreSQL】autovacuumが実行されているか確認する</title><link>https://atsum.in/database/pg-autovacuum-check/</link><pubDate>Thu, 23 Jul 2026 07:07:22 +0900</pubDate><guid>https://atsum.in/database/pg-autovacuum-check/</guid><description>&lt;h2 id="autovacuumとは">autovacuumとは&lt;/h2>
&lt;p>PostgreSQLは行を&lt;code>UPDATE&lt;/code>・&lt;code>DELETE&lt;/code>しても、既存の行を直接書き換えず新しいバージョンの行を追加する。古い行は不要領域（dead tuple）として残り続け、放置するとテーブルとインデックスが肥大化し、検索性能も低下する。autovacuumはこのdead tupleを定期的に回収するバックグラウンドプロセスであり、デフォルトで有効になっている。&lt;/p></description><enclosure url="https://atsum.in/database/pg-autovacuum-check/img/thumbnail.png" type="image/png"/></item><item><title>【PostgreSQL】式インデックスで関数を使った検索を高速化する</title><link>https://atsum.in/database/pg-expression-index/</link><pubDate>Thu, 23 Jul 2026 05:59:10 +0900</pubDate><guid>https://atsum.in/database/pg-expression-index/</guid><description>&lt;h2 id="関数を使った検索はインデックスが効かない">関数を使った検索はインデックスが効かない&lt;/h2>
&lt;p>&lt;code>email&lt;/code>列にインデックスがあっても、&lt;code>lower(email)&lt;/code>のように関数を適用した式で検索すると、そのインデックスは使われない。&lt;/p>
&lt;div class="highlight">&lt;pre tabindex="0" class="chroma">&lt;code class="language-sql" data-lang="sql">&lt;span class="line">&lt;span class="cl">&lt;span class="k">CREATE&lt;/span>&lt;span class="w"> &lt;/span>&lt;span class="k">INDEX&lt;/span>&lt;span class="w"> &lt;/span>&lt;span class="n">idx_users_email&lt;/span>&lt;span class="w"> &lt;/span>&lt;span class="k">ON&lt;/span>&lt;span class="w"> &lt;/span>&lt;span class="n">users&lt;/span>&lt;span class="w"> &lt;/span>&lt;span class="p">(&lt;/span>&lt;span class="n">email&lt;/span>&lt;span class="p">);&lt;/span>&lt;span class="w">
&lt;/span>&lt;/span>&lt;/span>&lt;span class="line">&lt;span class="cl">&lt;span class="w">
&lt;/span>&lt;/span>&lt;/span>&lt;span class="line">&lt;span class="cl">&lt;span class="w">&lt;/span>&lt;span class="k">EXPLAIN&lt;/span>&lt;span class="w"> &lt;/span>&lt;span class="k">SELECT&lt;/span>&lt;span class="w"> &lt;/span>&lt;span class="o">*&lt;/span>&lt;span class="w"> &lt;/span>&lt;span class="k">FROM&lt;/span>&lt;span class="w"> &lt;/span>&lt;span class="n">users&lt;/span>&lt;span class="w"> &lt;/span>&lt;span class="k">WHERE&lt;/span>&lt;span class="w"> &lt;/span>&lt;span class="k">lower&lt;/span>&lt;span class="p">(&lt;/span>&lt;span class="n">email&lt;/span>&lt;span class="p">)&lt;/span>&lt;span class="w"> &lt;/span>&lt;span class="o">=&lt;/span>&lt;span class="w"> &lt;/span>&lt;span class="s1">&amp;#39;user500@example.com&amp;#39;&lt;/span>&lt;span class="p">;&lt;/span>&lt;span class="w">
&lt;/span>&lt;/span>&lt;/span>&lt;/code>&lt;/pre>&lt;/div>&lt;div class="highlight">&lt;pre tabindex="0" class="chroma">&lt;code class="language-text" data-lang="text">&lt;span class="line">&lt;span class="cl"> Seq Scan on users (cost=0.00..2235.00 rows=500 width=25)
&lt;/span>&lt;/span>&lt;span class="line">&lt;span class="cl"> Filter: (lower(email) = &amp;#39;user500@example.com&amp;#39;::text)
&lt;/span>&lt;/span>&lt;/code>&lt;/pre>&lt;/div>&lt;p>&lt;code>email&lt;/code>列のインデックスは&lt;code>email&lt;/code>そのものの値に対して構築されているため、&lt;code>lower(email)&lt;/code>という別の値には使えず&lt;code>Seq Scan&lt;/code>になる。&lt;/p></description><enclosure url="https://atsum.in/database/pg-expression-index/img/thumbnail.png" type="image/png"/></item><item><title>【PostgreSQL】部分インデックス(Partial Index)でWHERE条件付きの軽量インデックスを作る</title><link>https://atsum.in/database/pg-partial-index/</link><pubDate>Thu, 23 Jul 2026 00:09:33 +0900</pubDate><guid>https://atsum.in/database/pg-partial-index/</guid><description>&lt;h2 id="部分インデックスとは">部分インデックスとは&lt;/h2>
&lt;p>&lt;code>CREATE INDEX&lt;/code>に&lt;code>WHERE&lt;/code>句を付けると、テーブルの一部の行だけを対象にしたインデックスを作成できる。これを部分インデックスと呼ぶ。全行を対象にした通常のインデックスと比べてサイズが小さくなり、更新時のオーバーヘッドも減らせる。&lt;/p></description><enclosure url="https://atsum.in/database/pg-partial-index/img/thumbnail.png" type="image/png"/></item><item><title>【PostgreSQL】pg_stat_user_indexesで使われていないインデックスを見つける</title><link>https://atsum.in/database/pg-stat-user-indexes/</link><pubDate>Wed, 22 Jul 2026 21:12:46 +0900</pubDate><guid>https://atsum.in/database/pg-stat-user-indexes/</guid><description>&lt;h2 id="pg_stat_user_indexesとは">pg_stat_user_indexesとは&lt;/h2>
&lt;p>&lt;code>pg_stat_user_indexes&lt;/code>は、インデックスごとの使用状況を集計するビューである。&lt;code>idx_scan&lt;/code>列でそのインデックスが何回検索に使われたかを確認できる。&lt;/p></description><enclosure url="https://atsum.in/database/pg-stat-user-indexes/img/thumbnail.png" type="image/png"/></item><item><title>【PostgreSQL】REINDEX CONCURRENTLYでインデックスを無停止で再構築する</title><link>https://atsum.in/database/reindex-concurrently/</link><pubDate>Wed, 22 Jul 2026 20:37:57 +0900</pubDate><guid>https://atsum.in/database/reindex-concurrently/</guid><description>&lt;h2 id="インデックスの再構築が必要になる場面">インデックスの再構築が必要になる場面&lt;/h2>
&lt;p>インデックスは&lt;code>UPDATE&lt;/code>や&lt;code>DELETE&lt;/code>を繰り返すと、削除済みの領域を残したまま肥大化することがある。&lt;/p>
&lt;div class="highlight">&lt;pre tabindex="0" class="chroma">&lt;code class="language-sql" data-lang="sql">&lt;span class="line">&lt;span class="cl">&lt;span class="k">SELECT&lt;/span>&lt;span class="w"> &lt;/span>&lt;span class="n">pg_size_pretty&lt;/span>&lt;span class="p">(&lt;/span>&lt;span class="n">pg_relation_size&lt;/span>&lt;span class="p">(&lt;/span>&lt;span class="s1">&amp;#39;idx_accounts_balance&amp;#39;&lt;/span>&lt;span class="p">));&lt;/span>&lt;span class="w">
&lt;/span>&lt;/span>&lt;/span>&lt;/code>&lt;/pre>&lt;/div>&lt;div class="highlight">&lt;pre tabindex="0" class="chroma">&lt;code class="language-text" data-lang="text">&lt;span class="line">&lt;span class="cl"> pg_size_pretty
&lt;/span>&lt;/span>&lt;span class="line">&lt;span class="cl">----------------
&lt;/span>&lt;/span>&lt;span class="line">&lt;span class="cl"> 1936 kB
&lt;/span>&lt;/span>&lt;/code>&lt;/pre>&lt;/div>&lt;p>同じ行を3回更新すると、インデックスのサイズが4倍近くに膨らむ。&lt;/p></description><enclosure url="https://atsum.in/database/reindex-concurrently/img/thumbnail.png" type="image/png"/></item><item><title>【PostgreSQL】CREATE INDEX CONCURRENTLYでサービス無停止でインデックスを作成する</title><link>https://atsum.in/database/create-index-concurrently/</link><pubDate>Wed, 22 Jul 2026 08:31:21 +0900</pubDate><guid>https://atsum.in/database/create-index-concurrently/</guid><description>&lt;h2 id="通常のcreate-indexが取得するロック">通常のCREATE INDEXが取得するロック&lt;/h2>
&lt;p>通常の&lt;code>CREATE INDEX&lt;/code>は対象テーブルに&lt;code>ShareLock&lt;/code>を取得する。&lt;code>ShareLock&lt;/code>は&lt;code>INSERT&lt;/code>・&lt;code>UPDATE&lt;/code>・&lt;code>DELETE&lt;/code>が取得する&lt;code>RowExclusiveLock&lt;/code>と競合するため、インデックス作成が完了するまで書き込みがブロックされる。&lt;/p></description><enclosure url="https://atsum.in/database/create-index-concurrently/img/thumbnail.png" type="image/png"/></item><item><title>【PostgreSQL】INCLUDE句でIndex Only Scanを実現する</title><link>https://atsum.in/database/index-include-column/</link><pubDate>Wed, 22 Jul 2026 08:17:39 +0900</pubDate><guid>https://atsum.in/database/index-include-column/</guid><description>&lt;h2 id="index-only-scanとは">Index Only Scanとは&lt;/h2>
&lt;p>&lt;code>Index Only Scan&lt;/code>はインデックスだけを読んでテーブル本体（ヒープ）にアクセスせず結果を返す実行方式である。テーブルへのアクセスが不要な分、通常の&lt;code>Index Scan&lt;/code>より高速になる。&lt;/p></description><enclosure url="https://atsum.in/database/index-include-column/img/thumbnail.png" type="image/png"/></item><item><title>【PostgreSQL】pg_stat_statementsで重いクエリを特定する</title><link>https://atsum.in/database/pg-stat-statements/</link><pubDate>Wed, 22 Jul 2026 07:39:27 +0900</pubDate><guid>https://atsum.in/database/pg-stat-statements/</guid><description>&lt;h2 id="pg_stat_statementsの有効化">pg_stat_statementsの有効化&lt;/h2>
&lt;p>&lt;code>pg_stat_statements&lt;/code>は、実行されたSQL文ごとに実行回数や実行時間を集計する拡張機能である。&lt;code>postgresql.conf&lt;/code>の&lt;code>shared_preload_libraries&lt;/code>に追加し、PostgreSQLを再起動してから&lt;code>CREATE EXTENSION&lt;/code>で有効化する。&lt;/p></description><enclosure url="https://atsum.in/database/pg-stat-statements/img/thumbnail.png" type="image/png"/></item><item><title>【PostgreSQL】EXPLAIN (ANALYZE, BUFFERS)でキャッシュヒット率を確認する</title><link>https://atsum.in/database/explain-analyze-buffers/</link><pubDate>Wed, 22 Jul 2026 07:17:52 +0900</pubDate><guid>https://atsum.in/database/explain-analyze-buffers/</guid><description>&lt;h2 id="buffersオプションとは">BUFFERSオプションとは&lt;/h2>
&lt;p>&lt;code>EXPLAIN&lt;/code>に&lt;code>BUFFERS&lt;/code>オプションを付けると、クエリの実行中に読み込んだブロック数が表示される。&lt;code>ANALYZE&lt;/code>と併用することで、実行計画の各ノードがどれだけ共有バッファ（キャッシュ）を使ったかを確認できる。&lt;/p></description><enclosure url="https://atsum.in/database/explain-analyze-buffers/img/thumbnail.png" type="image/png"/></item><item><title>【PostgreSQL】EXPLAIN ANALYZEの読み方の基本</title><link>https://atsum.in/database/postgresql-explain-analyze/</link><pubDate>Tue, 21 Jul 2026 23:27:10 +0900</pubDate><guid>https://atsum.in/database/postgresql-explain-analyze/</guid><description>&lt;h2 id="explain-analyzeとは">EXPLAIN ANALYZEとは&lt;/h2>
&lt;p>&lt;code>EXPLAIN&lt;/code>はクエリの実行計画を表示するコマンドである。&lt;code>ANALYZE&lt;/code>オプションを付けると、実際にクエリを実行し実行時間や実際の処理件数も表示する。&lt;/p></description><enclosure url="https://atsum.in/database/postgresql-explain-analyze/img/thumbnail.png" type="image/png"/></item><item><title>【PostgreSQL】pg_stat_activityで実行中クエリとロック待ちを確認する</title><link>https://atsum.in/database/pg-stat-activity/</link><pubDate>Tue, 21 Jul 2026 21:55:59 +0900</pubDate><guid>https://atsum.in/database/pg-stat-activity/</guid><description>&lt;p>参考: &lt;a href="https://atsum.in/database/mysql-show-processlist" target="_blank" rel="noopener">【MySQL】SHOW PROCESSLISTで実行中クエリとロック待ちを確認する&lt;/a>
&lt;/p>
&lt;h2 id="実行中のクエリを確認する">実行中のクエリを確認する&lt;/h2>
&lt;p>PostgreSQLで現在実行中のクエリを確認するには&lt;code>pg_stat_activity&lt;/code>ビューを&lt;code>SELECT&lt;/code>する。&lt;/p></description><enclosure url="https://atsum.in/database/pg-stat-activity/img/thumbnail.png" type="image/png"/></item><item><title>【Hugo】sectionページを使ってプライバシーポリシーページを作る</title><link>https://atsum.in/hugo/privacy-policy-with-section-page/</link><pubDate>Mon, 20 Jul 2026 14:53:10 +0900</pubDate><guid>https://atsum.in/hugo/privacy-policy-with-section-page/</guid><description>&lt;h2 id="実現したいこと">実現したいこと&lt;/h2>
&lt;p>ブログにプライバシーポリシーのような固定ページを追加したいとする。記事一覧は不要で、本文だけを表示したいが、タイトルや日付、TOCなど通常記事と同じ見た目には揃えたい。&lt;/p></description><enclosure url="https://atsum.in/hugo/privacy-policy-with-section-page/img/thumbnail.png" type="image/png"/></item><item><title>【Hugo】特定セクションだけ独自のsection.htmlを適用する方法</title><link>https://atsum.in/hugo/custom-section-template/</link><pubDate>Mon, 20 Jul 2026 10:13:31 +0900</pubDate><guid>https://atsum.in/hugo/custom-section-template/</guid><description>&lt;h2 id="実現したいこと">実現したいこと&lt;/h2>
&lt;p>&lt;code>content/recipes/&lt;/code>のように、レシピ記事だけを集めたセクションを追加したとする。他のセクションは記事タイトルだけの一覧で構わないが、レシピ記事の一覧では調理時間をひと目でわかるように表示したい。&lt;/p></description><enclosure url="https://atsum.in/hugo/custom-section-template/img/thumbnail.png" type="image/png"/></item><item><title>【Hugo】SEO対策としてJSON-LD構造化データを組み込む方法</title><link>https://atsum.in/hugo/jsonld-structured-data/</link><pubDate>Sun, 19 Jul 2026 23:00:54 +0900</pubDate><guid>https://atsum.in/hugo/jsonld-structured-data/</guid><description>&lt;h2 id="json-ldとは">JSON-LDとは&lt;/h2>
&lt;p>JSON-LDは、ページの内容を検索エンジンに構造的に伝えるための構造化データ記法である。schema.orgの語彙をJSON形式で記述し、&lt;code>&amp;lt;script type=&amp;quot;application/ld+json&amp;quot;&amp;gt;&lt;/code>としてHTMLに埋め込む。&lt;/p></description><enclosure url="https://atsum.in/hugo/jsonld-structured-data/img/thumbnail.png" type="image/png"/></item><item><title>【Hugo】enableGitInfoによるlastmodがCIのcloneした日時になっていた問題</title><link>https://atsum.in/hugo/enable-git-info-lastmod-clone-date/</link><pubDate>Sun, 19 Jul 2026 22:30:33 +0900</pubDate><guid>https://atsum.in/hugo/enable-git-info-lastmod-clone-date/</guid><description>&lt;h2 id="発生していた問題">発生していた問題&lt;/h2>
&lt;p>当ブログでは各記事に更新日（&lt;code>.Lastmod&lt;/code>）を表示している。この更新日は&lt;code>enableGitInfo&lt;/code>を有効にし、Gitのコミット履歴から取得する設定にしていた。&lt;/p></description><enclosure url="https://atsum.in/hugo/enable-git-info-lastmod-clone-date/img/thumbnail.png" type="image/png"/></item><item><title>【Shell Script】untilで条件が真になるまでループする</title><link>https://atsum.in/linux/shell-until-loop/</link><pubDate>Sun, 19 Jul 2026 20:10:18 +0900</pubDate><guid>https://atsum.in/linux/shell-until-loop/</guid><description>&lt;h2 id="untilループとは">untilループとは&lt;/h2>
&lt;p>&lt;code>until&lt;/code>は、条件式が真になるまでループを繰り返すシェルスクリプトの構文である。&lt;br>
&lt;code>while&lt;/code>とは逆に、条件式の終了ステータスが非ゼロ（偽）の間はループを継続し、ゼロ（真）になった時点でループを終了する。&lt;/p></description><enclosure url="https://atsum.in/linux/shell-until-loop/img/thumbnail.png" type="image/png"/></item><item><title>【Ruby】-w や -W で警告を表示する</title><link>https://atsum.in/ruby/warning-level/</link><pubDate>Sun, 19 Jul 2026 19:13:31 +0900</pubDate><guid>https://atsum.in/ruby/warning-level/</guid><description>&lt;p>Rubyは未使用変数の代入やメソッドの再定義など、実行に支障はないがバグの原因になりやすいコードに対して警告を出す機能がある。&lt;code>-w&lt;/code>や&lt;code>-W&lt;/code>オプションで、警告を表示するかどうかや表示するレベルを制御できる。構文エラーの有無だけを確認したい場合は&lt;a href="https://atsum.in/ruby/syntax-check/" target="_blank" rel="noopener">【Ruby】ruby -cオプションで構文チェックする&lt;/a>
を参照。&lt;/p></description><enclosure url="https://atsum.in/ruby/warning-level/img/thumbnail.png" type="image/png"/></item><item><title>【Ruby】ruby -c で構文チェックする</title><link>https://atsum.in/ruby/syntax-check/</link><pubDate>Sun, 19 Jul 2026 18:44:33 +0900</pubDate><guid>https://atsum.in/ruby/syntax-check/</guid><description>&lt;p>Rubyの&lt;code>-c&lt;/code>オプションを使うと、スクリプトを実行せずに構文だけをチェックできる。&lt;/p>
&lt;h2 id="基本的な使い方">基本的な使い方&lt;/h2>
&lt;p>&lt;code>ruby -c&lt;/code>にファイルを指定すると、構文が正しければ&lt;code>Syntax OK&lt;/code>と表示される。&lt;/p></description><enclosure url="https://atsum.in/ruby/syntax-check/img/thumbnail.png" type="image/png"/></item><item><title>【AWS CLI】特定のCIDRを許可しているセキュリティグループを検索する</title><link>https://atsum.in/aws/ec2-security-group-find-by-cidr/</link><pubDate>Sat, 18 Jul 2026 22:34:57 +0900</pubDate><guid>https://atsum.in/aws/ec2-security-group-find-by-cidr/</guid><description>&lt;h2 id="特定のcidrを許可しているセキュリティグループを検索したい">特定のCIDRを許可しているセキュリティグループを検索したい&lt;/h2>
&lt;p>特定のIPアドレス帯（オフィスのグローバルIPなど）を許可しているセキュリティグループが、アカウント内にいくつあるかを調べたい場合がある。セキュリティグループの数が多いと、マネジメントコンソールで1つずつルールを確認するのは手間がかかる。&lt;code>aws ec2 describe-security-group-rules&lt;/code>は、フィルタを指定しなければアカウント内（対象リージョン）の全セキュリティグループルールを返すため、&lt;code>--query&lt;/code>を組み合わせれば特定のCIDRを許可しているルールを横断的に検索できる。&lt;/p></description><enclosure url="https://atsum.in/aws/ec2-security-group-find-by-cidr/img/thumbnail.png" type="image/png"/></item><item><title>【AWS CLI】セキュリティグループのルールをCLIで追加・削除する</title><link>https://atsum.in/aws/ec2-add-remove-security-group-rules/</link><pubDate>Sat, 18 Jul 2026 16:56:36 +0900</pubDate><guid>https://atsum.in/aws/ec2-add-remove-security-group-rules/</guid><description>&lt;p>セキュリティグループのルールは &lt;code>authorize-security-group-ingress&lt;/code>/&lt;code>authorize-security-group-egress&lt;/code> で追加し、&lt;code>revoke-security-group-ingress&lt;/code>/&lt;code>revoke-security-group-egress&lt;/code> で削除する。現在のルールを確認する方法は &lt;a href="https://atsum.in/aws/ec2-describe-security-group-rules/" target="_blank" rel="noopener">【AWS CLI】セキュリティグループのインバウンド・アウトバウンドルールをCLIで確認する&lt;/a>
を参照。&lt;/p></description><enclosure url="https://atsum.in/aws/ec2-add-remove-security-group-rules/img/thumbnail.png" type="image/png"/></item><item><title>【AWS CLI】セキュリティグループのインバウンド・アウトバウンドルールをCLIで確認する</title><link>https://atsum.in/aws/ec2-describe-security-group-rules/</link><pubDate>Sat, 18 Jul 2026 16:00:35 +0900</pubDate><guid>https://atsum.in/aws/ec2-describe-security-group-rules/</guid><description>&lt;h2 id="aws-ec2-describe-security-group-rules-とは">aws ec2 describe-security-group-rules とは&lt;/h2>
&lt;p>&lt;code>aws ec2 describe-security-group-rules&lt;/code> は、セキュリティグループに設定されたルールを取得するコマンド。インバウンド・アウトバウンドの両方のルールが1件1エントリとして返るため、マネジメントコンソールのルール一覧をそのままCLIから確認できる。&lt;/p></description><enclosure url="https://atsum.in/aws/ec2-describe-security-group-rules/img/thumbnail.png" type="image/png"/></item><item><title>【ACM】証明書を削除する前に使用中のリソースをCLIで確認する</title><link>https://atsum.in/aws/acm-check-in-use-before-delete/</link><pubDate>Sat, 18 Jul 2026 15:45:34 +0900</pubDate><guid>https://atsum.in/aws/acm-check-in-use-before-delete/</guid><description>&lt;h2 id="inuseby-で証明書の利用状況を確認する">InUseBy で証明書の利用状況を確認する&lt;/h2>
&lt;p>ACM証明書を削除する前に、その証明書がCloudFrontやELBなどのリソースで使われていないかを確認する必要がある。使用中の証明書を削除しようとすると、操作自体がエラーになる。&lt;/p></description><enclosure url="https://atsum.in/aws/acm-check-in-use-before-delete/img/thumbnail.png" type="image/png"/></item><item><title>【AWS CLI】ACM証明書の詳細情報をCLIで確認する</title><link>https://atsum.in/aws/acm-describe-certificate/</link><pubDate>Sat, 18 Jul 2026 15:27:46 +0900</pubDate><guid>https://atsum.in/aws/acm-describe-certificate/</guid><description>&lt;h2 id="aws-acm-describe-certificate-とは">aws acm describe-certificate とは&lt;/h2>
&lt;p>&lt;code>aws acm describe-certificate&lt;/code> は、ACMに登録されている証明書1件の詳細情報を取得するコマンド。&lt;a href="https://atsum.in/aws/acm-list-certificates-expiry/" target="_blank" rel="noopener">【AWS CLI】ACM証明書の有効期限を一覧でCLIから確認する&lt;/a>
で紹介した &lt;code>list-certificates&lt;/code> はドメイン名やステータスなど概要のみを返す。一方 &lt;code>describe-certificate&lt;/code> では発行者やシリアル番号、利用中のACM以外のリソース、DNS検証の詳細まで取得できる。&lt;/p></description><enclosure url="https://atsum.in/aws/acm-describe-certificate/img/thumbnail.png" type="image/png"/></item><item><title>【AWS CLI】ACM証明書の有効期限を一覧でCLIから確認する</title><link>https://atsum.in/aws/acm-list-certificates-expiry/</link><pubDate>Sat, 18 Jul 2026 15:15:26 +0900</pubDate><guid>https://atsum.in/aws/acm-list-certificates-expiry/</guid><description>&lt;h2 id="aws-acm-list-certificates-とは">aws acm list-certificates とは&lt;/h2>
&lt;p>&lt;code>aws acm list-certificates&lt;/code> はAWS Certificate Manager(ACM)に登録されている証明書の一覧を取得するコマンド。証明書ごとのドメイン名やステータス、有効期限などをまとめて確認できる。&lt;/p></description><enclosure url="https://atsum.in/aws/acm-list-certificates-expiry/img/thumbnail.png" type="image/png"/></item><item><title>【VSCode】YAML拡張機能でtraefik.ymlをTraefik v3スキーマで検証する</title><link>https://atsum.in/vscode/yaml-extension-custom-schema/</link><pubDate>Mon, 13 Jul 2026 20:20:50 +0900</pubDate><guid>https://atsum.in/vscode/yaml-extension-custom-schema/</guid><description>&lt;h2 id="発生した問題">発生した問題&lt;/h2>
&lt;p>VSCodeの&lt;a href="https://marketplace.visualstudio.com/items?itemName=redhat.vscode-yaml" target="_blank" rel="noopener nofollow">YAML&lt;/a>
拡張機能を利用してTraefikの設定ファイル&lt;code>traefik.yml&lt;/code>を編集していると、以下の設定に対してエラーが表示された。&lt;/p></description><enclosure url="https://atsum.in/vscode/yaml-extension-custom-schema/img/thumbnail.png" type="image/png"/></item><item><title>【AWS CLI】aws ce get-cost-forecastで将来のコストを予測する</title><link>https://atsum.in/aws/ce-get-cost-forecast/</link><pubDate>Mon, 13 Jul 2026 08:22:19 +0900</pubDate><guid>https://atsum.in/aws/ce-get-cost-forecast/</guid><description>&lt;h2 id="aws-ce-get-cost-forecast-とは">aws ce get-cost-forecast とは&lt;/h2>
&lt;p>&lt;code>aws ce get-cost-forecast&lt;/code> はAWS Cost Explorer APIが過去の実績データを元に算出した、将来のコストの予測値を取得するコマンド。予測の処理自体はAWS側で行われ、CLIはその結果を取得しているだけである。&lt;/p></description><enclosure url="https://atsum.in/aws/ce-get-cost-forecast/img/thumbnail.png" type="image/png"/></item><item><title>atコマンドで一回限りのジョブを予約する</title><link>https://atsum.in/linux/at-command/</link><pubDate>Sun, 12 Jul 2026 21:58:14 +0900</pubDate><guid>https://atsum.in/linux/at-command/</guid><description>&lt;h2 id="atコマンドとは">atコマンドとは&lt;/h2>
&lt;p>&lt;code>at&lt;/code>コマンドは、指定した日時に1回限りコマンドを実行するジョブを予約できるコマンドである。&lt;/p>
&lt;p>&lt;code>cron&lt;/code>は定期的に繰り返し実行するジョブの予約に向いているが、「1時間後に1回だけ実行したい」のような1回限りのジョブには&lt;code>at&lt;/code>が向いている。&lt;/p></description><enclosure url="https://atsum.in/linux/at-command/img/thumbnail.png" type="image/png"/></item><item><title>dateコマンドの出力タイムゾーンをTZ環境変数で一時的に変更する</title><link>https://atsum.in/linux/date-tz-env/</link><pubDate>Sun, 12 Jul 2026 19:54:54 +0900</pubDate><guid>https://atsum.in/linux/date-tz-env/</guid><description>&lt;h2 id="tz環境変数とは">TZ環境変数とは&lt;/h2>
&lt;p>&lt;code>date&lt;/code>コマンドはシステムに設定されたタイムゾーンで日時を表示する。&lt;/p>
&lt;p>システム全体のタイムゾーンを変更せずに、コマンド実行時だけ別のタイムゾーンで日時を確認したい場合は&lt;code>TZ&lt;/code>環境変数を使用する。&lt;/p></description><enclosure url="https://atsum.in/linux/date-tz-env/img/thumbnail.png" type="image/png"/></item><item><title>dateコマンドでepoch秒とdate文字列を相互変換する</title><link>https://atsum.in/linux/date-epoch-conversion/</link><pubDate>Sun, 12 Jul 2026 18:11:23 +0900</pubDate><guid>https://atsum.in/linux/date-epoch-conversion/</guid><description>&lt;h2 id="epoch秒とは">epoch秒とは&lt;/h2>
&lt;p>epoch秒は、1970年1月1日00:00:00 UTC(協定世界時)からの経過秒数である。UNIX時間とも呼ばれる。&lt;/p>
&lt;p>シェルスクリプトで日時を数値として扱いたい場合、日時の差分を計算したい場合などに利用する。&lt;/p></description><enclosure url="https://atsum.in/linux/date-epoch-conversion/img/thumbnail.png" type="image/png"/></item><item><title>dateコマンドで相対日付を計算する(date -d)</title><link>https://atsum.in/linux/date-relative-date/</link><pubDate>Sun, 12 Jul 2026 17:42:12 +0900</pubDate><guid>https://atsum.in/linux/date-relative-date/</guid><description>&lt;h2 id="date--d">date -d&lt;/h2>
&lt;p>シェルスクリプトで「1日前」や「1ヶ月後」のような相対的な日付を計算したい場合がある。&lt;/p>
&lt;p>&lt;code>date&lt;/code>コマンドに&lt;code>-d&lt;/code>オプションで日付文字列を指定すると、相対的な日付を計算できる。&lt;/p></description><enclosure url="https://atsum.in/linux/date-relative-date/img/thumbnail.png" type="image/png"/></item><item><title>【Docker】diveでDockerイメージのレイヤーを分析する</title><link>https://atsum.in/linux/docker-dive/</link><pubDate>Sun, 12 Jul 2026 10:28:37 +0900</pubDate><guid>https://atsum.in/linux/docker-dive/</guid><description>&lt;h2 id="diveとは">diveとは&lt;/h2>
&lt;p>&lt;a href="https://github.com/wagoodman/dive" target="_blank" rel="noopener nofollow">dive&lt;/a>
は、Dockerイメージをレイヤーごとに分析するツール。&lt;br>
各レイヤーで追加・変更・削除されたファイルを確認できるほか、無駄なファイルによって肥大化した容量(Wasted Space)を検出できる。&lt;/p></description><enclosure url="https://atsum.in/linux/docker-dive/img/thumbnail.png" type="image/png"/></item><item><title>【Docker】docker system dfコマンドでディスク使用量の内訳を見る</title><link>https://atsum.in/linux/docker-system-df/</link><pubDate>Sun, 12 Jul 2026 09:34:17 +0900</pubDate><guid>https://atsum.in/linux/docker-system-df/</guid><description>&lt;h2 id="docker-system-dfコマンド">docker system dfコマンド&lt;/h2>
&lt;p>イメージやコンテナ、ボリュームなどDockerが使用しているディスク使用量の内訳を確認するには&lt;code>docker system df&lt;/code>コマンドを使う。&lt;/p></description><enclosure url="https://atsum.in/linux/docker-system-df/img/thumbnail.png" type="image/png"/></item><item><title>【Docker】docker statsコマンドでコンテナのリソース使用量を確認する</title><link>https://atsum.in/linux/docker-stats/</link><pubDate>Sun, 12 Jul 2026 09:19:57 +0900</pubDate><guid>https://atsum.in/linux/docker-stats/</guid><description>&lt;h2 id="docker-statsコマンド">docker statsコマンド&lt;/h2>
&lt;p>Dockerコンテナが使用しているCPUやメモリなどのリソース使用量を確認するには&lt;code>docker stats&lt;/code>コマンドを使う。&lt;/p>
&lt;div class="highlight">&lt;pre tabindex="0" class="chroma">&lt;code class="language-shell" data-lang="shell">&lt;span class="line">&lt;span class="cl">$ docker stats
&lt;/span>&lt;/span>&lt;/code>&lt;/pre>&lt;/div>&lt;p>コンテナ名を指定しない場合は起動中の全コンテナの情報を表示する。&lt;br>
デフォルトでは&lt;code>top&lt;/code>コマンドのようにリアルタイムで情報を更新し続ける。&lt;/p></description><enclosure url="https://atsum.in/linux/docker-stats/img/thumbnail.png" type="image/png"/></item><item><title>【Docker】docker logsコマンドで期間や行数を指定してログを見る(--since、--tail)</title><link>https://atsum.in/linux/docker-logs-since-tail/</link><pubDate>Sun, 12 Jul 2026 08:23:34 +0900</pubDate><guid>https://atsum.in/linux/docker-logs-since-tail/</guid><description>&lt;h2 id="docker-logsコマンド">docker logsコマンド&lt;/h2>
&lt;p>Dockerコンテナの標準出力・標準エラー出力を見るには&lt;code>docker logs&lt;/code>コマンドを使う。&lt;/p>
&lt;div class="highlight">&lt;pre tabindex="0" class="chroma">&lt;code class="language-shell" data-lang="shell">&lt;span class="line">&lt;span class="cl">$ docker logs &amp;lt;コンテナ&amp;gt;
&lt;/span>&lt;/span>&lt;/code>&lt;/pre>&lt;/div>&lt;p>&lt;code>&amp;lt;コンテナ&amp;gt;&lt;/code>の部分はコンテナ名かIDを指定する。&lt;/p></description><enclosure url="https://atsum.in/linux/docker-logs-since-tail/img/thumbnail.png" type="image/png"/></item><item><title>シェルスクリプトでcommandコマンドとwhichコマンドを使ってコマンドの存在チェックをする</title><link>https://atsum.in/linux/command-exists-check/</link><pubDate>Sun, 12 Jul 2026 08:07:43 +0900</pubDate><guid>https://atsum.in/linux/command-exists-check/</guid><description>&lt;h2 id="シェルスクリプトで外部コマンドの有無を確認したい">シェルスクリプトで外部コマンドの有無を確認したい&lt;/h2>
&lt;p>シェルスクリプトでは、実行環境に&lt;code>curl&lt;/code>や&lt;code>jq&lt;/code>などの外部コマンドが存在するかを事前にチェックし、存在しない場合はエラーメッセージを出して処理を止めたいことがある。コマンドの存在チェックには&lt;code>command&lt;/code>コマンドと&lt;code>which&lt;/code>コマンドが使える。&lt;/p></description><enclosure url="https://atsum.in/linux/command-exists-check/img/thumbnail.png" type="image/png"/></item><item><title>【systemd】Restart=alwaysでサービスを自動再起動する</title><link>https://atsum.in/linux/systemd-restart-always/</link><pubDate>Sat, 11 Jul 2026 22:12:06 +0900</pubDate><guid>https://atsum.in/linux/systemd-restart-always/</guid><description>&lt;h2 id="restartalwaysとは">Restart=alwaysとは&lt;/h2>
&lt;p>&lt;code>Restart=always&lt;/code>は、Unitファイルの&lt;code>[Service]&lt;/code>セクションに指定するプロパティであり、プロセスの終了理由を問わずサービスを自動的に再起動する設定である。正常終了・異常終了・シグナルによる強制終了のいずれの場合も再起動の対象になる。&lt;/p></description><enclosure url="https://atsum.in/linux/systemd-restart-always/img/thumbnail.png" type="image/png"/></item><item><title>【systemd】systemd-runで一時的にコマンドをサービス化する</title><link>https://atsum.in/linux/systemd-run/</link><pubDate>Sat, 11 Jul 2026 21:54:42 +0900</pubDate><guid>https://atsum.in/linux/systemd-run/</guid><description>&lt;h2 id="systemd-runとは">systemd-runとは&lt;/h2>
&lt;p>&lt;code>systemd-run&lt;/code>は、指定したコマンドをtransient unit（一時的なUnit）として実行するコマンドである。&lt;/p>
&lt;p>通常、systemdのサービスとしてコマンドを動かすにはUnitファイルを作成して&lt;code>systemctl start&lt;/code>する必要がある。&lt;code>systemd-run&lt;/code>を使うとUnitファイルを作成せずにコマンド1つでサービス化でき、cgroupによるリソース制限やjournaldへのログ集約といったsystemdの機能をその場で使える。&lt;/p></description><enclosure url="https://atsum.in/linux/systemd-run/img/thumbnail.png" type="image/png"/></item><item><title>【systemd】systemd-analyze blameで起動の遅いサービスを特定する</title><link>https://atsum.in/linux/systemd-analyze-blame/</link><pubDate>Sat, 11 Jul 2026 21:39:36 +0900</pubDate><guid>https://atsum.in/linux/systemd-analyze-blame/</guid><description>&lt;h2 id="systemd-analyze-blameとは">systemd-analyze blameとは&lt;/h2>
&lt;p>&lt;code>systemd-analyze blame&lt;/code>は、起動時に実行された各Unitの初期化にかかった時間を一覧表示するコマンドである。時間の長い順にソートされるため、起動が遅い原因となっているサービスを特定する際に利用する。&lt;/p></description><enclosure url="https://atsum.in/linux/systemd-analyze-blame/img/thumbnail.png" type="image/png"/></item><item><title>【sort -V】バージョン番号を考慮してソートする</title><link>https://atsum.in/linux/sort-v/</link><pubDate>Sat, 11 Jul 2026 20:45:45 +0900</pubDate><guid>https://atsum.in/linux/sort-v/</guid><description>&lt;h2 id="バージョン番号のソート">バージョン番号のソート&lt;/h2>
&lt;p>&lt;code>item2&lt;/code>、&lt;code>item10&lt;/code>のようなバージョン番号を含む文字列を正しい順序でソートするには、&lt;code>-V&lt;/code>(&lt;code>--version-sort&lt;/code>)オプションを使用する。&lt;/p></description><enclosure url="https://atsum.in/linux/sort-v/img/thumbnail.png" type="image/png"/></item><item><title>【sort -k】指定したフィールドをキーにソートする</title><link>https://atsum.in/linux/sort-k/</link><pubDate>Sat, 11 Jul 2026 20:24:21 +0900</pubDate><guid>https://atsum.in/linux/sort-k/</guid><description>&lt;h2 id="フィールドを指定してソートする">フィールドを指定してソートする&lt;/h2>
&lt;p>スペースやタブで区切られたデータの特定のフィールドをキーにソートするには、&lt;code>-k&lt;/code>(&lt;code>--key&lt;/code>)オプションを使用する。&lt;/p>
&lt;div class="highlight">&lt;pre tabindex="0" class="chroma">&lt;code class="language-shell" data-lang="shell">&lt;span class="line">&lt;span class="cl">$ cat data.txt
&lt;/span>&lt;/span>&lt;span class="line">&lt;span class="cl">banana &lt;span class="m">3&lt;/span> &lt;span class="m">100&lt;/span>
&lt;/span>&lt;/span>&lt;span class="line">&lt;span class="cl">apple &lt;span class="m">10&lt;/span> &lt;span class="m">20&lt;/span>
&lt;/span>&lt;/span>&lt;span class="line">&lt;span class="cl">cherry &lt;span class="m">1&lt;/span> &lt;span class="m">300&lt;/span>
&lt;/span>&lt;/span>&lt;span class="line">&lt;span class="cl">apple &lt;span class="m">2&lt;/span> &lt;span class="m">50&lt;/span>
&lt;/span>&lt;/span>&lt;span class="line">&lt;span class="cl">$ sort -k2 data.txt
&lt;/span>&lt;/span>&lt;span class="line">&lt;span class="cl">cherry &lt;span class="m">1&lt;/span> &lt;span class="m">300&lt;/span>
&lt;/span>&lt;/span>&lt;span class="line">&lt;span class="cl">apple &lt;span class="m">10&lt;/span> &lt;span class="m">20&lt;/span>
&lt;/span>&lt;/span>&lt;span class="line">&lt;span class="cl">apple &lt;span class="m">2&lt;/span> &lt;span class="m">50&lt;/span>
&lt;/span>&lt;/span>&lt;span class="line">&lt;span class="cl">banana &lt;span class="m">3&lt;/span> &lt;span class="m">100&lt;/span>
&lt;/span>&lt;/span>&lt;/code>&lt;/pre>&lt;/div>&lt;p>&lt;code>-k2&lt;/code>は2列目以降を文字列としてソートする。数値としてソートしたい場合は&lt;code>n&lt;/code>を付けて&lt;code>-k2n&lt;/code>とする。&lt;/p></description><enclosure url="https://atsum.in/linux/sort-k/img/thumbnail.png" type="image/png"/></item><item><title>jqコマンドでCSV/TSV形式に変換する（@csv / @tsv）</title><link>https://atsum.in/linux/jq-csv-tsv/</link><pubDate>Sat, 11 Jul 2026 20:16:16 +0900</pubDate><guid>https://atsum.in/linux/jq-csv-tsv/</guid><description>&lt;h2 id="csvフィルターでcsv形式に変換する">@csvフィルターでCSV形式に変換する&lt;/h2>
&lt;p>&lt;code>@csv&lt;/code>フィルターを使用すると、配列をCSV形式の1行に変換できる。&lt;/p>
&lt;div class="highlight">&lt;pre tabindex="0" class="chroma">&lt;code class="language-shell" data-lang="shell">&lt;span class="line">&lt;span class="cl">$ &lt;span class="nb">echo&lt;/span> &lt;span class="s1">&amp;#39;[&amp;#34;a&amp;#34;, &amp;#34;b,c&amp;#34;, &amp;#34;d\&amp;#34;e&amp;#34;]&amp;#39;&lt;/span> &lt;span class="p">|&lt;/span> jq -r &lt;span class="s1">&amp;#39;@csv&amp;#39;&lt;/span>
&lt;/span>&lt;/span>&lt;span class="line">&lt;span class="cl">&lt;span class="s2">&amp;#34;a&amp;#34;&lt;/span>,&lt;span class="s2">&amp;#34;b,c&amp;#34;&lt;/span>,&lt;span class="s2">&amp;#34;d&amp;#34;&amp;#34;e&amp;#34;&lt;/span>
&lt;/span>&lt;/span>&lt;/code>&lt;/pre>&lt;/div>&lt;p>カンマを含む値はダブルクオートで囲まれ、ダブルクオート自体は&lt;code>&amp;quot;&amp;quot;&lt;/code>にエスケープされる。&lt;/p></description><enclosure url="https://atsum.in/linux/jq-csv-tsv/img/thumbnail.png" type="image/png"/></item><item><title>【tr】文字を削除・圧縮する（tr -d / tr -s）</title><link>https://atsum.in/linux/tr-delete-squeeze/</link><pubDate>Sat, 11 Jul 2026 19:42:00 +0900</pubDate><guid>https://atsum.in/linux/tr-delete-squeeze/</guid><description>&lt;p>&lt;code>tr&lt;/code>コマンドは標準入力の文字を別の文字に変換するコマンドである。&lt;code>-d&lt;/code>オプションで指定した文字を削除でき、&lt;code>-s&lt;/code>オプションで連続する文字を1文字に圧縮できる。&lt;/p></description><enclosure url="https://atsum.in/linux/tr-delete-squeeze/img/thumbnail.png" type="image/png"/></item><item><title>【Git】git add -fで.gitignoreに無視されたファイルを強制的にステージングする</title><link>https://atsum.in/linux/git-add-force/</link><pubDate>Sat, 11 Jul 2026 13:56:44 +0900</pubDate><guid>https://atsum.in/linux/git-add-force/</guid><description>&lt;h2 id="gitignoreで無視されているファイルを一時的にコミットしたい">.gitignoreで無視されているファイルを一時的にコミットしたい&lt;/h2>
&lt;p>&lt;code>.gitignore&lt;/code>で無視しているファイルを、デバッグ用途などで一時的にコミットしたい場合がある。通常&lt;code>git add&lt;/code>で無視対象のファイルを指定すると、エラーになりステージングされない。&lt;/p></description><enclosure url="https://atsum.in/linux/git-add-force/img/thumbnail.png" type="image/png"/></item><item><title>【GitHub CLI】gh pr update-branchでPRブランチをベースブランチの最新の変更で更新する</title><link>https://atsum.in/linux/gh-pr-update-branch/</link><pubDate>Sat, 11 Jul 2026 13:42:25 +0900</pubDate><guid>https://atsum.in/linux/gh-pr-update-branch/</guid><description>&lt;h2 id="gh-pr-update-branchでprブランチを更新する">gh pr update-branchでPRブランチを更新する&lt;/h2>
&lt;p>GitHub CLIでPull RequestのブランチをベースブランチのHEADと合流させるには&lt;code>gh pr update-branch&lt;/code>コマンドを使う。&lt;/p></description><enclosure url="https://atsum.in/linux/gh-pr-update-branch/img/thumbnail.png" type="image/png"/></item><item><title>【goreleaser】release --snapshotとbuild --single-targetでリリース前にローカル動作確認する</title><link>https://atsum.in/linux/goreleaser-local-build/</link><pubDate>Sat, 11 Jul 2026 13:24:19 +0900</pubDate><guid>https://atsum.in/linux/goreleaser-local-build/</guid><description>&lt;h2 id="タグを打つ前にビルド結果を確認したい">タグを打つ前にビルド結果を確認したい&lt;/h2>
&lt;p>&lt;code>goreleaser&lt;/code>は通常、Gitのタグをトリガーにビルド・パッケージング・GitHubへの公開までを一気に行う。しかし、タグを打つたびにアーカイブの中身やビルドオプションを確認していては手間がかかる。&lt;code>goreleaser&lt;/code>には、タグの作成やGitHubへの公開といった実際のリリース操作を伴わずに、ローカルでビルド結果だけを確認できるオプションが用意されている。&lt;/p></description><enclosure url="https://atsum.in/linux/goreleaser-local-build/img/thumbnail.png" type="image/png"/></item><item><title>【goreleaser】check コマンドで .goreleaser.yaml の設定を検証する</title><link>https://atsum.in/linux/goreleaser-check/</link><pubDate>Sat, 11 Jul 2026 12:47:05 +0900</pubDate><guid>https://atsum.in/linux/goreleaser-check/</guid><description>&lt;h2 id="goreleaseryaml-の記述ミスをリリース前に検出したい">.goreleaser.yaml の記述ミスをリリース前に検出したい&lt;/h2>
&lt;p>&lt;code>goreleaser&lt;/code>は&lt;code>.goreleaser.yaml&lt;/code>の設定に基づいてGoアプリケーションをビルド・リリースするツールである。設定ファイルの記述ミスは、実際に&lt;code>goreleaser release&lt;/code>を実行するまで気づきにくい。&lt;code>goreleaser check&lt;/code>コマンドを使うと、&lt;code>.goreleaser.yaml&lt;/code>の構文やスキーマが正しいかをリリース前に検証できる。&lt;/p></description><enclosure url="https://atsum.in/linux/goreleaser-check/img/thumbnail.png" type="image/png"/></item><item><title>【Git】git archiveでリポジトリの内容をtarやzipにアーカイブする</title><link>https://atsum.in/linux/git-archive/</link><pubDate>Sat, 11 Jul 2026 08:16:46 +0900</pubDate><guid>https://atsum.in/linux/git-archive/</guid><description>&lt;h2 id="gitリポジトリの内容をアーカイブとして配布したい">Gitリポジトリの内容をアーカイブとして配布したい&lt;/h2>
&lt;p>&lt;code>.git&lt;/code>ディレクトリを含まず、コミット済みのファイルだけをtarやzipにまとめて配布したい場合がある。&lt;code>git clone&lt;/code>してから&lt;code>.git&lt;/code>を手動で削除する方法もあるが、&lt;code>git archive&lt;/code>コマンドを使うと1コマンドでアーカイブを作成できる。&lt;/p></description><enclosure url="https://atsum.in/linux/git-archive/img/thumbnail.png" type="image/png"/></item><item><title>【tar】-C オプションで作業ディレクトリを指定して展開・作成する</title><link>https://atsum.in/linux/tar-c-option/</link><pubDate>Sat, 11 Jul 2026 08:03:50 +0900</pubDate><guid>https://atsum.in/linux/tar-c-option/</guid><description>&lt;h2 id="アーカイブを任意のディレクトリに展開作成したい">アーカイブを任意のディレクトリに展開・作成したい&lt;/h2>
&lt;p>&lt;code>tar&lt;/code>コマンドは、実行時のカレントディレクトリを基準にアーカイブを展開・作成する。カレントディレクトリ以外の場所に展開したい場合、&lt;code>cd&lt;/code>で移動してから&lt;code>tar&lt;/code>を実行し、終わったら元のディレクトリへ戻るという手順が必要になる。&lt;code>tar&lt;/code>コマンドの&lt;code>-C&lt;/code>オプションを使うと、指定したディレクトリへ移動した状態でアーカイブを展開・作成でき、&lt;code>cd&lt;/code>による移動が不要になる。&lt;/p></description><enclosure url="https://atsum.in/linux/tar-c-option/img/thumbnail.png" type="image/png"/></item><item><title>【tar】--exclude オプションでアーカイブ・展開時にファイルを除外する</title><link>https://atsum.in/linux/tar-exclude/</link><pubDate>Sat, 11 Jul 2026 06:59:30 +0900</pubDate><guid>https://atsum.in/linux/tar-exclude/</guid><description>&lt;h2 id="アーカイブに不要なファイルを含めたくない">アーカイブに不要なファイルを含めたくない&lt;/h2>
&lt;p>ログファイルや&lt;code>.git&lt;/code>ディレクトリなど、アーカイブに含める必要のないファイルが混ざっている場合がある。すべてを含めてアーカイブを作成すると容量が無駄に大きくなったり、展開先に不要なファイルが残ったりする。&lt;code>tar&lt;/code>コマンドの&lt;code>--exclude&lt;/code>オプションを使うと、アーカイブ作成時・展開時の両方で特定のファイルやディレクトリを対象から除外できる。&lt;/p></description><enclosure url="https://atsum.in/linux/tar-exclude/img/thumbnail.png" type="image/png"/></item><item><title>【tar】--strip-components オプションで展開時にディレクトリ階層を除去する</title><link>https://atsum.in/linux/tar-strip-components/</link><pubDate>Sat, 11 Jul 2026 06:26:22 +0900</pubDate><guid>https://atsum.in/linux/tar-strip-components/</guid><description>&lt;h2 id="tar展開時に不要な親ディレクトリを取り除きたい">tar展開時に不要な親ディレクトリを取り除きたい&lt;/h2>
&lt;p>GitHubのリリースアーカイブなど、&lt;code>tar&lt;/code>アーカイブは&lt;code>myproject-1.2.3/&lt;/code>のような親ディレクトリを1つ持つ構成であることが多い。そのまま展開すると余分な階層ができてしまい、展開先のディレクトリ構成をそろえたい場合に扱いづらい。&lt;code>--strip-components&lt;/code>オプションを使うと、展開時に先頭のパスから指定した階層数を取り除ける。&lt;/p></description><enclosure url="https://atsum.in/linux/tar-strip-components/img/thumbnail.png" type="image/png"/></item><item><title>【diff -y】2つのファイルを左右に並べて比較表示する</title><link>https://atsum.in/linux/diff-y/</link><pubDate>Sat, 11 Jul 2026 00:35:21 +0900</pubDate><guid>https://atsum.in/linux/diff-y/</guid><description>&lt;h2 id="2つのファイルを左右に並べて比較したい">2つのファイルを左右に並べて比較したい&lt;/h2>
&lt;p>&lt;code>diff&lt;/code>コマンドの標準出力は差分箇所のみを表示する形式で、ファイル全体の対応関係が分かりづらい。&lt;code>-y&lt;/code>オプションを付けると、2つのファイルの内容を左右2列に並べて表示できる。&lt;/p></description><enclosure url="https://atsum.in/linux/diff-y/img/thumbnail.png" type="image/png"/></item><item><title>【Mac】sntpコマンドでシステム時計を即時に日本のNTPサーバーへ同期する</title><link>https://atsum.in/mac/sntp-sync-time/</link><pubDate>Fri, 10 Jul 2026 22:22:25 +0900</pubDate><guid>https://atsum.in/mac/sntp-sync-time/</guid><description>&lt;h2 id="sntpコマンドで即時に時刻を同期したい理由">sntpコマンドで即時に時刻を同期したい理由&lt;/h2>
&lt;p>AWS CLIをはじめとした、現在時刻から計算して得られるトークンで認証するシステムでは、システム時計がずれていると認証に失敗する。&lt;br>
macOSは通常自動で時刻同期を行うが、スリープからの復帰直後やタイムゾーンをまたぐ移動の直後などはずれが生じやすい。&lt;/p></description><enclosure url="https://atsum.in/mac/sntp-sync-time/img/thumbnail.png" type="image/png"/></item><item><title>【git check-ignore】ファイルが.gitignoreで無視されているか確認する</title><link>https://atsum.in/linux/git-check-ignore/</link><pubDate>Fri, 10 Jul 2026 08:49:45 +0900</pubDate><guid>https://atsum.in/linux/git-check-ignore/</guid><description>&lt;h2 id="ファイルがgitignoreで無視されているか確認したい">ファイルが.gitignoreで無視されているか確認したい&lt;/h2>
&lt;p>&lt;code>git status&lt;/code>に表示されないファイルが、&lt;code>.gitignore&lt;/code>によって無視されているのか、単にコマンドの見落としなのか判断しづらい場合がある。&lt;code>git check-ignore&lt;/code>コマンドを使うと、指定したファイルが無視対象かどうかを確認できる。&lt;/p></description><enclosure url="https://atsum.in/linux/git-check-ignore/img/thumbnail.png" type="image/png"/></item><item><title>【find -exec {} +】見つけたファイルをまとめてコマンド実行する</title><link>https://atsum.in/linux/find-exec/</link><pubDate>Sun, 05 Jul 2026 22:32:55 +0900</pubDate><guid>https://atsum.in/linux/find-exec/</guid><description>&lt;h2 id="検索したファイルをまとめてコマンド実行したい">検索したファイルをまとめてコマンド実行したい&lt;/h2>
&lt;p>&lt;code>find&lt;/code>コマンドで検索したファイルに対して、&lt;code>rm&lt;/code>や&lt;code>chmod&lt;/code>などのコマンドを実行したい場合がある。&lt;code>find&lt;/code>コマンドの&lt;code>-exec&lt;/code>オプションに&lt;code>{} +&lt;/code>を指定すると、検索結果のファイルをまとめて1回のコマンド実行にまとめられる。&lt;/p></description><enclosure url="https://atsum.in/linux/find-exec/img/thumbnail.png" type="image/png"/></item><item><title>【find -printf】検索結果の出力フォーマットを自由にカスタマイズする</title><link>https://atsum.in/linux/find-printf/</link><pubDate>Sun, 05 Jul 2026 22:11:18 +0900</pubDate><guid>https://atsum.in/linux/find-printf/</guid><description>&lt;h2 id="検索結果を独自フォーマットで出力したい">検索結果を独自フォーマットで出力したい&lt;/h2>
&lt;p>&lt;code>find&lt;/code>コマンドは通常ファイルパスのみを出力するが、ファイルサイズや更新日時、パーミッションなども合わせて確認したい場合がある。&lt;code>find&lt;/code>コマンドの&lt;code>-printf&lt;/code>オプションを使うと、検索結果の出力フォーマットを自由にカスタマイズできる。&lt;/p></description><enclosure url="https://atsum.in/linux/find-printf/img/thumbnail.png" type="image/png"/></item><item><title>【find -size】指定サイズ以上（以下）のファイルを検索する</title><link>https://atsum.in/linux/find-size/</link><pubDate>Sun, 05 Jul 2026 16:42:51 +0900</pubDate><guid>https://atsum.in/linux/find-size/</guid><description>&lt;h2 id="ファイルサイズを基準にファイルを検索したい">ファイルサイズを基準にファイルを検索したい&lt;/h2>
&lt;p>ディスク圧迫の原因になっている大きなファイルを探したり、逆に極端に小さいファイルだけを抽出したりしたい場合がある。&lt;code>find&lt;/code>コマンドの&lt;code>-size&lt;/code>オプションを使うと、ファイルサイズを基準にファイルを検索できる。&lt;/p></description><enclosure url="https://atsum.in/linux/find-size/img/thumbnail.png" type="image/png"/></item><item><title>【find -mtime】指定日数より古い（新しい）ファイルを検索する</title><link>https://atsum.in/linux/find-mtime/</link><pubDate>Sun, 05 Jul 2026 16:08:53 +0900</pubDate><guid>https://atsum.in/linux/find-mtime/</guid><description>&lt;h2 id="更新日時を基準にファイルを検索したい">更新日時を基準にファイルを検索したい&lt;/h2>
&lt;p>古いログファイルやバックアップファイルを整理する際、更新日時が指定日数より古い（または新しい）ファイルだけを検索したい場合がある。&lt;code>find&lt;/code>コマンドの&lt;code>-mtime&lt;/code>オプションを使うと、更新日時を基準にファイルを検索できる。&lt;/p></description><enclosure url="https://atsum.in/linux/find-mtime/img/thumbnail.png" type="image/png"/></item><item><title>【ln -s -r】相対パスでシンボリックリンクを作成する</title><link>https://atsum.in/linux/ln-r/</link><pubDate>Sun, 05 Jul 2026 15:46:12 +0900</pubDate><guid>https://atsum.in/linux/ln-r/</guid><description>&lt;h2 id="シンボリックリンクを相対パスで作成したい">シンボリックリンクを相対パスで作成したい&lt;/h2>
&lt;p>&lt;code>ln -s&lt;/code>でシンボリックリンクを作成すると、指定したパスがそのままリンク先として記録される。絶対パスで指定すると、ディレクトリごと別の場所へ移動した際にリンク切れを起こす。ディレクトリ構成ごと移動してもリンクを維持したい場合、&lt;code>-r&lt;/code>オプションを使う。&lt;/p></description><enclosure url="https://atsum.in/linux/ln-r/img/thumbnail.png" type="image/png"/></item><item><title>【cp -u】更新されたファイルのみをコピーして効率化する</title><link>https://atsum.in/linux/cp-u/</link><pubDate>Sun, 05 Jul 2026 15:36:53 +0900</pubDate><guid>https://atsum.in/linux/cp-u/</guid><description>&lt;h2 id="更新されたファイルだけをコピーしたい">更新されたファイルだけをコピーしたい&lt;/h2>
&lt;p>大量のファイルをバックアップやデプロイでコピーする際、変更のないファイルまで毎回コピーすると時間がかかる。差分バックアップを簡易的に実現したい場合、&lt;code>cp&lt;/code>コマンドの&lt;code>-u&lt;/code>オプションを使う。&lt;/p></description><enclosure url="https://atsum.in/linux/cp-u/img/thumbnail.png" type="image/png"/></item><item><title>【whereis】コマンドでバイナリ・ソース・マニュアルの場所を検索する</title><link>https://atsum.in/linux/whereis-command/</link><pubDate>Sun, 05 Jul 2026 15:05:33 +0900</pubDate><guid>https://atsum.in/linux/whereis-command/</guid><description>&lt;h2 id="コマンドの実行ファイルだけでなくマニュアルの場所も知りたい">コマンドの実行ファイルだけでなくマニュアルの場所も知りたい&lt;/h2>
&lt;p>&lt;code>which&lt;/code>コマンドはPATH上の実行ファイルの場所しか調べられない。実行ファイルに加えて、ソースコードやマニュアルページの場所もまとめて知りたい場合は&lt;code>whereis&lt;/code>コマンドを使う。&lt;/p></description><enclosure url="https://atsum.in/linux/whereis-command/img/thumbnail.png" type="image/png"/></item><item><title>【type】コマンドの種類を判定する（builtin/alias/file）</title><link>https://atsum.in/linux/type-command/</link><pubDate>Sun, 05 Jul 2026 14:32:16 +0900</pubDate><guid>https://atsum.in/linux/type-command/</guid><description>&lt;h2 id="コマンドの実体を確認したい">コマンドの実体を確認したい&lt;/h2>
&lt;p>シェルで実行するコマンドには、シェル自身が持つビルトインコマンド、エイリアス、PATH上の実行ファイルなど複数の種類がある。あるコマンド名が実際にはどれに該当するかを確認したい場合、&lt;code>type&lt;/code>コマンドを使う。&lt;/p></description><enclosure url="https://atsum.in/linux/type-command/img/thumbnail.png" type="image/png"/></item><item><title>【read -p / -s / -t】ユーザー入力を受け付けるシェルスクリプトを作る</title><link>https://atsum.in/linux/read-command/</link><pubDate>Sun, 05 Jul 2026 11:41:14 +0900</pubDate><guid>https://atsum.in/linux/read-command/</guid><description>&lt;h2 id="シェルスクリプトでユーザー入力を受け付けたい">シェルスクリプトでユーザー入力を受け付けたい&lt;/h2>
&lt;p>シェルスクリプトで対話的にユーザーからの入力を受け付けたい場合、&lt;code>read&lt;/code>コマンドを使う。&lt;/p>
&lt;p>&lt;code>read&lt;/code>コマンドには&lt;code>-p&lt;/code>、&lt;code>-s&lt;/code>、&lt;code>-t&lt;/code>といったオプションがあり、プロンプト表示・パスワード入力・タイムアウトをそれぞれ実現できる。&lt;/p></description><enclosure url="https://atsum.in/linux/read-command/img/thumbnail.png" type="image/png"/></item><item><title>【cp -p】ファイルコピー時にパーミッションとタイムスタンプを保持する</title><link>https://atsum.in/linux/cp-preserve-permission/</link><pubDate>Sun, 05 Jul 2026 09:22:49 +0900</pubDate><guid>https://atsum.in/linux/cp-preserve-permission/</guid><description>&lt;h2 id="cp-コマンドでパーミッションとタイムスタンプを保持したい">cp コマンドでパーミッションとタイムスタンプを保持したい&lt;/h2>
&lt;p>&lt;code>cp&lt;/code>コマンドでファイルをコピーすると、コピー先のパーミッションはumaskの影響を受け、更新日時はコピーした時刻になる。バックアップやデプロイでは、元のファイルの属性をそのまま維持したい場合がある。&lt;/p></description><enclosure url="https://atsum.in/linux/cp-preserve-permission/img/thumbnail.png" type="image/png"/></item><item><title>【Ghostty】Ctrl+Enterがエスケープシーケンスとして入力される現象を修正する</title><link>https://atsum.in/mac/ghostty-ctrl-enter/</link><pubDate>Fri, 03 Jul 2026 22:11:20 +0900</pubDate><guid>https://atsum.in/mac/ghostty-ctrl-enter/</guid><description>&lt;p>Ghosttyで&lt;code>Ctrl+Enter&lt;/code>を入力すると、改行の代わりに&lt;code>;5;13~&lt;/code>という文字列がそのまま入力される。&lt;/p>
&lt;h2 id="原因">原因&lt;/h2>
&lt;p>Enterキー単体では&lt;code>CR&lt;/code>（&lt;code>\r&lt;/code>）が送られるだけである。
Ctrlのような修飾キーを同時に押した場合、単なる&lt;code>\r&lt;/code>だけでは「Ctrl押下」の情報を伝えられない。&lt;/p></description><enclosure url="https://atsum.in/mac/ghostty-ctrl-enter/img/thumbnail.png" type="image/png"/></item><item><title>【sudo】-u オプションでユーザー切り替え時に-Eオプションで環境変数を引き継ぐ方法</title><link>https://atsum.in/linux/sudo-u-preserve-env/</link><pubDate>Fri, 03 Jul 2026 08:09:18 +0900</pubDate><guid>https://atsum.in/linux/sudo-u-preserve-env/</guid><description>&lt;h2 id="sudo--u-はデフォルトで環境変数をリセットする">sudo -u はデフォルトで環境変数をリセットする&lt;/h2>
&lt;p>&lt;code>sudo -u user command&lt;/code>で別ユーザーとしてコマンドを実行すると、呼び出し元シェルの環境変数は引き継がれない。これは&lt;code>sudoers&lt;/code>の&lt;code>env_reset&lt;/code>オプションがデフォルトで有効になっているためである。&lt;/p></description><enclosure url="https://atsum.in/linux/sudo-u-preserve-env/img/thumbnail.png" type="image/png"/></item><item><title>【VSCode】起動時にターミナルセッションを復元しないようにする</title><link>https://atsum.in/vscode/terminal-not-revive-session/</link><pubDate>Thu, 02 Jul 2026 08:12:27 +0900</pubDate><guid>https://atsum.in/vscode/terminal-not-revive-session/</guid><description>&lt;h2 id="ターミナルセッションの復元">ターミナルセッションの復元&lt;/h2>
&lt;p>VSCodeはデフォルトで、ウィンドウを再度開いたときに以前のターミナルセッションを復元する。&lt;/p>
&lt;p>復元してほしくない場合は&lt;code>terminal.integrated.persistentSessionReviveProcess&lt;/code>を設定する。&lt;/p></description><enclosure url="https://atsum.in/vscode/terminal-not-revive-session/img/thumbnail.png" type="image/png"/></item><item><title>【Android】コマンドでAndroidプロジェクトをAndroid Studioで開く</title><link>https://atsum.in/android/open-android-studio-from-command/</link><pubDate>Sun, 28 Jun 2026 22:54:05 +0900</pubDate><guid>https://atsum.in/android/open-android-studio-from-command/</guid><description>&lt;p>ターミナルからAndroidプロジェクトのディレクトリに移動し、そのままAndroid Studioで開く方法。&lt;/p>
&lt;h2 id="mac">Mac&lt;/h2>
&lt;p>&lt;code>open&lt;/code>コマンドに&lt;code>-a&lt;/code>オプションでアプリケーションを指定して開く。&lt;/p></description><enclosure url="https://atsum.in/android/open-android-studio-from-command/img/thumbnail.png" type="image/png"/></item><item><title>【Android】CameraXでライトをON/OFFする</title><link>https://atsum.in/android/camerax-torch/</link><pubDate>Sun, 28 Jun 2026 22:26:07 +0900</pubDate><guid>https://atsum.in/android/camerax-torch/</guid><description>&lt;p>CameraXでカメラのライト（トーチ）をON/OFFする方法。&lt;/p>
&lt;h2 id="camera-オブジェクトの取得">Camera オブジェクトの取得&lt;/h2>
&lt;p>ライトの制御には &lt;code>Camera&lt;/code> オブジェクトが必要である。&lt;code>cameraProvider.bindToLifecycle()&lt;/code> の戻り値として取得できる。&lt;/p></description><enclosure url="https://atsum.in/android/camerax-torch/img/thumbnail.png" type="image/png"/></item><item><title>【Android】MLKitでのCode39の読み取り精度をN回連続検出で向上させる</title><link>https://atsum.in/android/mlkit-code39-accuracy/</link><pubDate>Sun, 28 Jun 2026 21:52:21 +0900</pubDate><guid>https://atsum.in/android/mlkit-code39-accuracy/</guid><description>&lt;h2 id="問題と対策">問題と対策&lt;/h2>
&lt;p>AndroidのMLKitでCode39バーコードをスキャンすると、誤読が発生しやすい。&lt;br>
N回連続で同じ値を読み取れた場合に初めて採用することで、誤読を減らすことを考える。&lt;/p></description><enclosure url="https://atsum.in/android/mlkit-code39-accuracy/img/thumbnail.png" type="image/png"/></item><item><title>【VSCode】起動が遅い原因を特定する(Developer: Startup Performance/Show Running Extensions)</title><link>https://atsum.in/vscode/startup-performance/</link><pubDate>Sat, 27 Jun 2026 21:28:44 +0900</pubDate><guid>https://atsum.in/vscode/startup-performance/</guid><description>&lt;p>VSCodeの起動が遅いと感じたとき、原因を特定するための2つのコマンドがある。&lt;/p>
&lt;h2 id="developer-startup-performance">Developer: Startup Performance&lt;/h2>
&lt;p>&lt;code>Developer: Startup Performance&lt;/code> はVSCodeの起動にかかった時間を詳細に表示するコマンド。&lt;/p></description><enclosure url="https://atsum.in/vscode/startup-performance/img/thumbnail.png" type="image/png"/></item><item><title>【AWS】Systems Manager Run CommandのステータスをCLIで確認する</title><link>https://atsum.in/aws/ssm-run-command-list-commands/</link><pubDate>Fri, 26 Jun 2026 23:56:40 +0900</pubDate><guid>https://atsum.in/aws/ssm-run-command-list-commands/</guid><description>&lt;h2 id="aws-ssm-list-commands-でコマンドの実行状況を確認する">aws ssm list-commands でコマンドの実行状況を確認する&lt;/h2>
&lt;p>&lt;code>aws ssm send-command&lt;/code> でRun Commandを実行したあと、&lt;code>aws ssm list-commands&lt;/code> で実行状況を確認できる。&lt;/p>
&lt;div class="highlight">&lt;pre tabindex="0" class="chroma">&lt;code class="language-shell" data-lang="shell">&lt;span class="line">&lt;span class="cl">$ aws ssm list-commands
&lt;/span>&lt;/span>&lt;/code>&lt;/pre>&lt;/div>&lt;p>出力が多い場合は &lt;code>--command-id&lt;/code> で特定のコマンドに絞り込む。&lt;/p></description><enclosure url="https://atsum.in/aws/ssm-run-command-list-commands/img/thumbnail.png" type="image/png"/></item><item><title>nc -zv でポートの疎通確認をする</title><link>https://atsum.in/linux/nc-port-check/</link><pubDate>Fri, 26 Jun 2026 20:40:33 +0900</pubDate><guid>https://atsum.in/linux/nc-port-check/</guid><description>&lt;h2 id="nc--zv-でポートの疎通確認をしたい">nc -zv でポートの疎通確認をしたい&lt;/h2>
&lt;p>ポートの疎通確認には&lt;code>nc&lt;/code>（netcat）の&lt;code>-zv&lt;/code>オプションを組み合わせるのが便利である。&lt;/p>
&lt;ul>
&lt;li>&lt;code>-z&lt;/code>: データを送信せずに接続だけを試みる（ゼロI/Oモード）&lt;/li>
&lt;li>&lt;code>-v&lt;/code>: 接続結果を詳細に出力する（verbose）&lt;/li>
&lt;/ul>
&lt;h2 id="基本的な使い方">基本的な使い方&lt;/h2>
&lt;div class="highlight">&lt;pre tabindex="0" class="chroma">&lt;code class="language-shell" data-lang="shell">&lt;span class="line">&lt;span class="cl">nc -zv &lt;span class="o">[&lt;/span>ホスト&lt;span class="o">]&lt;/span> &lt;span class="o">[&lt;/span>ポート&lt;span class="o">]&lt;/span>
&lt;/span>&lt;/span>&lt;/code>&lt;/pre>&lt;/div>&lt;p>接続できる場合は&lt;code>succeeded!&lt;/code>が表示される。&lt;/p></description><enclosure url="https://atsum.in/linux/nc-port-check/img/thumbnail.png" type="image/png"/></item><item><title>【Linux】mktempコマンドで一時ファイル・ディレクトリを安全に作成する</title><link>https://atsum.in/linux/mktemp/</link><pubDate>Wed, 24 Jun 2026 21:09:42 +0900</pubDate><guid>https://atsum.in/linux/mktemp/</guid><description>&lt;h2 id="mktemp-コマンド">mktemp コマンド&lt;/h2>
&lt;p>&lt;code>mktemp&lt;/code>コマンドは一時ファイルや一時ディレクトリを安全に作成するコマンド。&lt;/p>
&lt;div class="highlight">&lt;pre tabindex="0" class="chroma">&lt;code class="language-shell" data-lang="shell">&lt;span class="line">&lt;span class="cl">$ mktemp
&lt;/span>&lt;/span>&lt;span class="line">&lt;span class="cl">/tmp/tmp.HkE3v2XsY9
&lt;/span>&lt;/span>&lt;/code>&lt;/pre>&lt;/div>&lt;p>実行するたびに異なるファイル名でファイルが作成され、そのパスが出力される。&lt;/p></description><enclosure url="https://atsum.in/linux/mktemp/img/thumbnail.png" type="image/png"/></item><item><title>【Android】IntentFilterでブラウザからアプリを開く（ディープリンク）</title><link>https://atsum.in/android/deep-link-intent-filter/</link><pubDate>Fri, 19 Jun 2026 23:46:06 +0900</pubDate><guid>https://atsum.in/android/deep-link-intent-filter/</guid><description>&lt;p>ブラウザやメールなどからURLをタップしたときに自分のアプリを開かせるには、&lt;code>IntentFilter&lt;/code> でディープリンクを設定する。URLのパラメータをアプリ内に渡せる。&lt;/p></description><enclosure url="https://atsum.in/android/deep-link-intent-filter/img/thumbnail.png" type="image/png"/></item><item><title>【systemd】RuntimeDirectoryでPIDファイルを/run直下以外に配置する</title><link>https://atsum.in/linux/systemd-runtime-directory/</link><pubDate>Fri, 19 Jun 2026 22:14:36 +0900</pubDate><guid>https://atsum.in/linux/systemd-runtime-directory/</guid><description>&lt;h2 id="runtimedirectoryとは">RuntimeDirectoryとは&lt;/h2>
&lt;p>systemdのUnit定義にて&lt;code>RuntimeDirectory&lt;/code>を指定すると、&lt;code>/run/&lt;/code>以下に指定した名前のディレクトリが自動作成される。&lt;/p>
&lt;p>サービスの起動時に作成され、停止時に削除される。PIDファイルやソケットファイルなどのランタイムファイルの格納先として利用する。&lt;/p></description><enclosure url="https://atsum.in/linux/systemd-runtime-directory/img/thumbnail.png" type="image/png"/></item><item><title>stat -c '%U' でファイルのオーナー名だけ取得する</title><link>https://atsum.in/linux/stat-get-owner/</link><pubDate>Thu, 18 Jun 2026 23:06:54 +0900</pubDate><guid>https://atsum.in/linux/stat-get-owner/</guid><description>&lt;h2 id="stat--c-u-でオーナーだけ取得する">stat -c &amp;lsquo;%U&amp;rsquo; でオーナーだけ取得する&lt;/h2>
&lt;p>&lt;code>stat&lt;/code>コマンドの&lt;code>-c&lt;/code>オプションでフォーマットを指定すると、特定の情報だけを出力できる。
&lt;code>%U&lt;/code>はオーナーのユーザー名を表すフォーマット指定子である。&lt;/p></description><enclosure url="https://atsum.in/linux/stat-get-owner/img/thumbnail.png" type="image/png"/></item><item><title>【Android】アプリを多言語対応する</title><link>https://atsum.in/android/localization/</link><pubDate>Wed, 17 Jun 2026 21:00:18 +0900</pubDate><guid>https://atsum.in/android/localization/</guid><description>&lt;p>Androidアプリを多言語対応するには、言語ごとのリソースファイルを用意し、システムのロケールに応じて適切な文字列を表示する仕組みを使う。&lt;/p>
&lt;h2 id="文字列リソースの基本構成">文字列リソースの基本構成&lt;/h2>
&lt;p>デフォルトの文字列リソースは &lt;code>res/values/strings.xml&lt;/code> に定義する。&lt;/p></description><enclosure url="https://atsum.in/android/localization/img/thumbnail.png" type="image/png"/></item><item><title>【Android, Kotlin】AppBarに検索ボックスを設置する</title><link>https://atsum.in/android/appbar-search-box/</link><pubDate>Wed, 17 Jun 2026 05:40:30 +0900</pubDate><guid>https://atsum.in/android/appbar-search-box/</guid><description>&lt;p>AppBarに検索ボックスを設置する方法を、ViewとComposeそれぞれで説明する。&lt;/p>
&lt;h2 id="viewsearchview">View（SearchView）&lt;/h2>
&lt;p>メニューリソースに &lt;code>SearchView&lt;/code> を追加し、&lt;code>onCreateOptionsMenu()&lt;/code> で設定する。&lt;/p></description><enclosure url="https://atsum.in/android/appbar-search-box/img/thumbnail.png" type="image/png"/></item><item><title>【Android,Kotlin】BottomSheetの初期高さを設定する</title><link>https://atsum.in/android/bottom-sheet-initial-height/</link><pubDate>Tue, 16 Jun 2026 21:03:16 +0900</pubDate><guid>https://atsum.in/android/bottom-sheet-initial-height/</guid><description>&lt;p>BottomSheetの初期高さ（最初に表示されたときの高さ）を設定する方法を、ViewとComposeそれぞれで説明する。&lt;/p>
&lt;h2 id="viewbottomsheetbehavior">View（BottomSheetBehavior）&lt;/h2>
&lt;p>&lt;code>BottomSheetBehavior&lt;/code> の &lt;code>peekHeight&lt;/code> プロパティで初期高さを設定する。&lt;/p></description><enclosure url="https://atsum.in/android/bottom-sheet-initial-height/img/thumbnail.png" type="image/png"/></item><item><title>【Android,Kotlin】BiometricPromptで生体認証を実装する</title><link>https://atsum.in/android/biometric-authentication/</link><pubDate>Mon, 15 Jun 2026 21:41:47 +0900</pubDate><guid>https://atsum.in/android/biometric-authentication/</guid><description>&lt;p>Androidで生体認証（指紋・顔認証）を実装するには &lt;code>BiometricPrompt&lt;/code> APIを使う。&lt;/p>
&lt;h2 id="依存を追加する">依存を追加する&lt;/h2>
&lt;p>&lt;code>app/build.gradle&lt;/code> に依存を追加する。&lt;/p>
&lt;div class="highlight" filename="app/build.gradle">&lt;pre tabindex="0" class="chroma">&lt;code class="language-gradle" data-lang="gradle">&lt;span class="line">&lt;span class="cl">&lt;span class="n">dependencies&lt;/span> &lt;span class="o">{&lt;/span>
&lt;/span>&lt;/span>&lt;span class="line">&lt;span class="cl"> &lt;span class="n">implementation&lt;/span> &lt;span class="s2">&amp;#34;androidx.biometric:biometric:1.1.0&amp;#34;&lt;/span>
&lt;/span>&lt;/span>&lt;span class="line">&lt;span class="cl">&lt;span class="o">}&lt;/span>
&lt;/span>&lt;/span>&lt;/code>&lt;/pre>&lt;/div>&lt;p>&lt;code>androidx.biometric&lt;/code> ライブラリはマニフェストマージにより &lt;code>USE_BIOMETRIC&lt;/code> パーミッションを自動的に追加するため、手動での追加は不要だ。意図を明示したい場合は &lt;code>AndroidManifest.xml&lt;/code> に明示的に記述する。&lt;/p></description><enclosure url="https://atsum.in/android/biometric-authentication/img/thumbnail.png" type="image/png"/></item><item><title>agvtoolでXcodeプロジェクトのバージョンを管理する</title><link>https://atsum.in/mac/agvtool/</link><pubDate>Sun, 14 Jun 2026 18:45:35 +0900</pubDate><guid>https://atsum.in/mac/agvtool/</guid><description>&lt;p>&lt;code>agvtool&lt;/code>（Apple Generic Versioning Tool）はXcodeプロジェクトのバージョン番号を管理するCLIツールである。
Xcodeプロジェクトの&lt;code>CURRENT_PROJECT_VERSION&lt;/code>（ビルド番号）と&lt;code>MARKETING_VERSION&lt;/code>（バージョン番号）をコマンドラインから確認・更新できる。&lt;/p></description><enclosure url="https://atsum.in/mac/agvtool/img/thumbnail.png" type="image/png"/></item><item><title>【Android,Kotlin】RecyclerView.Adapter#onViewDetachedFromWindow()でリスト要素が隠れたときに処理する</title><link>https://atsum.in/android/recyclerview-on-view-detached-from-window/</link><pubDate>Sun, 14 Jun 2026 16:39:54 +0900</pubDate><guid>https://atsum.in/android/recyclerview-on-view-detached-from-window/</guid><description>&lt;h2 id="onviewdetachedfromwindow">onViewDetachedFromWindow()&lt;/h2>
&lt;p>&lt;code>RecyclerView.Adapter&lt;/code>の&lt;code>onViewDetachedFromWindow()&lt;/code>メソッドは、リスト要素がスクロールで画面外へ出ると呼ばれる。&lt;/p></description><enclosure url="https://atsum.in/android/recyclerview-on-view-detached-from-window/img/thumbnail.png" type="image/png"/></item><item><title>【Android】debugビルドでoss-licenses-pluginのライセンス一覧をすべて表示する</title><link>https://atsum.in/android/oss-licenses-plugin-debug-build/</link><pubDate>Sun, 14 Jun 2026 10:58:48 +0900</pubDate><guid>https://atsum.in/android/oss-licenses-plugin-debug-build/</guid><description>&lt;p>&lt;a href="https://atsum.in/android/oss-licenses-plugin" target="_blank" rel="noopener">oss-licenses-plugin&lt;/a>
によるライセンス一覧は、debugビルドでは &amp;ldquo;Debug License Info&amp;rdquo; というデバッグビルド専用のライセンス情報のみが表示される。リリースビルドでは全ての依存ライブラリのライセンスが表示される。debugビルドでは表示されない。&lt;/p></description><enclosure url="https://atsum.in/android/oss-licenses-plugin-debug-build/img/thumbnail.png" type="image/png"/></item><item><title>【Android】oss-licenses-pluginでOSSライセンス一覧を表示する</title><link>https://atsum.in/android/oss-licenses-plugin/</link><pubDate>Sun, 14 Jun 2026 10:03:57 +0900</pubDate><guid>https://atsum.in/android/oss-licenses-plugin/</guid><description>&lt;p>&lt;a href="https://developers.google.com/android/guides/opensource" target="_blank" rel="noopener nofollow">oss-licenses-plugin&lt;/a>
を使うと、アプリが依存するOSSライブラリのライセンス一覧画面を簡単に表示できる。&lt;/p>
&lt;h2 id="依存の追加">依存の追加&lt;/h2>
&lt;p>&lt;code>settings.gradle.kts&lt;/code> の &lt;code>pluginManagement&lt;/code> ブロックに &lt;code>resolutionStrategy&lt;/code> を追加する。&lt;/p>
&lt;div class="highlight">&lt;pre tabindex="0" class="chroma">&lt;code class="language-kotlin" data-lang="kotlin">&lt;span class="line">&lt;span class="cl">&lt;span class="n">pluginManagement&lt;/span> &lt;span class="p">{&lt;/span>
&lt;/span>&lt;/span>&lt;span class="line">&lt;span class="cl"> &lt;span class="n">resolutionStrategy&lt;/span> &lt;span class="p">{&lt;/span>
&lt;/span>&lt;/span>&lt;span class="line">&lt;span class="cl"> &lt;span class="n">eachPlugin&lt;/span> &lt;span class="p">{&lt;/span>
&lt;/span>&lt;/span>&lt;span class="line">&lt;span class="cl"> &lt;span class="k">if&lt;/span> &lt;span class="p">(&lt;/span>&lt;span class="n">requested&lt;/span>&lt;span class="p">.&lt;/span>&lt;span class="n">id&lt;/span>&lt;span class="p">.&lt;/span>&lt;span class="n">id&lt;/span> &lt;span class="o">==&lt;/span> &lt;span class="s2">&amp;#34;com.google.android.gms.oss-licenses-plugin&amp;#34;&lt;/span>&lt;span class="p">)&lt;/span> &lt;span class="p">{&lt;/span>
&lt;/span>&lt;/span>&lt;span class="line">&lt;span class="cl"> &lt;span class="n">useModule&lt;/span>&lt;span class="p">(&lt;/span>&lt;span class="s2">&amp;#34;com.google.android.gms:oss-licenses-plugin:0.12.0&amp;#34;&lt;/span>&lt;span class="p">)&lt;/span>
&lt;/span>&lt;/span>&lt;span class="line">&lt;span class="cl"> &lt;span class="p">}&lt;/span>
&lt;/span>&lt;/span>&lt;span class="line">&lt;span class="cl"> &lt;span class="p">}&lt;/span>
&lt;/span>&lt;/span>&lt;span class="line">&lt;span class="cl"> &lt;span class="p">}&lt;/span>
&lt;/span>&lt;/span>&lt;span class="line">&lt;span class="cl">&lt;span class="p">}&lt;/span>
&lt;/span>&lt;/span>&lt;/code>&lt;/pre>&lt;/div>&lt;p>&lt;code>libs.versions.toml&lt;/code> にバージョンとライブラリ、プラグインを追加する。&lt;/p></description><enclosure url="https://atsum.in/android/oss-licenses-plugin/img/thumbnail.png" type="image/png"/></item><item><title>【Android,Kotlin】ImageDecoder.decodeBitmap()はEXIF回転を自動で適用する</title><link>https://atsum.in/android/imagedecoder-auto-rotation/</link><pubDate>Sun, 14 Jun 2026 06:44:02 +0900</pubDate><guid>https://atsum.in/android/imagedecoder-auto-rotation/</guid><description>&lt;h2 id="問題">問題&lt;/h2>
&lt;p>Android Q以降は&lt;code>ImageDecoder.decodeBitmap()&lt;/code>、それ以前は&lt;code>MediaStore.Images.Media.getBitmap()&lt;/code>でBitmapを取得し、EXIFから取得した回転情報を適用する実装がある。&lt;/p></description><enclosure url="https://atsum.in/android/imagedecoder-auto-rotation/img/thumbnail.png" type="image/png"/></item><item><title>【Android】コマンドでエミュレータを日本語設定にする</title><link>https://atsum.in/android/emulator-locale-ja/</link><pubDate>Sat, 13 Jun 2026 20:02:31 +0900</pubDate><guid>https://atsum.in/android/emulator-locale-ja/</guid><description>&lt;p>Appiumが提供するAndroid設定ヘルパーアプリを使ってコマンドラインでエミュレータを日本語設定にする方法。&lt;br>
ビジュアルリグレッションテストなどで日本語化されたスクリーンショットを自動で取得したい場合などに役立つ。&lt;/p></description><enclosure url="https://atsum.in/android/emulator-locale-ja/img/thumbnail.png" type="image/png"/></item><item><title>【bash】ヒアドキュメントとヒアストリングの使い方</title><link>https://atsum.in/linux/heredoc/</link><pubDate>Sat, 13 Jun 2026 16:45:56 +0900</pubDate><guid>https://atsum.in/linux/heredoc/</guid><description>&lt;h2 id="ヒアドキュメントeof">ヒアドキュメント（&amp;laquo;EOF）&lt;/h2>
&lt;p>ヒアドキュメントは複数行のテキストをコマンドの標準入力として渡す構文。
&lt;code>&amp;lt;&amp;lt;終端文字列&lt;/code>で始まり、同じ終端文字列だけの行で終わる。&lt;/p>
&lt;div class="highlight">&lt;pre tabindex="0" class="chroma">&lt;code class="language-shell" data-lang="shell">&lt;span class="line">&lt;span class="cl">cat &lt;span class="s">&amp;lt;&amp;lt;EOF
&lt;/span>&lt;/span>&lt;/span>&lt;span class="line">&lt;span class="cl">&lt;span class="s">Hello, World!
&lt;/span>&lt;/span>&lt;/span>&lt;span class="line">&lt;span class="cl">&lt;span class="s">EOF&lt;/span>
&lt;/span>&lt;/span>&lt;/code>&lt;/pre>&lt;/div>&lt;div class="highlight">&lt;pre tabindex="0" class="chroma">&lt;code class="language-shell" data-lang="shell">&lt;span class="line">&lt;span class="cl">Hello, World!
&lt;/span>&lt;/span>&lt;/code>&lt;/pre>&lt;/div>&lt;p>終端文字列は慣例的に&lt;code>EOF&lt;/code>が使われるが、任意の文字列を指定できる。&lt;/p></description><enclosure url="https://atsum.in/linux/heredoc/img/thumbnail.png" type="image/png"/></item><item><title>【Linux】df -iでinodeの枯渇を調査する</title><link>https://atsum.in/linux/df-inode/</link><pubDate>Sat, 13 Jun 2026 15:24:07 +0900</pubDate><guid>https://atsum.in/linux/df-inode/</guid><description>&lt;h2 id="ディスクに空きがあるのに書き込めない">ディスクに空きがあるのに書き込めない&lt;/h2>
&lt;p>ディスクの空き容量は十分あるのにファイルを作成できないことがある。&lt;/p>
&lt;div class="highlight">&lt;pre tabindex="0" class="chroma">&lt;code class="language-shell" data-lang="shell">&lt;span class="line">&lt;span class="cl">$ df -h
&lt;/span>&lt;/span>&lt;span class="line">&lt;span class="cl">Filesystem Size Used Avail Use% Mounted on
&lt;/span>&lt;/span>&lt;span class="line">&lt;span class="cl">/dev/sda1 50G 20G 30G 40% /
&lt;/span>&lt;/span>&lt;span class="line">&lt;span class="cl">$ touch /var/log/app/new.log
&lt;/span>&lt;/span>&lt;span class="line">&lt;span class="cl">touch: cannot touch &lt;span class="s1">&amp;#39;/var/log/app/new.log&amp;#39;&lt;/span>: No space left on device
&lt;/span>&lt;/span>&lt;/code>&lt;/pre>&lt;/div>&lt;p>&lt;code>df -h&lt;/code>では空き容量があるように見えるが、inode（アイノード）が枯渇している場合に同じエラーが出る。&lt;/p></description><enclosure url="https://atsum.in/linux/df-inode/img/thumbnail.png" type="image/png"/></item><item><title>telnetやncがない環境で/dev/tcpでポートの疎通確認をする</title><link>https://atsum.in/linux/bash-dev-tcp/</link><pubDate>Sat, 13 Jun 2026 15:13:14 +0900</pubDate><guid>https://atsum.in/linux/bash-dev-tcp/</guid><description>&lt;h2 id="ncやtelnetなしにポートの疎通確認をしたい">ncやtelnetなしにポートの疎通確認をしたい&lt;/h2>
&lt;p>ポートの疎通確認には&lt;code>nc&lt;/code>（netcat）や&lt;code>telnet&lt;/code>をよく使う。
しかしコンテナや最小構成のサーバではこれらのコマンドが入っていないことがある。&lt;/p></description><enclosure url="https://atsum.in/linux/bash-dev-tcp/img/thumbnail.png" type="image/png"/></item><item><title>【Shell Script】PIPESTATUSでパイプ途中のコマンドの終了コードを取得する</title><link>https://atsum.in/linux/pipestatus/</link><pubDate>Sat, 13 Jun 2026 14:16:17 +0900</pubDate><guid>https://atsum.in/linux/pipestatus/</guid><description>&lt;h2 id="パイプ途中のコマンドの終了コードを取得したい">パイプ途中のコマンドの終了コードを取得したい&lt;/h2>
&lt;p>&lt;code>set -o pipefail&lt;/code>を使うと、パイプ途中のコマンドが失敗した場合にスクリプトを停止できる。
ただし、どのコマンドが失敗したのかを特定したり、失敗を許容しつつ終了コードだけ取得したい場合には使えない。&lt;/p></description><enclosure url="https://atsum.in/linux/pipestatus/img/thumbnail.png" type="image/png"/></item><item><title>【Shell Script】set -euo pipefailでエラーに強いシェルスクリプトを書く</title><link>https://atsum.in/linux/set-euo-pipefail/</link><pubDate>Sat, 13 Jun 2026 10:17:45 +0900</pubDate><guid>https://atsum.in/linux/set-euo-pipefail/</guid><description>&lt;h2 id="シェルスクリプトをエラー時に停止させたい">シェルスクリプトをエラー時に停止させたい&lt;/h2>
&lt;p>シェルスクリプトはデフォルトでは途中のコマンドが失敗しても処理を続行する。&lt;/p>
&lt;div class="highlight" filename="deploy.sh">&lt;pre tabindex="0" class="chroma">&lt;code class="language-shell" data-lang="shell">&lt;span class="line">&lt;span class="cl">&lt;span class="cp">#!/bin/bash
&lt;/span>&lt;/span>&lt;/span>&lt;span class="line">&lt;span class="cl">&lt;span class="cp">&lt;/span>
&lt;/span>&lt;/span>&lt;span class="line">&lt;span class="cl">cp app.conf /etc/app/
&lt;/span>&lt;/span>&lt;span class="line">&lt;span class="cl">&lt;span class="nb">echo&lt;/span> &lt;span class="s2">&amp;#34;deploy done&amp;#34;&lt;/span>
&lt;/span>&lt;/span>&lt;/code>&lt;/pre>&lt;/div>&lt;p>&lt;code>cp&lt;/code>が失敗しても、後続の処理は実行される。
スクリプト全体の終了コードも&lt;code>0&lt;/code>になる。&lt;/p></description><enclosure url="https://atsum.in/linux/set-euo-pipefail/img/thumbnail.png" type="image/png"/></item><item><title>【awk】整形されたデータから特定のカラムを抽出する</title><link>https://atsum.in/linux/awk-print-column/</link><pubDate>Sat, 13 Jun 2026 09:36:22 +0900</pubDate><guid>https://atsum.in/linux/awk-print-column/</guid><description>&lt;h2 id="コマンド出力から特定のカラムを抽出したい">コマンド出力から特定のカラムを抽出したい&lt;/h2>
&lt;p>以下のような連続するスペースで整形されたデータから2列目だけを取得したい。&lt;/p>
&lt;div class="highlight" filename="users.txt">&lt;pre tabindex="0" class="chroma">&lt;code class="language-plain" data-lang="plain">&lt;span class="line">&lt;span class="cl">alice 25 Tokyo
&lt;/span>&lt;/span>&lt;span class="line">&lt;span class="cl">bob 3 Osaka
&lt;/span>&lt;/span>&lt;span class="line">&lt;span class="cl">charlie 31 Nagoya
&lt;/span>&lt;/span>&lt;/code>&lt;/pre>&lt;/div>&lt;p>&lt;code>cut&lt;/code>コマンドはスペース区切りを指定しても、連続するスペースを1つの区切りとして扱えない。
スペース1つごとにフィールドが区切られるため、2列目を指定しても空文字列が返る。&lt;/p></description><enclosure url="https://atsum.in/linux/awk-print-column/img/thumbnail.png" type="image/png"/></item><item><title>【useradd】ホームディレクトリを作成せずにユーザーを作成する</title><link>https://atsum.in/linux/useradd-no-create-home/</link><pubDate>Sat, 13 Jun 2026 00:17:55 +0900</pubDate><guid>https://atsum.in/linux/useradd-no-create-home/</guid><description>&lt;h2 id="useradd-の--d-オプションはホームディレクトリを作成する場合がある">useradd の -d オプションはホームディレクトリを作成する場合がある&lt;/h2>
&lt;p>&lt;code>useradd&lt;/code>コマンドの&lt;code>-d&lt;/code>オプションは、作成するユーザーのホームディレクトリのパスを指定する。RHEL系のディストリビューションでは、&lt;code>-d&lt;/code>オプションでパスを指定すると、指定したディレクトリが作成される。&lt;/p></description><enclosure url="https://atsum.in/linux/useradd-no-create-home/img/thumbnail.png" type="image/png"/></item><item><title>installコマンドでパーミッションと所有者を指定してディレクトリを作成する</title><link>https://atsum.in/linux/install-create-directory/</link><pubDate>Sat, 13 Jun 2026 00:01:37 +0900</pubDate><guid>https://atsum.in/linux/install-create-directory/</guid><description>&lt;h2 id="install-コマンド">install コマンド&lt;/h2>
&lt;p>&lt;code>install&lt;/code>コマンドはファイルのコピーと同時にパーミッションや所有者を設定するコマンド。Makefileのインストールターゲットなどでよく使われる。&lt;/p></description><enclosure url="https://atsum.in/linux/install-create-directory/img/thumbnail.png" type="image/png"/></item><item><title>【file -i】ファイルの MIME type を確認する</title><link>https://atsum.in/linux/file-mime-type/</link><pubDate>Wed, 03 Jun 2026 19:06:47 +0900</pubDate><guid>https://atsum.in/linux/file-mime-type/</guid><description>&lt;h2 id="ファイルの-mime-type-を確認したい">ファイルの MIME type を確認したい&lt;/h2>
&lt;p>ファイルのMIME typeをコマンドラインで確認したい場合、&lt;code>file&lt;/code> コマンドを使う。&lt;/p>
&lt;h2 id="file--i-で-mime-type-を確認するlinux">file -i で MIME type を確認する（Linux）&lt;/h2>
&lt;p>Linuxでは &lt;code>file -i&lt;/code> でファイルのMIME typeと文字エンコーディングを確認できる。&lt;/p></description><enclosure url="https://atsum.in/linux/file-mime-type/img/thumbnail.png" type="image/png"/></item><item><title>【Docker】host.docker.internal でコンテナからホストOSに接続する</title><link>https://atsum.in/linux/host-docker-internal/</link><pubDate>Wed, 03 Jun 2026 15:32:08 +0900</pubDate><guid>https://atsum.in/linux/host-docker-internal/</guid><description>&lt;h2 id="hostdockerinternal-とは">host.docker.internal とは&lt;/h2>
&lt;p>&lt;code>host.docker.internal&lt;/code> はDockerコンテナからホストマシンに接続するための特別なホスト名。&lt;/p>
&lt;p>ホストOSで動作しているPostgreSQLやRedisに、開発環境のコンテナから接続したい場面で利用できる。&lt;/p></description><enclosure url="https://atsum.in/linux/host-docker-internal/img/thumbnail.png" type="image/png"/></item><item><title>psコマンドでプロセスの起動日時を表示する（lstart）</title><link>https://atsum.in/linux/ps-lstart/</link><pubDate>Wed, 03 Jun 2026 10:01:41 +0900</pubDate><guid>https://atsum.in/linux/ps-lstart/</guid><description>&lt;h2 id="ps-コマンドのデフォルト表示">ps コマンドのデフォルト表示&lt;/h2>
&lt;p>&lt;code>ps aux&lt;/code> や &lt;code>ps -ef&lt;/code> では起動日時が表示されるが、精度が低く「日付だけ」や「時刻だけ」になる場合がある。&lt;/p>
&lt;div class="highlight">&lt;pre tabindex="0" class="chroma">&lt;code class="language-shell" data-lang="shell">&lt;span class="line">&lt;span class="cl">$ ps aux &lt;span class="p">|&lt;/span> head -3
&lt;/span>&lt;/span>&lt;span class="line">&lt;span class="cl">USER PID %CPU %MEM VSZ RSS TTY STAT START TIME COMMAND
&lt;/span>&lt;/span>&lt;span class="line">&lt;span class="cl">root &lt;span class="m">1&lt;/span> 0.0 0.0 &lt;span class="m">168936&lt;/span> &lt;span class="m">13312&lt;/span> ? Ss Jun01 0:02 /sbin/init
&lt;/span>&lt;/span>&lt;span class="line">&lt;span class="cl">root &lt;span class="m">2&lt;/span> 0.0 0.0 &lt;span class="m">0&lt;/span> &lt;span class="m">0&lt;/span> ? S Jun01 0:00 &lt;span class="o">[&lt;/span>kthreadd&lt;span class="o">]&lt;/span>
&lt;/span>&lt;/span>&lt;/code>&lt;/pre>&lt;/div>&lt;p>&lt;code>START&lt;/code> 列が日付だけで時刻が分からない。&lt;/p></description><enclosure url="https://atsum.in/linux/ps-lstart/img/thumbnail.png" type="image/png"/></item><item><title>【Ruby】% 演算子で文字列をフォーマットする</title><link>https://atsum.in/ruby/percent-operator/</link><pubDate>Sun, 31 May 2026 17:55:50 +0900</pubDate><guid>https://atsum.in/ruby/percent-operator/</guid><description>&lt;p>Rubyの&lt;code>%&lt;/code>演算子を使うと、C言語の&lt;code>sprintf&lt;/code>のような書式指定で文字列をフォーマットできる。&lt;/p>
&lt;h2 id="基本的な使い方">基本的な使い方&lt;/h2>
&lt;p>文字列に&lt;code>%&lt;/code>演算子を使い、右辺に値を指定する。&lt;/p>
&lt;div class="highlight">&lt;pre tabindex="0" class="chroma">&lt;code class="language-ruby" data-lang="ruby">&lt;span class="line">&lt;span class="cl">&lt;span class="s2">&amp;#34;Hello, %s!&amp;#34;&lt;/span> &lt;span class="o">%&lt;/span> &lt;span class="s2">&amp;#34;World&amp;#34;&lt;/span>
&lt;/span>&lt;/span>&lt;span class="line">&lt;span class="cl">&lt;span class="c1"># =&amp;gt; &amp;#34;Hello, World!&amp;#34;&lt;/span>
&lt;/span>&lt;/span>&lt;span class="line">&lt;span class="cl">
&lt;/span>&lt;/span>&lt;span class="line">&lt;span class="cl">&lt;span class="s2">&amp;#34;今日は%d件のタスクがある&amp;#34;&lt;/span> &lt;span class="o">%&lt;/span> &lt;span class="mi">5&lt;/span>
&lt;/span>&lt;/span>&lt;span class="line">&lt;span class="cl">&lt;span class="c1"># =&amp;gt; &amp;#34;今日は5件のタスクがある&amp;#34;&lt;/span>
&lt;/span>&lt;/span>&lt;/code>&lt;/pre>&lt;/div>&lt;h2 id="フォーマット指定子">フォーマット指定子&lt;/h2>
&lt;p>主なフォーマット指定子は以下の通り。&lt;/p></description><enclosure url="https://atsum.in/ruby/percent-operator/img/thumbnail.png" type="image/png"/></item><item><title>【AWS CLI】ce get-cost-and-usageでコストをコマンドラインで確認する</title><link>https://atsum.in/aws/ce-get-cost-and-usage/</link><pubDate>Thu, 30 Apr 2026 19:51:35 +0900</pubDate><guid>https://atsum.in/aws/ce-get-cost-and-usage/</guid><description>&lt;h2 id="ce-get-cost-and-usage-とは">ce get-cost-and-usage とは&lt;/h2>
&lt;p>&lt;code>aws ce get-cost-and-usage&lt;/code> はAWS Cost Explorer APIを使ってAWSのコストと使用量をCLIで取得するコマンド。マネジメントコンソールのCost Explorerで確認できる情報をコマンドラインから取得できる。&lt;/p></description><enclosure url="https://atsum.in/aws/ce-get-cost-and-usage/img/thumbnail.png" type="image/png"/></item><item><title>【AWS ECR】タグを削除してpull through cacheを強制更新する</title><link>https://atsum.in/aws/ecr-batch-delete-image-delete-tag/</link><pubDate>Wed, 29 Apr 2026 10:54:48 +0900</pubDate><guid>https://atsum.in/aws/ecr-batch-delete-image-delete-tag/</guid><description>&lt;h2 id="ecr-のタグ削除">ECR のタグ削除&lt;/h2>
&lt;p>&lt;code>aws ecr batch-delete-image&lt;/code> コマンドで &lt;code>--image-ids imageTag=[タグ名]&lt;/code> を指定すると、タグのみを削除する。イメージ本体（マニフェスト）は、削除したタグが最後のタグでない限り残る。最後のタグを削除した場合はマニフェストも削除される。&lt;/p></description><enclosure url="https://atsum.in/aws/ecr-batch-delete-image-delete-tag/img/thumbnail.png" type="image/png"/></item><item><title>【AWS SQS】--wait-time-secondsでLong Pollingを有効にして空レスポンスを減らす</title><link>https://atsum.in/aws/sqs-receive-message-wait-time-seconds/</link><pubDate>Wed, 29 Apr 2026 10:30:03 +0900</pubDate><guid>https://atsum.in/aws/sqs-receive-message-wait-time-seconds/</guid><description>&lt;h2 id="wait-time-secondsとは">&amp;ndash;wait-time-secondsとは&lt;/h2>
&lt;p>&lt;code>aws sqs receive-message&lt;/code> コマンドはデフォルトでShort Pollingを使用する。Short Pollingではキューにメッセージがなくても即座に空のレスポンスを返すため、ポーリングを繰り返すと無駄なAPIコールが発生する。&lt;/p></description><enclosure url="https://atsum.in/aws/sqs-receive-message-wait-time-seconds/img/thumbnail.png" type="image/png"/></item><item><title>【Maven】dependency:copy-dependenciesで動作に必要なJARを取得する</title><link>https://atsum.in/java/mvn-copy-dependencies/</link><pubDate>Sun, 26 Apr 2026 20:42:04 +0900</pubDate><guid>https://atsum.in/java/mvn-copy-dependencies/</guid><description>&lt;h2 id="概要">概要&lt;/h2>
&lt;p>&lt;code>mvn dependency:copy-dependencies&lt;/code> は、Mavenプロジェクトの依存JARを指定したディレクトリにコピーするコマンド。&lt;br>
アプリケーションの動作に必要なJARを個別に取得したい場合に使う。&lt;/p></description><enclosure url="https://atsum.in/java/mvn-copy-dependencies/img/thumbnail.png" type="image/png"/></item><item><title>【Docker】コンテナのファイルシステム差分を確認する(docker diff)</title><link>https://atsum.in/linux/docker-diff/</link><pubDate>Sun, 26 Apr 2026 08:17:23 +0900</pubDate><guid>https://atsum.in/linux/docker-diff/</guid><description>&lt;h2 id="docker-diffコマンド">docker diffコマンド&lt;/h2>
&lt;p>&lt;code>docker diff&lt;/code>コマンドは、コンテナが起動してからファイルシステムに加えられた変更を確認するコマンド。&lt;/p>
&lt;p>ベースイメージとコンテナの差分（追加・変更・削除されたファイル）を一覧で確認できる。&lt;/p></description><enclosure url="https://atsum.in/linux/docker-diff/img/thumbnail.png" type="image/png"/></item><item><title>【Swift】OSLogでログ出力する方法</title><link>https://atsum.in/mac/osx-oslog/</link><pubDate>Sun, 19 Apr 2026 20:28:18 +0900</pubDate><guid>https://atsum.in/mac/osx-oslog/</guid><description>&lt;h2 id="oslogとは">OSLogとは&lt;/h2>
&lt;p>&lt;code>OSLog&lt;/code>はAppleが提供する統合ログシステムのSwift APIで、macOS 11/iOS 14以降で利用できる。&lt;/p>
&lt;p>&lt;code>print()&lt;/code>と異なり、ログレベル・カテゴリ・プライバシー保護を備えており、本番環境でも安全に使える。&lt;/p></description><enclosure url="https://atsum.in/mac/osx-oslog/img/thumbnail.png" type="image/png"/></item><item><title>【Xcode】空行にインデントが入らないようにする</title><link>https://atsum.in/mac/xcode-disable-empty-indent/</link><pubDate>Sun, 19 Apr 2026 16:49:00 +0900</pubDate><guid>https://atsum.in/mac/xcode-disable-empty-indent/</guid><description>&lt;h2 id="空行のインデントを無効にする方法">空行のインデントを無効にする方法&lt;/h2>
&lt;p>Xcodeのデフォルト設定では、空行にもインデントが自動挿入される。&lt;br>
この動作を無効にするには&lt;code>Xcode&lt;/code>→&lt;code>Settings...&lt;/code>→&lt;code>Editing&lt;/code>タブを開き、以下のように設定する。&lt;/p></description><enclosure url="https://atsum.in/mac/xcode-disable-empty-indent/img/thumbnail.png" type="image/png"/></item><item><title>【Xcode】エディタの行折り返しを切り替える方法</title><link>https://atsum.in/mac/xcode-disable-folding/</link><pubDate>Sun, 19 Apr 2026 15:51:26 +0900</pubDate><guid>https://atsum.in/mac/xcode-disable-folding/</guid><description>&lt;h2 id="行折り返しの切り替え方法">行折り返しの切り替え方法&lt;/h2>
&lt;p>エディタの行折り返しは、メニューバーの &lt;code>Editor&lt;/code> → &lt;code>Wrap Lines&lt;/code> から切り替えられる。&lt;/p>
&lt;p>&lt;img src="img/line-wrapping-menu.png" alt="Line Wrapping メニュー">&lt;/p>
&lt;h2 id="メニューから切り替える">メニューから切り替える&lt;/h2>
&lt;p>Editorメニューの&lt;code>Wrap Lines&lt;/code>からも、行折り返しの表示/非表示を切り替えられる。&lt;/p></description><enclosure url="https://atsum.in/mac/xcode-disable-folding/img/thumbnail.png" type="image/png"/></item><item><title>【Xcode】ミニマップを非表示にする</title><link>https://atsum.in/mac/hide-minimap/</link><pubDate>Sun, 19 Apr 2026 14:36:37 +0900</pubDate><guid>https://atsum.in/mac/hide-minimap/</guid><description>&lt;h2 id="ミニマップを非表示にする方法">ミニマップを非表示にする方法&lt;/h2>
&lt;p>エディタの右上の以下の画像のアイコンから&lt;code>Minimap&lt;/code>をクリックすると、ミニマップの表示/非表示を切り替えられる。&lt;/p>
&lt;p>&lt;img src="img/hide-minimap-menu.png" alt="Minimap の表示/非表示メニュー">&lt;/p></description><enclosure url="https://atsum.in/mac/hide-minimap/img/thumbnail.png" type="image/png"/></item><item><title>【Docker】OOM KillerにKillされたか確認する(docker inspect)</title><link>https://atsum.in/linux/docker-oom-killed/</link><pubDate>Sun, 19 Apr 2026 13:16:35 +0900</pubDate><guid>https://atsum.in/linux/docker-oom-killed/</guid><description>&lt;h2 id="oom-killerにkillされたか確認する">OOM KillerにKillされたか確認する&lt;/h2>
&lt;p>コンテナが突然停止した場合、OOM Killer（Out Of Memory Killer）によるKillが原因の場合がある。&lt;br>
&lt;code>docker inspect&lt;/code>コマンドで&lt;code>.State.OOMKilled&lt;/code>フィールドを確認すると、OOM KillerによるKillかどうかを調べられる。&lt;/p></description><enclosure url="https://atsum.in/linux/docker-oom-killed/img/thumbnail.png" type="image/png"/></item><item><title>statコマンドでファイルの詳細情報（inode・タイムスタンプ・権限）を表示する</title><link>https://atsum.in/linux/stat-command/</link><pubDate>Tue, 13 Jan 2026 00:00:24 +0900</pubDate><guid>https://atsum.in/linux/stat-command/</guid><description>&lt;h2 id="stat-コマンド">stat コマンド&lt;/h2>
&lt;p>&lt;code>stat&lt;/code>コマンドはファイルやファイルシステムの詳細情報を表示するコマンド。&lt;/p>
&lt;div class="highlight">&lt;pre tabindex="0" class="chroma">&lt;code class="language-shell" data-lang="shell">&lt;span class="line">&lt;span class="cl">$ stat test.txt
&lt;/span>&lt;/span>&lt;span class="line">&lt;span class="cl"> File: test.txt
&lt;/span>&lt;/span>&lt;span class="line">&lt;span class="cl"> Size: &lt;span class="m">18&lt;/span> Blocks: &lt;span class="m">8&lt;/span> IO Block: &lt;span class="m">4096&lt;/span> regular file
&lt;/span>&lt;/span>&lt;span class="line">&lt;span class="cl">Device: 1,17 Inode: &lt;span class="m">219222175&lt;/span> Links: &lt;span class="m">1&lt;/span>
&lt;/span>&lt;/span>&lt;span class="line">&lt;span class="cl">Access: &lt;span class="o">(&lt;/span>0644/-rw-r--r--&lt;span class="o">)&lt;/span> Uid: &lt;span class="o">(&lt;/span> 501/ sue&lt;span class="o">)&lt;/span> Gid: &lt;span class="o">(&lt;/span> 0/ wheel&lt;span class="o">)&lt;/span>
&lt;/span>&lt;/span>&lt;span class="line">&lt;span class="cl">Access: 2026-01-13 00:03:58.731037436 +0900
&lt;/span>&lt;/span>&lt;span class="line">&lt;span class="cl">Modify: 2026-01-13 00:03:58.731137019 +0900
&lt;/span>&lt;/span>&lt;span class="line">&lt;span class="cl">Change: 2026-01-13 00:03:58.731137019 +0900
&lt;/span>&lt;/span>&lt;span class="line">&lt;span class="cl"> Birth: 2026-01-13 00:03:58.731037436 +0900
&lt;/span>&lt;/span>&lt;/code>&lt;/pre>&lt;/div>&lt;p>ファイルの詳細情報が表示される。&lt;/p></description><enclosure url="https://atsum.in/linux/stat-command/img/thumbnail.png" type="image/png"/></item><item><title>nlコマンドで行番号を柔軟に付与する</title><link>https://atsum.in/linux/nl-command/</link><pubDate>Mon, 12 Jan 2026 21:04:31 +0900</pubDate><guid>https://atsum.in/linux/nl-command/</guid><description>&lt;h2 id="nl-コマンド">nl コマンド&lt;/h2>
&lt;p>&lt;code>nl&lt;/code>コマンドはテキストに行番号をつけて出力するコマンド。&lt;/p>
&lt;div class="highlight" filename="sample.txt">&lt;pre tabindex="0" class="chroma">&lt;code class="language-text" data-lang="text">&lt;span class="line">&lt;span class="cl">apple
&lt;/span>&lt;/span>&lt;span class="line">&lt;span class="cl">banana
&lt;/span>&lt;/span>&lt;span class="line">&lt;span class="cl">cherry
&lt;/span>&lt;/span>&lt;span class="line">&lt;span class="cl">grape
&lt;/span>&lt;/span>&lt;span class="line">&lt;span class="cl">melon
&lt;/span>&lt;/span>&lt;/code>&lt;/pre>&lt;/div>&lt;p>上記の&lt;code>sample.txt&lt;/code>に&lt;code>nl&lt;/code>コマンドを実行すると以下のように行番号が付加される。&lt;/p></description><enclosure url="https://atsum.in/linux/nl-command/img/thumbnail.png" type="image/png"/></item><item><title>【comm】ソート済みファイル同士を比較して差分・共通部分を抽出する</title><link>https://atsum.in/linux/comm-command/</link><pubDate>Mon, 12 Jan 2026 15:43:24 +0900</pubDate><guid>https://atsum.in/linux/comm-command/</guid><description>&lt;h2 id="ソート済みファイル同士を比較したい">ソート済みファイル同士を比較したい&lt;/h2>
&lt;p>2つのソート済みファイルを比較して、どちらか片方にだけ存在する行や、両方に共通する行を抽出したい。&lt;/p>
&lt;p>例えば以下のような2つのファイルがある。&lt;/p>
&lt;div class="highlight" filename="file1.txt">&lt;pre tabindex="0" class="chroma">&lt;code class="language-text" data-lang="text">&lt;span class="line">&lt;span class="cl">apple
&lt;/span>&lt;/span>&lt;span class="line">&lt;span class="cl">banana
&lt;/span>&lt;/span>&lt;span class="line">&lt;span class="cl">cherry
&lt;/span>&lt;/span>&lt;span class="line">&lt;span class="cl">grape
&lt;/span>&lt;/span>&lt;/code>&lt;/pre>&lt;/div>&lt;div class="highlight" filename="file2.txt">&lt;pre tabindex="0" class="chroma">&lt;code class="language-text" data-lang="text">&lt;span class="line">&lt;span class="cl">banana
&lt;/span>&lt;/span>&lt;span class="line">&lt;span class="cl">cherry
&lt;/span>&lt;/span>&lt;span class="line">&lt;span class="cl">melon
&lt;/span>&lt;/span>&lt;span class="line">&lt;span class="cl">orange
&lt;/span>&lt;/span>&lt;/code>&lt;/pre>&lt;/div>&lt;p>2つのファイルを比較して、以下の情報を得たい。&lt;/p></description><enclosure url="https://atsum.in/linux/comm-command/img/thumbnail.png" type="image/png"/></item><item><title>tacコマンドでファイルを末尾から逆順に表示</title><link>https://atsum.in/linux/tac-command/</link><pubDate>Sun, 11 Jan 2026 23:08:34 +0900</pubDate><guid>https://atsum.in/linux/tac-command/</guid><description>&lt;h2 id="ファイルを末尾から表示したい">ファイルを末尾から表示したい&lt;/h2>
&lt;p>ファイルを末尾から逆順に表示したい。&lt;/p>
&lt;p>例えば以下のようなテキストファイルがある。&lt;/p>
&lt;div class="highlight" filename="test.txt">&lt;pre tabindex="0" class="chroma">&lt;code class="language-text" data-lang="text">&lt;span class="line">&lt;span class="cl">aaa
&lt;/span>&lt;/span>&lt;span class="line">&lt;span class="cl">bbb
&lt;/span>&lt;/span>&lt;span class="line">&lt;span class="cl">ccc
&lt;/span>&lt;/span>&lt;span class="line">&lt;span class="cl">ddd
&lt;/span>&lt;/span>&lt;span class="line">&lt;span class="cl">eee
&lt;/span>&lt;/span>&lt;/code>&lt;/pre>&lt;/div>&lt;p>test.txtを末尾から逆順に表示したい。&lt;/p>
&lt;div class="highlight">&lt;pre tabindex="0" class="chroma">&lt;code class="language-text" data-lang="text">&lt;span class="line">&lt;span class="cl">eee
&lt;/span>&lt;/span>&lt;span class="line">&lt;span class="cl">ddd
&lt;/span>&lt;/span>&lt;span class="line">&lt;span class="cl">ccc
&lt;/span>&lt;/span>&lt;span class="line">&lt;span class="cl">bbb
&lt;/span>&lt;/span>&lt;span class="line">&lt;span class="cl">aaa
&lt;/span>&lt;/span>&lt;/code>&lt;/pre>&lt;/div>&lt;h2 id="tac-コマンド">tac コマンド&lt;/h2>
&lt;p>&lt;code>tac&lt;/code>コマンドはファイルを末尾から逆順に表示するコマンドである。&lt;/p></description><enclosure url="https://atsum.in/linux/tac-command/img/thumbnail.png" type="image/png"/></item><item><title>【split】大きなファイルを行数やサイズで分割する</title><link>https://atsum.in/linux/split-command/</link><pubDate>Sun, 11 Jan 2026 21:33:27 +0900</pubDate><guid>https://atsum.in/linux/split-command/</guid><description>&lt;h2 id="split-コマンド">split コマンド&lt;/h2>
&lt;p>&lt;code>split&lt;/code>コマンドはファイルを複数のファイルに分割するコマンド。&lt;/p>
&lt;div class="highlight">&lt;pre tabindex="0" class="chroma">&lt;code class="language-shell" data-lang="shell">&lt;span class="line">&lt;span class="cl">$ split large.txt
&lt;/span>&lt;/span>&lt;/code>&lt;/pre>&lt;/div>&lt;p>このコマンドを実行すると、&lt;code>large.txt&lt;/code>を1000行ごとに分割し、&lt;code>xaa&lt;/code>、&lt;code>xab&lt;/code>、&lt;code>xac&lt;/code>&amp;hellip;という名前のファイルを生成する。&lt;/p></description><enclosure url="https://atsum.in/linux/split-command/img/thumbnail.png" type="image/png"/></item><item><title>pasteコマンドで複数ファイルを横に結合する</title><link>https://atsum.in/linux/paste-command/</link><pubDate>Sun, 11 Jan 2026 19:35:16 +0900</pubDate><guid>https://atsum.in/linux/paste-command/</guid><description>&lt;h2 id="複数のファイルを横に結合したい">複数のファイルを横に結合したい&lt;/h2>
&lt;p>複数のファイルの内容を横に並べて結合したい場合がある。&lt;/p>
&lt;p>例えば以下のような2つのファイルがある。&lt;/p>
&lt;div class="highlight" filename="file1.txt">&lt;pre tabindex="0" class="chroma">&lt;code class="language-text" data-lang="text">&lt;span class="line">&lt;span class="cl">apple
&lt;/span>&lt;/span>&lt;span class="line">&lt;span class="cl">banana
&lt;/span>&lt;/span>&lt;span class="line">&lt;span class="cl">cherry
&lt;/span>&lt;/span>&lt;/code>&lt;/pre>&lt;/div>&lt;div class="highlight" filename="file2.txt">&lt;pre tabindex="0" class="chroma">&lt;code class="language-text" data-lang="text">&lt;span class="line">&lt;span class="cl">red
&lt;/span>&lt;/span>&lt;span class="line">&lt;span class="cl">yellow
&lt;/span>&lt;/span>&lt;span class="line">&lt;span class="cl">red
&lt;/span>&lt;/span>&lt;/code>&lt;/pre>&lt;/div>&lt;p>2つのファイルを横に結合して以下のような出力を得たい。&lt;/p></description><enclosure url="https://atsum.in/linux/paste-command/img/thumbnail.png" type="image/png"/></item><item><title>【grep -l】マッチしたファイル名のみを表示する</title><link>https://atsum.in/linux/grep-l/</link><pubDate>Sat, 10 Jan 2026 20:33:08 +0900</pubDate><guid>https://atsum.in/linux/grep-l/</guid><description>&lt;p>&lt;code>grep&lt;/code>の&lt;code>-l&lt;/code>オプションを使うと、マッチした行の内容を出さずにファイル名だけを表示できる。逆にマッチしなかったファイル名を表示する&lt;code>-L&lt;/code>オプションもある。&lt;/p></description><enclosure url="https://atsum.in/linux/grep-l/img/thumbnail.png" type="image/png"/></item><item><title>【grep -o】マッチした部分のみを抽出して表示する</title><link>https://atsum.in/linux/grep-o/</link><pubDate>Sat, 10 Jan 2026 19:58:08 +0900</pubDate><guid>https://atsum.in/linux/grep-o/</guid><description>&lt;h2 id="マッチした部分だけを抽出したい">マッチした部分だけを抽出したい&lt;/h2>
&lt;p>テキストから特定のパターンにマッチした部分だけを抽出したい。&lt;/p>
&lt;p>通常の&lt;code>grep&lt;/code>コマンドはマッチした行全体を表示するため、マッチした部分以外の情報も含まれてしまう。&lt;/p></description><enclosure url="https://atsum.in/linux/grep-o/img/thumbnail.png" type="image/png"/></item><item><title>【tail】行数を指定して末尾やN行目以降を表示する</title><link>https://atsum.in/linux/tail-after/</link><pubDate>Thu, 08 Jan 2026 20:26:09 +0900</pubDate><guid>https://atsum.in/linux/tail-after/</guid><description>&lt;p>&lt;code>tail&lt;/code>で表示する行数を指定するには&lt;code>-n&lt;/code>を使う。&lt;code>-n 5&lt;/code>は末尾5行、&lt;code>-n +5&lt;/code>は5行目以降を表示する。&lt;code>+&lt;/code>の有無で意味が変わる。&lt;/p>
&lt;h2 id="ファイルの指定行以降を表示したい">ファイルの指定行以降を表示したい&lt;/h2>
&lt;p>テキストファイルの先頭N行をスキップして、N行目以降を表示したい。&lt;/p></description><enclosure url="https://atsum.in/linux/tail-after/img/thumbnail.png" type="image/png"/></item><item><title>shufコマンドでファイルの行をランダムにシャッフル</title><link>https://atsum.in/linux/shuf-command/</link><pubDate>Tue, 06 Jan 2026 22:41:52 +0900</pubDate><guid>https://atsum.in/linux/shuf-command/</guid><description>&lt;h2 id="ファイルの行をランダムにシャッフルしたい">ファイルの行をランダムにシャッフルしたい&lt;/h2>
&lt;p>テキストファイルの各行をランダムな順序で表示したい。&lt;/p>
&lt;p>例えば以下のようなファイルがある。&lt;/p>
&lt;div class="highlight" filename="numbers.txt">&lt;pre tabindex="0" class="chroma">&lt;code class="language-text" data-lang="text">&lt;span class="line">&lt;span class="cl">1
&lt;/span>&lt;/span>&lt;span class="line">&lt;span class="cl">2
&lt;/span>&lt;/span>&lt;span class="line">&lt;span class="cl">3
&lt;/span>&lt;/span>&lt;span class="line">&lt;span class="cl">4
&lt;/span>&lt;/span>&lt;span class="line">&lt;span class="cl">5
&lt;/span>&lt;/span>&lt;/code>&lt;/pre>&lt;/div>&lt;p>各行をランダムな順序で並び替えて表示したい。&lt;/p>
&lt;div class="highlight">&lt;pre tabindex="0" class="chroma">&lt;code class="language-text" data-lang="text">&lt;span class="line">&lt;span class="cl">3
&lt;/span>&lt;/span>&lt;span class="line">&lt;span class="cl">1
&lt;/span>&lt;/span>&lt;span class="line">&lt;span class="cl">5
&lt;/span>&lt;/span>&lt;span class="line">&lt;span class="cl">2
&lt;/span>&lt;/span>&lt;span class="line">&lt;span class="cl">4
&lt;/span>&lt;/span>&lt;/code>&lt;/pre>&lt;/div>&lt;h2 id="shuf">shuf&lt;/h2>
&lt;p>&lt;code>shuf&lt;/code>コマンドを使用すると、入力の各行をランダムにシャッフルして出力する。&lt;/p></description><enclosure url="https://atsum.in/linux/shuf-command/img/thumbnail.png" type="image/png"/></item><item><title>【column -t】コマンド出力をテーブル形式で見やすく整形する</title><link>https://atsum.in/linux/column-command/</link><pubDate>Sun, 04 Jan 2026 20:53:29 +0900</pubDate><guid>https://atsum.in/linux/column-command/</guid><description>&lt;h2 id="コマンド出力を整形してテーブル形式で表示したい">コマンド出力を整形してテーブル形式で表示したい&lt;/h2>
&lt;p>スペースやタブで区切られたコマンドの出力結果を、列が揃ったテーブル形式で見やすく表示したい。&lt;/p>
&lt;p>例えば以下のようなスペース区切りのデータがある。&lt;/p>
&lt;div class="highlight" filename="data.txt">&lt;pre tabindex="0" class="chroma">&lt;code class="language-text" data-lang="text">&lt;span class="line">&lt;span class="cl">Name Age City
&lt;/span>&lt;/span>&lt;span class="line">&lt;span class="cl">Alice 25 Tokyo
&lt;/span>&lt;/span>&lt;span class="line">&lt;span class="cl">Bob 30 Osaka
&lt;/span>&lt;/span>&lt;span class="line">&lt;span class="cl">Charlie 28 Kyoto
&lt;/span>&lt;/span>&lt;/code>&lt;/pre>&lt;/div>&lt;p>このデータの列を揃えて見やすく表示したい。&lt;/p></description><enclosure url="https://atsum.in/linux/column-command/img/thumbnail.png" type="image/png"/></item><item><title>【uniq -c】uniqコマンドで重複行数をカウントする</title><link>https://atsum.in/linux/uniq-count/</link><pubDate>Sun, 04 Jan 2026 19:58:06 +0900</pubDate><guid>https://atsum.in/linux/uniq-count/</guid><description>&lt;h2 id="重複行数をカウント">重複行数をカウント&lt;/h2>
&lt;p>&lt;code>uniq&lt;/code>コマンドの&lt;code>-c&lt;/code>オプションを使用すると、連続する重複行を削除しつつ各行の重複数をカウントできる。&lt;/p>
&lt;div class="highlight">&lt;pre tabindex="0" class="chroma">&lt;code class="language-bash" data-lang="bash">&lt;span class="line">&lt;span class="cl">$ cat sample.txt
&lt;/span>&lt;/span>&lt;span class="line">&lt;span class="cl">apple
&lt;/span>&lt;/span>&lt;span class="line">&lt;span class="cl">apple
&lt;/span>&lt;/span>&lt;span class="line">&lt;span class="cl">banana
&lt;/span>&lt;/span>&lt;span class="line">&lt;span class="cl">banana
&lt;/span>&lt;/span>&lt;span class="line">&lt;span class="cl">banana
&lt;/span>&lt;/span>&lt;span class="line">&lt;span class="cl">banana
&lt;/span>&lt;/span>&lt;span class="line">&lt;span class="cl">orange
&lt;/span>&lt;/span>&lt;span class="line">&lt;span class="cl">apple
&lt;/span>&lt;/span>&lt;span class="line">&lt;span class="cl">$ uniq -c sample.txt
&lt;/span>&lt;/span>&lt;span class="line">&lt;span class="cl"> &lt;span class="m">2&lt;/span> apple
&lt;/span>&lt;/span>&lt;span class="line">&lt;span class="cl"> &lt;span class="m">4&lt;/span> banana
&lt;/span>&lt;/span>&lt;span class="line">&lt;span class="cl"> &lt;span class="m">1&lt;/span> orange
&lt;/span>&lt;/span>&lt;span class="line">&lt;span class="cl"> &lt;span class="m">1&lt;/span> apple
&lt;/span>&lt;/span>&lt;/code>&lt;/pre>&lt;/div>&lt;p>連続しないと重複行はカウントされないため、全体での重複数をカウントしたい場合は、事前に&lt;code>sort&lt;/code>コマンドでソートする必要がある。&lt;/p></description><enclosure url="https://atsum.in/linux/uniq-count/img/thumbnail.png" type="image/png"/></item><item><title>【VSCode】vscodevimで日本語入力がおかしくなる問題の対処法</title><link>https://atsum.in/vscode/vim-edit-context/</link><pubDate>Fri, 02 Jan 2026 21:24:28 +0900</pubDate><guid>https://atsum.in/vscode/vim-edit-context/</guid><description>&lt;h2 id="vscodevimで日本語入力がおかしくなる場合の設定">vscodevimで日本語入力がおかしくなる場合の設定&lt;/h2>
&lt;p>vscodevim拡張機能を使用していると、日本語入力のうまく動作しない場合がある。&lt;br>
そのような場合は&lt;code>settings.json&lt;/code>に&lt;code>&amp;quot;editor.editContext&amp;quot;: false&lt;/code>を追加する。&lt;/p></description><enclosure url="https://atsum.in/vscode/vim-edit-context/img/thumbnail.png" type="image/png"/></item><item><title>【VSCode】GitHub CLIで作成するPull RequestのDescriptionを書く</title><link>https://atsum.in/vscode/create-pr/</link><pubDate>Fri, 02 Jan 2026 14:25:36 +0900</pubDate><guid>https://atsum.in/vscode/create-pr/</guid><description>&lt;h2 id="github-cliで作るpull-requestのdescriptionをvisual-studio-codeで書きたい">GitHub CLIで作るPull RequestのDescriptionをVisual Studio Codeで書きたい&lt;/h2>
&lt;p>普段エディタとしてVisual Studio Codeを使っているので、Pull RequestのDescriptionもVisual Studio Codeで書きたい。&lt;br>
Visual Studio Codeを使えばGitHub CopilotによるサポートやVisual Studio Codeの拡張機能も利用できる。&lt;/p></description><enclosure url="https://atsum.in/vscode/create-pr/img/thumbnail.png" type="image/png"/></item><item><title>【Go言語】logrusorgru/auroraでCLIアプリの出力に色をつける</title><link>https://atsum.in/golang/aurora-ansi-colors/</link><pubDate>Thu, 01 Jan 2026 20:29:08 +0900</pubDate><guid>https://atsum.in/golang/aurora-ansi-colors/</guid><description>&lt;h2 id="logrusorgruaurora">logrusorgru/aurora&lt;/h2>
&lt;p>&lt;a href="https://github.com/logrusorgru/aurora" target="_blank" rel="noopener nofollow">logrusorgru/aurora&lt;/a>
は、Go言語のターミナル出力に色やスタイルを追加するANSIカラーライブラリ。&lt;/p>
&lt;p>&lt;code>Printf&lt;/code>や&lt;code>Sprintf&lt;/code>との互換性があり、メソッドチェーンで複数のスタイルを組み合わせられる。&lt;/p></description><enclosure url="https://atsum.in/golang/aurora-ansi-colors/img/thumbnail.png" type="image/png"/></item><item><title>【Go言語】goreleaser-actionアクションで作成するGitHubのReleaseの説明文をPull Requestごとでまとめる</title><link>https://atsum.in/golang/goreleaser-pr-description/</link><pubDate>Thu, 01 Jan 2026 15:58:28 +0900</pubDate><guid>https://atsum.in/golang/goreleaser-pr-description/</guid><description>&lt;h2 id="goreleaserで作成したgithubのrelease">GoReleaserで作成したGitHubのRelease&lt;/h2>
&lt;p>GitHub Actionsで&lt;a href="https://github.com/goreleaser/goreleaser-action" target="_blank" rel="noopener nofollow">goreleaser-action&lt;/a>
を使うとGoReleaserでGitHubのRelease作成できる。&lt;/p>
&lt;div class="highlight">&lt;pre tabindex="0" class="chroma">&lt;code class="language-yaml" data-lang="yaml">&lt;span class="line">&lt;span class="cl">&lt;span class="nt">jobs&lt;/span>&lt;span class="p">:&lt;/span>&lt;span class="w">
&lt;/span>&lt;/span>&lt;/span>&lt;span class="line">&lt;span class="cl">&lt;span class="w"> &lt;/span>&lt;span class="nt">goreleaser&lt;/span>&lt;span class="p">:&lt;/span>&lt;span class="w">
&lt;/span>&lt;/span>&lt;/span>&lt;span class="line">&lt;span class="cl">&lt;span class="w"> &lt;/span>&lt;span class="nt">runs-on&lt;/span>&lt;span class="p">:&lt;/span>&lt;span class="w"> &lt;/span>&lt;span class="l">ubuntu-latest&lt;/span>&lt;span class="w">
&lt;/span>&lt;/span>&lt;/span>&lt;span class="line">&lt;span class="cl">&lt;span class="w"> &lt;/span>&lt;span class="nt">steps&lt;/span>&lt;span class="p">:&lt;/span>&lt;span class="w">
&lt;/span>&lt;/span>&lt;/span>&lt;span class="line">&lt;span class="cl">&lt;span class="w"> &lt;/span>&lt;span class="l">(略)&lt;/span>&lt;span class="w">
&lt;/span>&lt;/span>&lt;/span>&lt;span class="line">&lt;span class="cl">&lt;span class="w"> &lt;/span>- &lt;span class="nt">name&lt;/span>&lt;span class="p">:&lt;/span>&lt;span class="w"> &lt;/span>&lt;span class="l">Run GoReleaser&lt;/span>&lt;span class="w">
&lt;/span>&lt;/span>&lt;/span>&lt;span class="line">&lt;span class="cl">&lt;span class="w"> &lt;/span>&lt;span class="nt">uses&lt;/span>&lt;span class="p">:&lt;/span>&lt;span class="w"> &lt;/span>&lt;span class="l">goreleaser/goreleaser-action@v6&lt;/span>&lt;span class="w">
&lt;/span>&lt;/span>&lt;/span>&lt;span class="line">&lt;span class="cl">&lt;span class="w"> &lt;/span>&lt;span class="nt">with&lt;/span>&lt;span class="p">:&lt;/span>&lt;span class="w">
&lt;/span>&lt;/span>&lt;/span>&lt;span class="line">&lt;span class="cl">&lt;span class="w"> &lt;/span>&lt;span class="nt">version&lt;/span>&lt;span class="p">:&lt;/span>&lt;span class="w"> &lt;/span>&lt;span class="l">latest&lt;/span>&lt;span class="w">
&lt;/span>&lt;/span>&lt;/span>&lt;span class="line">&lt;span class="cl">&lt;span class="w"> &lt;/span>&lt;span class="nt">args&lt;/span>&lt;span class="p">:&lt;/span>&lt;span class="w"> &lt;/span>&lt;span class="l">release --clean&lt;/span>&lt;span class="w">
&lt;/span>&lt;/span>&lt;/span>&lt;span class="line">&lt;span class="cl">&lt;span class="w"> &lt;/span>&lt;span class="nt">env&lt;/span>&lt;span class="p">:&lt;/span>&lt;span class="w">
&lt;/span>&lt;/span>&lt;/span>&lt;span class="line">&lt;span class="cl">&lt;span class="w"> &lt;/span>&lt;span class="nt">GITHUB_TOKEN&lt;/span>&lt;span class="p">:&lt;/span>&lt;span class="w"> &lt;/span>&lt;span class="l">${{ secrets.GITHUB_TOKEN }}&lt;/span>&lt;span class="w">
&lt;/span>&lt;/span>&lt;/span>&lt;/code>&lt;/pre>&lt;/div>&lt;p>上記ワークフローで作成されるDescriptionに記載されるのはコミットの一覧になる。&lt;br>
この一覧をPull Requestごとの説明文に変更したい。&lt;/p></description><enclosure url="https://atsum.in/golang/goreleaser-pr-description/img/thumbnail.png" type="image/png"/></item><item><title>【Go言語】成果物のバージョン情報をdebug.ReadBuildInfo()で出力する</title><link>https://atsum.in/golang/show-version/</link><pubDate>Thu, 01 Jan 2026 14:57:59 +0900</pubDate><guid>https://atsum.in/golang/show-version/</guid><description>&lt;h2 id="go-build-の成果物のバージョン情報を取得する">go build の成果物のバージョン情報を取得する&lt;/h2>
&lt;p>&lt;code>go build&lt;/code>でビルドしたバイナリのバージョン情報を取得するには、&lt;code>runtime/debug&lt;/code>パッケージの&lt;code>ReadBuildInfo()&lt;/code>関数を使用する。&lt;/p></description><enclosure url="https://atsum.in/golang/show-version/img/thumbnail.png" type="image/png"/></item><item><title>【PostgreSQL】TOASTテーブルの仕組みとサイズ確認方法</title><link>https://atsum.in/database/postgresql-toast/</link><pubDate>Wed, 31 Dec 2025 16:16:02 +0900</pubDate><guid>https://atsum.in/database/postgresql-toast/</guid><description>&lt;h2 id="toastとは">TOASTとは&lt;/h2>
&lt;p>PostgreSQLのTOAST（The Oversized-Attribute Storage Technique）は、大きなデータを効率的に格納するための仕組み。PostgreSQLではテーブルの行サイズが約8KBに制限されているため、大きなデータはTOASTテーブルと呼ばれる別のテーブルに自動的に分割して格納される。&lt;/p></description><enclosure url="https://atsum.in/database/postgresql-toast/img/thumbnail.png" type="image/png"/></item><item><title>Github Cli ExtensionをGitHubでリリースする</title><link>https://atsum.in/golang/release-github-cli-extension/</link><pubDate>Mon, 29 Dec 2025 21:39:51 +0900</pubDate><guid>https://atsum.in/golang/release-github-cli-extension/</guid><description>&lt;h2 id="github-cli-extensionのプロジェクト">GitHub CLI Extensionのプロジェクト&lt;/h2>
&lt;p>GitHub CLI ExtensionのGoプロジェクトを作成する方法については、&lt;a href="../create-github-cli-plugin/">GitHub CLI Extension を Go 言語で作る&lt;/a>を参照。&lt;/p>
&lt;p>上記記事通りに&lt;code>gh extension create&lt;/code>コマンドでプロジェクトを作成すると、GitHub Actionsのワークフローファイルとして&lt;code>.github/workflows/release.yml&lt;/code>が生成される。&lt;/p></description><enclosure url="https://atsum.in/golang/release-github-cli-extension/img/thumbnail.png" type="image/png"/></item><item><title>GitHub CLI Extension を Go 言語で作る</title><link>https://atsum.in/golang/create-github-cli-plugin/</link><pubDate>Mon, 29 Dec 2025 16:37:31 +0900</pubDate><guid>https://atsum.in/golang/create-github-cli-plugin/</guid><description>&lt;h2 id="github-cli-extension">GitHub CLI Extension&lt;/h2>
&lt;p>GitHub CLIは独自のサブコマンドを追加できる。GitHub CLI 2.0から導入され、GitHub CLIのコア機能を拡張できる。&lt;/p>
&lt;p>BashとGoで拡張を作成できるが、ここではGo言語での作成方法を説明する。&lt;/p></description><enclosure url="https://atsum.in/golang/create-github-cli-plugin/img/thumbnail.png" type="image/png"/></item><item><title>【PostgreSQL】各データベースのサイズを確認する</title><link>https://atsum.in/database/postgresql-database-size/</link><pubDate>Wed, 24 Dec 2025 19:27:13 +0900</pubDate><guid>https://atsum.in/database/postgresql-database-size/</guid><description>&lt;h2 id="pg_database_sizeデータベース名">pg_database_size(データベース名)&lt;/h2>
&lt;p>PostgreSQLで各データベースのサイズを確認するには、&lt;code>pg_database_size&lt;/code>関数を使用する。
&lt;code>pg_database_size&lt;/code>関数は、引数にデータベース名を指定し、そのサイズをバイト単位で返す。&lt;/p></description><enclosure url="https://atsum.in/database/postgresql-database-size/img/thumbnail.png" type="image/png"/></item><item><title>【ls -d】ディレクトリ名を指定してディレクトリ自体の情報を表示する</title><link>https://atsum.in/linux/ls-d/</link><pubDate>Sat, 20 Dec 2025 20:05:49 +0900</pubDate><guid>https://atsum.in/linux/ls-d/</guid><description>&lt;h2 id="ls--d">ls -d&lt;/h2>
&lt;p>&lt;code>ls&lt;/code>コマンドでディレクトリ名を指定すると、そのディレクトリ配下のファイルやサブディレクトリが表示される。しかし、ディレクトリ自体の情報を表示したい場合がある。&lt;/p></description><enclosure url="https://atsum.in/linux/ls-d/img/thumbnail.png" type="image/png"/></item><item><title>tarとunzipで特定のファイルだけを抽出する</title><link>https://atsum.in/linux/tar-unzip-specific-files/</link><pubDate>Fri, 19 Dec 2025 19:43:39 +0900</pubDate><guid>https://atsum.in/linux/tar-unzip-specific-files/</guid><description>&lt;h2 id="圧縮ファイルの一部だけを抽出したい">圧縮ファイルの一部だけを抽出したい&lt;/h2>
&lt;p>大きな圧縮ファイルから特定のファイルだけを抽出したい場合がある。全体を展開すると時間がかかったり、不要なファイルがゴミとなったりするため、必要なファイルだけを取り出したい。&lt;/p></description><enclosure url="https://atsum.in/linux/tar-unzip-specific-files/img/thumbnail.png" type="image/png"/></item><item><title>【ClamAV】 許可リストを作る</title><link>https://atsum.in/linux/clamav-allow-list/</link><pubDate>Fri, 19 Dec 2025 16:50:55 +0900</pubDate><guid>https://atsum.in/linux/clamav-allow-list/</guid><description>&lt;h2 id="clamavの許可リストの配置場所">ClamAVの許可リストの配置場所&lt;/h2>
&lt;p>ClamAVでは特定のファイルをスキャン対象から除外できる。&lt;/p>
&lt;p>許可リストは以下のルールで作成する。&lt;/p>
&lt;ul>
&lt;li>配置ディレクトリ: ウイルス定義ファイルが格納されているディレクトリ(通常は&lt;code>/var/lib/clamav&lt;/code>)&lt;/li>
&lt;li>拡張子: &lt;code>.fp&lt;/code>&lt;/li>
&lt;/ul>
&lt;h2 id="許可リストの作成方法">許可リストの作成方法&lt;/h2>
&lt;p>内容は&lt;code>sigtool&lt;/code>コマンドを使って生成する。&lt;/p></description><enclosure url="https://atsum.in/linux/clamav-allow-list/img/thumbnail.png" type="image/png"/></item><item><title>macOSのdateコマンドで次の日付を取得する</title><link>https://atsum.in/mac/next-date/</link><pubDate>Thu, 18 Dec 2025 21:45:20 +0900</pubDate><guid>https://atsum.in/mac/next-date/</guid><description>&lt;h2 id="次の日付を取得する">次の日付を取得する&lt;/h2>
&lt;p>macOSで現在の日付から次の日付を取得するには、&lt;code>date&lt;/code>コマンドを使用して以下のように実行する。&lt;/p>
&lt;div class="highlight">&lt;pre tabindex="0" class="chroma">&lt;code class="language-shell" data-lang="shell">&lt;span class="line">&lt;span class="cl">date -v+1d &lt;span class="s2">&amp;#34;+%Y-%m-%d&amp;#34;&lt;/span>
&lt;/span>&lt;/span>&lt;/code>&lt;/pre>&lt;/div>&lt;p>N日後を取得したい場合は、&lt;code>-v+Nd&lt;/code>のように指定する。&lt;br>
例えば10日後を取得したい場合は以下のように実行する。&lt;/p></description><enclosure url="https://atsum.in/mac/next-date/img/thumbnail.png" type="image/png"/></item><item><title>macOSのdate コマンドで日付文字列とunixタイムスタンプを相互に変換する</title><link>https://atsum.in/mac/date-to-timestamp/</link><pubDate>Wed, 17 Dec 2025 23:08:11 +0900</pubDate><guid>https://atsum.in/mac/date-to-timestamp/</guid><description>&lt;h2 id="日付文字列unixタイムスタンプ">日付文字列→UNIXタイムスタンプ&lt;/h2>
&lt;p>macOSで&lt;code>&amp;quot;2024-06-01 12:34:56&amp;quot;&lt;/code>のような日付文字列をUNIXタイムスタンプに変換するには、&lt;code>date&lt;/code>コマンドを使用して以下のように実行する。&lt;/p></description><enclosure url="https://atsum.in/mac/date-to-timestamp/img/thumbnail.png" type="image/png"/></item><item><title>【LSCOLORS】lsコマンドで表示されるファイル・ディレクトリの色を変更する</title><link>https://atsum.in/linux/lscolors/</link><pubDate>Tue, 16 Dec 2025 23:00:47 +0900</pubDate><guid>https://atsum.in/linux/lscolors/</guid><description>&lt;h2 id="lscolors環境変数">LSCOLORS環境変数&lt;/h2>
&lt;p>BSD版(macOSやFreeBSDなど)の&lt;code>ls&lt;/code>コマンドの&lt;code>ls -G&lt;/code>で表示されるファイル・ディレクトリの色を変更するには、環境変数&lt;code>LSCOLORS&lt;/code>を設定する。&lt;br>
&lt;code>CLICOLOR&lt;/code>環境変数を設定すると、&lt;code>-G&lt;/code>オプションなしでも自動的に色が有効になる。&lt;br>
ターミナルのテーマによってはデフォルトの色が見づらい。その場合は好みの色に変更するとよい。&lt;/p></description><enclosure url="https://atsum.in/linux/lscolors/img/thumbnail.png" type="image/png"/></item><item><title>sortコマンドでhuman readableな数値をソートする</title><link>https://atsum.in/linux/sort-human-numeric/</link><pubDate>Sun, 14 Dec 2025 21:59:02 +0900</pubDate><guid>https://atsum.in/linux/sort-human-numeric/</guid><description>&lt;h2 id="human-readableな数値のソート">human readableな数値のソート&lt;/h2>
&lt;p>K, M, Gなどのsuffixを考慮してhuman readableな数値をソートするには、&lt;code>-h&lt;/code>(&lt;code>--human-numeric-sort&lt;/code>、&lt;code>--sort=human-numeric&lt;/code>)オプションを使用する。&lt;/p></description><enclosure url="https://atsum.in/linux/sort-human-numeric/img/thumbnail.png" type="image/png"/></item><item><title>【GitHub Actions】ジョブの実行をEnvironmentで承認必須にする</title><link>https://atsum.in/linux/github-actions-environments/</link><pubDate>Fri, 12 Dec 2025 11:48:26 +0900</pubDate><guid>https://atsum.in/linux/github-actions-environments/</guid><description>&lt;p>GitHub Actionsのワークフローの特定ジョブの実行を承認必須にできる。&lt;br>
この機能はGitHubのリポジトリ設定のEnvironmentsのRequired reviewers設定を使用する。&lt;br>
本番環境へのデプロイなど、慎重な操作でダブルチェックが欲しいときなどに活用できる。&lt;/p></description><enclosure url="https://atsum.in/linux/github-actions-environments/img/thumbnail.png" type="image/png"/></item><item><title>【Claude Code】許可するコマンドを設定する</title><link>https://atsum.in/linux/claude-code-allow-commands/</link><pubDate>Sun, 07 Dec 2025 11:07:55 +0900</pubDate><guid>https://atsum.in/linux/claude-code-allow-commands/</guid><description>&lt;p>Claude Codeで毎回許可を求められるコマンドを事前に許可する設定方法。
この記事の設定を適用するとClaude Codeが自動的にコマンドを実行するようになる。セキュリティリスクがあるため自己責任で行うこと。&lt;/p></description><enclosure url="https://atsum.in/linux/claude-code-allow-commands/img/thumbnail.png" type="image/png"/></item><item><title>【Gemini CLI】許可するコマンドを設定する</title><link>https://atsum.in/linux/gemini-allow-commands/</link><pubDate>Sun, 07 Dec 2025 09:22:31 +0900</pubDate><guid>https://atsum.in/linux/gemini-allow-commands/</guid><description>&lt;p>Gemini CLIで毎回許可を求められるコマンドを事前に許可する設定方法。
この記事の設定を適用するとGeminiが自動的にコマンドを実行するようになる。セキュリティリスクがあるため自己責任で行うこと。&lt;/p></description><enclosure url="https://atsum.in/linux/gemini-allow-commands/img/thumbnail.png" type="image/png"/></item><item><title>Rocky Linux に dnf (yum) で Redis 6 をインストールする</title><link>https://atsum.in/linux/redis6-rocky/</link><pubDate>Mon, 11 Aug 2025 12:46:59 +0900</pubDate><guid>https://atsum.in/linux/redis6-rocky/</guid><description>&lt;h2 id="rocky-linux-8-に-dnf-でインストールされる-redis-のバージョン">Rocky Linux 8 に dnf でインストールされる Redis のバージョン&lt;/h2>
&lt;p>Rocky Linux 8でインストールできるRedisのバージョンは、デフォルトではRedis 5。&lt;/p>
&lt;div class="highlight">&lt;pre tabindex="0" class="chroma">&lt;code class="language-shell" data-lang="shell">&lt;span class="line">&lt;span class="cl">$ sudo dnf info redis
&lt;/span>&lt;/span>&lt;span class="line">&lt;span class="cl">Available Packages
&lt;/span>&lt;/span>&lt;span class="line">&lt;span class="cl">Name : redis
&lt;/span>&lt;/span>&lt;span class="line">&lt;span class="cl">Version : 5.0.7
&lt;/span>&lt;/span>&lt;span class="line">&lt;span class="cl">...
&lt;/span>&lt;/span>&lt;/code>&lt;/pre>&lt;/div>&lt;p>Redis5のクライアントコマンド(redis-cli)は&lt;code>--tls&lt;/code>オプションをサポートしていない。&lt;br>
そのためTLS接続が必要な場合はRedis 6をインストールする必要がある。&lt;/p></description><enclosure url="https://atsum.in/linux/redis6-rocky/img/thumbnail.png" type="image/png"/></item><item><title>GitHub Actions で Checks を実行できる Pull Request を作成する</title><link>https://atsum.in/linux/github-actions-create-pr/</link><pubDate>Sun, 13 Jul 2025 14:34:53 +0900</pubDate><guid>https://atsum.in/linux/github-actions-create-pr/</guid><description>&lt;h2 id="github-actionsでchecksを実行できるpull-requestを作成する">GitHub ActionsでChecksを実行できるPull Requestを作成する&lt;/h2>
&lt;p>デフォルトの&lt;code>GITHUB_TOKEN&lt;/code>でPull Requestを作成した場合、そのPull RequestにフックするはずのGitHub Actions(Checks)が実行されない。&lt;/p></description><enclosure url="https://atsum.in/linux/github-actions-create-pr/img/thumbnail.png" type="image/png"/></item><item><title>【fluentbit】利用可能なプラグインを調べる</title><link>https://atsum.in/linux/available-fluent-bit-plugins/</link><pubDate>Thu, 19 Jun 2025 21:36:35 +0900</pubDate><guid>https://atsum.in/linux/available-fluent-bit-plugins/</guid><description>&lt;h2 id="fluentbitの利用可能なプラグインの確認方法">fluentbitの利用可能なプラグインの確認方法&lt;/h2>
&lt;p>fluentbitがインストールされているホストで利用可能なプラグインを確認するにはヘルプを確認すればよい。&lt;/p>
&lt;div class="highlight">&lt;pre tabindex="0" class="chroma">&lt;code class="language-shell" data-lang="shell">&lt;span class="line">&lt;span class="cl">$ fluent-bit --help
&lt;/span>&lt;/span>&lt;span class="line">&lt;span class="cl">...
&lt;/span>&lt;/span>&lt;span class="line">&lt;span class="cl">Available Options
&lt;/span>&lt;/span>&lt;span class="line">&lt;span class="cl">...
&lt;/span>&lt;/span>&lt;span class="line">&lt;span class="cl">
&lt;/span>&lt;/span>&lt;span class="line">&lt;span class="cl">Inputs
&lt;/span>&lt;/span>&lt;span class="line">&lt;span class="cl">&lt;span class="o">(&lt;/span>Inputプラグインの一覧...&lt;span class="o">)&lt;/span>
&lt;/span>&lt;/span>&lt;span class="line">&lt;span class="cl">
&lt;/span>&lt;/span>&lt;span class="line">&lt;span class="cl">Processors
&lt;/span>&lt;/span>&lt;span class="line">&lt;span class="cl">&lt;span class="o">(&lt;/span>Processorプラグインの一覧...&lt;span class="o">)&lt;/span>
&lt;/span>&lt;/span>&lt;span class="line">&lt;span class="cl">
&lt;/span>&lt;/span>&lt;span class="line">&lt;span class="cl">Filters
&lt;/span>&lt;/span>&lt;span class="line">&lt;span class="cl">&lt;span class="o">(&lt;/span>Filterプラグインの一覧...&lt;span class="o">)&lt;/span>
&lt;/span>&lt;/span>&lt;span class="line">&lt;span class="cl">
&lt;/span>&lt;/span>&lt;span class="line">&lt;span class="cl">Outputs
&lt;/span>&lt;/span>&lt;span class="line">&lt;span class="cl">&lt;span class="o">(&lt;/span>Outputプラグインの一覧...&lt;span class="o">)&lt;/span>
&lt;/span>&lt;/span>&lt;/code>&lt;/pre>&lt;/div>&lt;p>例えば&lt;code>cloudwatch_logs&lt;/code>プラグインを利用可能か確認するには&lt;code>grep&lt;/code>で確認できる。&lt;/p></description><enclosure url="https://atsum.in/linux/available-fluent-bit-plugins/img/thumbnail.png" type="image/png"/></item><item><title>【tig】カスタムキーバインドを追加してGit操作を効率化する</title><link>https://atsum.in/linux/tig-custom-keybind/</link><pubDate>Wed, 18 Jun 2025 20:29:52 +0900</pubDate><guid>https://atsum.in/linux/tig-custom-keybind/</guid><description>&lt;h2 id="設定ファイルの場所">設定ファイルの場所&lt;/h2>
&lt;p>tigのキーバインド設定は &lt;code>~/.tigrc&lt;/code> ファイルに書く。ファイルが存在しない場合は新規作成する。&lt;/p>
&lt;div class="highlight">&lt;pre tabindex="0" class="chroma">&lt;code class="language-shell" data-lang="shell">&lt;span class="line">&lt;span class="cl">touch ~/.tigrc
&lt;/span>&lt;/span>&lt;/code>&lt;/pre>&lt;/div>&lt;h2 id="キーバインドの基本構文">キーバインドの基本構文&lt;/h2>
&lt;p>キーバインドの設定は以下の構文で記述する：&lt;/p>
&lt;div class="highlight">&lt;pre tabindex="0" class="chroma">&lt;code class="language-text" data-lang="text">&lt;span class="line">&lt;span class="cl">bind [keymap] [key] [action]
&lt;/span>&lt;/span>&lt;/code>&lt;/pre>&lt;/div>&lt;ul>
&lt;li>&lt;code>keymap&lt;/code>: キーが有効な画面（main、diff、logなど）&lt;/li>
&lt;li>&lt;code>key&lt;/code>: 割り当てるキー&lt;/li>
&lt;li>&lt;code>action&lt;/code>: キーに対応するアクション&lt;/li>
&lt;/ul>
&lt;h2 id="よく使うキーマップ">よく使うキーマップ&lt;/h2>
&lt;table class="table table-bordered table-striped">
&lt;thead>
&lt;tr>
&lt;th>キーマップ(画面)&lt;/th>
&lt;th>説明&lt;/th>
&lt;/tr>
&lt;/thead>
&lt;tbody>
&lt;tr>
&lt;td>generic&lt;/td>
&lt;td>全画面で有効&lt;/td>
&lt;/tr>
&lt;tr>
&lt;td>main&lt;/td>
&lt;td>メイン画面（コミット一覧）&lt;/td>
&lt;/tr>
&lt;tr>
&lt;td>diff&lt;/td>
&lt;td>差分の表示画面&lt;/td>
&lt;/tr>
&lt;tr>
&lt;td>log&lt;/td>
&lt;td>ログ表示画面&lt;/td>
&lt;/tr>
&lt;tr>
&lt;td>tree&lt;/td>
&lt;td>ツリー表示画面&lt;/td>
&lt;/tr>
&lt;tr>
&lt;td>blob&lt;/td>
&lt;td>ファイル内容の表示画面&lt;/td>
&lt;/tr>
&lt;tr>
&lt;td>blame&lt;/td>
&lt;td>blame表示画面&lt;/td>
&lt;/tr>
&lt;tr>
&lt;td>refs&lt;/td>
&lt;td>ブランチ・タグ一覧画面&lt;/td>
&lt;/tr>
&lt;tr>
&lt;td>status&lt;/td>
&lt;td>ステータス画面&lt;/td>
&lt;/tr>
&lt;/tbody>
&lt;/table>
&lt;h2 id="変数">変数&lt;/h2>
&lt;p>アクション内で使用できる変数は以下の通り。&lt;/p></description><enclosure url="https://atsum.in/linux/tig-custom-keybind/img/thumbnail.png" type="image/png"/></item><item><title>【Shell Script】グループコマンドで複数コマンド出力をまとめてリダイレクト</title><link>https://atsum.in/linux/shell-script-block-redirect/</link><pubDate>Tue, 17 Jun 2025 19:17:30 +0900</pubDate><guid>https://atsum.in/linux/shell-script-block-redirect/</guid><description>&lt;h2 id="グループコマンドによる標準出力のリダイレクト">グループコマンドによる標準出力のリダイレクト&lt;/h2>
&lt;p>複数のコマンドの出力を同じファイルに出力する場合、グループコマンドの使用が推奨される。&lt;/p>
&lt;p>例えば以下のように2つのコマンドが標準出力に出力する場合：&lt;/p></description><enclosure url="https://atsum.in/linux/shell-script-block-redirect/img/thumbnail.png" type="image/png"/></item><item><title>rsync -a コマンドでも owner と group を実行ユーザーにする</title><link>https://atsum.in/linux/rsync-no-o-g/</link><pubDate>Sun, 15 Jun 2025 23:26:45 +0900</pubDate><guid>https://atsum.in/linux/rsync-no-o-g/</guid><description>&lt;h2 id="rsync--a">rsync -a&lt;/h2>
&lt;p>&lt;code>rsync -a&lt;/code>は&lt;code>-rlptgoD&lt;/code>オプションの省略形で、短く指定できる。&lt;br>
&lt;code>-a&lt;/code>は以下を保存して同期する。&lt;/p>
&lt;ul>
&lt;li>owner（所有者）&lt;/li>
&lt;li>group（グループ）&lt;/li>
&lt;li>パーミッション&lt;/li>
&lt;li>タイムスタンプ&lt;/li>
&lt;/ul>
&lt;p>短く指定できて便利だが、&lt;code>-a&lt;/code>を指定しつつ、owner（所有者）とgroup（グループ）は実行ユーザーにしたい場合がある。&lt;/p></description><enclosure url="https://atsum.in/linux/rsync-no-o-g/img/thumbnail.png" type="image/png"/></item><item><title>【Shell Script】エラーで途中で止まっても実行される後処理を設定する</title><link>https://atsum.in/linux/trap-exit/</link><pubDate>Tue, 10 Jun 2025 20:30:19 +0900</pubDate><guid>https://atsum.in/linux/trap-exit/</guid><description>&lt;h2 id="trap-処理-exit">trap &amp;lsquo;処理&amp;rsquo; EXIT&lt;/h2>
&lt;p>以下の形式で&lt;code>trap&lt;/code>コマンドを使用して、スクリプトの終了時に必ず実行される処理を設定できる。&lt;/p>
&lt;div class="highlight">&lt;pre tabindex="0" class="chroma">&lt;code class="language-shell" data-lang="shell">&lt;span class="line">&lt;span class="cl">&lt;span class="nb">trap&lt;/span> &lt;span class="s1">&amp;#39;処理&amp;#39;&lt;/span> EXIT
&lt;/span>&lt;/span>&lt;/code>&lt;/pre>&lt;/div>&lt;p>例えば、スクリプトの終了時にログを出力する場合は以下のように実行する。&lt;/p></description><enclosure url="https://atsum.in/linux/trap-exit/img/thumbnail.png" type="image/png"/></item><item><title>sedコマンドで指定した行に文字列を挿入・削除する</title><link>https://atsum.in/linux/sed-insert/</link><pubDate>Fri, 06 Jun 2025 21:15:04 +0900</pubDate><guid>https://atsum.in/linux/sed-insert/</guid><description>&lt;h2 id="サンプルファイル">サンプルファイル&lt;/h2>
&lt;p>例として以下のファイルに文字列を挿入・削除する。&lt;/p>
&lt;div class="highlight">&lt;pre tabindex="0" class="chroma">&lt;code class="language-shell" data-lang="shell">&lt;span class="line">&lt;span class="cl">aaa
&lt;/span>&lt;/span>&lt;span class="line">&lt;span class="cl">bbb
&lt;/span>&lt;/span>&lt;span class="line">&lt;span class="cl">ccc
&lt;/span>&lt;/span>&lt;span class="line">&lt;span class="cl">ddd
&lt;/span>&lt;/span>&lt;span class="line">&lt;span class="cl">eee
&lt;/span>&lt;/span>&lt;/code>&lt;/pre>&lt;/div>&lt;h2 id="行数を指定して文字列を挿入する">行数を指定して文字列を挿入する&lt;/h2>
&lt;p>指定した行数の前に文字列を挿入するには、&lt;code>行数i 文字列&lt;/code>の形式で実行する。&lt;/p>
&lt;div class="highlight">&lt;pre tabindex="0" class="chroma">&lt;code class="language-shell" data-lang="shell">&lt;span class="line">&lt;span class="cl">sed &lt;span class="s1">&amp;#39;行数i 文字列&amp;#39;&lt;/span> ファイル名
&lt;/span>&lt;/span>&lt;/code>&lt;/pre>&lt;/div>&lt;p>例えば上記ファイルの3行目に&lt;code>xxx&lt;/code>を挿入する場合は以下のように実行する。&lt;/p></description><enclosure url="https://atsum.in/linux/sed-insert/img/thumbnail.png" type="image/png"/></item><item><title>【PostgreSQL】 データベース名を変更する</title><link>https://atsum.in/database/postgresql-rename-db/</link><pubDate>Sun, 01 Jun 2025 12:46:05 +0900</pubDate><guid>https://atsum.in/database/postgresql-rename-db/</guid><description>&lt;h2 id="データベース名を変更する方法">データベース名を変更する方法&lt;/h2>
&lt;p>PostgreSQLではデータベース名を変更するためには&lt;code>ALTER DATABASE&lt;/code>を使用して以下のように実行する。&lt;/p>
&lt;div class="highlight">&lt;pre tabindex="0" class="chroma">&lt;code class="language-sql" data-lang="sql">&lt;span class="line">&lt;span class="cl">&lt;span class="k">ALTER&lt;/span>&lt;span class="w"> &lt;/span>&lt;span class="k">DATABASE&lt;/span>&lt;span class="w"> &lt;/span>&lt;span class="err">現在の&lt;/span>&lt;span class="n">DB名&lt;/span>&lt;span class="w"> &lt;/span>&lt;span class="k">RENAME&lt;/span>&lt;span class="w"> &lt;/span>&lt;span class="k">TO&lt;/span>&lt;span class="w"> &lt;/span>&lt;span class="err">新しい&lt;/span>&lt;span class="n">DB名&lt;/span>&lt;span class="p">;&lt;/span>&lt;span class="w">
&lt;/span>&lt;/span>&lt;/span>&lt;/code>&lt;/pre>&lt;/div>&lt;p>変更するには変更対象のデータベースに接続しているセッションが存在しない状態で実行する必要がある。&lt;br>
すべてのセッションの接続を切断した上で実行する。&lt;/p></description><enclosure url="https://atsum.in/database/postgresql-rename-db/img/thumbnail.png" type="image/png"/></item><item><title>【PostgreSQL】テーブルとデータベースのoidを取得する方法</title><link>https://atsum.in/database/postgresql-oid/</link><pubDate>Sun, 01 Jun 2025 10:21:34 +0900</pubDate><guid>https://atsum.in/database/postgresql-oid/</guid><description>&lt;h2 id="oid2nameコマンドでoidを取得する">oid2nameコマンドでoidを取得する&lt;/h2>
&lt;p>PostgreSQLの&lt;code>oid2name&lt;/code>コマンドを使用してテーブルやデータベースのoidを取得できる。&lt;/p>
&lt;h3 id="dbの一覧">DBの一覧&lt;/h3>
&lt;p>DBを指定せずに&lt;code>oid2name&lt;/code>を実行すると、全てのデータベースの一覧が表示される。&lt;/p></description><enclosure url="https://atsum.in/database/postgresql-oid/img/thumbnail.png" type="image/png"/></item><item><title>コマンドでパスワードを生成する</title><link>https://atsum.in/linux/generate-password/</link><pubDate>Sat, 31 May 2025 21:13:44 +0900</pubDate><guid>https://atsum.in/linux/generate-password/</guid><description>&lt;h2 id="devurandom-を使ったパスワード生成">/dev/urandom を使ったパスワード生成&lt;/h2>
&lt;p>&lt;code>/dev/urandom&lt;/code>を使用してランダムなバイト列を生成し、ascii文字列のみを抽出してパスワードを生成する。&lt;/p>
&lt;div class="highlight">&lt;pre tabindex="0" class="chroma">&lt;code class="language-shell" data-lang="shell">&lt;span class="line">&lt;span class="cl">$ cat /dev/urandom &lt;span class="p">|&lt;/span> tr -dc &lt;span class="s1">&amp;#39;a-zA-Z0-9!@#$%^&amp;amp;*()_+-=[]{}&amp;lt;&amp;gt;?&amp;#39;&lt;/span> &lt;span class="p">|&lt;/span> fold -w &lt;span class="m">20&lt;/span> &lt;span class="p">|&lt;/span> head -n &lt;span class="m">1&lt;/span>
&lt;/span>&lt;/span>&lt;/code>&lt;/pre>&lt;/div>&lt;p>&lt;code>'a-zA-Z0-9!@#$%^&amp;amp;*()_+-=[]{}&amp;lt;&amp;gt;?'&lt;/code>の部分に使用したい文字セットを指定する。&lt;br>
生成されるパスワードの長さは&lt;code>fold -w&lt;/code>の引数に指定する。上記の場合は20文字のパスワードが生成される。&lt;/p></description><enclosure url="https://atsum.in/linux/generate-password/img/thumbnail.png" type="image/png"/></item><item><title>シェルスクリプトで使えるファイルサイズのみを取得するコマンド</title><link>https://atsum.in/linux/file-size-only/</link><pubDate>Wed, 28 May 2025 23:04:34 +0900</pubDate><guid>https://atsum.in/linux/file-size-only/</guid><description>&lt;h2 id="ls--lでのファイルサイズの取得">ls -lでのファイルサイズの取得&lt;/h2>
&lt;p>&lt;code>ls -l&lt;/code>コマンドでファイルサイズを取得できる。&lt;br>
しかしファイル名やその他の情報も表示されるため処理が必要となる。&lt;/p>
&lt;div class="highlight">&lt;pre tabindex="0" class="chroma">&lt;code class="language-shell" data-lang="shell">&lt;span class="line">&lt;span class="cl">$ ls -l ファイル名
&lt;/span>&lt;/span>&lt;span class="line">&lt;span class="cl">-rw-r--r-- &lt;span class="m">1&lt;/span> user group &lt;span class="m">123456&lt;/span> May &lt;span class="m">28&lt;/span> 23:04 ファイル名
&lt;/span>&lt;/span>&lt;/code>&lt;/pre>&lt;/div>&lt;h2 id="wc--cでのファイルサイズの取得">wc -cでのファイルサイズの取得&lt;/h2>
&lt;p>&lt;code>wc -c&lt;/code>コマンドに標準入力でファイルを流すと、ファイルのバイト数のみを取得できる。&lt;/p></description><enclosure url="https://atsum.in/linux/file-size-only/img/thumbnail.png" type="image/png"/></item><item><title>dateコマンドでファイルの最終更新日時を取得する(date -r)</title><link>https://atsum.in/linux/date-file-last-update/</link><pubDate>Wed, 28 May 2025 22:29:59 +0900</pubDate><guid>https://atsum.in/linux/date-file-last-update/</guid><description>&lt;h2 id="date--r">date -r&lt;/h2>
&lt;p>&lt;code>ls -l&lt;/code>コマンドでファイルの更新日時を取得できる。&lt;br>
しかし更新日時の他に権限やオーナーなどの情報も表示されるため、シェルスクリプトなどで日時だけ欲しい場合などに不便。&lt;/p></description><enclosure url="https://atsum.in/linux/date-file-last-update/img/thumbnail.png" type="image/png"/></item><item><title>jqコマンドでURIエンコード</title><link>https://atsum.in/linux/jq-uri-encoding/</link><pubDate>Tue, 27 May 2025 22:41:16 +0900</pubDate><guid>https://atsum.in/linux/jq-uri-encoding/</guid><description>&lt;h2 id="jqコマンドでuriエンコーディング">jqコマンドでURIエンコーディング&lt;/h2>
&lt;p>以下のように&lt;code>@uri&lt;/code>フィルターを使用してURIエンコードができる。&lt;/p>
&lt;div class="highlight">&lt;pre tabindex="0" class="chroma">&lt;code class="language-shell" data-lang="shell">&lt;span class="line">&lt;span class="cl">$ &lt;span class="nb">echo&lt;/span> -n &lt;span class="s1">&amp;#39;&amp;#34;テスト&amp;#34;&amp;#39;&lt;/span> &lt;span class="p">|&lt;/span> jq &lt;span class="s1">&amp;#39;@uri&amp;#39;&lt;/span>
&lt;/span>&lt;/span>&lt;span class="line">&lt;span class="cl">&lt;span class="s2">&amp;#34;%E3%83%86%E3%82%B9%E3%83%88&amp;#34;&lt;/span>
&lt;/span>&lt;/span>&lt;/code>&lt;/pre>&lt;/div>&lt;p>&lt;code>@uri&lt;/code>フィルターはURIエンコードを行う。&lt;/p>
&lt;h2 id="入力をrawモードで扱う">入力をRawモードで扱う&lt;/h2>
&lt;p>&lt;code>-R&lt;/code>オプションを指定すると、入力がJSON形式ではなくただの文字列(Rawモード)で扱える。&lt;br>
先述のコマンド例ではダブルクオートで囲って無理やりJSONとしているが、Rawモードを使用するとそのまま文字列を扱える。&lt;/p></description><enclosure url="https://atsum.in/linux/jq-uri-encoding/img/thumbnail.png" type="image/png"/></item><item><title>【Shell Script】長い処理を待っている間に別の処理を実行する</title><link>https://atsum.in/linux/concurrent-shell-script/</link><pubDate>Tue, 27 May 2025 13:58:07 +0900</pubDate><guid>https://atsum.in/linux/concurrent-shell-script/</guid><description>&lt;h2 id="シェルスクリプトで長い処理を待っている間に別の処理を実行する">シェルスクリプトで長い処理を待っている間に別の処理を実行する&lt;/h2>
&lt;p>長いコマンドを処理している間に別のコマンドを実行したい場合、以下のようにすればよい。&lt;/p>
&lt;div class="highlight">&lt;pre tabindex="0" class="chroma">&lt;code class="language-shell" data-lang="shell">&lt;span class="line">&lt;span class="cl">long_command &lt;span class="p">&amp;amp;&lt;/span> &lt;span class="c1"># 長い処理をバックグラウンドで実行&lt;/span>
&lt;/span>&lt;/span>&lt;span class="line">&lt;span class="cl">&lt;span class="nv">jobid&lt;/span>&lt;span class="o">=&lt;/span>&lt;span class="nv">$!&lt;/span> &lt;span class="c1"># プロセスIDを取得&lt;/span>
&lt;/span>&lt;/span>&lt;span class="line">&lt;span class="cl">other_command &lt;span class="c1"># 待っている間に別の処理を実行&lt;/span>
&lt;/span>&lt;/span>&lt;span class="line">&lt;span class="cl">&lt;span class="nb">wait&lt;/span> &lt;span class="nv">$jobid&lt;/span> &lt;span class="c1"># 長い処理が終わるのを待つ&lt;/span>
&lt;/span>&lt;/span>&lt;/code>&lt;/pre>&lt;/div>&lt;ol>
&lt;li>&lt;code>&amp;amp;&lt;/code>で長い処理をバックグラウンドで実行し、&lt;code>$!&lt;/code>でそのプロセスIDを取得する。&lt;/li>
&lt;li>&lt;code>other_command&lt;/code>で待っている間に別の処理を実行する。&lt;code>other_command&lt;/code>は&lt;code>&amp;amp;&lt;/code>をつけずに実行しているのでブロックする。&lt;/li>
&lt;li>&lt;code>wait $jobid&lt;/code>で長い処理が終わるのを待つ。&lt;/li>
&lt;/ol>
&lt;h2 id="プロセスidの変数">プロセスIDの変数&lt;/h2>
&lt;p>&lt;code>$!&lt;/code>は直前にバックグラウンドで実行したジョブのプロセスIDを取得するための変数。&lt;br>
後の処理でkillしたり、ジョブの状態を確認したりするために使用できる。&lt;/p></description><enclosure url="https://atsum.in/linux/concurrent-shell-script/img/thumbnail.png" type="image/png"/></item><item><title>【Homebrew】brew installでの自動更新を無効化する</title><link>https://atsum.in/mac/brew-disable-auto-update/</link><pubDate>Tue, 27 May 2025 13:36:28 +0900</pubDate><guid>https://atsum.in/mac/brew-disable-auto-update/</guid><description>&lt;h2 id="homebrew_no_auto_update1">HOMEBREW_NO_AUTO_UPDATE=1&lt;/h2>
&lt;p>&lt;code>brew install&lt;/code>の実行時に、インストールしようとしているパッケージ以外のパッケージも自動的に更新される。&lt;br>
これを無効にするには、環境変数&lt;code>HOMEBREW_NO_AUTO_UPDATE=1&lt;/code>を設定する。&lt;/p></description><enclosure url="https://atsum.in/mac/brew-disable-auto-update/img/thumbnail.png" type="image/png"/></item><item><title>【Linux】ディストリビューションとバージョンを確認する</title><link>https://atsum.in/linux/os-version/</link><pubDate>Sun, 25 May 2025 12:46:11 +0900</pubDate><guid>https://atsum.in/linux/os-version/</guid><description>&lt;p>Linuxのディストリビューション名とバージョンを確認するには&lt;code>/etc/os-release&lt;/code>を見る。ディストリビューションを問わず使えるため、まず確認するファイルとして適している。&lt;/p></description><enclosure url="https://atsum.in/linux/os-version/img/thumbnail.png" type="image/png"/></item><item><title>【VSCode】vscodevimがCopilot Next Edit Suggestions(NES)のキー入力を邪魔する問題を解決する</title><link>https://atsum.in/vscode/nes-with-vscodevim/</link><pubDate>Sun, 23 Feb 2025 08:11:46 +0900</pubDate><guid>https://atsum.in/vscode/nes-with-vscodevim/</guid><description>&lt;h2 id="vscodevimがcopilot-next-edit-suggestionsnesのキー入力を邪魔する">vscodevimがCopilot Next Edit Suggestions(NES)のキー入力を邪魔する&lt;/h2>
&lt;p>GitHub CopilotのNext Edit Suggestionsは次の編集を提案する機能。&lt;/p>
&lt;p>2025年2月現在はpreview段階で以下をsettings.jsonに追加すると有効になる。&lt;/p></description><enclosure url="https://atsum.in/vscode/nes-with-vscodevim/img/thumbnail.png" type="image/png"/></item><item><title>【Docker】docker-composeでホスト名を指定して立ち上げる</title><link>https://atsum.in/linux/docker-compose-hostname/</link><pubDate>Sun, 02 Feb 2025 15:53:23 +0900</pubDate><guid>https://atsum.in/linux/docker-compose-hostname/</guid><description>&lt;h2 id="docker-composeでホスト名を指定して立ち上げる">docker-composeでホスト名を指定して立ち上げる&lt;/h2>
&lt;p>docker-composeでたちあげるコンテナのホスト名を指定するには&lt;code>hostname&lt;/code>プロパティを使う。&lt;/p>
&lt;div class="highlight">&lt;pre tabindex="0" class="chroma">&lt;code class="language-yaml" data-lang="yaml">&lt;span class="line">&lt;span class="cl">&lt;span class="nt">services&lt;/span>&lt;span class="p">:&lt;/span>&lt;span class="w">
&lt;/span>&lt;/span>&lt;/span>&lt;span class="line">&lt;span class="cl">&lt;span class="w"> &lt;/span>&lt;span class="nt">web&lt;/span>&lt;span class="p">:&lt;/span>&lt;span class="w">
&lt;/span>&lt;/span>&lt;/span>&lt;span class="line">&lt;span class="cl">&lt;span class="w"> &lt;/span>&lt;span class="nt">image&lt;/span>&lt;span class="p">:&lt;/span>&lt;span class="w"> &lt;/span>&lt;span class="l">rockylinux:9.3&lt;/span>&lt;span class="w">
&lt;/span>&lt;/span>&lt;/span>&lt;span class="line">&lt;span class="cl">&lt;span class="w"> &lt;/span>&lt;span class="nt">command&lt;/span>&lt;span class="p">:&lt;/span>&lt;span class="w"> &lt;/span>&lt;span class="l">tail -f /dev/null&lt;/span>&lt;span class="w">
&lt;/span>&lt;/span>&lt;/span>&lt;span class="line">&lt;span class="cl">&lt;span class="w"> &lt;/span>&lt;span class="nt">hostname&lt;/span>&lt;span class="p">:&lt;/span>&lt;span class="w"> &lt;/span>&lt;span class="l">ホスト名&lt;/span>&lt;span class="w">
&lt;/span>&lt;/span>&lt;/span>&lt;/code>&lt;/pre>&lt;/div>&lt;h2 id="例">例&lt;/h2>
&lt;p>例えば以下のように&lt;code>hostname&lt;/code>プロパティを指定する。&lt;/p></description><enclosure url="https://atsum.in/linux/docker-compose-hostname/img/thumbnail.png" type="image/png"/></item><item><title>【Terraform】removedブロックでリソースを破棄せずにtfstateからのみ削除する</title><link>https://atsum.in/terraform/removed-block/</link><pubDate>Mon, 20 Jan 2025 19:46:23 +0900</pubDate><guid>https://atsum.in/terraform/removed-block/</guid><description>&lt;h2 id="tfstateからのみ削除する">tfstateからのみ削除する&lt;/h2>
&lt;p>Terraformでリソースを破棄せずにtfstateからのみ削除するには&lt;code>removed&lt;/code>ブロックのlifecycle設定を使う。&lt;/p>
&lt;div class="highlight">&lt;pre tabindex="0" class="chroma">&lt;code class="language-hcl" data-lang="hcl">&lt;span class="line">&lt;span class="cl">&lt;span class="k">removed&lt;/span> {
&lt;/span>&lt;/span>&lt;span class="line">&lt;span class="cl">&lt;span class="n"> from&lt;/span> &lt;span class="o">=&lt;/span> &lt;span class="k">リソース&lt;/span>
&lt;/span>&lt;/span>&lt;span class="line">&lt;span class="cl"> &lt;span class="k">lifecycle&lt;/span> {
&lt;/span>&lt;/span>&lt;span class="line">&lt;span class="cl">&lt;span class="n"> destroy&lt;/span> &lt;span class="o">=&lt;/span> &lt;span class="kt">false&lt;/span>
&lt;/span>&lt;/span>&lt;span class="line">&lt;span class="cl"> }
&lt;/span>&lt;/span>&lt;span class="line">&lt;span class="cl">}
&lt;/span>&lt;/span>&lt;/code>&lt;/pre>&lt;/div>&lt;p>ポイントは &lt;code>lifecycle { destroy = false }&lt;/code> を指定すること。&lt;br>
この指定により実際のリソースは削除されず、tfstateからのみ削除される。&lt;/p></description><enclosure url="https://atsum.in/terraform/removed-block/img/thumbnail.png" type="image/png"/></item><item><title>【Terraform】import ブロックで既存リソースを取り込む</title><link>https://atsum.in/terraform/import-block/</link><pubDate>Sat, 18 Jan 2025 21:37:42 +0900</pubDate><guid>https://atsum.in/terraform/import-block/</guid><description>&lt;h2 id="importブロック">importブロック&lt;/h2>
&lt;p>Terraformのimportブロックは既存のリソースをTerraformの管理下に取り込むための機能。&lt;br>
&lt;code>terraform import&lt;/code>コマンドでも同様にリソースを取り込めるが、importブロックを使うとコードで記述できる。&lt;br>
そのためバージョン管理化でインポートした事実を残せたり、コードレビューしたりできる。&lt;/p></description><enclosure url="https://atsum.in/terraform/import-block/img/thumbnail.png" type="image/png"/></item><item><title>【Terraform】terraform_remote_stateでtfstateを分割する</title><link>https://atsum.in/terraform/terraform-remote-state/</link><pubDate>Mon, 13 Jan 2025 13:36:39 +0900</pubDate><guid>https://atsum.in/terraform/terraform-remote-state/</guid><description>&lt;h2 id="tfstateを分割したい">tfstateを分割したい&lt;/h2>
&lt;p>Terraformはリソース数が多くなってくるとplanやapplyの実行時間が長くなってくる。&lt;br>
planやapplyの実行時間が長くなると手元での確認やCI/CDに時間がかかるようになり、開発効率や開発体験が悪くなる。&lt;br>
そのためtfstateを分割してそれぞれのtfstateを小さくし、planやapplyの実行時間を短くしたい。&lt;/p></description><enclosure url="https://atsum.in/terraform/terraform-remote-state/img/thumbnail.png" type="image/png"/></item><item><title>findコマンドだけで空フォルダを一括削除する(find -empty -deleteオプション)</title><link>https://atsum.in/linux/find-empty-delete/</link><pubDate>Fri, 10 Jan 2025 08:06:08 +0900</pubDate><guid>https://atsum.in/linux/find-empty-delete/</guid><description>&lt;h2 id="findコマンドだけで空フォルダを一括削除-empty--deleteオプション">findコマンドだけで空フォルダを一括削除(-empty -deleteオプション)&lt;/h2>
&lt;p>&lt;code>find&lt;/code>コマンドを使って空フォルダを一括削除するには以下のようにする。&lt;/p>
&lt;div class="highlight">&lt;pre tabindex="0" class="chroma">&lt;code class="language-shell" data-lang="shell">&lt;span class="line">&lt;span class="cl">find /path/to/dir -type d -empty -delete
&lt;/span>&lt;/span>&lt;/code>&lt;/pre>&lt;/div>&lt;p>オプションの意味は以下の通り。&lt;/p>
&lt;ul>
&lt;li>&lt;code>-type d&lt;/code> : ディレクトリを対象にする&lt;/li>
&lt;li>&lt;code>-empty&lt;/code> : 空のディレクトリを対象にする&lt;/li>
&lt;li>&lt;code>-delete&lt;/code> : マッチしたディレクトリを削除する&lt;/li>
&lt;/ul>
&lt;p>上記コマンドは&lt;code>/path/to/dir&lt;/code>以下の空のディレクトリを再帰的に削除する。&lt;/p></description><enclosure url="https://atsum.in/linux/find-empty-delete/img/thumbnail.png" type="image/png"/></item><item><title>【Terraform】JSONを構文エラーをplanの段階で検出したい(jsonencode)</title><link>https://atsum.in/terraform/jsonencode/</link><pubDate>Fri, 03 Jan 2025 16:43:32 +0900</pubDate><guid>https://atsum.in/terraform/jsonencode/</guid><description>&lt;h2 id="json文字列を必要とする引数">JSON文字列を必要とする引数&lt;/h2>
&lt;p>Terraformのリソースやデータソースの引数にはJSON文字列の指定必要とする場合がある。&lt;/p>
&lt;p>例えば&lt;code>aws_iam_policy&lt;/code>リソースの&lt;code>policy&lt;/code>引数には以下のようなJSON文字列を指定する。&lt;/p></description><enclosure url="https://atsum.in/terraform/jsonencode/img/thumbnail.png" type="image/png"/></item><item><title>【Terraform】map関数っぽい表現(for式)</title><link>https://atsum.in/terraform/map-function/</link><pubDate>Fri, 03 Jan 2025 14:10:58 +0900</pubDate><guid>https://atsum.in/terraform/map-function/</guid><description>&lt;h2 id="map関数っぽい表現">map関数っぽい表現&lt;/h2>
&lt;p>Terraformでlistやmapのようなコレクションのそれぞれの要素を変換した新たなlistやmapを作るには&lt;code>for&lt;/code>式を使う。&lt;/p>
&lt;h3 id="list--list-の場合">list → list の場合&lt;/h3>
&lt;p>list型の値をlist型に変換する場合は以下のように書く。&lt;/p></description><enclosure url="https://atsum.in/terraform/map-function/img/thumbnail.png" type="image/png"/></item><item><title>【Android】エミュレータのアニメーションを無効にして自動テストによるスクリーンショットをきれいに撮る</title><link>https://atsum.in/android/turn-animation-off/</link><pubDate>Sun, 22 Dec 2024 15:42:17 +0900</pubDate><guid>https://atsum.in/android/turn-animation-off/</guid><description>&lt;h2 id="自動テストで撮ったスクリーンショットが薄い">自動テストで撮ったスクリーンショットが薄い&lt;/h2>
&lt;p>Androidアプリの自動テストで画面キャプチャを取ると画面遷移の直後などで以下のように薄い画像を取得する場合がある。&lt;br>
これは画面遷移の直後でアニメーションの終了前にキャプチャを取得しているため。&lt;/p></description><enclosure url="https://atsum.in/android/turn-animation-off/img/thumbnail.png" type="image/png"/></item><item><title>【PostgreSQL】ページャーを無効にして大量件数の結果でも一度に出力する</title><link>https://atsum.in/database/psql-pager-off/</link><pubDate>Sun, 15 Dec 2024 13:05:51 +0900</pubDate><guid>https://atsum.in/database/psql-pager-off/</guid><description>&lt;h2 id="psqlでページャーが有効になっている場合">psqlでページャーが有効になっている場合&lt;/h2>
&lt;p>psqlコマンドでクエリを実行すると、結果が多い場合にページャーが有効になる。&lt;/p>
&lt;p>例えば以下のように&lt;code>-c&lt;/code>オプションで結果が多いクエリを実行する。&lt;/p>
&lt;div class="highlight">&lt;pre tabindex="0" class="chroma">&lt;code class="language-shell" data-lang="shell">&lt;span class="line">&lt;span class="cl">$ psql -d testdb -c &lt;span class="s2">&amp;#34;SELECT id FROM users;&amp;#34;&lt;/span>
&lt;/span>&lt;/span>&lt;span class="line">&lt;span class="cl"> id
&lt;/span>&lt;/span>&lt;span class="line">&lt;span class="cl">-----
&lt;/span>&lt;/span>&lt;span class="line">&lt;span class="cl"> &lt;span class="m">8&lt;/span>
&lt;/span>&lt;/span>&lt;span class="line">&lt;span class="cl"> &lt;span class="m">9&lt;/span>
&lt;/span>&lt;/span>&lt;span class="line">&lt;span class="cl"> &lt;span class="m">10&lt;/span>
&lt;/span>&lt;/span>&lt;span class="line">&lt;span class="cl"> &lt;span class="m">11&lt;/span>
&lt;/span>&lt;/span>&lt;span class="line">&lt;span class="cl"> &lt;span class="m">12&lt;/span>
&lt;/span>&lt;/span>&lt;span class="line">&lt;span class="cl"> &lt;span class="m">13&lt;/span>
&lt;/span>&lt;/span>&lt;span class="line">&lt;span class="cl"> &lt;span class="m">14&lt;/span>
&lt;/span>&lt;/span>&lt;span class="line">&lt;span class="cl"> &lt;span class="m">15&lt;/span>
&lt;/span>&lt;/span>&lt;span class="line">&lt;span class="cl"> &lt;span class="m">16&lt;/span>
&lt;/span>&lt;/span>&lt;span class="line">&lt;span class="cl"> &lt;span class="m">17&lt;/span>
&lt;/span>&lt;/span>&lt;span class="line">&lt;span class="cl"> &lt;span class="m">18&lt;/span>
&lt;/span>&lt;/span>&lt;span class="line">&lt;span class="cl"> &lt;span class="m">19&lt;/span>
&lt;/span>&lt;/span>&lt;span class="line">&lt;span class="cl"> &lt;span class="m">20&lt;/span>
&lt;/span>&lt;/span>&lt;span class="line">&lt;span class="cl"> &lt;span class="m">21&lt;/span>
&lt;/span>&lt;/span>&lt;span class="line">&lt;span class="cl"> &lt;span class="m">22&lt;/span>
&lt;/span>&lt;/span>&lt;span class="line">&lt;span class="cl"> &lt;span class="m">23&lt;/span>
&lt;/span>&lt;/span>&lt;span class="line">&lt;span class="cl"> &lt;span class="m">24&lt;/span>
&lt;/span>&lt;/span>&lt;span class="line">&lt;span class="cl"> &lt;span class="m">25&lt;/span>
&lt;/span>&lt;/span>&lt;span class="line">&lt;span class="cl"> &lt;span class="m">26&lt;/span>
&lt;/span>&lt;/span>&lt;span class="line">&lt;span class="cl">:
&lt;/span>&lt;/span>&lt;/code>&lt;/pre>&lt;/div>&lt;p>以上のようにページャーが有効になっており、末尾に&lt;code>:&lt;/code>が表示される。&lt;/p></description><enclosure url="https://atsum.in/database/psql-pager-off/img/thumbnail.png" type="image/png"/></item><item><title>【PostgreSQL】指定したテーブルのインデックスを確認する</title><link>https://atsum.in/database/postgresql-show-index/</link><pubDate>Sun, 15 Dec 2024 09:54:18 +0900</pubDate><guid>https://atsum.in/database/postgresql-show-index/</guid><description>&lt;h2 id="sqlでインデックスを確認する">SQLでインデックスを確認する&lt;/h2>
&lt;p>PostgreSQLで指定したテーブルのインデックスを確認するには&lt;code>pg_indexes&lt;/code>システムカタログを&lt;code>SELECT&lt;/code>する。&lt;/p>
&lt;div class="highlight">&lt;pre tabindex="0" class="chroma">&lt;code class="language-sql" data-lang="sql">&lt;span class="line">&lt;span class="cl">&lt;span class="k">SELECT&lt;/span>&lt;span class="w"> &lt;/span>&lt;span class="o">*&lt;/span>&lt;span class="w"> &lt;/span>&lt;span class="k">FROM&lt;/span>&lt;span class="w"> &lt;/span>&lt;span class="n">pg_indexes&lt;/span>&lt;span class="w"> &lt;/span>&lt;span class="k">WHERE&lt;/span>&lt;span class="w"> &lt;/span>&lt;span class="n">tablename&lt;/span>&lt;span class="w"> &lt;/span>&lt;span class="o">=&lt;/span>&lt;span class="w"> &lt;/span>&lt;span class="s1">&amp;#39;テーブル名&amp;#39;&lt;/span>&lt;span class="p">;&lt;/span>&lt;span class="w">
&lt;/span>&lt;/span>&lt;/span>&lt;/code>&lt;/pre>&lt;/div>&lt;p>例えば&lt;code>users&lt;/code>テーブルのインデックスを確認するには以下のように実行する。&lt;/p></description><enclosure url="https://atsum.in/database/postgresql-show-index/img/thumbnail.png" type="image/png"/></item><item><title>【unzip】大きなzipファイルをunzipで展開する</title><link>https://atsum.in/linux/unzip-large-file/</link><pubDate>Fri, 13 Dec 2024 17:27:50 +0900</pubDate><guid>https://atsum.in/linux/unzip-large-file/</guid><description>&lt;h2 id="注意">注意&lt;/h2>
&lt;aside class="info">
&lt;i class="fas fa-info-circle">&lt;/i>
&lt;span class="info-body">展開後サイズが4GB以上のzipファイルをunzipファイルで展開できないのはzip bombの可能性を考慮しているため。&lt;br>
以降のコマンドの実行は自分で作ったzipファイルであるなど信頼できる場合に限ること。&lt;/span>
&lt;/aside>
&lt;h2 id="大きなzipファイルをunzipで展開した場合のエラー">大きなzipファイルをunzipで展開した場合のエラー&lt;/h2>
&lt;p>展開後サイズが4GB以上のzipファイルをunzipファイルで展開しようとすると以下のようなエラーが発生する。&lt;/p></description><enclosure url="https://atsum.in/linux/unzip-large-file/img/thumbnail.png" type="image/png"/></item><item><title>【Android】コマンドでApp Bundle(aab)をapksに変換してエミュレーターにインストールする(bundletool)</title><link>https://atsum.in/android/bundletool/</link><pubDate>Fri, 13 Dec 2024 16:51:16 +0900</pubDate><guid>https://atsum.in/android/bundletool/</guid><description>&lt;h2 id="bundletool">bundletool&lt;/h2>
&lt;p>&lt;a href="https://developer.android.com/tools/bundletool?hl=ja" target="_blank" rel="noopener nofollow">bundletool&lt;/a>
はApp Bundle(aab)ファイルを.apksファイルへ変換できる。&lt;br>
さらにエミュレーターや接続された端末に.apksファイルをインストールできる。&lt;/p></description><enclosure url="https://atsum.in/android/bundletool/img/thumbnail.png" type="image/png"/></item><item><title>Android Studioで動作しているgradleタスクをコマンドで停止する(Timeout waiting to lock artifact cache...)</title><link>https://atsum.in/android/gradlew-stop/</link><pubDate>Thu, 12 Dec 2024 21:38:17 +0900</pubDate><guid>https://atsum.in/android/gradlew-stop/</guid><description>&lt;h2 id="gradleタスクを停止するコマンド">gradleタスクを停止するコマンド&lt;/h2>
&lt;p>Androidプロジェクトでgradleタスクを停止するには&lt;code>gradlew&lt;/code>コマンドに&lt;code>--stop&lt;/code>オプションを指定する。&lt;/p>
&lt;div class="highlight">&lt;pre tabindex="0" class="chroma">&lt;code class="language-shell" data-lang="shell">&lt;span class="line">&lt;span class="cl">$ ./gradlew --stop
&lt;/span>&lt;/span>&lt;/code>&lt;/pre>&lt;/div>&lt;h2 id="android-studio-で実行中にコマンドでgradleを実行したときに起きるエラー">Android Studio で実行中にコマンドでgradleを実行したときに起きるエラー&lt;/h2>
&lt;p>Android Studioでgradleタスクを実行中にコマンドでgradleを実行すると以下のようなエラーが発生する。&lt;/p></description><enclosure url="https://atsum.in/android/gradlew-stop/img/thumbnail.png" type="image/png"/></item><item><title>【Android】コマンドでアプリ一覧表示とアンインストールする</title><link>https://atsum.in/android/cli-installed-apps/</link><pubDate>Sun, 08 Dec 2024 23:47:03 +0900</pubDate><guid>https://atsum.in/android/cli-installed-apps/</guid><description>&lt;h2 id="コマンドでインストールされちるアプリケーションの一覧を取得する">コマンドでインストールされちるアプリケーションの一覧を取得する&lt;/h2>
&lt;p>Androidの端末やエミュレータでインストールされているアプリの一覧を取得するには&lt;code>adb shell&lt;/code>コマンドを使って以下のように実行する。&lt;/p>
&lt;div class="highlight">&lt;pre tabindex="0" class="chroma">&lt;code class="language-shell" data-lang="shell">&lt;span class="line">&lt;span class="cl">$ adb shell pm list packages
&lt;/span>&lt;/span>&lt;span class="line">&lt;span class="cl">package:com.google.android.networkstack.tethering
&lt;/span>&lt;/span>&lt;span class="line">&lt;span class="cl">package:com.android.cts.priv.ctsshim
&lt;/span>&lt;/span>&lt;span class="line">&lt;span class="cl">package:com.google.android.youtube
&lt;/span>&lt;/span>&lt;span class="line">&lt;span class="cl">...
&lt;/span>&lt;/span>&lt;/code>&lt;/pre>&lt;/div>&lt;p>&lt;code>adb shell&lt;/code>コマンドで端末に接続した上で、端末内のOS上で&lt;code>pm list packages&lt;/code>を実行している。&lt;/p></description><enclosure url="https://atsum.in/android/cli-installed-apps/img/thumbnail.png" type="image/png"/></item><item><title>【Android】エミュレータの音声をオフにする</title><link>https://atsum.in/android/emulator-no-audio/</link><pubDate>Sun, 08 Dec 2024 11:47:13 +0900</pubDate><guid>https://atsum.in/android/emulator-no-audio/</guid><description>&lt;h2 id="エミュレータの音声をオフにする">エミュレータの音声をオフにする&lt;/h2>
&lt;p>MacでイヤホンをつけているときにAndroidのエミュレータを立ち上げると音質が劣化する。&lt;br>
ボリュームも変わるので調節が面倒となる。&lt;br>
エミュレータからの音声だけでなくMac自体の音声も変わるので、他のアプリの音声も影響を受ける。&lt;br>
開発中で音声が必要無い場合は音声をオフにしたい。&lt;/p></description><enclosure url="https://atsum.in/android/emulator-no-audio/img/thumbnail.png" type="image/png"/></item><item><title>【Android】コマンドラインでエミュレータを立ち上げる</title><link>https://atsum.in/android/launch-emulator-cli/</link><pubDate>Sun, 08 Dec 2024 11:17:07 +0900</pubDate><guid>https://atsum.in/android/launch-emulator-cli/</guid><description>&lt;h2 id="emulatorコマンド">emulatorコマンド&lt;/h2>
&lt;p>コマンドラインでエミュレータを立ち上げるにはAndroid SDKに付属されている&lt;code>emulator&lt;/code>コマンドを使う。&lt;/p>
&lt;p>&lt;code>emulator&lt;/code>コマンドはMacの場合は以下のディレクトリにインストールされている。&lt;/p></description><enclosure url="https://atsum.in/android/launch-emulator-cli/img/thumbnail.png" type="image/png"/></item><item><title>【Android】App Distributionからコマンドで最新バイナリをダウンロードする</title><link>https://atsum.in/android/download-apk-app-distribution/</link><pubDate>Sun, 08 Dec 2024 10:38:35 +0900</pubDate><guid>https://atsum.in/android/download-apk-app-distribution/</guid><description>&lt;h2 id="firebase-app-distribution-api">Firebase App Distribution API&lt;/h2>
&lt;p>Firebase App Distributionから最新バイナリをダウンロードするために&lt;a href="https://firebase.google.com/docs/reference/app-distribution/rest?hl=ja" target="_blank" rel="noopener nofollow">Firebase App Distribution API&lt;/a>
を利用する。&lt;/p>
&lt;p>REST APIの&lt;a href="https://firebase.google.com/docs/reference/app-distribution/rest/v1/projects.apps.releases/list?hl=ja" target="_blank" rel="noopener nofollow">projects.apps.releases.list&lt;/a>
を利用すると、App DistributionにアップロードされたバイナリのダウンロードURLを取得できる。&lt;/p></description><enclosure url="https://atsum.in/android/download-apk-app-distribution/img/thumbnail.png" type="image/png"/></item><item><title>【Android】Firebase App Distribution へ GitHub Actions でアップロードする</title><link>https://atsum.in/android/app-distribution-github-actions/</link><pubDate>Sun, 08 Dec 2024 09:36:27 +0900</pubDate><guid>https://atsum.in/android/app-distribution-github-actions/</guid><description>&lt;h2 id="firebase-app-distribution-へのアップロード">Firebase App Distribution へのアップロード&lt;/h2>
&lt;p>GitHub ActionsでFirebase App Distributionにアプリをアップロードするには
&lt;a href="https://github.com/wzieba/Firebase-Distribution-Github-Action" target="_blank" rel="noopener nofollow">wzieba/Firebase-Distribution-Github-Action&lt;/a>
を使用して以下のように設定する。&lt;/p></description><enclosure url="https://atsum.in/android/app-distribution-github-actions/img/thumbnail.png" type="image/png"/></item><item><title>【Wezterm】カレントディレクトリをホームにして新規タブを開くショートカット</title><link>https://atsum.in/linux/wezterm-home-new-tab/</link><pubDate>Sat, 07 Dec 2024 21:51:48 +0900</pubDate><guid>https://atsum.in/linux/wezterm-home-new-tab/</guid><description>&lt;h2 id="weztermの新規タブ">Weztermの新規タブ&lt;/h2>
&lt;p>新規タブを開くために+ボタンをクリックすると、新しいシェルのカレントディレクトリは最後に開いていたタブのディレクトリと同じになる。&lt;br>
iTerm2のデフォルト設定では、新規タブを開くとホームディレクトリがカレントディレクトリになる。&lt;br>
Weztermでも同様の設定としたい。&lt;/p></description><enclosure url="https://atsum.in/linux/wezterm-home-new-tab/img/thumbnail.png" type="image/png"/></item><item><title>【AWS CLI】タグを指定してEC2サーバのName一覧を取得する</title><link>https://atsum.in/aws/list-ec2-by-tag/</link><pubDate>Mon, 14 Oct 2024 20:18:52 +0900</pubDate><guid>https://atsum.in/aws/list-ec2-by-tag/</guid><description>&lt;h2 id="タグを指定してec2サーバのname一覧を取得するコマンド">タグを指定してEC2サーバのName一覧を取得するコマンド&lt;/h2>
&lt;p>指定したタグの値に一致するEC2サーバのNameを取得するには以下のコマンドを実行する。&lt;/p>
&lt;div class="highlight">&lt;pre tabindex="0" class="chroma">&lt;code class="language-shell" data-lang="shell">&lt;span class="line">&lt;span class="cl">aws ec2 describe-instances &lt;span class="se">\
&lt;/span>&lt;/span>&lt;/span>&lt;span class="line">&lt;span class="cl">&lt;span class="se">&lt;/span> --filters &lt;span class="s2">&amp;#34;Name=tag:タグ名,Values=値&amp;#34;&lt;/span> &lt;span class="se">\
&lt;/span>&lt;/span>&lt;/span>&lt;span class="line">&lt;span class="cl">&lt;span class="se">&lt;/span> --query &lt;span class="s1">&amp;#39;Reservations[*].Instances[*].Tags[?Key==`Name`].Value&amp;#39;&lt;/span> &lt;span class="se">\
&lt;/span>&lt;/span>&lt;/span>&lt;span class="line">&lt;span class="cl">&lt;span class="se">&lt;/span> --output text
&lt;/span>&lt;/span>&lt;/code>&lt;/pre>&lt;/div>&lt;h2 id="例">例&lt;/h2>
&lt;p>タグ名が&lt;code>Environment&lt;/code>で値が&lt;code>production&lt;/code>のEC2サーバのNameを取得する場合は以下のようになる。&lt;/p></description><enclosure url="https://atsum.in/aws/list-ec2-by-tag/img/thumbnail.png" type="image/png"/></item><item><title>【AWS CLI】コマンドで CloudWatch メトリクスのグラフ画像を取得する(get-metric-widget-image)</title><link>https://atsum.in/aws/get-metric-widget-image/</link><pubDate>Sat, 12 Oct 2024 20:28:38 +0900</pubDate><guid>https://atsum.in/aws/get-metric-widget-image/</guid><description>&lt;h2 id="aws-cli-で-cloudwatch-メトリクスのウィジェット画像を取得する">AWS CLI で CloudWatch メトリクスのウィジェット画像を取得する&lt;/h2>
&lt;p>AWS CLIでAWS CloudWatchメトリクスのグラフを画像としてダウンロードするには以下のコマンドを実行する。&lt;/p></description><enclosure url="https://atsum.in/aws/get-metric-widget-image/img/thumbnail.png" type="image/png"/></item><item><title>【Docker】docker compose でホストの環境変数をコンテナに引き継ぐ</title><link>https://atsum.in/linux/docker-compose-pass-env-var/</link><pubDate>Sat, 12 Oct 2024 01:15:29 +0900</pubDate><guid>https://atsum.in/linux/docker-compose-pass-env-var/</guid><description>&lt;h2 id="docker-composeでホストの環境変数を引き継ぎたい">docker composeでホストの環境変数を引き継ぎたい&lt;/h2>
&lt;p>&lt;code>docker-compose.yml&lt;/code>をバージョン管理していてパスワードやトークンなどの機密情報をコンテナに渡したい場合、
&lt;code>docker-compose.yml&lt;/code>に直接書くのを避けたい。&lt;/p></description><enclosure url="https://atsum.in/linux/docker-compose-pass-env-var/img/thumbnail.png" type="image/png"/></item><item><title>【VSCode】VSCodeVimでCtrl+Aを無効化する</title><link>https://atsum.in/vscode/disable-ctrl-a-vscodevim/</link><pubDate>Fri, 11 Oct 2024 00:22:01 +0900</pubDate><guid>https://atsum.in/vscode/disable-ctrl-a-vscodevim/</guid><description>&lt;h2 id="vimのctrla">vimのctrl+a&lt;/h2>
&lt;p>vimで&lt;code>ctrl+a&lt;/code>はカーソル位置の数値をインクリメントする。&lt;br>
あまり使わないが誤って入力してしまう場合があり、無効化したい。&lt;/p>
&lt;h2 id="vscodevimでctrlaを無効化する">VSCodeVimでctrl+aを無効化する&lt;/h2>
&lt;p>VSCodeVimで&lt;code>ctrl+a&lt;/code>を無効化するには、&lt;code>settings.json&lt;/code>に&lt;code>vim.handleKeys&lt;/code>を追加し、&lt;code>C-a&lt;/code>の値を&lt;code>false&lt;/code>にする。&lt;/p></description><enclosure url="https://atsum.in/vscode/disable-ctrl-a-vscodevim/img/thumbnail.png" type="image/png"/></item><item><title>【grep -C】マッチした行の前後の行も表示する</title><link>https://atsum.in/linux/grep-ab/</link><pubDate>Sun, 01 Sep 2024 16:41:00 +0900</pubDate><guid>https://atsum.in/linux/grep-ab/</guid><description>&lt;p>&lt;code>grep&lt;/code>はマッチした行だけを表示する。ログの調査などでは前後の行も見たい場合がある。前後の行を一緒に表示するには&lt;code>-C&lt;/code>、後ろだけなら&lt;code>-A&lt;/code>、前だけなら&lt;code>-B&lt;/code>を指定する。&lt;/p></description><enclosure url="https://atsum.in/linux/grep-ab/img/thumbnail.png" type="image/png"/></item><item><title>【unzip】日本語ファイル名(Windows)を含むzipをLinuxで解凍する(-O cp932)</title><link>https://atsum.in/linux/unzip-cp932/</link><pubDate>Sat, 03 Aug 2024 19:42:57 +0900</pubDate><guid>https://atsum.in/linux/unzip-cp932/</guid><description>&lt;h2 id="windowsで作ったzipをlinuxでunzipコマンドで解凍すると文字化けする">Windowsで作ったzipをLinuxでunzipコマンドで解凍すると文字化けする&lt;/h2>
&lt;p>Windowsで作ったzipファイルをLinux(UTF-8環境)のunzipコマンドで解凍すると、日本語ファイル名が文字化けする。&lt;/p>
&lt;div class="highlight">&lt;pre tabindex="0" class="chroma">&lt;code class="language-shell" data-lang="shell">&lt;span class="line">&lt;span class="cl">$ unzip test.zip
&lt;/span>&lt;/span>&lt;span class="line">&lt;span class="cl">Archive: test.zip
&lt;/span>&lt;/span>&lt;span class="line">&lt;span class="cl"> inflating: ?????
&lt;/span>&lt;/span>&lt;span class="line">&lt;span class="cl"> inflating: ???????
&lt;/span>&lt;/span>&lt;/code>&lt;/pre>&lt;/div>&lt;h2 id="unzipコマンドでcp932shift_jisのファイル名を解凍する">unzipコマンドでcp932(Shift_JIS)のファイル名を解凍する&lt;/h2>
&lt;p>&lt;code>unzip&lt;/code>コマンドで&lt;code>-O&lt;/code>オプションを指定するとファイル名のエンコードを指定できる。
Windowsのファイル名のエンコードはCP932なので&lt;code>-O cp932&lt;/code>オプションを指定する。&lt;/p></description><enclosure url="https://atsum.in/linux/unzip-cp932/img/thumbnail.png" type="image/png"/></item><item><title>yum, dnfで作成されたファイルの一覧を確認する(repoquery --list, --whatprovides)</title><link>https://atsum.in/linux/yum-dnf-installed-files/</link><pubDate>Sat, 13 Jul 2024 09:48:44 +0900</pubDate><guid>https://atsum.in/linux/yum-dnf-installed-files/</guid><description>&lt;h2 id="yum-dnfで作成されたファイルの一覧">yum, dnfで作成されたファイルの一覧&lt;/h2>
&lt;p>&lt;code>yum&lt;/code>コマンドや&lt;code>dnf&lt;/code>コマンドで作成されたファイルの一覧を確認するには&lt;code>repoquery&lt;/code>コマンドを使用する。&lt;/p></description><enclosure url="https://atsum.in/linux/yum-dnf-installed-files/img/thumbnail.png" type="image/png"/></item><item><title>【AWS】EC2上でIMDSv2でAWS_SESSION_TOKENを取得する</title><link>https://atsum.in/aws/ec2-get-token/</link><pubDate>Fri, 05 Jul 2024 08:13:38 +0900</pubDate><guid>https://atsum.in/aws/ec2-get-token/</guid><description>&lt;h2 id="ec2でaws-cliの認証トークンを取得する">EC2でAWS CLIの認証トークンを取得する&lt;/h2>
&lt;p>EC2インスタンス上でAWS CLIなどで使う&lt;code>AWS_SESSION_TOKEN&lt;/code>に設定するトークンをIMDSv2を利用して取得するには以下の手順で実行する&lt;/p></description><enclosure url="https://atsum.in/aws/ec2-get-token/img/thumbnail.png" type="image/png"/></item><item><title>【AWS CLI】設定済みプロファイルの一覧を表示する</title><link>https://atsum.in/aws/configure-list-profiles/</link><pubDate>Thu, 04 Jul 2024 21:45:25 +0900</pubDate><guid>https://atsum.in/aws/configure-list-profiles/</guid><description>&lt;p>AWS CLIで設定済みのプロファイル名を確認するには&lt;code>aws configure list-profiles&lt;/code>を実行する。プロファイルの設定内容まで確認する場合は&lt;code>aws configure list&lt;/code>を使う。&lt;/p></description><enclosure url="https://atsum.in/aws/configure-list-profiles/img/thumbnail.png" type="image/png"/></item><item><title>【Terraform】ecspresso execコマンドでコンテナ内に接続する</title><link>https://atsum.in/terraform/ecspresso-exec/</link><pubDate>Sat, 15 Jun 2024 05:18:02 +0900</pubDate><guid>https://atsum.in/terraform/ecspresso-exec/</guid><description>&lt;h2 id="ecspresso-execコマンド">ecspresso execコマンド&lt;/h2>
&lt;p>ecspressoの&lt;code>exec&lt;/code>コマンドを使うと&lt;a href="https://docs.aws.amazon.com/ja_jp/AmazonECS/latest/developerguide/ecs-exec.html" target="_blank" rel="noopener nofollow">ECS exec&lt;/a>
を利用したコンテナへの接続を実現できる。&lt;/p>
&lt;h2 id="準備">準備&lt;/h2>
&lt;p>&lt;a href="https://atsum.in/terraform/ecspresso" target="_blank" rel="noopener">TerraformとecspressoでECS(Fargete)を構築する&lt;/a>
で作成したTerraformとecspressoのコードを用意する。&lt;/p></description><enclosure url="https://atsum.in/terraform/ecspresso-exec/img/thumbnail.png" type="image/png"/></item><item><title>TerraformとecspressoでECS(Fargate)を構築する</title><link>https://atsum.in/terraform/ecspresso/</link><pubDate>Sun, 09 Jun 2024 07:49:01 +0900</pubDate><guid>https://atsum.in/terraform/ecspresso/</guid><description>&lt;h2 id="ecspresso">ecspresso&lt;/h2>
&lt;p>&lt;a href="https://github.com/kayac/ecspresso" target="_blank" rel="noopener nofollow">ecspresso&lt;/a>
はECSのタスク定義やサービスを管理するためのツール。&lt;/p>
&lt;h2 id="terraform--ecspresso">Terraform + ecspresso&lt;/h2>
&lt;h3 id="ecsの構成">ECSの構成&lt;/h3>
&lt;p>ECSを構成するコンポーネントとして以下がある。&lt;/p>
&lt;ul>
&lt;li>タスク定義&lt;/li>
&lt;li>クラスター&lt;/li>
&lt;li>サービス&lt;/li>
&lt;li>タスク&lt;/li>
&lt;/ul>
&lt;p>クラスターがサービスを持ち、サービスがタスクを持つ。&lt;br>
タスクはタスク定義から作成される。&lt;/p></description><enclosure url="https://atsum.in/terraform/ecspresso/img/thumbnail.png" type="image/png"/></item><item><title>【Terraform】planの対象を絞って変更の確認を高速にまわす(-targetオプション)</title><link>https://atsum.in/terraform/plan-target/</link><pubDate>Thu, 06 Jun 2024 07:16:58 +0900</pubDate><guid>https://atsum.in/terraform/plan-target/</guid><description>&lt;h2 id="terraformのplanの対象を絞る-targetオプション">Terraformのplanの対象を絞る(-targetオプション)&lt;/h2>
&lt;h3 id="-targetオプションの使い方">-targetオプションの使い方&lt;/h3>
&lt;p>Terraformのコードが大規模になってくると修正時に&lt;code>terraform plan&lt;/code>コマンドを実行すると時間がかかるようになってくる。&lt;/p>
&lt;p>Terraformの&lt;code>terraform plan&lt;/code>コマンドで&lt;code>-target&lt;/code>オプションを指定すると、指定したリソースの変更のみを確認できる。&lt;br>
一部の変更のみを確認するので高速に実行できる。&lt;/p></description><enclosure url="https://atsum.in/terraform/plan-target/img/thumbnail.png" type="image/png"/></item><item><title>【VSCode】新規ファイル作成時のヒント文を非表示にする</title><link>https://atsum.in/vscode/empty-hint-hidden/</link><pubDate>Wed, 29 May 2024 07:32:21 +0900</pubDate><guid>https://atsum.in/vscode/empty-hint-hidden/</guid><description>&lt;h2 id="新規ファイル作成時のヒント文">新規ファイル作成時のヒント文&lt;/h2>
&lt;p>Visual Studio Codeで新規ファイルを作成するとヒント文が表示される。&lt;/p>
&lt;p>&lt;img src="img/new-file-hint.png" alt="新規ファイル作成時のヒント文">&lt;/p>
&lt;p>ヒント文は入力すれば消える。&lt;/p>
&lt;h2 id="ヒント文を非表示にする">ヒント文を非表示にする&lt;/h2>
&lt;p>上記ヒント文を最初から非表示にするには&lt;code>settings.json&lt;/code>へ以下のように&lt;code>workbench.editor.empty.hint&lt;/code>の設定を追加する。&lt;/p></description><enclosure url="https://atsum.in/vscode/empty-hint-hidden/img/thumbnail.png" type="image/png"/></item><item><title>【PostgreSQL】psqlコマンドの結果をシェルスクリプトで利用する(psql -qtAF)</title><link>https://atsum.in/database/psql-command-result-for-shellscript/</link><pubDate>Tue, 28 May 2024 20:28:50 +0900</pubDate><guid>https://atsum.in/database/psql-command-result-for-shellscript/</guid><description>&lt;h2 id="結果が1行1列のみの場合">結果が1行1列のみの場合&lt;/h2>
&lt;p>&lt;code>psql&lt;/code>コマンドでクエリを実行した結果をシェルスクリプトで利用するには、&lt;code>-qtA&lt;/code>オプションを指定すると扱いやすくなる。&lt;/p>
&lt;div class="highlight">&lt;pre tabindex="0" class="chroma">&lt;code class="language-shell" data-lang="shell">&lt;span class="line">&lt;span class="cl">$ psql -qtA -U 接続ユーザ -d データベース名 -c &lt;span class="s2">&amp;#34;クエリ(SQL)&amp;#34;&lt;/span>
&lt;/span>&lt;/span>&lt;/code>&lt;/pre>&lt;/div>&lt;p>例えば&lt;code>count(*)&lt;/code>で集計した結果は以下のような出力となる&lt;/p></description><enclosure url="https://atsum.in/database/psql-command-result-for-shellscript/img/thumbnail.png" type="image/png"/></item><item><title>【VSCode】現在行のハイライトの方法を変更する</title><link>https://atsum.in/vscode/current-line-highlight/</link><pubDate>Thu, 23 May 2024 00:07:37 +0900</pubDate><guid>https://atsum.in/vscode/current-line-highlight/</guid><description>&lt;h2 id="vscodeの現在行のハイライト">VSCodeの現在行のハイライト&lt;/h2>
&lt;p>Visual Studio Codeのデフォルト設定ではカーソルのある行が以下のようにハイライトされる。&lt;/p>
&lt;p>&lt;img src="img/render-highlight-default.png" alt="デフォルト設定">&lt;/p>
&lt;h2 id="現在行のハイライトの方法を変更する">現在行のハイライトの方法を変更する&lt;/h2>
&lt;p>VSCodeの設定ファイル&lt;code>settings.json&lt;/code>に以下のように&lt;code>editor.renderLineHighlight&lt;/code>を設定に追加すると、現在行のハイライトの方法を変更できる。&lt;/p></description><enclosure url="https://atsum.in/vscode/current-line-highlight/img/thumbnail.png" type="image/png"/></item><item><title>【curl】404 Not Foundで0以外の終了ステータスコードを返すようにする</title><link>https://atsum.in/linux/curl-404-error/</link><pubDate>Wed, 22 May 2024 20:58:22 +0900</pubDate><guid>https://atsum.in/linux/curl-404-error/</guid><description>&lt;h2 id="curlの404のときのステータスコード">curlの404のときのステータスコード&lt;/h2>
&lt;p>&lt;code>curl&lt;/code>コマンドでURLにアクセスしたとき、404 Not Foundの場合は終了ステータスコードが0になる。&lt;/p>
&lt;div class="highlight">&lt;pre tabindex="0" class="chroma">&lt;code class="language-shell" data-lang="shell">&lt;span class="line">&lt;span class="cl">$ curl https://example.com/notfound
&lt;/span>&lt;/span>&lt;span class="line">&lt;span class="cl">・・・
&lt;/span>&lt;/span>&lt;span class="line">&lt;span class="cl">$ &lt;span class="nb">echo&lt;/span> &lt;span class="nv">$?&lt;/span>
&lt;/span>&lt;/span>&lt;span class="line">&lt;span class="cl">&lt;span class="m">0&lt;/span>
&lt;/span>&lt;/span>&lt;/code>&lt;/pre>&lt;/div>&lt;h2 id="404のときに0以外のステータスコードを返す">404のときに0以外のステータスコードを返す&lt;/h2>
&lt;p>&lt;code>curl&lt;/code>コマンドで404 Not Foundの場合に0以外のステータスコードを返すには、&lt;code>-f&lt;/code>オプション(&lt;code>--fail&lt;/code>オプション)を指定する。&lt;/p></description><enclosure url="https://atsum.in/linux/curl-404-error/img/thumbnail.png" type="image/png"/></item><item><title>【PostgreSQL】postgresql.confの場所を探す(show config_file)</title><link>https://atsum.in/database/postgresql-conf-location/</link><pubDate>Tue, 21 May 2024 23:13:42 +0900</pubDate><guid>https://atsum.in/database/postgresql-conf-location/</guid><description>&lt;h2 id="postgresqlの設定ファイルの場所を探すコマンドshow-config_file">PostgreSQLの設定ファイルの場所を探すコマンド(show config_file)&lt;/h2>
&lt;p>PostgreSQLの設定ファイル&lt;code>postgresql.conf&lt;/code>はOSやインストール方法によって場所が異なる。&lt;br>
稼働しているPostgreSQLの設定ファイルの場所を確認するには以下のコマンドを実行する。&lt;/p></description><enclosure url="https://atsum.in/database/postgresql-conf-location/img/thumbnail.png" type="image/png"/></item><item><title>【Android Studio】エミュレータをスタンドアロンで起動する</title><link>https://atsum.in/android/emulator-standalone/</link><pubDate>Sun, 19 May 2024 19:50:39 +0900</pubDate><guid>https://atsum.in/android/emulator-standalone/</guid><description>&lt;h2 id="android-studioでのエミュレータの起動">Android Studioでのエミュレータの起動&lt;/h2>
&lt;p>Android Studioでエミュレータを起動するとAndroid Studioのウインドウ内にエミュレータが表示される。&lt;/p></description><enclosure url="https://atsum.in/android/emulator-standalone/img/thumbnail.png" type="image/png"/></item><item><title>【Android】Playwrightでネイティブアプリをテストする</title><link>https://atsum.in/android/playwright/</link><pubDate>Mon, 13 May 2024 00:16:46 +0900</pubDate><guid>https://atsum.in/android/playwright/</guid><description>&lt;h2 id="準備">準備&lt;/h2>
&lt;p>Playwrightでネイティブアプリをテストするには、以下の準備が必要。&lt;/p>
&lt;h3 id="android-studioのインストール">Android Studioのインストール&lt;/h3>
&lt;p>adbコマンドなどのエミュレータ操作に必要なAndroid SDK Platform Toolsをインストールするため、Android Studioをインストールする。&lt;br>
Android Studioをダウンロードして起動すると必要なツールは自動でインストールされる。&lt;/p></description><enclosure url="https://atsum.in/android/playwright/img/thumbnail.png" type="image/png"/></item><item><title>【VSCode】同じファイル名のタブの表示をカスタマイズして見やすくする</title><link>https://atsum.in/vscode/editor-custom-label/</link><pubDate>Sun, 12 May 2024 18:02:34 +0900</pubDate><guid>https://atsum.in/vscode/editor-custom-label/</guid><description>&lt;h2 id="同じファイル名が並ぶと見分けづらい">同じファイル名が並ぶと見分けづらい&lt;/h2>
&lt;p>当サイトはHugoで生成しており、記事のファイル名は&lt;code>index.md&lt;/code>になっている。&lt;/p>
&lt;p>&lt;img src="img/vscode-tab.png" alt="同じファイル名">&lt;/p>
&lt;p>ファイル名&lt;code>index.md&lt;/code>が強調されていてフォルダ名はグレーになっているため、同じファイル名が並ぶと見分けづらい。&lt;/p></description><enclosure url="https://atsum.in/vscode/editor-custom-label/img/thumbnail.png" type="image/png"/></item><item><title>CotEditorで折り返し表示の有効・無効を切り替える方法</title><link>https://atsum.in/mac/coteditor-wrap/</link><pubDate>Fri, 10 May 2024 20:18:13 +0900</pubDate><guid>https://atsum.in/mac/coteditor-wrap/</guid><description>&lt;h2 id="coteditorの折り返し設定">CotEditorの折り返し設定&lt;/h2>
&lt;p>CotEditorの折り返し設定は、設定画面のウインドウタブにある。&lt;/p>
&lt;p>&lt;img src="img/wrap-setting.png" alt="折り返し設定">&lt;/p>
&lt;p>「折り返した行のインデント」を設定すると折り返した行のインデントを変更できる。&lt;/p></description><enclosure url="https://atsum.in/mac/coteditor-wrap/img/thumbnail.png" type="image/png"/></item><item><title>【VSCode】vscodevimのUndo/Redoが想定より多く操作する問題に対処する</title><link>https://atsum.in/vscode/vim-fix-undo/</link><pubDate>Tue, 07 May 2024 22:24:33 +0900</pubDate><guid>https://atsum.in/vscode/vim-fix-undo/</guid><description>&lt;h2 id="vscodevimのundoredoで想定より多く戻る進む">vscodevimのUndo/Redoで想定より多く戻る/進む&lt;/h2>
&lt;p>Visual Studio Codeのvim拡張機能である&lt;code>vscodevim&lt;/code>を使用していると、&lt;code>u&lt;/code>でUndo、&lt;code>Ctrl + r&lt;/code>でRedoできる。&lt;br>
このUndo/Redoを実行すると複数回の操作分がまとめて戻ったり進んだりする場合がある。&lt;/p></description><enclosure url="https://atsum.in/vscode/vim-fix-undo/img/thumbnail.png" type="image/png"/></item><item><title>【AWS CLI】結果をタグでフィルタする</title><link>https://atsum.in/aws/cli-filter-by-tag/</link><pubDate>Tue, 07 May 2024 20:05:57 +0900</pubDate><guid>https://atsum.in/aws/cli-filter-by-tag/</guid><description>&lt;h2 id="aws-cliで結果をフィルタするfiltersオプション">AWS CLIで結果をフィルタする(&amp;ndash;filtersオプション)&lt;/h2>
&lt;p>AWS CLIで取得した結果をフィルタするには&lt;code>--filters&lt;/code>オプションを使用する。&lt;br>
(ただしコマンドによっては&lt;code>--filter&lt;/code>オプション)&lt;br>
&lt;code>--filters&lt;/code>オプションには&lt;code>Name&lt;/code>と&lt;code>Values&lt;/code>を指定する。&lt;/p></description><enclosure url="https://atsum.in/aws/cli-filter-by-tag/img/thumbnail.png" type="image/png"/></item><item><title>【Terraform】ALBにAWS WAFv2を適用する</title><link>https://atsum.in/terraform/aws-wafv2-alb/</link><pubDate>Mon, 06 May 2024 14:19:32 +0900</pubDate><guid>https://atsum.in/terraform/aws-wafv2-alb/</guid><description>&lt;p>TerraformでALBにAWS WAFv2を適用する。&lt;/p>
&lt;h2 id="alb">ALB&lt;/h2>
&lt;p>適用対象のALB。&lt;br>
詳細は省略。
&lt;code>aws_lb&lt;/code>リソースについては&lt;a href="https://registry.terraform.io/providers/hashicorp/aws/latest/docs/resources/lb" target="_blank" rel="noopener nofollow">公式ドキュメント&lt;/a>
を参照。&lt;/p></description><enclosure url="https://atsum.in/terraform/aws-wafv2-alb/img/thumbnail.png" type="image/png"/></item><item><title>【Terraform】Error putting S3 policy: AccessDenied: Access Deniedの対処法</title><link>https://atsum.in/terraform/error-s3-policy-access-denied/</link><pubDate>Sun, 05 May 2024 16:48:36 +0900</pubDate><guid>https://atsum.in/terraform/error-s3-policy-access-denied/</guid><description>&lt;h2 id="s3のバケットポリシー作成でerror-putting-s3-policy-accessdenied-access-denied">S3のバケットポリシー作成でError putting S3 policy: AccessDenied: Access Denied&lt;/h2>
&lt;p>TerraformでS3のバケットポリシーで&lt;code>Principal&lt;/code>に対してすべてを許可しようとするとエラーとなる。&lt;/p>
&lt;div class="highlight">&lt;pre tabindex="0" class="chroma">&lt;code class="language-hcl" data-lang="hcl">&lt;span class="line">&lt;span class="cl">&lt;span class="k">data&lt;/span> &lt;span class="s2">&amp;#34;aws_iam_policy_document&amp;#34; &amp;#34;example&amp;#34;&lt;/span> {
&lt;/span>&lt;/span>&lt;span class="line">&lt;span class="cl"> &lt;span class="k">statement&lt;/span> {
&lt;/span>&lt;/span>&lt;span class="line">&lt;span class="cl">&lt;span class="n"> actions&lt;/span> &lt;span class="o">=&lt;/span> &lt;span class="p">[&lt;/span>&lt;span class="s2">&amp;#34;s3:GetObject&amp;#34;&lt;/span>&lt;span class="p">]&lt;/span>
&lt;/span>&lt;/span>&lt;span class="line">&lt;span class="cl">&lt;span class="n"> resources&lt;/span> &lt;span class="o">=&lt;/span> &lt;span class="p">[&lt;/span>&lt;span class="s2">&amp;#34;${aws_s3_bucket.example.arn}/*&amp;#34;&lt;/span>&lt;span class="p">]&lt;/span>
&lt;/span>&lt;/span>&lt;span class="line">&lt;span class="cl"> &lt;span class="k">principals&lt;/span> {
&lt;/span>&lt;/span>&lt;span class="line">&lt;span class="cl">&lt;span class="n"> type&lt;/span> &lt;span class="o">=&lt;/span> &lt;span class="s2">&amp;#34;AWS&amp;#34;&lt;/span>
&lt;/span>&lt;/span>&lt;span class="line">&lt;span class="cl">&lt;span class="n"> identifiers&lt;/span> &lt;span class="o">=&lt;/span> &lt;span class="p">[&lt;/span>&lt;span class="s2">&amp;#34;*&amp;#34;&lt;/span>&lt;span class="p">]&lt;/span>&lt;span class="c1"> # すべてのPrincipalに許可
&lt;/span>&lt;/span>&lt;/span>&lt;span class="line">&lt;span class="cl">&lt;span class="c1">&lt;/span> }
&lt;/span>&lt;/span>&lt;span class="line">&lt;span class="cl"> }
&lt;/span>&lt;/span>&lt;span class="line">&lt;span class="cl">}
&lt;/span>&lt;/span>&lt;/code>&lt;/pre>&lt;/div>&lt;p>&lt;code>apply&lt;/code>時に発生するエラーは以下の通り。&lt;/p></description><enclosure url="https://atsum.in/terraform/error-s3-policy-access-denied/img/thumbnail.png" type="image/png"/></item><item><title>【Terraform】Error putting S3 policy: MalformedPolicy: Action does not apply to any resource(s) in statementの対処法</title><link>https://atsum.in/terraform/error-s3-malformed-policy-listbucket/</link><pubDate>Sun, 05 May 2024 13:55:26 +0900</pubDate><guid>https://atsum.in/terraform/error-s3-malformed-policy-listbucket/</guid><description>&lt;h2 id="s3のバケットポリシー作成でerror-putting-s3-policy-malformedpolicy-action-does-not-apply-to-any-resources-in-statement">S3のバケットポリシー作成でError putting S3 policy: MalformedPolicy: Action does not apply to any resource(s) in statement&lt;/h2>
&lt;p>TerraformでS3のバケットポリシーで&lt;code>s3:ListBucket&lt;/code>に対してパスを含めたARNのみの&lt;code>Resource&lt;/code>を指定するとエラーが発生する。&lt;/p></description><enclosure url="https://atsum.in/terraform/error-s3-malformed-policy-listbucket/img/thumbnail.png" type="image/png"/></item><item><title>【VSCode】draw.io統合拡張でAWSの部品をサイドバーに配置する</title><link>https://atsum.in/vscode/drawio-aws-parts/</link><pubDate>Sun, 05 May 2024 10:53:38 +0900</pubDate><guid>https://atsum.in/vscode/drawio-aws-parts/</guid><description>&lt;h2 id="サイドバーにawsの部品を追加する">サイドバーにAWSの部品を追加する&lt;/h2>
&lt;p>Visual Studio Codeのdraw.io統合拡張でAWSの部品をサイドバーに追加できる。&lt;/p>
&lt;p>まずサイドバーの&lt;code>+ More Shapes&lt;/code>をクリックする。&lt;/p>
&lt;p>&lt;img src="img/drawio-more-shapes.png" alt="More Shapes">&lt;/p>
&lt;p>ダイアログが表示されるのでAWS**を選択して&lt;code>Apply&lt;/code>をクリックする。&lt;/p></description><enclosure url="https://atsum.in/vscode/drawio-aws-parts/img/thumbnail.png" type="image/png"/></item><item><title>【VScode】draw.io統合拡張で図が見づらいときにテーマを変更して見やすくする</title><link>https://atsum.in/vscode/drawio-theme/</link><pubDate>Sun, 05 May 2024 09:07:53 +0900</pubDate><guid>https://atsum.in/vscode/drawio-theme/</guid><description>&lt;h2 id="drawioで図が見づらいテーマ">Draw.ioで図が見づらいテーマ&lt;/h2>
&lt;p>Visual Studio Codeのdraw.io統合拡張を使用しているとき、部品によっては色が決まっていてテーマによっては見づらい場合がある。&lt;/p>
&lt;p>例えば以下の図。&lt;/p>
&lt;p>&lt;img src="img/drawio-dark.png" alt="見づらい図">&lt;/p>
&lt;p>&lt;code>AWS Cloud&lt;/code>の枠が暗めの配色となっており、ダークテーマの場合は見づらい。&lt;/p></description><enclosure url="https://atsum.in/vscode/drawio-theme/img/thumbnail.png" type="image/png"/></item><item><title>GitHub Actionsのself-hosted runnerをCodeBuildで動かす</title><link>https://atsum.in/aws/codebuild-as-self-hosted-runner/</link><pubDate>Sat, 04 May 2024 16:34:44 +0900</pubDate><guid>https://atsum.in/aws/codebuild-as-self-hosted-runner/</guid><description>&lt;h2 id="codebuildがgithub-actionsのself-hosted-runnerをサポート">CodeBuildがGitHub Actionsのself-hosted runnerをサポート&lt;/h2>
&lt;p>CodeBuildがGitHub Actionsのself-hosted runnerに対応した。&lt;/p></description><enclosure url="https://atsum.in/aws/codebuild-as-self-hosted-runner/img/thumbnail.png" type="image/png"/></item><item><title>【AWS】アカウントを超えてS3のファイルをコピーする</title><link>https://atsum.in/aws/copy-s3-inter-accounts/</link><pubDate>Sat, 04 May 2024 13:24:19 +0900</pubDate><guid>https://atsum.in/aws/copy-s3-inter-accounts/</guid><description>&lt;h2 id="構成">構成&lt;/h2>
&lt;p>2つのAWSアカウントのS3バケット間でファイルをコピーする設定を考える。&lt;/p>
&lt;p>構成としては以下のようになる。&lt;/p>
&lt;p>&lt;img src="img/architecture.png" alt="構成">&lt;/p>
&lt;p>権限設定としては以下のようになる。&lt;/p>
&lt;ul>
&lt;li>コピー先AWSアカウント: コピー元、コピー先のS3バケットにアクセスするための権限をIAM Userに与える&lt;/li>
&lt;li>コピー元AWSアカウント: コピー先のAWSアカウントのIAM Userがアクセスできるようにバケットポリシーを設定する&lt;/li>
&lt;/ul>
&lt;p>&lt;a href="https://atsum.in/aws/access-to-s3-in-other-acount/" target="_blank" rel="noopener">【AWS】他アカウントのS3へアクセスできるようにする&lt;/a>
の構成に加えて自アカウントのS3バケットにアクセスするための権限をIAM Userに追加した形となる。&lt;/p></description><enclosure url="https://atsum.in/aws/copy-s3-inter-accounts/img/thumbnail.png" type="image/png"/></item><item><title>【AWS】他アカウントのS3にアクセスできるようにする</title><link>https://atsum.in/aws/access-to-s3-in-other-acount/</link><pubDate>Sat, 04 May 2024 11:00:02 +0900</pubDate><guid>https://atsum.in/aws/access-to-s3-in-other-acount/</guid><description>&lt;h2 id="構成">構成&lt;/h2>
&lt;p>別のAWSアカウント内のS3バケットにアクセスする設定を考える。&lt;br>
構成としては一方のAWSアカウントにアクセスするAWS Userがあり、他方のAWSアカウントにS3バケットがある。&lt;/p></description><enclosure url="https://atsum.in/aws/access-to-s3-in-other-acount/img/thumbnail.png" type="image/png"/></item><item><title>【tig】diffの行番号表示をオフにする</title><link>https://atsum.in/linux/tig-diff-view-line-number-display-off/</link><pubDate>Wed, 01 May 2024 22:43:10 +0900</pubDate><guid>https://atsum.in/linux/tig-diff-view-line-number-display-off/</guid><description>&lt;h2 id="diffの行番号">diffの行番号&lt;/h2>
&lt;p>&lt;code>tig&lt;/code>の&lt;code>diff&lt;/code>では行番号が表示される。&lt;/p>
&lt;p>&lt;img src="img/diff-view-line-number.png" alt="diffの行番号">&lt;/p>
&lt;p>この画面からコピーして他人に共有したいとき、コピー内容に行番号が含まれてしまい邪魔になる。&lt;br>
この行自体は元ソースの行とは関係が無いため非表示にしたい。&lt;/p></description><enclosure url="https://atsum.in/linux/tig-diff-view-line-number-display-off/img/thumbnail.png" type="image/png"/></item><item><title>【Shell】コマンド引数にスペースを含む値を持つ変数を渡したときの動作(SH_WORD_SPLIT)</title><link>https://atsum.in/linux/sh-word-split/</link><pubDate>Wed, 01 May 2024 20:37:59 +0900</pubDate><guid>https://atsum.in/linux/sh-word-split/</guid><description>&lt;h2 id="変数内のスペースを含む値を渡す">変数内のスペースを含む値を渡す&lt;/h2>
&lt;p>スペースを含む文字列を変数に格納してコマンドの引数として渡すときの動作を考える。&lt;/p>
&lt;p>例えば以下のように&lt;code>files&lt;/code>変数に&lt;code>a.txt&lt;/code>と&lt;code>b.txt&lt;/code>を格納して&lt;code>ls&lt;/code>コマンドに渡すとする。&lt;/p></description><enclosure url="https://atsum.in/linux/sh-word-split/img/thumbnail.png" type="image/png"/></item><item><title>【Packer】Rocky Linux 8 の yum update 済み AMI を作成する</title><link>https://atsum.in/aws/packer-rocky-yum-update-ami/</link><pubDate>Mon, 29 Apr 2024 21:45:48 +0900</pubDate><guid>https://atsum.in/aws/packer-rocky-yum-update-ami/</guid><description>&lt;h2 id="rocky-linux-8-の-ami">Rocky Linux 8 の AMI&lt;/h2>
&lt;p>Rocky Linux 8のEC2インスタンスが欲しいが、それなりに古いAMIであるため初回の&lt;code>yum update&lt;/code>の実行に時間がかかる。&lt;br>
そこで&lt;code>yum update&lt;/code>済みのAMIを作成してみる。&lt;/p></description><enclosure url="https://atsum.in/aws/packer-rocky-yum-update-ami/img/thumbnail.png" type="image/png"/></item><item><title>【tig】Staging is not supported for wrapped linesの対処方法</title><link>https://atsum.in/linux/tig-staging-not-supported/</link><pubDate>Mon, 29 Apr 2024 12:10:48 +0900</pubDate><guid>https://atsum.in/linux/tig-staging-not-supported/</guid><description>&lt;h2 id="staging-is-not-supported-for-wrapped-lines">Staging is not supported for wrapped lines&lt;/h2>
&lt;p>&lt;code>tig&lt;/code>の&lt;code>Staging View&lt;/code>で&lt;code>1&lt;/code>を入力して1行だけステージングしたいときに以下のエラーメッセージを表示する場合がある。&lt;/p>
&lt;div class="highlight">&lt;pre tabindex="0" class="chroma">&lt;code class="language-text" data-lang="text">&lt;span class="line">&lt;span class="cl">Staging is not supported for wrapped lines
&lt;/span>&lt;/span>&lt;/code>&lt;/pre>&lt;/div>&lt;p>&lt;img src="img/error.png" alt="Staging is not supported for wrapped lines">&lt;/p></description><enclosure url="https://atsum.in/linux/tig-staging-not-supported/img/thumbnail.png" type="image/png"/></item><item><title>【AWS CLI】AWS IAM Identity Center(AWS SSO)のユーザ名を変更する</title><link>https://atsum.in/aws/identitystore-update-user/</link><pubDate>Wed, 24 Apr 2024 23:09:36 +0900</pubDate><guid>https://atsum.in/aws/identitystore-update-user/</guid><description>&lt;h2 id="aws-cliでaws-iam-identity-centerのユーザ名を変更する">AWS CLIでAWS IAM Identity Centerのユーザ名を変更する&lt;/h2>
&lt;p>AWS IAM Identity Center(AWS SSO)のユーザ名は管理コンソールから変更するUIが提供されていない。&lt;br>
代わりにAWS CLIを使って以下のように変更できる。&lt;/p></description><enclosure url="https://atsum.in/aws/identitystore-update-user/img/thumbnail.png" type="image/png"/></item><item><title>【s3get】ワンバイナリでS3からファイルをダウンロードする</title><link>https://atsum.in/aws/s3get/</link><pubDate>Mon, 22 Apr 2024 23:21:30 +0900</pubDate><guid>https://atsum.in/aws/s3get/</guid><description>&lt;h2 id="s3get">s3get&lt;/h2>
&lt;p>&lt;code>s3get&lt;/code>はワンバイナリでS3からファイルをダウンロードするためのツール。&lt;br>
AWS CLIを使わずにS3からファイルをダウンロードしたい場合に利用できる。&lt;/p></description><enclosure url="https://atsum.in/aws/s3get/img/thumbnail.png" type="image/png"/></item><item><title>CocoapodsのSpecsのCDN</title><link>https://atsum.in/mac/cocoapods-cdn/</link><pubDate>Mon, 22 Apr 2024 22:04:13 +0900</pubDate><guid>https://atsum.in/mac/cocoapods-cdn/</guid><description>&lt;h2 id="通常使うcocoapodsのspecs">通常使うCocoapodsのSpecs&lt;/h2>
&lt;p>Cocoapodsの依存定義は&lt;a href="https://github.com/CocoaPods/Specs" target="_blank" rel="noopener">CocoaPods/Specs&lt;/a>
リポジトリにある。&lt;br>
Cocoapodsを使用すると通常はこのリポジトリを参照する。&lt;/p>
&lt;h2 id="cocoapodsのspecsのcdn">CocoapodsのSpecsのCDN&lt;/h2>
&lt;p>Cocoapods 1.7.2移行ではCDNでSpecsが用意されている。&lt;br>
URLは&lt;code>CocoaPods/Specs&lt;/code>リポジトリの代わりに&lt;a href="https://cdn.cocoapods.org" target="_blank" rel="noopener">https://cdn.cocoapods.org&lt;/a>
を指定すると利用できる。&lt;/p></description><enclosure url="https://atsum.in/mac/cocoapods-cdn/img/thumbnail.png" type="image/png"/></item><item><title>Github Actions でコミットを作る</title><link>https://atsum.in/linux/github-actions-commit/</link><pubDate>Mon, 22 Apr 2024 15:54:43 +0900</pubDate><guid>https://atsum.in/linux/github-actions-commit/</guid><description>&lt;h2 id="github-actions-でコミットを作る">Github Actions でコミットを作る&lt;/h2>
&lt;h3 id="エラー">エラー&lt;/h3>
&lt;p>GitHub Actionsでコミットを作るには&lt;code>user.name&lt;/code>と&lt;code>user.email&lt;/code>の設定が必要となる。&lt;br>
設定していない場合はエラーとなる。&lt;/p></description><enclosure url="https://atsum.in/linux/github-actions-commit/img/thumbnail.png" type="image/png"/></item><item><title>標準入出力を直接 gzip 圧縮・解凍する</title><link>https://atsum.in/linux/stdout-gzip/</link><pubDate>Sat, 20 Apr 2024 22:58:06 +0900</pubDate><guid>https://atsum.in/linux/stdout-gzip/</guid><description>&lt;h2 id="標準出力を直接-gzip-圧縮する">標準出力を直接 gzip 圧縮する&lt;/h2>
&lt;h3 id="-c-オプション">-c オプション&lt;/h3>
&lt;p>コマンドの標準出力を直接&lt;code>gzip&lt;/code>コマンドで圧縮するには&lt;code>-c&lt;/code>オプションを指定して以下のようにする。&lt;/p>
&lt;div class="highlight">&lt;pre tabindex="0" class="chroma">&lt;code class="language-shell" data-lang="shell">&lt;span class="line">&lt;span class="cl">コマンド &lt;span class="p">|&lt;/span> gzip -c &amp;gt; 出力ファイル名.gz
&lt;/span>&lt;/span>&lt;/code>&lt;/pre>&lt;/div>&lt;p>例&lt;/p></description><enclosure url="https://atsum.in/linux/stdout-gzip/img/thumbnail.png" type="image/png"/></item><item><title>【Mac】GNUのsedを使う</title><link>https://atsum.in/mac/gnu-sed/</link><pubDate>Sun, 07 Apr 2024 06:15:21 +0900</pubDate><guid>https://atsum.in/mac/gnu-sed/</guid><description>&lt;h2 id="bsd-sed">BSD sed&lt;/h2>
&lt;p>Macの標準の&lt;code>sed&lt;/code>はBSDの&lt;code>sed&lt;/code>でGNUの&lt;code>sed&lt;/code>とはオプションが異なる。&lt;br>
例えば&lt;code>-i&lt;/code>オプションでファイルを編集する場合、BSDの&lt;code>sed&lt;/code>では&lt;code>-i&lt;/code>オプションに引数が必要となる。&lt;/p></description><enclosure url="https://atsum.in/mac/gnu-sed/img/thumbnail.png" type="image/png"/></item><item><title>【Java】System.console()でコンソールから入力を受け取る</title><link>https://atsum.in/java/system-console/</link><pubDate>Sun, 07 Apr 2024 04:47:29 +0900</pubDate><guid>https://atsum.in/java/system-console/</guid><description>&lt;h2 id="プロンプトを表示して入力を受け取る">プロンプトを表示して入力を受け取る&lt;/h2>
&lt;p>Javaでコンソールから入力を受け取るには&lt;code>System.console()&lt;/code>を使う。
(JDK 1.6以降)&lt;/p>
&lt;div class="highlight" filename="Main.java">&lt;pre tabindex="0" class="chroma">&lt;code class="language-java" data-lang="java">&lt;span class="line">&lt;span class="cl">&lt;span class="kn">import&lt;/span>&lt;span class="w"> &lt;/span>&lt;span class="nn">java.io.Console&lt;/span>&lt;span class="p">;&lt;/span>&lt;span class="w">
&lt;/span>&lt;/span>&lt;/span>&lt;span class="line">&lt;span class="cl">&lt;span class="w">
&lt;/span>&lt;/span>&lt;/span>&lt;span class="line">&lt;span class="cl">&lt;span class="w">&lt;/span>&lt;span class="kd">public&lt;/span>&lt;span class="w"> &lt;/span>&lt;span class="kd">class&lt;/span> &lt;span class="nc">Main&lt;/span>&lt;span class="w"> &lt;/span>&lt;span class="p">{&lt;/span>&lt;span class="w">
&lt;/span>&lt;/span>&lt;/span>&lt;span class="line">&lt;span class="cl">&lt;span class="w"> &lt;/span>&lt;span class="kd">public&lt;/span>&lt;span class="w"> &lt;/span>&lt;span class="kd">static&lt;/span>&lt;span class="w"> &lt;/span>&lt;span class="kt">void&lt;/span>&lt;span class="w"> &lt;/span>&lt;span class="nf">main&lt;/span>&lt;span class="p">(&lt;/span>&lt;span class="n">String&lt;/span>&lt;span class="o">[]&lt;/span>&lt;span class="w"> &lt;/span>&lt;span class="n">args&lt;/span>&lt;span class="p">)&lt;/span>&lt;span class="w"> &lt;/span>&lt;span class="p">{&lt;/span>&lt;span class="w">
&lt;/span>&lt;/span>&lt;/span>&lt;span class="line">&lt;span class="cl">&lt;span class="w"> &lt;/span>&lt;span class="n">Console&lt;/span>&lt;span class="w"> &lt;/span>&lt;span class="n">console&lt;/span>&lt;span class="w"> &lt;/span>&lt;span class="o">=&lt;/span>&lt;span class="w"> &lt;/span>&lt;span class="n">System&lt;/span>&lt;span class="p">.&lt;/span>&lt;span class="na">console&lt;/span>&lt;span class="p">();&lt;/span>&lt;span class="w">
&lt;/span>&lt;/span>&lt;/span>&lt;span class="line">&lt;span class="cl">&lt;span class="w"> &lt;/span>&lt;span class="n">String&lt;/span>&lt;span class="w"> &lt;/span>&lt;span class="n">input&lt;/span>&lt;span class="w"> &lt;/span>&lt;span class="o">=&lt;/span>&lt;span class="w"> &lt;/span>&lt;span class="n">console&lt;/span>&lt;span class="p">.&lt;/span>&lt;span class="na">readLine&lt;/span>&lt;span class="p">(&lt;/span>&lt;span class="s">&amp;#34;input: &amp;#34;&lt;/span>&lt;span class="p">);&lt;/span>&lt;span class="w">
&lt;/span>&lt;/span>&lt;/span>&lt;span class="line">&lt;span class="cl">&lt;span class="w"> &lt;/span>&lt;span class="n">System&lt;/span>&lt;span class="p">.&lt;/span>&lt;span class="na">out&lt;/span>&lt;span class="p">.&lt;/span>&lt;span class="na">println&lt;/span>&lt;span class="p">(&lt;/span>&lt;span class="n">input&lt;/span>&lt;span class="p">);&lt;/span>&lt;span class="w">
&lt;/span>&lt;/span>&lt;/span>&lt;span class="line">&lt;span class="cl">&lt;span class="w"> &lt;/span>&lt;span class="p">}&lt;/span>&lt;span class="w">
&lt;/span>&lt;/span>&lt;/span>&lt;span class="line">&lt;span class="cl">&lt;span class="w">&lt;/span>&lt;span class="p">}&lt;/span>&lt;span class="w">
&lt;/span>&lt;/span>&lt;/span>&lt;/code>&lt;/pre>&lt;/div>&lt;p>&lt;code>readLine&lt;/code>メソッドの引数にプロンプトを指定すると、そのプロンプトが表示されて入力待ちになる。&lt;br>
入力された文字列は&lt;code>String&lt;/code>型で返される。&lt;/p></description><enclosure url="https://atsum.in/java/system-console/img/thumbnail.png" type="image/png"/></item><item><title>【openssl】指定したURLの証明書をコマンドで確認する</title><link>https://atsum.in/linux/openssl-showcert/</link><pubDate>Fri, 05 Apr 2024 22:19:58 +0900</pubDate><guid>https://atsum.in/linux/openssl-showcert/</guid><description>&lt;h2 id="opensslコマンドで指定したurlの証明書を確認する">opensslコマンドで指定したURLの証明書を確認する&lt;/h2>
&lt;p>httpsのURLの証明書をコマンドで確認するには&lt;code>openssl&lt;/code>コマンドを使う。&lt;/p>
&lt;div class="highlight">&lt;pre tabindex="0" class="chroma">&lt;code class="language-shell" data-lang="shell">&lt;span class="line">&lt;span class="cl">$ openssl s_client -connect example.com:443 &amp;lt; /dev/null
&lt;/span>&lt;/span>&lt;/code>&lt;/pre>&lt;/div>&lt;p>&lt;code>openssl s_client&lt;/code>コマンドだけの場合は続きの入力を求められてコマンドが終わらないので&lt;code>&amp;lt; /dev/null&lt;/code>で空入力を渡して終了させている。&lt;/p></description><enclosure url="https://atsum.in/linux/openssl-showcert/img/thumbnail.png" type="image/png"/></item><item><title>【シェルスクリプト】文字のASCIIコードを取得する</title><link>https://atsum.in/linux/shellscript-ascii-code/</link><pubDate>Fri, 05 Apr 2024 05:52:45 +0900</pubDate><guid>https://atsum.in/linux/shellscript-ascii-code/</guid><description>&lt;h2 id="文字のasciiコードを表示する">文字のASCIIコードを表示する&lt;/h2>
&lt;p>&lt;code>printf&lt;/code>コマンドで文字を&lt;code>%d&lt;/code>でフォーマットするとその文字のASCIIコードが表示される。&lt;/p>
&lt;div class="highlight">&lt;pre tabindex="0" class="chroma">&lt;code class="language-shell" data-lang="shell">&lt;span class="line">&lt;span class="cl">$ &lt;span class="nb">printf&lt;/span> &lt;span class="s2">&amp;#34;%d\n&amp;#34;&lt;/span> &lt;span class="s2">&amp;#34;&amp;#39;A&amp;#34;&lt;/span>
&lt;/span>&lt;/span>&lt;span class="line">&lt;span class="cl">&lt;span class="m">65&lt;/span>
&lt;/span>&lt;/span>&lt;/code>&lt;/pre>&lt;/div>&lt;h2 id="シェルスクリプトで文字のasciiコードを取得する">シェルスクリプトで文字のASCIIコードを取得する&lt;/h2>
&lt;p>シェルスクリプトで指定した文字のASCIIコードを取得し、保持したい場合は&lt;code>$()&lt;/code>で&lt;code>printf&lt;/code>コマンドを評価して格納すればよい。&lt;br>
例えば以下のようにする。&lt;/p></description><enclosure url="https://atsum.in/linux/shellscript-ascii-code/img/thumbnail.png" type="image/png"/></item><item><title>【シェルスクリプト】変数や引数のデフォルト値 ${var:-default} ${1:-default}</title><link>https://atsum.in/linux/vars-args-default/</link><pubDate>Tue, 02 Apr 2024 23:51:15 +0900</pubDate><guid>https://atsum.in/linux/vars-args-default/</guid><description>&lt;h2 id="変数のデフォルト値">変数のデフォルト値&lt;/h2>
&lt;p>シェルスクリプトで変数が未定義の場合や空の場合にデフォルト値を設定する方法。&lt;/p>
&lt;div class="highlight">&lt;pre tabindex="0" class="chroma">&lt;code class="language-shell" data-lang="shell">&lt;span class="line">&lt;span class="cl">&lt;span class="si">${&lt;/span>&lt;span class="nv">var&lt;/span>&lt;span class="k">:-&lt;/span>&lt;span class="nv">default&lt;/span>&lt;span class="si">}&lt;/span>
&lt;/span>&lt;/span>&lt;/code>&lt;/pre>&lt;/div>&lt;p>&lt;code>${var:-default}&lt;/code>のように&lt;code>${}&lt;/code>で変数を囲み、&lt;code>:-&lt;/code>でデフォルト値を指定する。&lt;br>
&lt;code>${var:-default}&lt;/code>は&lt;code>var&lt;/code>が定義されている場合は変数&lt;code>var&lt;/code>の値を、未定義の場合や空の場合は文字列&lt;code>default&lt;/code>を表示する。&lt;/p></description><enclosure url="https://atsum.in/linux/vars-args-default/img/thumbnail.png" type="image/png"/></item><item><title>【GitHub Actions】シェルスクリプトでSTEPをまたいでPATHを通す(GITHUB_PATH)</title><link>https://atsum.in/linux/github-actions-githuh-path-variable/</link><pubDate>Sat, 23 Mar 2024 23:47:19 +0900</pubDate><guid>https://atsum.in/linux/github-actions-githuh-path-variable/</guid><description>&lt;h2 id="github_path変数">GITHUB_PATH変数&lt;/h2>
&lt;p>GitHub Actions内のシェルスクリプトで&lt;code>GITHUB_PATH&lt;/code>変数にリダイレクトでパス文字列を追加すると、そのパスが次のSTEPでも有効になる。&lt;/p></description><enclosure url="https://atsum.in/linux/github-actions-githuh-path-variable/img/thumbnail.png" type="image/png"/></item><item><title>【Linux】アーキテクチャを確認する(uname)</title><link>https://atsum.in/linux/uname-arch/</link><pubDate>Sat, 23 Mar 2024 00:35:03 +0900</pubDate><guid>https://atsum.in/linux/uname-arch/</guid><description>&lt;h2 id="uname--m">uname -m&lt;/h2>
&lt;p>Linuxでアーキテクチャを確認するには&lt;code>uname&lt;/code>コマンドを使う。&lt;br>
&lt;code>-m&lt;/code>オプションを指定するとアーキテクチャが表示される。&lt;/p>
&lt;div class="highlight">&lt;pre tabindex="0" class="chroma">&lt;code class="language-shell" data-lang="shell">&lt;span class="line">&lt;span class="cl">$ uname -m
&lt;/span>&lt;/span>&lt;span class="line">&lt;span class="cl">aarch64
&lt;/span>&lt;/span>&lt;/code>&lt;/pre>&lt;/div>&lt;p>macOSでも同様にアーキテクチャを確認できる。&lt;br>
Intel Macの場合は&lt;code>x86_64&lt;/code>が表示され、Apple Silicon Macの場合は&lt;code>arm64&lt;/code>が表示される。&lt;/p></description><enclosure url="https://atsum.in/linux/uname-arch/img/thumbnail.png" type="image/png"/></item><item><title>【1Password】アカウントを追加する方法(Ver.8)</title><link>https://atsum.in/mac/1password-add-accounts/</link><pubDate>Fri, 22 Mar 2024 22:42:31 +0900</pubDate><guid>https://atsum.in/mac/1password-add-accounts/</guid><description>&lt;h2 id="アカウントの追加">アカウントの追加&lt;/h2>
&lt;p>すでに1Passwordを利用していて、別のアカウントを追加したい場合の手順。&lt;br>
まずは1Passwordアプリに既に登録されているアカウントにログインする。&lt;/p></description><enclosure url="https://atsum.in/mac/1password-add-accounts/img/thumbnail.png" type="image/png"/></item><item><title>【PostgreSQL】SQLでテーブル一覧を取得する</title><link>https://atsum.in/database/postgresql-show-tables/</link><pubDate>Tue, 19 Mar 2024 22:22:59 +0900</pubDate><guid>https://atsum.in/database/postgresql-show-tables/</guid><description>&lt;h2 id="sqlでテーブル一覧を取得する">SQLでテーブル一覧を取得する&lt;/h2>
&lt;p>PostgreSQLでテーブル一覧を取得するには&lt;code>information_schema.tables&lt;/code>テーブルを参照する。&lt;/p>
&lt;div class="highlight">&lt;pre tabindex="0" class="chroma">&lt;code class="language-sql" data-lang="sql">&lt;span class="line">&lt;span class="cl">&lt;span class="k">SELECT&lt;/span>&lt;span class="w"> &lt;/span>&lt;span class="k">table_name&lt;/span>&lt;span class="w">
&lt;/span>&lt;/span>&lt;/span>&lt;span class="line">&lt;span class="cl">&lt;span class="w">&lt;/span>&lt;span class="k">FROM&lt;/span>&lt;span class="w"> &lt;/span>&lt;span class="n">information_schema&lt;/span>&lt;span class="p">.&lt;/span>&lt;span class="n">tables&lt;/span>&lt;span class="w">
&lt;/span>&lt;/span>&lt;/span>&lt;span class="line">&lt;span class="cl">&lt;span class="w">&lt;/span>&lt;span class="k">WHERE&lt;/span>&lt;span class="w"> &lt;/span>&lt;span class="n">table_type&lt;/span>&lt;span class="w"> &lt;/span>&lt;span class="o">=&lt;/span>&lt;span class="w"> &lt;/span>&lt;span class="s1">&amp;#39;BASE TABLE&amp;#39;&lt;/span>&lt;span class="w">
&lt;/span>&lt;/span>&lt;/span>&lt;span class="line">&lt;span class="cl">&lt;span class="w">&lt;/span>&lt;span class="k">AND&lt;/span>&lt;span class="w"> &lt;/span>&lt;span class="n">table_schema&lt;/span>&lt;span class="w"> &lt;/span>&lt;span class="o">=&lt;/span>&lt;span class="w"> &lt;/span>&lt;span class="s1">&amp;#39;public&amp;#39;&lt;/span>&lt;span class="w">
&lt;/span>&lt;/span>&lt;/span>&lt;span class="line">&lt;span class="cl">&lt;span class="w">&lt;/span>&lt;span class="k">ORDER&lt;/span>&lt;span class="w"> &lt;/span>&lt;span class="k">BY&lt;/span>&lt;span class="w"> &lt;/span>&lt;span class="k">table_name&lt;/span>&lt;span class="p">;&lt;/span>&lt;span class="w">
&lt;/span>&lt;/span>&lt;/span>&lt;/code>&lt;/pre>&lt;/div>&lt;p>&lt;code>table_schema&lt;/code>の条件にはスキーマ名を指定する。&lt;br>
スキーマ名で絞らない場合&lt;code>pg_catalog&lt;/code>スキーマのシステムテーブルも取得されるため指定しておくとよい。&lt;/p></description><enclosure url="https://atsum.in/database/postgresql-show-tables/img/thumbnail.png" type="image/png"/></item><item><title>【PostgreSQL】psqlコマンドでcsv, tsv形式でクエリ結果を出力する</title><link>https://atsum.in/database/psql-csv-tsv/</link><pubDate>Tue, 19 Mar 2024 11:58:59 +0900</pubDate><guid>https://atsum.in/database/psql-csv-tsv/</guid><description>&lt;h2 id="csv形式でクエリ結果を出力する">CSV形式でクエリ結果を出力する&lt;/h2>
&lt;p>&lt;code>psql&lt;/code>コマンドでクエリ結果をCSV形式で出力するには以下のようにする。&lt;/p>
&lt;div class="highlight">&lt;pre tabindex="0" class="chroma">&lt;code class="language-shell" data-lang="shell">&lt;span class="line">&lt;span class="cl">psql -h ホスト名 -U ユーザ名 -d データベース名 -c &lt;span class="s2">&amp;#34;SQL&amp;#34;&lt;/span> -A -F &lt;span class="s1">&amp;#39;,&amp;#39;&lt;/span> &amp;gt; output.csv
&lt;/span>&lt;/span>&lt;/code>&lt;/pre>&lt;/div>&lt;p>オプションは以下の通り。&lt;/p></description><enclosure url="https://atsum.in/database/psql-csv-tsv/img/thumbnail.png" type="image/png"/></item><item><title>【PostgreSQL】テーブルのレコード件数を高速に概算する</title><link>https://atsum.in/database/pg-faster-count/</link><pubDate>Fri, 15 Mar 2024 22:24:32 +0900</pubDate><guid>https://atsum.in/database/pg-faster-count/</guid><description>&lt;h2 id="高速なレコード件数の取得">高速なレコード件数の取得&lt;/h2>
&lt;p>PostgreSQLで大量のレコードを含むテーブルで&lt;code>count&lt;/code>関数を使って件数取得すると時間がかかる。&lt;/p>
&lt;div class="highlight">&lt;pre tabindex="0" class="chroma">&lt;code class="language-sql" data-lang="sql">&lt;span class="line">&lt;span class="cl">&lt;span class="k">SELECT&lt;/span>&lt;span class="w"> &lt;/span>&lt;span class="k">count&lt;/span>&lt;span class="p">(&lt;/span>&lt;span class="o">*&lt;/span>&lt;span class="p">)&lt;/span>&lt;span class="w"> &lt;/span>&lt;span class="k">FROM&lt;/span>&lt;span class="w"> &lt;/span>&lt;span class="err">テーブル名&lt;/span>&lt;span class="p">;&lt;/span>&lt;span class="w">
&lt;/span>&lt;/span>&lt;/span>&lt;/code>&lt;/pre>&lt;/div>&lt;p>統計情報ビューの一種である&lt;code>pg_stat_user_tables&lt;/code>を使うと高速にレコード件数を取得できる。&lt;/p></description><enclosure url="https://atsum.in/database/pg-faster-count/img/thumbnail.png" type="image/png"/></item><item><title>【GitHub CLI】組織・ユーザ以下のリポジトリのWebhookを一覧表示する</title><link>https://atsum.in/linux/gh-list-hooks/</link><pubDate>Sun, 10 Mar 2024 01:38:53 +0900</pubDate><guid>https://atsum.in/linux/gh-list-hooks/</guid><description>&lt;h2 id="github-cliで組織以下のリポジトリのwebhookを一覧表示する">GitHub CLIで組織以下のリポジトリのWebhookを一覧表示する&lt;/h2>
&lt;p>GitHub CLIで組織以下のリポジトリのWebhookを一覧表示するには以下のようにする。&lt;/p></description><enclosure url="https://atsum.in/linux/gh-list-hooks/img/thumbnail.png" type="image/png"/></item><item><title>【PostgreSQL】json文字列の要素を追加・更新する(jsonb_set, jsonb_insert)</title><link>https://atsum.in/database/jsonb-set/</link><pubDate>Sun, 03 Mar 2024 16:50:42 +0900</pubDate><guid>https://atsum.in/database/jsonb-set/</guid><description>&lt;h2 id="jsonb_set関数">jsonb_set関数&lt;/h2>
&lt;p>&lt;code>jsonb_set&lt;/code>関数はJSON文字列の要素を更新する関数。&lt;br>
以下の書式で定義される。&lt;/p>
&lt;div class="highlight">&lt;pre tabindex="0" class="chroma">&lt;code class="language-sql" data-lang="sql">&lt;span class="line">&lt;span class="cl">&lt;span class="n">jsonb_set&lt;/span>&lt;span class="p">(&lt;/span>&lt;span class="n">target&lt;/span>&lt;span class="p">,&lt;/span>&lt;span class="w"> &lt;/span>&lt;span class="n">path&lt;/span>&lt;span class="p">,&lt;/span>&lt;span class="w"> &lt;/span>&lt;span class="n">new_value&lt;/span>&lt;span class="p">,&lt;/span>&lt;span class="w"> &lt;/span>&lt;span class="p">[&lt;/span>&lt;span class="n">create_missing&lt;/span>&lt;span class="p">])&lt;/span>&lt;span class="w">
&lt;/span>&lt;/span>&lt;/span>&lt;/code>&lt;/pre>&lt;/div>&lt;ul>
&lt;li>target: 更新対象のJSON&lt;/li>
&lt;li>path: 更新する要素のパス&lt;/li>
&lt;li>new_value: 更新する値&lt;/li>
&lt;li>create_missing: パスで指定したキーが無い場合に追加しない場合は&lt;code>false&lt;/code>を指定する&lt;/li>
&lt;/ul>
&lt;h3 id="更新する要素のパス">更新する要素のパス&lt;/h3>
&lt;p>要素のパスは&lt;code>{}&lt;/code>の中にカンマ区切りで指定する。&lt;br>
キーバリューの場合はキー名、配列の場合はインデックスを指定する。&lt;/p></description><enclosure url="https://atsum.in/database/jsonb-set/img/thumbnail.png" type="image/png"/></item><item><title>【AWS CLI】WSL2のLinuxでブラウザが使えない状況でAWS SSOで認証して実行</title><link>https://atsum.in/aws/sso-login-no-browser/</link><pubDate>Wed, 21 Feb 2024 23:01:23 +0900</pubDate><guid>https://atsum.in/aws/sso-login-no-browser/</guid><description>&lt;h2 id="ブラウザが使える状況でのaws-sso-loginコマンドによる通常の認証">ブラウザが使える状況でのaws sso loginコマンドによる通常の認証&lt;/h2>
&lt;p>AWS SSOで認証するには&lt;code>aws sso login&lt;/code>コマンドを使う。&lt;/p>
&lt;div class="highlight">&lt;pre tabindex="0" class="chroma">&lt;code class="language-bash" data-lang="bash">&lt;span class="line">&lt;span class="cl">$ aws sso login --profile &amp;lt;profile-name&amp;gt;
&lt;/span>&lt;/span>&lt;/code>&lt;/pre>&lt;/div>&lt;p>&lt;code>&amp;lt;profile-name&amp;gt;&lt;/code>は&lt;code>~/.aws/config&lt;/code>に設定したプロファイル名を指定する。&lt;/p></description><enclosure url="https://atsum.in/aws/sso-login-no-browser/img/thumbnail.png" type="image/png"/></item><item><title>【Terraform】movedブロックでリファクタリング</title><link>https://atsum.in/terraform/moved-block/</link><pubDate>Sun, 18 Feb 2024 13:02:57 +0900</pubDate><guid>https://atsum.in/terraform/moved-block/</guid><description>&lt;h2 id="movedブロック">movedブロック&lt;/h2>
&lt;p>movedブロックはTerraformのリソース名を変更するためのブロック。&lt;/p>
&lt;p>既にapply済みでAWS上に作成済みのリソースの名称を変更したい場合に利用する。&lt;/p></description><enclosure url="https://atsum.in/terraform/moved-block/img/thumbnail.png" type="image/png"/></item><item><title>DockerでDevice or resource busyでコピーできないresolv.confをリダイレクトで無理やり上書きする</title><link>https://atsum.in/linux/busy-resolve-conf-overwrite/</link><pubDate>Wed, 14 Feb 2024 23:56:43 +0900</pubDate><guid>https://atsum.in/linux/busy-resolve-conf-overwrite/</guid><description>&lt;h2 id="device-or-resource-busy">Device or resource busy&lt;/h2>
&lt;p>Dockerで&lt;a href="https://hub.docker.com/r/prom/blackbox-exporter" target="_blank" rel="noopener nofollow">prom/blackbox-exporter - Docker Image&lt;/a>
をベースにしたイメージを作ろうとしたときに&lt;code>/etc/resolv.conf&lt;/code>を上書きしようとしたら&lt;code>Device or resource busy&lt;/code>というエラーが出て上書きできなかった。&lt;/p></description><enclosure url="https://atsum.in/linux/busy-resolve-conf-overwrite/img/thumbnail.png" type="image/png"/></item><item><title>GitHubでDependabotが作成したPull Requestをフィルタリングする</title><link>https://atsum.in/linux/github-pr-filter-dependabot/</link><pubDate>Tue, 13 Feb 2024 19:17:04 +0900</pubDate><guid>https://atsum.in/linux/github-pr-filter-dependabot/</guid><description>&lt;h2 id="githubのpullrequestを作成者でフィルタリングする">GitHubのPullRequestを作成者でフィルタリングする&lt;/h2>
&lt;p>Pull Requestを作成者でフィルターしたい場合は&lt;code>author:作成者のID&lt;/code>を指定する。&lt;/p>
&lt;p>例えば&lt;code>is:open is:pr author:suer&lt;/code>は&lt;code>suer&lt;/code>が作成したPull Requestをフィルタリングする。&lt;/p></description><enclosure url="https://atsum.in/linux/github-pr-filter-dependabot/img/thumbnail.png" type="image/png"/></item><item><title>nohupコマンドでnohup.outファイルを作成しない</title><link>https://atsum.in/linux/no-nohup-log/</link><pubDate>Fri, 09 Feb 2024 23:47:27 +0900</pubDate><guid>https://atsum.in/linux/no-nohup-log/</guid><description>&lt;h2 id="nohupコマンドとnohupout">nohupコマンドとnohup.out&lt;/h2>
&lt;p>&lt;code>nohup&lt;/code>コマンドを使うと端末を閉じてもプロセスを続行できる。&lt;/p>
&lt;div class="highlight">&lt;pre tabindex="0" class="chroma">&lt;code class="language-shell" data-lang="shell">&lt;span class="line">&lt;span class="cl">$ nohup &lt;span class="nb">command&lt;/span> &lt;span class="p">&amp;amp;&lt;/span>
&lt;/span>&lt;/span>&lt;/code>&lt;/pre>&lt;/div>&lt;p>このとき&lt;code>nohup.out&lt;/code>というファイルが作成され、標準出力と標準エラー出力がリダイレクトされる。&lt;/p></description><enclosure url="https://atsum.in/linux/no-nohup-log/img/thumbnail.png" type="image/png"/></item><item><title>【AWS】Mac で Session Manager でリモートログイン時に ctrl+y で切断されないようにする</title><link>https://atsum.in/aws/ctrl-y/</link><pubDate>Fri, 09 Feb 2024 21:56:18 +0900</pubDate><guid>https://atsum.in/aws/ctrl-y/</guid><description>&lt;h2 id="ctrlyで切断される問題">ctrl+yで切断される問題&lt;/h2>
&lt;p>MacでSession Managerによるリモートログイン時に&lt;code>ctrl+y&lt;/code>を入力するとセッションが切断される。&lt;/p>
&lt;div class="highlight">&lt;pre tabindex="0" class="chroma">&lt;code class="language-shell" data-lang="shell">&lt;span class="line">&lt;span class="cl">$ aws ssm start-session --target i-xxxxxxxxxxxxxxxxx
&lt;/span>&lt;/span>&lt;span class="line">&lt;span class="cl">Starting session with SessionId: xxxxxxxx-xxxx-xxxx-xxxx-xxxxxxxxxxxx
&lt;/span>&lt;/span>&lt;span class="line">&lt;span class="cl">sh-4.2$ ← ここで ctrl+y を入力
&lt;/span>&lt;/span>&lt;span class="line">&lt;span class="cl">sh-5.2$ Cannot perform start session: &lt;span class="nb">read&lt;/span> /dev/stdin: resource temporarily unavailable
&lt;/span>&lt;/span>&lt;span class="line">&lt;span class="cl">$ ← ローカルのシェルに戻る
&lt;/span>&lt;/span>&lt;/code>&lt;/pre>&lt;/div>&lt;p>&lt;code>ctrl+y&lt;/code>は&lt;code>ctrl+k&lt;/code>や&lt;code>ctrl+w&lt;/code>などでカットした文字列を貼り付けるため(yank)に手癖として使ってしまうので、
不意にセッションが切断されると不便。&lt;/p></description><enclosure url="https://atsum.in/aws/ctrl-y/img/thumbnail.png" type="image/png"/></item><item><title>【Docker】docker-compose execでrootユーザーでコンテナにログインする</title><link>https://atsum.in/linux/docker-compose-root-login/</link><pubDate>Tue, 06 Feb 2024 22:20:46 +0900</pubDate><guid>https://atsum.in/linux/docker-compose-root-login/</guid><description>&lt;p>デフォルトユーザが&lt;code>root&lt;/code>でないコンテナで、&lt;code>sudo&lt;/code>コマンドも無い場合にコンテナ内で&lt;code>root&lt;/code>ユーザになる方法。&lt;/p>
&lt;h2 id="docker-composeの-uオプション">docker composeの-uオプション&lt;/h2>
&lt;p>&lt;code>docker compose exec&lt;/code>コマンドに&lt;code>-u&lt;/code>オプションをつけると&lt;code>root&lt;/code>ユーザーでコンテナにログインできる。&lt;/p></description><enclosure url="https://atsum.in/linux/docker-compose-root-login/img/thumbnail.png" type="image/png"/></item><item><title>【AWS EC2】IMDSv1、IMDSv2でアカウントIDを取得するワンライナー</title><link>https://atsum.in/aws/imds-account-id/</link><pubDate>Mon, 05 Feb 2024 00:41:52 +0900</pubDate><guid>https://atsum.in/aws/imds-account-id/</guid><description>&lt;h2 id="curlコマンドでimdsv1のアカウントidを取得する">curlコマンドでIMDSv1のアカウントIDを取得する&lt;/h2>
&lt;p>EC2インスタンスでは&lt;code>169.254.169.254&lt;/code>にHTTPでアクセスするとインスタンスのメタデータを取得できる。&lt;/p>
&lt;p>アカウントIDは&lt;code>http://169.254.169.254/latest/dynamic/instance-identity/document&lt;/code>に含まれている。&lt;/p></description><enclosure url="https://atsum.in/aws/imds-account-id/img/thumbnail.png" type="image/png"/></item><item><title>1Password CLIで添付ファイルがあるアイテムの一覧を取得する</title><link>https://atsum.in/linux/1password-cli-find-attachments/</link><pubDate>Sun, 04 Feb 2024 12:16:00 +0900</pubDate><guid>https://atsum.in/linux/1password-cli-find-attachments/</guid><description>&lt;h2 id="1password-cliで添付ファイルがあるアイテムの一覧を取得するワンライナー">1Password CLIで添付ファイルがあるアイテムの一覧を取得するワンライナー&lt;/h2>
&lt;p>以下のワンライナーで1Password CLIコマンドを使って添付ファイルがあるアイテムの一覧を取得できる。&lt;/p></description><enclosure url="https://atsum.in/linux/1password-cli-find-attachments/img/thumbnail.png" type="image/png"/></item><item><title>timeコマンドの実行結果をファイルに出力する</title><link>https://atsum.in/linux/time-command-result-to-file/</link><pubDate>Sun, 04 Feb 2024 09:21:08 +0900</pubDate><guid>https://atsum.in/linux/time-command-result-to-file/</guid><description>&lt;h2 id="timeコマンドの実行結果がファイルに出力できない">timeコマンドの実行結果がファイルに出力できない&lt;/h2>
&lt;p>以下のように実行すると&lt;code>time&lt;/code>コマンドで出力される経過時間がファイルに出力されない。&lt;/p>
&lt;div class="highlight">&lt;pre tabindex="0" class="chroma">&lt;code class="language-shell" data-lang="shell">&lt;span class="line">&lt;span class="cl">$ &lt;span class="nb">time&lt;/span> ls &amp;gt; ls.txt
&lt;/span>&lt;/span>&lt;span class="line">&lt;span class="cl">ls -G &amp;gt; ls.txt 0.00s user 0.00s system 56% cpu 0.003 total
&lt;/span>&lt;/span>&lt;span class="line">&lt;span class="cl">
&lt;/span>&lt;/span>&lt;span class="line">&lt;span class="cl">$ cat ls.txt
&lt;/span>&lt;/span>&lt;span class="line">&lt;span class="cl">a.txt
&lt;/span>&lt;/span>&lt;span class="line">&lt;span class="cl">b.txt
&lt;/span>&lt;/span>&lt;span class="line">&lt;span class="cl">c.txt
&lt;/span>&lt;/span>&lt;span class="line">&lt;span class="cl">d.txt
&lt;/span>&lt;/span>&lt;span class="line">&lt;span class="cl">e.txt
&lt;/span>&lt;/span>&lt;/code>&lt;/pre>&lt;/div>&lt;p>ターミナルへ経過時間が表示されてしまいファイルへ出力されていない。&lt;/p></description><enclosure url="https://atsum.in/linux/time-command-result-to-file/img/thumbnail.png" type="image/png"/></item><item><title>シェルスクリプトでテキストの先頭に連番をつける(cat -n)</title><link>https://atsum.in/linux/cat-n/</link><pubDate>Sun, 04 Feb 2024 03:09:58 +0900</pubDate><guid>https://atsum.in/linux/cat-n/</guid><description>&lt;h2 id="テキストの連番をつけたい">テキストの連番をつけたい&lt;/h2>
&lt;p>テキストファイルやコマンドの出力結果に連番をつけたい。&lt;/p>
&lt;p>例えば以下のようなテキストがある。&lt;/p>
&lt;div class="highlight">&lt;pre tabindex="0" class="chroma">&lt;code class="language-text" data-lang="text">&lt;span class="line">&lt;span class="cl">xxxx
&lt;/span>&lt;/span>&lt;span class="line">&lt;span class="cl">yyyy
&lt;/span>&lt;/span>&lt;span class="line">&lt;span class="cl">zzzz
&lt;/span>&lt;/span>&lt;/code>&lt;/pre>&lt;/div>&lt;p>このテキストに連番をつけたい。&lt;/p>
&lt;div class="highlight" filename="test.txt">&lt;pre tabindex="0" class="chroma">&lt;code class="language-text" data-lang="text">&lt;span class="line">&lt;span class="cl">1 xxxx
&lt;/span>&lt;/span>&lt;span class="line">&lt;span class="cl">2 yyyy
&lt;/span>&lt;/span>&lt;span class="line">&lt;span class="cl">3 zzzz
&lt;/span>&lt;/span>&lt;/code>&lt;/pre>&lt;/div>&lt;h2 id="cat--n">cat -n&lt;/h2>
&lt;p>&lt;code>cat&lt;/code>コマンドは&lt;code>-n&lt;/code>オプションをつけると出力結果に連番をつけて出力する。&lt;/p></description><enclosure url="https://atsum.in/linux/cat-n/img/thumbnail.png" type="image/png"/></item><item><title>【PostgreSQL】標準入力で受け取った構文エラーのSQLをpsqlで実行したときのステータスコードを0以外にする</title><link>https://atsum.in/database/psql-status-code-from-file/</link><pubDate>Wed, 31 Jan 2024 21:01:25 +0900</pubDate><guid>https://atsum.in/database/psql-status-code-from-file/</guid><description>&lt;h2 id="psqlでエラーが出てもステータスコードが0になるパターン">psqlでエラーが出てもステータスコードが0になるパターン&lt;/h2>
&lt;p>psqlコマンドでSQLファイルから標準入力で受け取って実行するには以下のようにする。&lt;/p>
&lt;div class="highlight">&lt;pre tabindex="0" class="chroma">&lt;code class="language-shell" data-lang="shell">&lt;span class="line">&lt;span class="cl">$ psql -U usename -d dbname &amp;lt; test.sql
&lt;/span>&lt;/span>&lt;/code>&lt;/pre>&lt;/div>&lt;p>上記で&lt;code>test.sql&lt;/code>の内容を受け取ってSQLを実行する。&lt;/p></description><enclosure url="https://atsum.in/database/psql-status-code-from-file/img/thumbnail.png" type="image/png"/></item><item><title>【AWS】セッションマネージャーでポートフォワード</title><link>https://atsum.in/linux/ssm-port-forward/</link><pubDate>Sun, 28 Jan 2024 15:03:45 +0900</pubDate><guid>https://atsum.in/linux/ssm-port-forward/</guid><description>&lt;h2 id="aws-ssmコマンドでポートフォワード">aws ssmコマンドでポートフォワード&lt;/h2>
&lt;p>AWS CLIのサブコマンド&lt;code>aws ssm start-session&lt;/code>ではログインだけでなくポートフォワードもできる。&lt;br>
セッションマネージャーをセッションマネージャーでポートフォワードができるので、SSHのポートを公開する必要が無くなる。&lt;/p></description><enclosure url="https://atsum.in/linux/ssm-port-forward/img/thumbnail.png" type="image/png"/></item><item><title>【Docker】コンテナに入ってコマンドを実行する</title><link>https://atsum.in/linux/docker-exec/</link><pubDate>Tue, 23 Jan 2024 23:08:06 +0900</pubDate><guid>https://atsum.in/linux/docker-exec/</guid><description>&lt;p>起動中のコンテナに入って操作するには&lt;code>docker exec&lt;/code>にシェルを指定して実行する。コンテナに入らず1つのコマンドだけ実行する使い方もある。&lt;/p>
&lt;h2 id="起動中のコンテナに入る">起動中のコンテナに入る&lt;/h2>
&lt;p>&lt;code>docker exec -it &amp;lt;コンテナ&amp;gt; bash&lt;/code>を実行するとコンテナ内のシェルが起動し、そのまま操作できる。&lt;/p></description><enclosure url="https://atsum.in/linux/docker-exec/img/thumbnail.png" type="image/png"/></item><item><title>【TFLint】Warning: [Fixable] List items should be accessed using square brackets(terraform_deprecated_index)の対応</title><link>https://atsum.in/terraform/tflint-terraform-deprecated-index/</link><pubDate>Tue, 23 Jan 2024 00:29:57 +0900</pubDate><guid>https://atsum.in/terraform/tflint-terraform-deprecated-index/</guid><description>&lt;p>TFLintの設定については以下を参照。
&lt;a href="https://atsum.in/terraform/tflint" target="_blank" rel="noopener">【TFLint】Terraformのコードをチェックする&lt;/a>
&lt;/p>
&lt;h2 id="terraform_deprecated_index">terraform_deprecated_index&lt;/h2>
&lt;div class="highlight">&lt;pre tabindex="0" class="chroma">&lt;code class="language-terraform" data-lang="terraform">&lt;span class="line">&lt;span class="cl">&lt;span class="err">リソースの配列&lt;/span>&lt;span class="p">.&lt;/span>&lt;span class="o">*&lt;/span>&lt;span class="p">.&lt;/span>&lt;span class="err">リソースの属性&lt;/span>
&lt;/span>&lt;/span>&lt;/code>&lt;/pre>&lt;/div>&lt;p>のようにリソースのリストの要素をリストで取得しようとするとTFLintで以下のようなWarningが出た。&lt;br>
(例では&lt;code>local.subnets.*.id&lt;/code>と記載した。)&lt;/p></description><enclosure url="https://atsum.in/terraform/tflint-terraform-deprecated-index/img/thumbnail.png" type="image/png"/></item><item><title>【Apache】mod_proxyの代わりにmod_rewriteでリバースプロキシを設定する</title><link>https://atsum.in/linux/apache-mod-rewrite-proxy/</link><pubDate>Sun, 21 Jan 2024 19:25:51 +0900</pubDate><guid>https://atsum.in/linux/apache-mod-rewrite-proxy/</guid><description>&lt;h2 id="mod_proxyで長いurlは設定できない">mod_proxyで長いURLは設定できない&lt;/h2>
&lt;p>Apacheのmod_proxyを使って長いURLを設定しようとした。&lt;/p>
&lt;div class="highlight">&lt;pre tabindex="0" class="chroma">&lt;code class="language-apache" data-lang="apache">&lt;span class="line">&lt;span class="cl">&lt;span class="nb">ProxyPass&lt;/span> &lt;span class="sx">/something/&lt;/span> https://...長いURL...
&lt;/span>&lt;/span>&lt;span class="line">&lt;span class="cl">&lt;span class="nb">ProxyPassReverse&lt;/span> &lt;span class="sx">/something/&lt;/span> https://...長いURL...
&lt;/span>&lt;/span>&lt;/code>&lt;/pre>&lt;/div>&lt;p>以下のようなエラーが出る。&lt;/p></description><enclosure url="https://atsum.in/linux/apache-mod-rewrite-proxy/img/thumbnail.png" type="image/png"/></item><item><title>【Docker】コンテナの外から動作しているプロセスを調べる(docker container top)</title><link>https://atsum.in/linux/docker-container-top/</link><pubDate>Sun, 21 Jan 2024 18:41:13 +0900</pubDate><guid>https://atsum.in/linux/docker-container-top/</guid><description>&lt;h2 id="docker-container-topコマンド">docker container topコマンド&lt;/h2>
&lt;p>Dockerコンテナは最小限のコマンドしかインストールされていないことが多い。&lt;br>
そのためコンテナの中に入ったとしても&lt;code>ps&lt;/code>コマンドが無い場合も多く、プロセスの確認が面倒になる。&lt;/p></description><enclosure url="https://atsum.in/linux/docker-container-top/img/thumbnail.png" type="image/png"/></item><item><title>【Mac】スクリーンキャプチャにつく余白を無くしたい</title><link>https://atsum.in/mac/remove-screen-capture-margin/</link><pubDate>Mon, 15 Jan 2024 17:04:11 +0900</pubDate><guid>https://atsum.in/mac/remove-screen-capture-margin/</guid><description>&lt;h2 id="ウインドウの画面キャプチャでつく余白">ウインドウの画面キャプチャでつく余白&lt;/h2>
&lt;p>&lt;code>Command+Shift+4&lt;/code>の後&lt;code>Space&lt;/code>キーを入力し、マウスでウインドウをクリックすると、そのウインドウの画面キャプチャを撮れる。&lt;/p>
&lt;p>Macのデフォルト設定では上下左右に透明の余白がつく。&lt;/p></description><enclosure url="https://atsum.in/mac/remove-screen-capture-margin/img/thumbnail.png" type="image/png"/></item><item><title>【Mac】1Password CLIのインストールと初期設定</title><link>https://atsum.in/mac/1password-cli/</link><pubDate>Mon, 15 Jan 2024 09:39:08 +0900</pubDate><guid>https://atsum.in/mac/1password-cli/</guid><description>&lt;h2 id="1password-cliのインストール">1Password CLIのインストール&lt;/h2>
&lt;p>Macの場合はHomebrewでインストールできる。&lt;/p>
&lt;div class="highlight">&lt;pre tabindex="0" class="chroma">&lt;code class="language-shell" data-lang="shell">&lt;span class="line">&lt;span class="cl">$ brew install 1password-cli
&lt;/span>&lt;/span>&lt;/code>&lt;/pre>&lt;/div>&lt;p>その他のOSの場合は以下を参照。&lt;/p>
&lt;a href="https://developer.1password.com/docs/cli/get-started/#install" target="_blank" rel="noopener nofollow">Get started with 1Password CLI | 1Password Developer&lt;/a>
&lt;p>正常にインストールできると1Password CLIである&lt;code>op&lt;/code>コマンドを使用できるようになる。&lt;/p></description><enclosure url="https://atsum.in/mac/1password-cli/img/thumbnail.png" type="image/png"/></item><item><title>【Hugo】CloudFront+S3構成で404(Not Found)ページを作成する</title><link>https://atsum.in/hugo/404-page-with-cloudfront/</link><pubDate>Sun, 14 Jan 2024 20:58:15 +0900</pubDate><guid>https://atsum.in/hugo/404-page-with-cloudfront/</guid><description>&lt;h2 id="前提">前提&lt;/h2>
&lt;p>CloudFront+S3構成でサイトを公開していること。&lt;/p>
&lt;h2 id="aws-cloudfrontの設定">AWS CloudFrontの設定&lt;/h2>
&lt;h3 id="コンソールでの作成">コンソールでの作成&lt;/h3>
&lt;p>CloudFrontディストリビューションのエラーページの設定で以下のように404ページを設定する。&lt;/p></description><enclosure url="https://atsum.in/hugo/404-page-with-cloudfront/img/thumbnail.png" type="image/png"/></item><item><title>【Terraform】CloudFront + S3 + Origin Access Control(OAC)でS3のオブジェクトを公開する</title><link>https://atsum.in/terraform/cloudfront-s3-oac/</link><pubDate>Sun, 14 Jan 2024 19:26:53 +0900</pubDate><guid>https://atsum.in/terraform/cloudfront-s3-oac/</guid><description>&lt;h2 id="origin-access-controloac">Origin Access Control(OAC)&lt;/h2>
&lt;p>S3のオブジェクトをCloudFrontで配信する方法の1つ。&lt;br>
S3を非公開設定にしてCloudFrontからのみアクセスできるようにする。&lt;/p></description><enclosure url="https://atsum.in/terraform/cloudfront-s3-oac/img/thumbnail.png" type="image/png"/></item><item><title>【Git】diff-highlightでdiffを見やすくする</title><link>https://atsum.in/linux/git-diff-highlight/</link><pubDate>Sat, 13 Jan 2024 01:07:29 +0900</pubDate><guid>https://atsum.in/linux/git-diff-highlight/</guid><description>&lt;h2 id="diff-highlightにパスを通す">diff-highlightにパスを通す&lt;/h2>
&lt;p>diff-highlightにパスを通す必要がある。&lt;/p>
&lt;p>MacにHomebrewでインストールした場合は既にインストールされているので以下のようにパスを通せばよい。&lt;/p></description><enclosure url="https://atsum.in/linux/git-diff-highlight/img/thumbnail.png" type="image/png"/></item><item><title>【Git】グローバルな.gitignoreを設定する</title><link>https://atsum.in/linux/gitignore-global/</link><pubDate>Fri, 12 Jan 2024 21:20:41 +0900</pubDate><guid>https://atsum.in/linux/gitignore-global/</guid><description>&lt;h2 id="グローバルなgitignoreのデフォルトパス">グローバルな.gitignoreのデフォルトパス&lt;/h2>
&lt;p>Gitのリポジトリによらない、グローバルな.gitignoreを設定するには &lt;code>$HOME/.config/git/ignore&lt;/code> に設定する。&lt;/p>
&lt;div class="highlight">&lt;pre tabindex="0" class="chroma">&lt;code class="language-shell" data-lang="shell">&lt;span class="line">&lt;span class="cl">$ mkdir -p &lt;span class="nv">$HOME&lt;/span>/.config/git
&lt;/span>&lt;/span>&lt;span class="line">&lt;span class="cl">$ touch &lt;span class="nv">$HOME&lt;/span>/.config/git/ignore
&lt;/span>&lt;/span>&lt;/code>&lt;/pre>&lt;/div>&lt;p>上記で&lt;code>$HOME/.config/git/ignore&lt;/code>にファイルを作成した上で無視するファイルを記述する。&lt;/p></description><enclosure url="https://atsum.in/linux/gitignore-global/img/thumbnail.png" type="image/png"/></item><item><title>iTerm2で複数のペインに同じコマンドを同時に実行する</title><link>https://atsum.in/mac/iterm-multi-pane-broadcast/</link><pubDate>Sat, 06 Jan 2024 21:37:28 +0900</pubDate><guid>https://atsum.in/mac/iterm-multi-pane-broadcast/</guid><description>&lt;h2 id="iterm2のbroadcast-input機能">iTerm2のBroadcast Input機能&lt;/h2>
&lt;p>iTerm2にはBroadcast Inputという機能があり、複数のペインに同じコマンドを同時に実行できる。&lt;/p>
&lt;p>&lt;img src="img/iterm-broadcast.gif" alt="Broadcast">&lt;/p>
&lt;p>アプリメニューでは&lt;code>Shell&lt;/code>メニューの&lt;code>Broadcast Input&lt;/code>から設定できる。&lt;/p></description><enclosure url="https://atsum.in/mac/iterm-multi-pane-broadcast/img/thumbnail.png" type="image/png"/></item><item><title>teeコマンドで標準エラー出力もファイルに出力する</title><link>https://atsum.in/linux/tee-stderr/</link><pubDate>Sat, 06 Jan 2024 20:47:00 +0900</pubDate><guid>https://atsum.in/linux/tee-stderr/</guid><description>&lt;h2 id="teeコマンド">teeコマンド&lt;/h2>
&lt;p>teeコマンドで以下のように標準出力をファイルに出力できる。&lt;/p>
&lt;div class="highlight">&lt;pre tabindex="0" class="chroma">&lt;code class="language-shell" data-lang="shell">&lt;span class="line">&lt;span class="cl">コマンド &lt;span class="p">|&lt;/span> tee ファイルパス
&lt;/span>&lt;/span>&lt;/code>&lt;/pre>&lt;/div>&lt;p>上記コマンドでは標準エラーに出力された内容はファイルに出力されない。&lt;/p></description><enclosure url="https://atsum.in/linux/tee-stderr/img/thumbnail.png" type="image/png"/></item><item><title>sshpassで別ファイルに書かれたパスワードを使う(-f)</title><link>https://atsum.in/linux/sshpass-f/</link><pubDate>Sat, 06 Jan 2024 20:06:41 +0900</pubDate><guid>https://atsum.in/linux/sshpass-f/</guid><description>&lt;p>諸事情によりssh、scp、rsync実行時にパスワード入力を自動化する必要があって&lt;code>sshpass&lt;/code>を使う場合に、別ファイルへ保存しておいたパスワードを使う方法。&lt;br>
可能なのであれば公開鍵認証を使うこと。&lt;/p></description><enclosure url="https://atsum.in/linux/sshpass-f/img/thumbnail.png" type="image/png"/></item><item><title>【VSCode】エラー表示を強調して見やすくする拡張(Error Lens)</title><link>https://atsum.in/vscode/error-lens/</link><pubDate>Fri, 05 Jan 2024 01:54:09 +0900</pubDate><guid>https://atsum.in/vscode/error-lens/</guid><description>&lt;h2 id="vscodeの標準のエラー表示">VSCodeの標準のエラー表示&lt;/h2>
&lt;p>VSCodeでコード上のエラーやワーニングは赤や黄色の下線で表示される。&lt;/p>
&lt;p>&lt;img src="img/vscode-error.png" alt="エラー表示">&lt;/p>
&lt;p>マウスホバーで内容を確認できる。&lt;/p>
&lt;p>&lt;img src="img/vscode-error-mouse-hover.png" alt="エラー内容表示">&lt;/p>
&lt;p>VSCodeのエラーやワーニングの波線は控えめなので人によっては見落としてしまう可能性がある。&lt;/p></description><enclosure url="https://atsum.in/vscode/error-lens/img/thumbnail.png" type="image/png"/></item><item><title>【getent hosts】 nslookupやdigコマンドが無いLinux環境でIPアドレスを調べる</title><link>https://atsum.in/linux/ip-with-getent/</link><pubDate>Sat, 30 Dec 2023 15:56:42 +0900</pubDate><guid>https://atsum.in/linux/ip-with-getent/</guid><description>&lt;h2 id="getentコマンド">getentコマンド&lt;/h2>
&lt;p>getentコマンドはLinuxシステムにおいてpasswd, groups, hostsなど様々なデータベースからエントリを取得する。&lt;/p>
&lt;p>getentはシステムが参照している実際のソースから情報を取得し、設定ファイルだけでなく、DNS、NIS、LDAPなどの外部ソースにあるデータを直接確認できる。&lt;/p></description><enclosure url="https://atsum.in/linux/ip-with-getent/img/thumbnail.png" type="image/png"/></item><item><title>【Docker】PostgreSQLコンテナに初期データを投入する(docker-entrypoint-initdb.d)</title><link>https://atsum.in/linux/docker-postgres-init/</link><pubDate>Sat, 30 Dec 2023 12:56:31 +0900</pubDate><guid>https://atsum.in/linux/docker-postgres-init/</guid><description>&lt;h2 id="postgres-official-イメージ">postgres Official イメージ&lt;/h2>
&lt;p>PostgreSQLのDockerイメージとしてオフィシャルイメージがDocker Hubで公開されている。&lt;br>
&lt;a href="https://hub.docker.com/_/postgres">postgres - Official Image&lt;/a>&lt;/p>
&lt;p>このイメージでは初回起動時に初期データを投入するための仕組みが用意されている。&lt;/p></description><enclosure url="https://atsum.in/linux/docker-postgres-init/img/thumbnail.png" type="image/png"/></item><item><title>【AWS】セッションマネージャーでEC2に単発コマンドを実行する</title><link>https://atsum.in/aws/ssm-non-interactive-command/</link><pubDate>Fri, 22 Dec 2023 23:06:09 +0900</pubDate><guid>https://atsum.in/aws/ssm-non-interactive-command/</guid><description>&lt;h2 id="sshでできるような単発コマンドをセッションマネージャーで実行する">sshでできるような単発コマンドをセッションマネージャーで実行する&lt;/h2>
&lt;p>&lt;code>ssh&lt;/code>ではコマンドの最後にリモートホスト上で実行したいコマンドを記述すると、そのコマンドを実行した上で接続を切断する。&lt;br>
例えば&lt;code>ssh ホスト ls -l&lt;/code>のように実行するとリモートホスト上で&lt;code>ls -l&lt;/code>コマンドを実行する。&lt;/p></description><enclosure url="https://atsum.in/aws/ssm-non-interactive-command/img/thumbnail.png" type="image/png"/></item><item><title>【Java】BigDecimalの文字列化で指数表記(E)になるのを避ける(toPlainString)</title><link>https://atsum.in/java/to-plain-string/</link><pubDate>Tue, 19 Dec 2023 01:29:08 +0900</pubDate><guid>https://atsum.in/java/to-plain-string/</guid><description>&lt;h2 id="bigdecimalをtostringすると指数表記に場合がある">BigDecimalをtoStringすると指数表記に場合がある&lt;/h2>
&lt;p>BigDecimalをtoStringすると指数表記になる場合がある。&lt;/p>
&lt;div class="highlight">&lt;pre tabindex="0" class="chroma">&lt;code class="language-java" data-lang="java">&lt;span class="line">&lt;span class="cl">&lt;span class="n">BigDecimal&lt;/span>&lt;span class="w"> &lt;/span>&lt;span class="n">b&lt;/span>&lt;span class="w"> &lt;/span>&lt;span class="o">=&lt;/span>&lt;span class="w"> &lt;/span>&lt;span class="k">new&lt;/span>&lt;span class="w"> &lt;/span>&lt;span class="n">BigDecimal&lt;/span>&lt;span class="p">(&lt;/span>&lt;span class="s">&amp;#34;0.00000000012345&amp;#34;&lt;/span>&lt;span class="p">);&lt;/span>&lt;span class="w">
&lt;/span>&lt;/span>&lt;/span>&lt;span class="line">&lt;span class="cl">&lt;span class="w">&lt;/span>&lt;span class="n">String&lt;/span>&lt;span class="w"> &lt;/span>&lt;span class="n">value&lt;/span>&lt;span class="w"> &lt;/span>&lt;span class="o">=&lt;/span>&lt;span class="w"> &lt;/span>&lt;span class="n">b&lt;/span>&lt;span class="p">.&lt;/span>&lt;span class="na">toString&lt;/span>&lt;span class="p">();&lt;/span>&lt;span class="w">
&lt;/span>&lt;/span>&lt;/span>&lt;span class="line">&lt;span class="cl">&lt;span class="w">&lt;/span>&lt;span class="n">System&lt;/span>&lt;span class="p">.&lt;/span>&lt;span class="na">out&lt;/span>&lt;span class="p">.&lt;/span>&lt;span class="na">println&lt;/span>&lt;span class="p">(&lt;/span>&lt;span class="n">value&lt;/span>&lt;span class="p">);&lt;/span>&lt;span class="w"> &lt;/span>&lt;span class="c1">// 1.2345E-10&lt;/span>&lt;span class="w">
&lt;/span>&lt;/span>&lt;/span>&lt;/code>&lt;/pre>&lt;/div>&lt;p>上記プログラムでは&lt;code>0.00000000012345&lt;/code>を文字列として&lt;code>BigDecimal&lt;/code>に渡しているが、&lt;code>toString()&lt;/code>で文字列化すると&lt;code>1.2345E-10&lt;/code>という指数表記になっている。&lt;/p></description><enclosure url="https://atsum.in/java/to-plain-string/img/thumbnail.png" type="image/png"/></item><item><title>tfenvで好きなバージョンのTerraformを使えるようにする</title><link>https://atsum.in/terraform/tfenv/</link><pubDate>Mon, 04 Dec 2023 23:54:16 +0900</pubDate><guid>https://atsum.in/terraform/tfenv/</guid><description>&lt;h2 id="tfenvとは">tfenvとは&lt;/h2>
&lt;p>&lt;a href="https://github.com/tfutils/tfenv" target="_blank" rel="noopener nofollow">tfenv&lt;/a>
は
rbenvやpyenvのようにTerraformのバージョンを切り替えられるツール。&lt;/p>
&lt;p>好きなバージョンをインストールして切り替えたり、&lt;code>.terraform-version&lt;/code>ファイルを配置して
指定フォルダ以下のTerraformのバージョンを固定したりできる。&lt;/p></description><enclosure url="https://atsum.in/terraform/tfenv/img/thumbnail.png" type="image/png"/></item><item><title>systemctl cat: systemdの設定ファイルの内容を確認する</title><link>https://atsum.in/linux/systemctl-cat/</link><pubDate>Sun, 03 Dec 2023 15:17:59 +0900</pubDate><guid>https://atsum.in/linux/systemctl-cat/</guid><description>&lt;h2 id="systemdの設定ファイル">systemdの設定ファイル&lt;/h2>
&lt;p>systemdの設定ファイルは&lt;code>/etc/systemd/system&lt;/code>や、&lt;code>/usr/lib/systemd/system&lt;/code>など複数箇所に配置されている可能性がある。&lt;br>
サービス名がわかっていてもサービスの設定ファイルを探すには全ての候補を探す必要がある。&lt;/p></description><enclosure url="https://atsum.in/linux/systemctl-cat/img/thumbnail.png" type="image/png"/></item><item><title>【AWS】s3-pit-restoreでS3を特定時点にまとめて復元する</title><link>https://atsum.in/aws/s3-pit-restore/</link><pubDate>Sun, 03 Dec 2023 01:53:45 +0900</pubDate><guid>https://atsum.in/aws/s3-pit-restore/</guid><description>&lt;h2 id="s3-pit-restoreとは">s3-pit-restoreとは&lt;/h2>
&lt;p>&lt;a href="https://github.com/angeloc/s3-pit-restore" target="_blank" rel="noopener nofollow">s3-pit-restore&lt;/a>
はAWSのS3で利用できるポイントインタイムリカバリ機能を提供するコマンドラインツール。&lt;/p>
&lt;p>特定時点にS3を復元できる。&lt;/p>
&lt;p>S3バケットはバージョニングを有効にしておくと、ファイルごとにバージョン管理ができる。&lt;br>
ところがバケット内のすべてのファイルを特定時点の状態にするには全てのファイルを個別に復元する必要がある。&lt;br>
s3-pit-restoreを使うとバケット内のすべてのファイルを特定時点にまとめて復元できる。&lt;/p></description><enclosure url="https://atsum.in/aws/s3-pit-restore/img/thumbnail.png" type="image/png"/></item><item><title>【AWS CLI】s3 cp, s3 syncコマンドの進捗を表示しない</title><link>https://atsum.in/aws/s3-cp-no-progress/</link><pubDate>Thu, 30 Nov 2023 22:44:10 +0900</pubDate><guid>https://atsum.in/aws/s3-cp-no-progress/</guid><description>&lt;h2 id="aws-cliによるコピーコマンドの進捗ログ">AWS CLIによるコピーコマンドの進捗ログ&lt;/h2>
&lt;p>AWS CLIでS3へコピー(&lt;code>aws s3 cp&lt;/code>)するとき、デフォルトでは進捗が表示される。&lt;/p>
&lt;div class="highlight">&lt;pre tabindex="0" class="chroma">&lt;code class="language-bash" data-lang="bash">&lt;span class="line">&lt;span class="cl">$ aws s3 cp s3://bucket-name/path/to/file .
&lt;/span>&lt;/span>&lt;span class="line">&lt;span class="cl">Completed 22.0 MiB/45.5 MiB &lt;span class="o">(&lt;/span>7.1 MiB/s&lt;span class="o">)&lt;/span> with &lt;span class="m">1&lt;/span> file&lt;span class="o">(&lt;/span>s&lt;span class="o">)&lt;/span> remaining
&lt;/span>&lt;/span>&lt;/code>&lt;/pre>&lt;/div>&lt;p>&lt;code>aws s3 sync&lt;/code>コマンドの場合も同様。&lt;/p></description><enclosure url="https://atsum.in/aws/s3-cp-no-progress/img/thumbnail.png" type="image/png"/></item><item><title>ISUCON13に参加して敗退した</title><link>https://atsum.in/linux/isucon13/</link><pubDate>Sun, 26 Nov 2023 10:57:51 +0900</pubDate><guid>https://atsum.in/linux/isucon13/</guid><description>&lt;p>ISUCON13に「炉端焼きはどう生きるか」というチームで参加した。&lt;br>
最終スコアは約10000点で時間切れ。&lt;/p>
&lt;p>復習として準備したことと当日やったことをまとめる。&lt;/p></description><enclosure url="https://atsum.in/linux/isucon13/img/thumbnail.png" type="image/png"/></item><item><title>【Terraform】Amazon FSx for NetApp ONTAPでNFSストレージを構築する</title><link>https://atsum.in/terraform/fsx-ontap/</link><pubDate>Thu, 23 Nov 2023 22:31:41 +0900</pubDate><guid>https://atsum.in/terraform/fsx-ontap/</guid><description>&lt;h2 id="amazon-fsx-for-netapp-ontapとは">Amazon FSx for NetApp ONTAPとは&lt;/h2>
&lt;p>Amazon FSx for NetApp ONTAPはNetApp ONTAPファイルシステム上に構築されたスケーラブルなフルマネージド型のファイルストレージ。&lt;/p></description><enclosure url="https://atsum.in/terraform/fsx-ontap/img/thumbnail.png" type="image/png"/></item><item><title>【Terraform】現在のリージョンを取得する(aws_regionデータソース)</title><link>https://atsum.in/terraform/get-region/</link><pubDate>Tue, 21 Nov 2023 22:43:23 +0900</pubDate><guid>https://atsum.in/terraform/get-region/</guid><description>&lt;h2 id="aws_regionデータソース">aws_regionデータソース&lt;/h2>
&lt;p>現在のリージョンを取得するには&lt;code>aws_region&lt;/code>データソースを使用する。&lt;/p>
&lt;div class="highlight">&lt;pre tabindex="0" class="chroma">&lt;code class="language-terraform" data-lang="terraform">&lt;span class="line">&lt;span class="cl">&lt;span class="kr">data&lt;/span> &lt;span class="s2">&amp;#34;aws_region&amp;#34;&lt;/span> &lt;span class="s2">&amp;#34;current&amp;#34;&lt;/span> &lt;span class="p">{}&lt;/span>
&lt;/span>&lt;/span>&lt;/code>&lt;/pre>&lt;/div>&lt;p>上記データソースを定義したうえで、&lt;code>name&lt;/code>属性を参照することで現在のリージョンを取得できる。&lt;/p></description><enclosure url="https://atsum.in/terraform/get-region/img/thumbnail.png" type="image/png"/></item><item><title>【AWS】マーケットプレイスのAMIのAMI IDを調べる方法</title><link>https://atsum.in/aws/find-ami-id/</link><pubDate>Sun, 19 Nov 2023 22:57:08 +0900</pubDate><guid>https://atsum.in/aws/find-ami-id/</guid><description>&lt;h2 id="awsコンソールでami-idを調べる">AWSコンソールでAMI IDを調べる&lt;/h2>
&lt;p>AWSコンソールのEC2サービスページにアクセスし、左ペインの「AMIカタログ」を選択する。&lt;/p>
&lt;p>&lt;img src="img/ec2-menu.png" alt="AMIカタログ">&lt;/p>
&lt;p>AMI Marketplaceタブを選択し、目的のAMIを検索し選択する。&lt;/p></description><enclosure url="https://atsum.in/aws/find-ami-id/img/thumbnail.png" type="image/png"/></item><item><title>【AWS】when calling the CopyObject operation: Access Denied が発生する場合に必要なIAMポリシー</title><link>https://atsum.in/aws/s3-copy-object-policy/</link><pubDate>Sun, 19 Nov 2023 20:45:51 +0900</pubDate><guid>https://atsum.in/aws/s3-copy-object-policy/</guid><description>&lt;h2 id="s3copyobjectaccess-denied">S3:CopyObjectAccess Denied&lt;/h2>
&lt;p>AWS CLIで&lt;code>aws s3 cp&lt;/code>コマンドを実行するときに、権限によっては以下のようなエラーが発生する。&lt;/p>
&lt;div class="highlight">&lt;pre tabindex="0" class="chroma">&lt;code class="language-bash" data-lang="bash">&lt;span class="line">&lt;span class="cl">$ aws s3 cp s3://... s3://...
&lt;/span>&lt;/span>&lt;span class="line">&lt;span class="cl">copy failed: s3://... to s3://... An error occurred &lt;span class="o">(&lt;/span>AccessDenied&lt;span class="o">)&lt;/span> when calling the CopyObject operation: Access Denied
&lt;/span>&lt;/span>&lt;/code>&lt;/pre>&lt;/div>&lt;p>このエラーが発生する場合、実行ロールに対して適切な権限(IAMポリシー)が付与されていない。&lt;/p></description><enclosure url="https://atsum.in/aws/s3-copy-object-policy/img/thumbnail.png" type="image/png"/></item><item><title>【AWS】Session Managerで放置して接続が切れるまでの時間(idle timeout)を設定する</title><link>https://atsum.in/aws/session-manager-idle-timeout/</link><pubDate>Sun, 19 Nov 2023 02:24:08 +0900</pubDate><guid>https://atsum.in/aws/session-manager-idle-timeout/</guid><description>&lt;h2 id="session-managerの接続を放置すると20分で切断される">Session Managerの接続を放置すると20分で切断される&lt;/h2>
&lt;p>&lt;code>aws ssm start-session&lt;/code>コマンドでSession Managerを使用してEC2インスタンスに接続すると、一定時間の間放置すると接続が切断される。&lt;/p></description><enclosure url="https://atsum.in/aws/session-manager-idle-timeout/img/thumbnail.png" type="image/png"/></item><item><title>特定ポートの使用状況を確認する(lsof, ss, netstat)</title><link>https://atsum.in/linux/inspect-port-usage/</link><pubDate>Sun, 12 Nov 2023 09:24:11 +0900</pubDate><guid>https://atsum.in/linux/inspect-port-usage/</guid><description>&lt;h2 id="lsofコマンド">lsofコマンド&lt;/h2>
&lt;p>&lt;code>lsof&lt;/code>コマンドでポートの使用状況を確認できる。&lt;/p>
&lt;div class="highlight">&lt;pre tabindex="0" class="chroma">&lt;code class="language-shell" data-lang="shell">&lt;span class="line">&lt;span class="cl">$ lsof -i:ポート番号
&lt;/span>&lt;/span>&lt;/code>&lt;/pre>&lt;/div>&lt;p>&lt;code>-i&lt;/code>オプションでポート番号を指定する。&lt;/p>
&lt;p>権限によっては取得できないプロセスがあるので、その場合はroot権限で実行する。&lt;/p></description><enclosure url="https://atsum.in/linux/inspect-port-usage/img/thumbnail.png" type="image/png"/></item><item><title>GitHubに登録した公開鍵でLinuxサーバーにログインできるようにする</title><link>https://atsum.in/linux/ssh-github-keys/</link><pubDate>Tue, 07 Nov 2023 23:33:59 +0900</pubDate><guid>https://atsum.in/linux/ssh-github-keys/</guid><description>&lt;h2 id="githubに登録した公開鍵">GitHubに登録した公開鍵&lt;/h2>
&lt;p>GitHubに登録した公開鍵は以下のURLから確認できる。&lt;/p>
&lt;div class="highlight">&lt;pre tabindex="0" class="chroma">&lt;code class="language-text" data-lang="text">&lt;span class="line">&lt;span class="cl">https://github.com/&amp;lt;ユーザ名&amp;gt;.keys
&lt;/span>&lt;/span>&lt;/code>&lt;/pre>&lt;/div>&lt;h2 id="linuxサーバーにgithubへ登録した公開鍵でsshログインできるようにする">LinuxサーバーにGitHubへ登録した公開鍵でSSHログインできるようにする&lt;/h2>
&lt;p>上記のとおりWeb経由で公開鍵を取得できるので、&lt;code>curl&lt;/code>コマンドで取得して&lt;code>~/ssh/authorized_keys&lt;/code>に追記すればよい。&lt;/p></description><enclosure url="https://atsum.in/linux/ssh-github-keys/img/thumbnail.png" type="image/png"/></item><item><title>TrivyでTerraformのセキュリティスキャン</title><link>https://atsum.in/terraform/trivy-config/</link><pubDate>Mon, 06 Nov 2023 00:37:52 +0900</pubDate><guid>https://atsum.in/terraform/trivy-config/</guid><description>&lt;h2 id="trivyとは">Trivyとは&lt;/h2>
&lt;p>&lt;a href="https://github.com/aquasecurity/trivy" target="_blank" rel="noopener nofollow">Trivy&lt;/a>
は多目的な脆弱性スキャナ。&lt;/p>
&lt;p>Trivyにはさまざまな対象のスキャナがあり、本記事ではTerraformのコード(.tf)をスキャンする方法を記述する。&lt;/p></description><enclosure url="https://atsum.in/terraform/trivy-config/img/thumbnail.png" type="image/png"/></item><item><title>【Docker】コンテナ内のシェルスクリプトの標準出力をjournaldに出力する</title><link>https://atsum.in/linux/docker-stdout-journald/</link><pubDate>Fri, 03 Nov 2023 01:54:25 +0900</pubDate><guid>https://atsum.in/linux/docker-stdout-journald/</guid><description>&lt;h2 id="ロギングドライバー">ロギングドライバー&lt;/h2>
&lt;p>Dockerの標準出力はロギングドライバーの設定によって出力先が変わる。&lt;/p>
&lt;p>ロギングドライバーの設定は&lt;code>docker-compose.yml&lt;/code>の&lt;code>logging&lt;/code>で指定する。&lt;/p></description><enclosure url="https://atsum.in/linux/docker-stdout-journald/img/thumbnail.png" type="image/png"/></item><item><title>改行を含む文字列の変数をechoすると改行が消えるときの対処</title><link>https://atsum.in/linux/shell-reserve-newline-variable/</link><pubDate>Fri, 03 Nov 2023 01:16:43 +0900</pubDate><guid>https://atsum.in/linux/shell-reserve-newline-variable/</guid><description>&lt;h2 id="改行を含む文字列の変数をechoすると改行が消えるパターン">改行を含む文字列の変数をechoすると改行が消えるパターン&lt;/h2>
&lt;p>以下のように&lt;code>echo&lt;/code>で改行を含む文字列の変数を出力すると改行が消える。&lt;/p>
&lt;div class="highlight">&lt;pre tabindex="0" class="chroma">&lt;code class="language-shell" data-lang="shell">&lt;span class="line">&lt;span class="cl">&lt;span class="nv">FOO&lt;/span>&lt;span class="o">=&lt;/span>&lt;span class="k">$(&lt;/span>ls&lt;span class="k">)&lt;/span>
&lt;/span>&lt;/span>&lt;span class="line">&lt;span class="cl">&lt;span class="nb">echo&lt;/span> &lt;span class="nv">$FOO&lt;/span>
&lt;/span>&lt;/span>&lt;span class="line">&lt;span class="cl">bin boot dev etc home lib lib32 lib64 libx32 lost+found media mnt opt proc root run sbin snap srv sys tmp usr var
&lt;/span>&lt;/span>&lt;/code>&lt;/pre>&lt;/div>&lt;p>&lt;code>ls&lt;/code>コマンドは標準では改行区切りで出力されるので、&lt;code>FOO&lt;/code>には改行を含む文字列が入っている。&lt;br>
しかし、変数&lt;code>FOO&lt;/code>に格納したうえで&lt;code>$FOO&lt;/code>を&lt;code>echo&lt;/code>で出力すると改行が消えている。&lt;/p></description><enclosure url="https://atsum.in/linux/shell-reserve-newline-variable/img/thumbnail.png" type="image/png"/></item><item><title>【Kotlin】正規表現でfindとmatchEntireの違い</title><link>https://atsum.in/android/regex-find-match-entire/</link><pubDate>Thu, 02 Nov 2023 22:03:27 +0900</pubDate><guid>https://atsum.in/android/regex-find-match-entire/</guid><description>&lt;h2 id="kotlinのregexクラスのfindメソッドとmatchentireメソッドの違い">KotlinのRegexクラスのfindメソッドとmatchEntireメソッドの違い&lt;/h2>
&lt;p>Kotlinの&lt;code>Regex&lt;/code>クラスの&lt;code>find&lt;/code>メソッドと&lt;code>matchEntire&lt;/code>メソッドはどちらも正規表現にマッチするかを確認し&lt;code>MatchResult&lt;/code>を返すが、以下のとおり挙動が異なる。&lt;/p></description><enclosure url="https://atsum.in/android/regex-find-match-entire/img/thumbnail.png" type="image/png"/></item><item><title>localectlでOSのロケールを設定する</title><link>https://atsum.in/linux/localectl/</link><pubDate>Tue, 31 Oct 2023 05:00:58 +0900</pubDate><guid>https://atsum.in/linux/localectl/</guid><description>&lt;h2 id="ロケールの設定">ロケールの設定&lt;/h2>
&lt;h3 id="現在の設定の確認localectl-status">現在の設定の確認(localectl status)&lt;/h3>
&lt;p>&lt;code>localectl status&lt;/code>コマンドで現在の設定を確認する。&lt;/p>
&lt;div class="highlight">&lt;pre tabindex="0" class="chroma">&lt;code class="language-shell" data-lang="shell">&lt;span class="line">&lt;span class="cl">$ localectl status
&lt;/span>&lt;/span>&lt;span class="line">&lt;span class="cl"> System Locale: &lt;span class="nv">LANG&lt;/span>&lt;span class="o">=&lt;/span>C.UTF-8
&lt;/span>&lt;/span>&lt;span class="line">&lt;span class="cl"> VC Keymap: n/a
&lt;/span>&lt;/span>&lt;span class="line">&lt;span class="cl"> X11 Layout: us
&lt;/span>&lt;/span>&lt;span class="line">&lt;span class="cl"> X11 Model: pc105
&lt;/span>&lt;/span>&lt;/code>&lt;/pre>&lt;/div>&lt;p>上記ではLANGが&lt;code>C.UTF-8&lt;/code>になっているので日本語のロケールが設定されていない。&lt;/p></description><enclosure url="https://atsum.in/linux/localectl/img/thumbnail.png" type="image/png"/></item><item><title>【Ruby】MySQL2 gemで複数SQL文を一度に実行する(Mysql2::Client::MULTI_STATEMENTS)</title><link>https://atsum.in/ruby/mysql2-multi-statements/</link><pubDate>Fri, 27 Oct 2023 21:23:57 +0900</pubDate><guid>https://atsum.in/ruby/mysql2-multi-statements/</guid><description>&lt;h2 id="複数のsql文を許可するmysql2clientmulti_statementsオプション">複数のSQL文を許可するMysql2::Client::MULTI_STATEMENTSオプション&lt;/h2>
&lt;p>&lt;code>query&lt;/code>メソッドで複数文を許可するには&lt;code>Mysql2::Client.new&lt;/code>メソッドの&lt;code>flags&lt;/code>オプションに&lt;code>Mysql2::Client::MULTI_STATEMENTS&lt;/code>を指定する。&lt;/p></description><enclosure url="https://atsum.in/ruby/mysql2-multi-statements/img/thumbnail.png" type="image/png"/></item><item><title>【TFLint】Terraformのコードをチェックする</title><link>https://atsum.in/terraform/tflint/</link><pubDate>Wed, 25 Oct 2023 13:45:08 +0900</pubDate><guid>https://atsum.in/terraform/tflint/</guid><description>&lt;h2 id="tflintとは">TFLintとは&lt;/h2>
&lt;p>TFLintはTerraformのコード(.hcl)をチェックするためのフレームワークを提供する。&lt;br>
実際のチェックルールはプラグインとして提供されている。&lt;br>
AWS用、Azure用、GCP用のように必要なプラグインを導入して利用する。&lt;/p></description><enclosure url="https://atsum.in/terraform/tflint/img/thumbnail.png" type="image/png"/></item><item><title>vimでGithub Copilot</title><link>https://atsum.in/linux/github-copilot-vim/</link><pubDate>Mon, 23 Oct 2023 02:12:54 +0900</pubDate><guid>https://atsum.in/linux/github-copilot-vim/</guid><description>&lt;h2 id="copilotvim">copilot.vim&lt;/h2>
&lt;p>&lt;a href="https://github.com/github/copilot.vim" target="_blank" rel="noopener nofollow">github/copilot.vim&lt;/a>
は
vim/NeoVimでGitHub Copilotを使うためのプラグイン。&lt;/p>
&lt;p>VisualStudio Codeと同様にGitHub Copilotによるコードの提案をvim/NeoVimでも受けられるようになる。&lt;/p></description><enclosure url="https://atsum.in/linux/github-copilot-vim/img/thumbnail.png" type="image/png"/></item><item><title>【ShellCheck】Lintでシェルスクリプトの品質を高める</title><link>https://atsum.in/linux/shellcheck/</link><pubDate>Mon, 23 Oct 2023 01:06:58 +0900</pubDate><guid>https://atsum.in/linux/shellcheck/</guid><description>&lt;h2 id="shellcheckとは">ShellCheckとは&lt;/h2>
&lt;p>&lt;a href="https://github.com/koalaman/shellcheck" target="_blank" rel="noopener nofollow">ShellCheck&lt;/a>
はシェルスクリプトのLintで静的解析ツール。&lt;/p>
&lt;p>よくない書き方や不具合を引き起こしそうな記述を検出してくれる。&lt;/p>
&lt;h2 id="shellcheckの使い方">ShellCheckの使い方&lt;/h2>
&lt;h3 id="インストール">インストール&lt;/h3>
&lt;p>Macの場合はHomebrewでインストールできる。&lt;/p></description><enclosure url="https://atsum.in/linux/shellcheck/img/thumbnail.png" type="image/png"/></item><item><title>【Trivy】Dockerイメージのセキュリティ診断</title><link>https://atsum.in/linux/trivy/</link><pubDate>Sun, 22 Oct 2023 19:18:00 +0900</pubDate><guid>https://atsum.in/linux/trivy/</guid><description>&lt;h2 id="trivyとは">Trivyとは&lt;/h2>
&lt;p>&lt;a href="https://github.com/aquasecurity/trivy" target="_blank" rel="noopener nofollow">Trivy&lt;/a>
は
Dockerイメージの脆弱性を診断するツール。&lt;/p>
&lt;p>オープンソースで公開されており、静的にチェックする。&lt;br>
シングルバイナリで配布されているので、バイナリをダウンロードすればすぐに使える。&lt;/p></description><enclosure url="https://atsum.in/linux/trivy/img/thumbnail.png" type="image/png"/></item><item><title>【Hadolint】DockerfileのLintツールでベストプラクティスをチェックする</title><link>https://atsum.in/linux/hadolint/</link><pubDate>Sun, 22 Oct 2023 13:24:42 +0900</pubDate><guid>https://atsum.in/linux/hadolint/</guid><description>&lt;h2 id="hadolintとは">Hadolintとは&lt;/h2>
&lt;p>&lt;a href="https://github.com/hadolint/hadolint" target="_blank" rel="noopener nofollow">Hadolint&lt;/a>
はDockerfileのLintツールで、
&lt;a href="https://docs.docker.com/develop/develop-images/dockerfile_best-practices/" target="_blank" rel="noopener nofollow">Dockerfileのベストプラクティス&lt;/a>
に
沿っているかをチェックする。&lt;/p>
&lt;h2 id="hadolintの使い方">Hadolintの使い方&lt;/h2>
&lt;h3 id="インストール">インストール&lt;/h3>
&lt;p>Macの場合はHomebrewでインストールできる。&lt;/p></description><enclosure url="https://atsum.in/linux/hadolint/img/thumbnail.png" type="image/png"/></item><item><title>DockleでDockerイメージのベストプラクティス準拠&amp;セキュリティ診断</title><link>https://atsum.in/linux/dockle/</link><pubDate>Sat, 21 Oct 2023 16:04:39 +0900</pubDate><guid>https://atsum.in/linux/dockle/</guid><description>&lt;h2 id="dockleとは">Dockleとは&lt;/h2>
&lt;p>DockleはセキュリティのためのDockerイメージのLinter。Dockerfileの&lt;a href="https://docs.docker.com/develop/develop-images/dockerfile_best-practices/" target="_blank" rel="noopener nofollow">ベストプラクティス&lt;/a>
のチェック、Dockerイメージのセキュリティ診断をする。&lt;/p></description><enclosure url="https://atsum.in/linux/dockle/img/thumbnail.png" type="image/png"/></item><item><title>terraform show, terraform state show, terraform state listでリソースの情報を確認する</title><link>https://atsum.in/terraform/state-show/</link><pubDate>Fri, 20 Oct 2023 22:30:47 +0900</pubDate><guid>https://atsum.in/terraform/state-show/</guid><description>&lt;p>Terraformのコードを書いていて「このリソースの◯◯の値は何ていうプロパティ名だっけ」というときに、
適用済みのリソースから確認したい場合。&lt;/p></description><enclosure url="https://atsum.in/terraform/state-show/img/thumbnail.png" type="image/png"/></item><item><title>【Shell Script】ファイルの最終更新からの経過日数を取得する</title><link>https://atsum.in/linux/elapsed-days/</link><pubDate>Fri, 20 Oct 2023 21:26:33 +0900</pubDate><guid>https://atsum.in/linux/elapsed-days/</guid><description>&lt;h2 id="シェルスクリプトでファイルの最終更新からの経過日数を取得する">シェルスクリプトでファイルの最終更新からの経過日数を取得する&lt;/h2>
&lt;p>シェルスクリプトで&lt;code>/path/to/file&lt;/code>というパスにあるファイルの最終更新からの経過日数を取得するには以下のようにする。&lt;/p>
&lt;div class="highlight">&lt;pre tabindex="0" class="chroma">&lt;code class="language-shell" data-lang="shell">&lt;span class="line">&lt;span class="cl">&lt;span class="nv">days&lt;/span>&lt;span class="o">=&lt;/span>&lt;span class="k">$(($(($(&lt;/span>date +%s&lt;span class="k">)&lt;/span> &lt;span class="o">-&lt;/span> &lt;span class="k">$(&lt;/span>date -r /path/to/file +%s&lt;span class="k">)))&lt;/span> &lt;span class="o">/&lt;/span> &lt;span class="m">86400&lt;/span>&lt;span class="k">))&lt;/span>
&lt;/span>&lt;/span>&lt;span class="line">&lt;span class="cl">&lt;span class="nb">echo&lt;/span> &lt;span class="nv">$days&lt;/span>
&lt;/span>&lt;/span>&lt;/code>&lt;/pre>&lt;/div>&lt;p>以下それぞれの部分の解説。&lt;/p></description><enclosure url="https://atsum.in/linux/elapsed-days/img/thumbnail.png" type="image/png"/></item><item><title>【AWS】Session Managerを通してSSH・SCPする</title><link>https://atsum.in/aws/ssh-over-ssm/</link><pubDate>Thu, 19 Oct 2023 21:21:18 +0900</pubDate><guid>https://atsum.in/aws/ssh-over-ssm/</guid><description>&lt;h2 id="session-managerとは">Session Managerとは&lt;/h2>
&lt;p>AWSのEC2インスタンスにリモート接続するための方法はいくつかあるが、その中の1つに&lt;a href="https://docs.aws.amazon.com/ja_jp/systems-manager/latest/userguide/session-manager.html" target="_blank" rel="noopener nofollow">Session Manager&lt;/a>
がある。&lt;/p>
&lt;p>Session Managerを使うとSSH接続するためのポートを開ける必要がなく、IAMロールで認証できる。&lt;/p></description><enclosure url="https://atsum.in/aws/ssh-over-ssm/img/thumbnail.png" type="image/png"/></item><item><title>sudoでリダイレクトに失敗(permission denied)する場合の対処法</title><link>https://atsum.in/linux/sudo-redirect/</link><pubDate>Thu, 19 Oct 2023 01:00:30 +0900</pubDate><guid>https://atsum.in/linux/sudo-redirect/</guid><description>&lt;h2 id="sudo---ファイル名でpermission-denied">sudo .. &amp;raquo; ファイル名でpermission denied&lt;/h2>
&lt;p>以下の様に&lt;code>sudo&lt;/code>コマンドの結果をファイルに書き込もうとするとエラーになる場合がある。&lt;/p>
&lt;div class="highlight">&lt;pre tabindex="0" class="chroma">&lt;code class="language-shell" data-lang="shell">&lt;span class="line">&lt;span class="cl">$ sudo systemctl status nginx &amp;gt;&amp;gt; /var/log/nginx.log
&lt;/span>&lt;/span>&lt;/code>&lt;/pre>&lt;/div>&lt;p>&lt;code>systemctl&lt;/code>コマンドは&lt;code>root&lt;/code>権限で実行されるが、&lt;code>&amp;gt;&amp;gt; /var/log/nginx.log&lt;/code>の部分は実行ユーザーの権限で実行される。&lt;br>
そのため、&lt;code>/var/log/nginx.log&lt;/code>に書き込む権限がない場合はpermission deniedで失敗する。&lt;/p></description><enclosure url="https://atsum.in/linux/sudo-redirect/img/thumbnail.png" type="image/png"/></item><item><title>systemdのサービスごとに/tmpディレクトリを分ける(PrivateTmp)</title><link>https://atsum.in/linux/systemd-private-tmp/</link><pubDate>Tue, 17 Oct 2023 00:24:09 +0900</pubDate><guid>https://atsum.in/linux/systemd-private-tmp/</guid><description>&lt;h2 id="privatetmpとは">PrivateTmpとは&lt;/h2>
&lt;p>systemdのUnit定義にて&lt;code>PrivateTmp&lt;/code>を&lt;code>yes&lt;/code>もしくは&lt;code>true&lt;/code>にすると、&lt;code>/tmp&lt;/code>ディレクトリ以下に&lt;code>systemd-private-サービス名-UUID&lt;/code>というディレクトリが作成され、そのディレクトリ以下に&lt;code>tmp&lt;/code>ディレクトリが作成される。&lt;/p></description><enclosure url="https://atsum.in/linux/systemd-private-tmp/img/thumbnail.png" type="image/png"/></item><item><title>alpでnginxのアクセスログを解析してボトルネックを探す</title><link>https://atsum.in/linux/alp/</link><pubDate>Sat, 14 Oct 2023 14:49:42 +0900</pubDate><guid>https://atsum.in/linux/alp/</guid><description>&lt;h2 id="alpとは">alpとは&lt;/h2>
&lt;p>&lt;a href="https://github.com/tkuchiki/alp" target="_blank" rel="noopener nofollow">alp(Access Log Profiler)&lt;/a>
はWebサーバーのアクセスログの集計ツール。&lt;/p>
&lt;p>所定の形式で出力されたアクセスログを解析してレスポンスタイムを集計できる。&lt;/p>
&lt;h2 id="準備">準備&lt;/h2>
&lt;h3 id="alpのインストール">alpのインストール&lt;/h3>
&lt;p>&lt;a href="https://github.com/tkuchiki/alp/releases" target="_blank" rel="noopener nofollow">Releases · tkuchiki/alp&lt;/a>
から対応するOS向けの最新版をダウンロードして解凍する。&lt;/p></description><enclosure url="https://atsum.in/linux/alp/img/thumbnail.png" type="image/png"/></item><item><title>kataribeでnginxのアクセスログを解析してボトルネックを探す</title><link>https://atsum.in/linux/kataribe/</link><pubDate>Sat, 14 Oct 2023 00:38:38 +0900</pubDate><guid>https://atsum.in/linux/kataribe/</guid><description>&lt;h2 id="kataribe">kataribe&lt;/h2>
&lt;p>&lt;a href="https://github.com/matsuu/kataribe" target="_blank" rel="noopener nofollow">kataribe&lt;/a>
はWebサーバーのアクセスログを解析してボトルネックを探すためのツール。&lt;/p>
&lt;p>所定の形式で出力されたアクセスログを解析してレスポンスタイムを集計できる。&lt;/p></description><enclosure url="https://atsum.in/linux/kataribe/img/thumbnail.png" type="image/png"/></item><item><title>SSH(OpenSSH)の接続が切れないようにする</title><link>https://atsum.in/linux/ssh-keepalive/</link><pubDate>Wed, 11 Oct 2023 20:28:07 +0900</pubDate><guid>https://atsum.in/linux/ssh-keepalive/</guid><description>&lt;h2 id="sshの接続が切れないようにする設定">SSHの接続が切れないようにする設定&lt;/h2>
&lt;p>SSH(OpenSSH)の接続が切れないようにするには&lt;code>.ssh/config&lt;/code>に以下の設定を追加する。&lt;/p>
&lt;div class="highlight">&lt;pre tabindex="0" class="chroma">&lt;code class="language-bash" data-lang="bash">&lt;span class="line">&lt;span class="cl">ServerAliveInterval &lt;span class="m">60&lt;/span>
&lt;/span>&lt;/span>&lt;span class="line">&lt;span class="cl">TCPKeepAlive yes
&lt;/span>&lt;/span>&lt;/code>&lt;/pre>&lt;/div>&lt;p>ホストごとに設定する場合は以下の通り。&lt;/p></description><enclosure url="https://atsum.in/linux/ssh-keepalive/img/thumbnail.png" type="image/png"/></item><item><title>pt-query-digestでMySQLのスロークエリを集計する</title><link>https://atsum.in/linux/pt-query-digest/</link><pubDate>Mon, 09 Oct 2023 23:15:02 +0900</pubDate><guid>https://atsum.in/linux/pt-query-digest/</guid><description>&lt;h2 id="pt-query-digest">pt-query-digest&lt;/h2>
&lt;p>pt-query-digestはスローログを集計して分析するためのツール。&lt;br>
&lt;a href="https://www.percona.com/software/database-tools/percona-toolkit" target="_blank" rel="noopener nofollow">Percona Toolkit&lt;/a>
に含まれている。&lt;/p>
&lt;h2 id="percona-toolkitのインストール">Percona Toolkitのインストール&lt;/h2>
&lt;h3 id="ubuntuの場合">Ubuntuの場合&lt;/h3>
&lt;div class="highlight">&lt;pre tabindex="0" class="chroma">&lt;code class="language-shell" data-lang="shell">&lt;span class="line">&lt;span class="cl">$ sudo apt install percona-toolkit
&lt;/span>&lt;/span>&lt;/code>&lt;/pre>&lt;/div>&lt;h3 id="centosの場合">CentOSの場合&lt;/h3>
&lt;div class="highlight">&lt;pre tabindex="0" class="chroma">&lt;code class="language-shell" data-lang="shell">&lt;span class="line">&lt;span class="cl">$ sudo yum install -y https://repo.percona.com/yum/percona-release-latest.noarch.rpm
&lt;/span>&lt;/span>&lt;span class="line">&lt;span class="cl">$ sudo yum install -y percona-toolkit
&lt;/span>&lt;/span>&lt;/code>&lt;/pre>&lt;/div>&lt;h2 id="mysqlのスロークエリを出力する設定">MySQLのスロークエリを出力する設定&lt;/h2>
&lt;p>MySQLのスロークエリを出力する設定は以下の通り。&lt;/p></description><enclosure url="https://atsum.in/linux/pt-query-digest/img/thumbnail.png" type="image/png"/></item><item><title>grepコマンドで終了ステータスコードだけほしいときに検索結果を標準出力に出さない方法</title><link>https://atsum.in/linux/grep-quiet/</link><pubDate>Wed, 27 Sep 2023 22:54:04 +0900</pubDate><guid>https://atsum.in/linux/grep-quiet/</guid><description>&lt;h2 id="シェルスクリプトで指定文字列がファイルに含まれるかを確認したい">シェルスクリプトで指定文字列がファイルに含まれるかを確認したい&lt;/h2>
&lt;p>シェルスクリプトで指定文字列がファイルに含まれるかを確認したい場合は&lt;code>grep&lt;/code>コマンドの終了ステータスを確認する。&lt;/p>
&lt;div class="highlight">&lt;pre tabindex="0" class="chroma">&lt;code class="language-bash" data-lang="bash">&lt;span class="line">&lt;span class="cl">&lt;span class="cp">#!/bin/bash
&lt;/span>&lt;/span>&lt;/span>&lt;span class="line">&lt;span class="cl">&lt;span class="cp">&lt;/span>
&lt;/span>&lt;/span>&lt;span class="line">&lt;span class="cl">grep 検索文字列 ファイル名
&lt;/span>&lt;/span>&lt;span class="line">&lt;span class="cl">&lt;span class="k">if&lt;/span> &lt;span class="o">[&lt;/span> &lt;span class="nv">$?&lt;/span> -eq &lt;span class="m">0&lt;/span> &lt;span class="o">]&lt;/span>&lt;span class="p">;&lt;/span> &lt;span class="k">then&lt;/span>
&lt;/span>&lt;/span>&lt;span class="line">&lt;span class="cl"> &lt;span class="nb">echo&lt;/span> &lt;span class="s2">&amp;#34;検索文字列が見つかりました&amp;#34;&lt;/span>
&lt;/span>&lt;/span>&lt;span class="line">&lt;span class="cl">&lt;span class="k">fi&lt;/span>
&lt;/span>&lt;/span>&lt;/code>&lt;/pre>&lt;/div>&lt;p>これを実行すると&lt;code>grep&lt;/code>で引っかかった行が標準出力に出力されるので煩わしい。&lt;/p></description><enclosure url="https://atsum.in/linux/grep-quiet/img/thumbnail.png" type="image/png"/></item><item><title>【Android】gradle wrapperのバージョンアップ</title><link>https://atsum.in/android/upgrade-gradle-wrapper/</link><pubDate>Mon, 18 Sep 2023 19:15:33 +0900</pubDate><guid>https://atsum.in/android/upgrade-gradle-wrapper/</guid><description>&lt;h2 id="gradle-wrapperのバージョンアップ手順">gradle wrapperのバージョンアップ手順&lt;/h2>
&lt;p>以下のコマンドを実行する。&lt;/p>
&lt;div class="highlight">&lt;pre tabindex="0" class="chroma">&lt;code class="language-shell" data-lang="shell">&lt;span class="line">&lt;span class="cl">$ ./gradlew wrapper --gradle-version&lt;span class="o">=&lt;/span>バージョン番号
&lt;/span>&lt;/span>&lt;/code>&lt;/pre>&lt;/div>&lt;p>例えばバージョン&lt;code>8.0.0&lt;/code>に変更する場合は以下のとおりとなる。&lt;/p>
&lt;div class="highlight">&lt;pre tabindex="0" class="chroma">&lt;code class="language-shell" data-lang="shell">&lt;span class="line">&lt;span class="cl">$ ./gradlew wrapper --gradle-version&lt;span class="o">=&lt;/span>8.0.0
&lt;/span>&lt;/span>&lt;/code>&lt;/pre>&lt;/div>&lt;p>次回&lt;code>gradlew&lt;/code>コマンドの実行時に必要なgradleのバージョンが自動的にダウンロードされる。&lt;/p></description><enclosure url="https://atsum.in/android/upgrade-gradle-wrapper/img/thumbnail.png" type="image/png"/></item><item><title>【Android】MobSFで静的セキュリティ解析</title><link>https://atsum.in/android/mobsf/</link><pubDate>Sun, 17 Sep 2023 18:11:49 +0900</pubDate><guid>https://atsum.in/android/mobsf/</guid><description>&lt;h2 id="mobsfとは">MobSFとは&lt;/h2>
&lt;p>&lt;a href="https://github.com/MobSF/Mobile-Security-Framework-MobSF" target="_blank" rel="noopener nofollow">MobSF(Mobile Security Framework)&lt;/a>
はモバイルアプリケーションのセキュリティを評価するためのツール。&lt;br>
オープンソースで公開されており、Android、iOS、Webアプリの脆弱性を検出できる。&lt;/p></description><enclosure url="https://atsum.in/android/mobsf/img/thumbnail.png" type="image/png"/></item><item><title>特定ファイルをオープンしているプロセスを探す</title><link>https://atsum.in/linux/find-processes/</link><pubDate>Sun, 10 Sep 2023 13:07:35 +0900</pubDate><guid>https://atsum.in/linux/find-processes/</guid><description>&lt;h2 id="ロックされて編集できないときにそのファイルをオープンしているプロセスを探したい">ロックされて編集できないときにそのファイルをオープンしているプロセスを探したい&lt;/h2>
&lt;p>MacやLinuxで、ファイルを編集しようとしたり削除しようとしたときにロックされていて処理できないとき、
そのファイルをオープンしているプロセスを特定する方法。&lt;/p></description><enclosure url="https://atsum.in/linux/find-processes/img/thumbnail.png" type="image/png"/></item><item><title>【VSCode】文字化け対策:文字エンコーディングを自動判定してファイルを開く</title><link>https://atsum.in/vscode/auto-guess-encoding/</link><pubDate>Sat, 09 Sep 2023 15:24:20 +0900</pubDate><guid>https://atsum.in/vscode/auto-guess-encoding/</guid><description>&lt;p>Visual Studio Codeはデフォルト設定ではUTF-8でファイルを開こうとする。&lt;br>
Shift-JISのファイルを開いて文字化けしたまう場合の対策方法。&lt;/p>
&lt;h2 id="文字コードの自動判定の設定">文字コードの自動判定の設定&lt;/h2>
&lt;h3 id="uiでの設定">UIでの設定&lt;/h3>
&lt;p>基本設定で&lt;code>Files: Auto Guess Encoding&lt;/code>を探し、チェックを入れる。&lt;/p></description><enclosure url="https://atsum.in/vscode/auto-guess-encoding/img/thumbnail.png" type="image/png"/></item><item><title>【Java】spotbugs-maven-pluginで検出されるFindBugsの一部のルールを無視する</title><link>https://atsum.in/java/spotbugs-maven-plugin-ignore-rules/</link><pubDate>Sat, 09 Sep 2023 01:08:34 +0900</pubDate><guid>https://atsum.in/java/spotbugs-maven-plugin-ignore-rules/</guid><description>&lt;h2 id="バージョン">バージョン&lt;/h2>
&lt;ul>
&lt;li>spotbugs-maven-plugin 4.7.3.5&lt;/li>
&lt;/ul>
&lt;h2 id="pomxml-の設定">pom.xml の設定&lt;/h2>
&lt;p>&lt;code>configuration&lt;/code>タグに&lt;code>excludeFilterFile&lt;/code>タグを追加し、無視するルールを指定するXMLファイルを指定する。
以下では&lt;code>findbugs.xml&lt;/code>というファイルを指定している。&lt;/p></description><enclosure url="https://atsum.in/java/spotbugs-maven-plugin-ignore-rules/img/thumbnail.png" type="image/png"/></item><item><title>【Java】JD-GUIでスタンドアロンでjarごとclassをデコンパイルする</title><link>https://atsum.in/java/jd-gui/</link><pubDate>Sun, 27 Aug 2023 13:03:15 +0900</pubDate><guid>https://atsum.in/java/jd-gui/</guid><description>&lt;h2 id="バージョン">バージョン&lt;/h2>
&lt;ul>
&lt;li>JD-GUI 1.6.6&lt;/li>
&lt;/ul>
&lt;h2 id="ダウンロード">ダウンロード&lt;/h2>
&lt;p>&lt;a href="http://java-decompiler.github.io/" target="_blank" rel="noopener nofollow">Java Decompiler&lt;/a>
からJD-GUIの&lt;code>jd-gui-バージョン-min.jar&lt;/code>をダウンロードする。&lt;/p>
&lt;h2 id="jd-guiを起動">JD-GUIを起動&lt;/h2>
&lt;p>以下のコマンドで起動する。&lt;/p>
&lt;div class="highlight">&lt;pre tabindex="0" class="chroma">&lt;code class="language-shell" data-lang="shell">&lt;span class="line">&lt;span class="cl">$ java -jar jd-gui-バージョン-min.jar
&lt;/span>&lt;/span>&lt;/code>&lt;/pre>&lt;/div>&lt;h2 id="実行例">実行例&lt;/h2>
&lt;p>見たいjarを開くと、jar内のclassが表示される。&lt;/p></description><enclosure url="https://atsum.in/java/jd-gui/img/thumbnail.png" type="image/png"/></item><item><title>コマンドの標準出力を大文字・小文字に変換する</title><link>https://atsum.in/linux/tr-upper-lower/</link><pubDate>Thu, 17 Aug 2023 20:48:14 +0900</pubDate><guid>https://atsum.in/linux/tr-upper-lower/</guid><description>&lt;h2 id="標準出力を大文字に変換する">標準出力を大文字に変換する&lt;/h2>
&lt;p>テキストデータをすべて大文字に変換したい場合、以下のように&lt;code>tr&lt;/code>コマンドを使用する。&lt;/p>
&lt;div class="highlight">&lt;pre tabindex="0" class="chroma">&lt;code class="language-bash" data-lang="bash">&lt;span class="line">&lt;span class="cl">$ &lt;span class="nb">echo&lt;/span> &lt;span class="s2">&amp;#34;abc&amp;#34;&lt;/span> &lt;span class="p">|&lt;/span> tr &lt;span class="s1">&amp;#39;[:lower:]&amp;#39;&lt;/span> &lt;span class="s1">&amp;#39;[:upper:]&amp;#39;&lt;/span>
&lt;/span>&lt;/span>&lt;span class="line">&lt;span class="cl">ABC
&lt;/span>&lt;/span>&lt;/code>&lt;/pre>&lt;/div>&lt;p>上記&lt;code>tr&lt;/code>コマンドは、文字列の中から &lt;code>[:lower:]&lt;/code>（小文字）で指定された文字を&lt;code>[:upper:]&lt;/code>（大文字）に変換する。&lt;br>
結果として、&amp;ldquo;abc&amp;rdquo; が &amp;ldquo;ABC&amp;rdquo; に変換される。&lt;/p></description><enclosure url="https://atsum.in/linux/tr-upper-lower/img/thumbnail.png" type="image/png"/></item><item><title>【Java】Mockitoでモックメソッドの引数を一部だけanyにする</title><link>https://atsum.in/java/mockito-partial-args/</link><pubDate>Sun, 13 Aug 2023 19:47:20 +0900</pubDate><guid>https://atsum.in/java/mockito-partial-args/</guid><description>&lt;h2 id="一部だけをany系のメソッドにする方法">一部だけをany系のメソッドにする方法&lt;/h2>
&lt;p>&lt;code>ArgumentMatchers&lt;/code>クラスの&lt;code>eq&lt;/code>メソッドを使うと、引数の値を指定できる。&lt;/p>
&lt;div class="highlight">&lt;pre tabindex="0" class="chroma">&lt;code class="language-java" data-lang="java">&lt;span class="line">&lt;span class="cl">&lt;span class="kd">public&lt;/span>&lt;span class="w"> &lt;/span>&lt;span class="kd">class&lt;/span> &lt;span class="nc">AppTest&lt;/span>&lt;span class="w"> &lt;/span>&lt;span class="p">{&lt;/span>&lt;span class="w">
&lt;/span>&lt;/span>&lt;/span>&lt;span class="line">&lt;span class="cl">&lt;span class="w">
&lt;/span>&lt;/span>&lt;/span>&lt;span class="line">&lt;span class="cl">&lt;span class="w"> &lt;/span>&lt;span class="nd">@Test&lt;/span>&lt;span class="w">
&lt;/span>&lt;/span>&lt;/span>&lt;span class="line">&lt;span class="cl">&lt;span class="w"> &lt;/span>&lt;span class="kd">public&lt;/span>&lt;span class="w"> &lt;/span>&lt;span class="kt">void&lt;/span>&lt;span class="w"> &lt;/span>&lt;span class="nf">tesFoo&lt;/span>&lt;span class="p">()&lt;/span>&lt;span class="w"> &lt;/span>&lt;span class="p">{&lt;/span>&lt;span class="w">
&lt;/span>&lt;/span>&lt;/span>&lt;span class="line">&lt;span class="cl">&lt;span class="w"> &lt;/span>&lt;span class="n">App&lt;/span>&lt;span class="w"> &lt;/span>&lt;span class="n">app&lt;/span>&lt;span class="w"> &lt;/span>&lt;span class="o">=&lt;/span>&lt;span class="w"> &lt;/span>&lt;span class="n">spy&lt;/span>&lt;span class="p">(&lt;/span>&lt;span class="k">new&lt;/span>&lt;span class="w"> &lt;/span>&lt;span class="n">App&lt;/span>&lt;span class="p">());&lt;/span>&lt;span class="w">
&lt;/span>&lt;/span>&lt;/span>&lt;span class="line">&lt;span class="cl">&lt;span class="w"> &lt;/span>&lt;span class="n">doReturn&lt;/span>&lt;span class="p">(&lt;/span>&lt;span class="s">&amp;#34;&amp;#34;&lt;/span>&lt;span class="p">).&lt;/span>&lt;span class="na">when&lt;/span>&lt;span class="p">(&lt;/span>&lt;span class="n">app&lt;/span>&lt;span class="p">).&lt;/span>&lt;span class="na">foo&lt;/span>&lt;span class="p">(&lt;/span>&lt;span class="n">anyString&lt;/span>&lt;span class="p">(),&lt;/span>&lt;span class="w"> &lt;/span>&lt;span class="n">eq&lt;/span>&lt;span class="p">(&lt;/span>&lt;span class="n">1&lt;/span>&lt;span class="p">));&lt;/span>&lt;span class="w"> &lt;/span>&lt;span class="c1">// 1を指定したい場合は eq(1) にする&lt;/span>&lt;span class="w">
&lt;/span>&lt;/span>&lt;/span>&lt;span class="line">&lt;span class="cl">&lt;span class="w"> &lt;/span>&lt;span class="n">String&lt;/span>&lt;span class="w"> &lt;/span>&lt;span class="n">result&lt;/span>&lt;span class="w"> &lt;/span>&lt;span class="o">=&lt;/span>&lt;span class="w"> &lt;/span>&lt;span class="n">app&lt;/span>&lt;span class="p">.&lt;/span>&lt;span class="na">foo&lt;/span>&lt;span class="p">(&lt;/span>&lt;span class="s">&amp;#34;a&amp;#34;&lt;/span>&lt;span class="p">,&lt;/span>&lt;span class="w"> &lt;/span>&lt;span class="n">1&lt;/span>&lt;span class="p">);&lt;/span>&lt;span class="w">
&lt;/span>&lt;/span>&lt;/span>&lt;span class="line">&lt;span class="cl">&lt;span class="w"> &lt;/span>&lt;span class="n">assertThat&lt;/span>&lt;span class="p">(&lt;/span>&lt;span class="n">result&lt;/span>&lt;span class="p">,&lt;/span>&lt;span class="w"> &lt;/span>&lt;span class="n">is&lt;/span>&lt;span class="p">(&lt;/span>&lt;span class="s">&amp;#34;&amp;#34;&lt;/span>&lt;span class="p">));&lt;/span>&lt;span class="w">
&lt;/span>&lt;/span>&lt;/span>&lt;span class="line">&lt;span class="cl">&lt;span class="w"> &lt;/span>&lt;span class="p">}&lt;/span>&lt;span class="w">
&lt;/span>&lt;/span>&lt;/span>&lt;span class="line">&lt;span class="cl">&lt;span class="w">
&lt;/span>&lt;/span>&lt;/span>&lt;span class="line">&lt;span class="cl">&lt;span class="w">&lt;/span>&lt;span class="p">}&lt;/span>&lt;span class="w">
&lt;/span>&lt;/span>&lt;/span>&lt;/code>&lt;/pre>&lt;/div>&lt;h2 id="mockitoでのモックメソッド">Mockitoでのモックメソッド&lt;/h2>
&lt;p>Mockitoでは&lt;code>doReturn(戻り値).when(モックオブジェクト).メソッド名(引数)&lt;/code>でモックメソッドを作成する。&lt;/p></description><enclosure url="https://atsum.in/java/mockito-partial-args/img/thumbnail.png" type="image/png"/></item><item><title>コマンド結果をdiffコマンドで比較する</title><link>https://atsum.in/linux/diff-two-commands/</link><pubDate>Fri, 11 Aug 2023 18:08:37 +0900</pubDate><guid>https://atsum.in/linux/diff-two-commands/</guid><description>&lt;h2 id="プロセス置換を使用する">プロセス置換を使用する&lt;/h2>
&lt;p>&lt;code>&amp;lt;(コマンド)&lt;/code>でコマンドの出力を&lt;code>diff&lt;/code>コマンドに渡す。&lt;/p>
&lt;div class="highlight">&lt;pre tabindex="0" class="chroma">&lt;code class="language-bash" data-lang="bash">&lt;span class="line">&lt;span class="cl">diff &amp;lt;&lt;span class="o">(&lt;/span>コマンド1&lt;span class="o">)&lt;/span> &amp;lt;&lt;span class="o">(&lt;/span>コマンド2&lt;span class="o">)&lt;/span>
&lt;/span>&lt;/span>&lt;/code>&lt;/pre>&lt;/div>&lt;p>プロセス置換を使わない場合は、一時ファイルを作成してから&lt;code>diff&lt;/code>コマンドに渡す必要がある。&lt;/p></description><enclosure url="https://atsum.in/linux/diff-two-commands/img/thumbnail.png" type="image/png"/></item><item><title>【Java】1文でMapを初期化する Map.of(), Map.ofEntries()</title><link>https://atsum.in/java/map-initialize/</link><pubDate>Sun, 06 Aug 2023 19:45:02 +0900</pubDate><guid>https://atsum.in/java/map-initialize/</guid><description>&lt;h2 id="javaのバージョン">Javaのバージョン&lt;/h2>
&lt;p>Java9以降。&lt;/p>
&lt;h2 id="immutableなmapを1文でmapを初期化する">immutableなMapを1文でMapを初期化する&lt;/h2>
&lt;p>&lt;code>Map.of&lt;/code>または&lt;code>Map.ofEntries&lt;/code>を使用する。&lt;/p>
&lt;div class="highlight" filename="Map.of()">&lt;pre tabindex="0" class="chroma">&lt;code class="language-java" data-lang="java">&lt;span class="line">&lt;span class="cl">&lt;span class="n">Map&lt;/span>&lt;span class="o">&amp;lt;&lt;/span>&lt;span class="n">String&lt;/span>&lt;span class="p">,&lt;/span>&lt;span class="w"> &lt;/span>&lt;span class="n">String&lt;/span>&lt;span class="o">&amp;gt;&lt;/span>&lt;span class="w"> &lt;/span>&lt;span class="n">map&lt;/span>&lt;span class="w"> &lt;/span>&lt;span class="o">=&lt;/span>&lt;span class="w"> &lt;/span>&lt;span class="n">Map&lt;/span>&lt;span class="p">.&lt;/span>&lt;span class="na">of&lt;/span>&lt;span class="p">(&lt;/span>&lt;span class="w">
&lt;/span>&lt;/span>&lt;/span>&lt;span class="line">&lt;span class="cl">&lt;span class="w"> &lt;/span>&lt;span class="s">&amp;#34;key1&amp;#34;&lt;/span>&lt;span class="p">,&lt;/span>&lt;span class="w"> &lt;/span>&lt;span class="s">&amp;#34;value1&amp;#34;&lt;/span>&lt;span class="p">,&lt;/span>&lt;span class="w">
&lt;/span>&lt;/span>&lt;/span>&lt;span class="line">&lt;span class="cl">&lt;span class="w"> &lt;/span>&lt;span class="s">&amp;#34;key2&amp;#34;&lt;/span>&lt;span class="p">,&lt;/span>&lt;span class="w"> &lt;/span>&lt;span class="s">&amp;#34;value2&amp;#34;&lt;/span>&lt;span class="p">,&lt;/span>&lt;span class="w">
&lt;/span>&lt;/span>&lt;/span>&lt;span class="line">&lt;span class="cl">&lt;span class="w"> &lt;/span>&lt;span class="s">&amp;#34;key3&amp;#34;&lt;/span>&lt;span class="p">,&lt;/span>&lt;span class="w"> &lt;/span>&lt;span class="s">&amp;#34;value3&amp;#34;&lt;/span>&lt;span class="w">
&lt;/span>&lt;/span>&lt;/span>&lt;span class="line">&lt;span class="cl">&lt;span class="w">&lt;/span>&lt;span class="p">);&lt;/span>&lt;span class="w">
&lt;/span>&lt;/span>&lt;/span>&lt;/code>&lt;/pre>&lt;/div>&lt;div class="highlight" filename="Map.ofEntries()">&lt;pre tabindex="0" class="chroma">&lt;code class="language-java" data-lang="java">&lt;span class="line">&lt;span class="cl">&lt;span class="n">Map&lt;/span>&lt;span class="o">&amp;lt;&lt;/span>&lt;span class="n">String&lt;/span>&lt;span class="p">,&lt;/span>&lt;span class="w"> &lt;/span>&lt;span class="n">String&lt;/span>&lt;span class="o">&amp;gt;&lt;/span>&lt;span class="w"> &lt;/span>&lt;span class="n">map&lt;/span>&lt;span class="w"> &lt;/span>&lt;span class="o">=&lt;/span>&lt;span class="w"> &lt;/span>&lt;span class="n">Map&lt;/span>&lt;span class="p">.&lt;/span>&lt;span class="na">ofEntries&lt;/span>&lt;span class="p">(&lt;/span>&lt;span class="w">
&lt;/span>&lt;/span>&lt;/span>&lt;span class="line">&lt;span class="cl">&lt;span class="w"> &lt;/span>&lt;span class="n">Map&lt;/span>&lt;span class="p">.&lt;/span>&lt;span class="na">entry&lt;/span>&lt;span class="p">(&lt;/span>&lt;span class="s">&amp;#34;key1&amp;#34;&lt;/span>&lt;span class="p">,&lt;/span>&lt;span class="w"> &lt;/span>&lt;span class="s">&amp;#34;value1&amp;#34;&lt;/span>&lt;span class="p">),&lt;/span>&lt;span class="w">
&lt;/span>&lt;/span>&lt;/span>&lt;span class="line">&lt;span class="cl">&lt;span class="w"> &lt;/span>&lt;span class="n">Map&lt;/span>&lt;span class="p">.&lt;/span>&lt;span class="na">entry&lt;/span>&lt;span class="p">(&lt;/span>&lt;span class="s">&amp;#34;key2&amp;#34;&lt;/span>&lt;span class="p">,&lt;/span>&lt;span class="w"> &lt;/span>&lt;span class="s">&amp;#34;value2&amp;#34;&lt;/span>&lt;span class="p">),&lt;/span>&lt;span class="w">
&lt;/span>&lt;/span>&lt;/span>&lt;span class="line">&lt;span class="cl">&lt;span class="w"> &lt;/span>&lt;span class="n">Map&lt;/span>&lt;span class="p">.&lt;/span>&lt;span class="na">entry&lt;/span>&lt;span class="p">(&lt;/span>&lt;span class="s">&amp;#34;key3&amp;#34;&lt;/span>&lt;span class="p">,&lt;/span>&lt;span class="w"> &lt;/span>&lt;span class="s">&amp;#34;value3&amp;#34;&lt;/span>&lt;span class="p">)&lt;/span>&lt;span class="w">
&lt;/span>&lt;/span>&lt;/span>&lt;span class="line">&lt;span class="cl">&lt;span class="w">&lt;/span>&lt;span class="p">);&lt;/span>&lt;span class="w">
&lt;/span>&lt;/span>&lt;/span>&lt;/code>&lt;/pre>&lt;/div>&lt;p>&lt;code>entry&lt;/code>メソッドをstatic importすれば以下のように記述できる。&lt;/p></description><enclosure url="https://atsum.in/java/map-initialize/img/thumbnail.png" type="image/png"/></item><item><title>【PostgreSQL】テーブル定義とカラム一覧を確認する</title><link>https://atsum.in/database/postgresql-show-columns/</link><pubDate>Sat, 05 Aug 2023 23:06:11 +0900</pubDate><guid>https://atsum.in/database/postgresql-show-columns/</guid><description>&lt;p>テーブル定義を確認するにはpsqlの&lt;code>\d&lt;/code>コマンドを使う。SQLで取得する場合は&lt;code>information_schema.columns&lt;/code>を参照する。&lt;/p></description><enclosure url="https://atsum.in/database/postgresql-show-columns/img/thumbnail.png" type="image/png"/></item><item><title>【Mac】brew --prefix でパッケージのインストールパスを取得する</title><link>https://atsum.in/mac/brew-prefix/</link><pubDate>Sat, 05 Aug 2023 22:49:39 +0900</pubDate><guid>https://atsum.in/mac/brew-prefix/</guid><description>&lt;p>Homebrewのインストールパスは昔から使っているMacの場合は&lt;code>/usr/local/opt&lt;/code>、最近購入したMacの場合は&lt;code>/opt/homebrew/opt&lt;/code>になっている。&lt;br>
.zshrcなどの設定ファイルは引き継ぎつつすべての端末で共有しているので異なるパスを指定するのが面倒となる。&lt;br>
そこで&lt;code>brew --prefix&lt;/code>を使用してパッケージのインストールパスを取得するようにすると便利。&lt;/p></description><enclosure url="https://atsum.in/mac/brew-prefix/img/thumbnail.png" type="image/png"/></item><item><title>【Java】ExecutorServiceで最大スレッド数を指定して並行実行する</title><link>https://atsum.in/java/executor-service-fixed-thread-pool/</link><pubDate>Sat, 29 Jul 2023 18:14:23 +0900</pubDate><guid>https://atsum.in/java/executor-service-fixed-thread-pool/</guid><description>&lt;h2 id="executorservice">ExecutorService&lt;/h2>
&lt;p>&lt;code>ExecutorService&lt;/code>はスレッドを管理するクラス。&lt;/p>
&lt;p>マルチスレッドで並行処理をしたい場合、無制限にスレッドがCPUを専有することを防ぐために、
キューなどを使って最大スレッド数を制限する必要がある。&lt;br>
&lt;code>ExecutorService&lt;/code>を使うと、自分で実装しなくても最大スレッド数を制限した並行処理を簡単に実現できる。&lt;/p></description><enclosure url="https://atsum.in/java/executor-service-fixed-thread-pool/img/thumbnail.png" type="image/png"/></item><item><title>lessコマンドで折り返さないようにするオプション</title><link>https://atsum.in/linux/less-no-wrap/</link><pubDate>Mon, 17 Jul 2023 18:39:47 +0900</pubDate><guid>https://atsum.in/linux/less-no-wrap/</guid><description>&lt;h2 id="lessコマンドで折り返さないようにするオプション">lessコマンドで折り返さないようにするオプション&lt;/h2>
&lt;h3 id="-sオプション">-Sオプション&lt;/h3>
&lt;div class="highlight">&lt;pre tabindex="0" class="chroma">&lt;code class="language-shell" data-lang="shell">&lt;span class="line">&lt;span class="cl">$ less -S
&lt;/span>&lt;/span>&lt;/code>&lt;/pre>&lt;/div>&lt;p>&lt;code>-S&lt;/code>オプションを付けると折り返さずに表示される。&lt;/p>
&lt;h3 id="-sオプションをつけない場合の表示例">-Sオプションをつけない場合の表示例&lt;/h3>
&lt;p>例えば&lt;code>ps&lt;/code>コマンドの出力をlessで見る場合。&lt;br>
&lt;code>-S&lt;/code>オプションをつけないと折り返される。&lt;/p></description><enclosure url="https://atsum.in/linux/less-no-wrap/img/thumbnail.png" type="image/png"/></item><item><title>【AWS】goofysを使ってfstabでS3のフォルダをマウントする</title><link>https://atsum.in/aws/goofys-fstab/</link><pubDate>Sat, 15 Jul 2023 16:37:38 +0900</pubDate><guid>https://atsum.in/aws/goofys-fstab/</guid><description>&lt;h2 id="確認環境">確認環境&lt;/h2>
&lt;ul>
&lt;li>Rocky Linux release 8.5&lt;/li>
&lt;/ul>
&lt;h2 id="goofysとは">goofysとは&lt;/h2>
&lt;p>&lt;a href="https://github.com/kahing/goofys" target="_blank" rel="noopener nofollow">goofys&lt;/a>
はAmazon S3をファイルシステムとしてマウントするためのツール。&lt;br>
POSIX互換のファイルシステムとして動作し、LinuxやmacOSなどのUnix系OSで使用できる。&lt;br>
&lt;code>goofys&lt;/code>を使ってS3のバケットをマウントすると、S3上のファイルをローカルのファイルシステムと同様に扱える。&lt;br>
そのため、LinuxのコマンドでS3上のファイルを直接操作できる。&lt;/p></description><enclosure url="https://atsum.in/aws/goofys-fstab/img/thumbnail.png" type="image/png"/></item><item><title>【GitHub Actions】setup-rubyでプロジェクト直下以外の.ruby-versionを指定する</title><link>https://atsum.in/linux/github-actions-ruby-version/</link><pubDate>Tue, 11 Jul 2023 20:08:52 +0900</pubDate><guid>https://atsum.in/linux/github-actions-ruby-version/</guid><description>&lt;p>Github Actionsのワークフローの記述において、&lt;a href="https://github.com/ruby/setup-ruby" target="_blank" rel="noopener nofollow">setup-ruby&lt;/a>
でプロジェクト直下以外のディレクトリに設置した&lt;code>.ruby-version&lt;/code>ファイルを指定してRubyのバージョンを設定したい。&lt;/p></description><enclosure url="https://atsum.in/linux/github-actions-ruby-version/img/thumbnail.png" type="image/png"/></item><item><title>【Git】 not a git repository (or any of the parent directories)の対処法</title><link>https://atsum.in/linux/github-actions-cli-repository-not-found/</link><pubDate>Wed, 05 Jul 2023 21:45:54 +0900</pubDate><guid>https://atsum.in/linux/github-actions-cli-repository-not-found/</guid><description>&lt;h2 id="原因">原因&lt;/h2>
&lt;p>Gitコマンドで&lt;code>not a git repository (or any of the parent directories)&lt;/code>が表示される場合、カレントディレクトリがGitリポジトリではないことが原因。&lt;br>
カレントディレクトリか上位のディレクトリに&lt;code>.git&lt;/code>ディレクトリがない場合に発生する。&lt;/p></description><enclosure url="https://atsum.in/linux/github-actions-cli-repository-not-found/img/thumbnail.png" type="image/png"/></item><item><title>GitHub Actions の Workflow で v[0-9]+\\.[0-9]+\\.[0-9]+ は v1.0.0 にマッチしない</title><link>https://atsum.in/linux/github-workflow-tags-not-regex/</link><pubDate>Wed, 05 Jul 2023 21:01:33 +0900</pubDate><guid>https://atsum.in/linux/github-workflow-tags-not-regex/</guid><description>&lt;h2 id="タグのパターンマッチで指定するパターン文字列のは正規表現ではない">タグのパターンマッチで指定するパターン文字列のは正規表現ではない&lt;/h2>
&lt;p>Github Actionsのワークフローにおいて&lt;code>tags&lt;/code>に指定するパターン文字列は正規表現ではない。&lt;/p>
&lt;div class="highlight">&lt;pre tabindex="0" class="chroma">&lt;code class="language-yaml" data-lang="yaml">&lt;span class="line">&lt;span class="cl">&lt;span class="nt">on&lt;/span>&lt;span class="p">:&lt;/span>&lt;span class="w">
&lt;/span>&lt;/span>&lt;/span>&lt;span class="line">&lt;span class="cl">&lt;span class="w"> &lt;/span>&lt;span class="nt">push&lt;/span>&lt;span class="p">:&lt;/span>&lt;span class="w">
&lt;/span>&lt;/span>&lt;/span>&lt;span class="line">&lt;span class="cl">&lt;span class="w"> &lt;/span>&lt;span class="nt">tags&lt;/span>&lt;span class="p">:&lt;/span>&lt;span class="w">
&lt;/span>&lt;/span>&lt;/span>&lt;span class="line">&lt;span class="cl">&lt;span class="w"> &lt;/span>- &lt;span class="s2">&amp;#34;v[0-9]+.[0-9]+.[0-9]+&amp;#34;&lt;/span>&lt;span class="w"> &lt;/span>&lt;span class="c"># ←ここ&lt;/span>&lt;span class="w">
&lt;/span>&lt;/span>&lt;/span>&lt;/code>&lt;/pre>&lt;/div>&lt;p>正規表現の場合、&lt;code>.&lt;/code>(ピリオド)だけではどの文字でもマッチするが、&lt;code>tags&lt;/code>で指定するパターンはそもそも正規表現ではない。&lt;/p></description><enclosure url="https://atsum.in/linux/github-workflow-tags-not-regex/img/thumbnail.png" type="image/png"/></item><item><title>【tmux】設定ファイルを即時反映する</title><link>https://atsum.in/linux/tmux-source-file/</link><pubDate>Sat, 01 Jul 2023 18:04:41 +0900</pubDate><guid>https://atsum.in/linux/tmux-source-file/</guid><description>&lt;p>&lt;code>tmux&lt;/code>の設定を変更していて設定内容を確認する場合、毎回&lt;code>tmux&lt;/code>を再起動するのは面倒なので設定ファイルを即時反映させたい。&lt;br>
本記事では再起動せずに即時反映するコマンドを記載する。&lt;/p></description><enclosure url="https://atsum.in/linux/tmux-source-file/img/thumbnail.png" type="image/png"/></item><item><title>【timedatectl】コマンドでタイムゾーンとシステムクロックを設定</title><link>https://atsum.in/linux/timedatectl/</link><pubDate>Sat, 01 Jul 2023 10:47:44 +0900</pubDate><guid>https://atsum.in/linux/timedatectl/</guid><description>&lt;h2 id="timedatectlコマンドとは">timedatectlコマンドとは&lt;/h2>
&lt;p>&lt;code>timedatectl&lt;/code>コマンドはLinuxシステムで時計やタイムゾーンを設定するためのコマンド。&lt;/p>
&lt;p>&lt;code>timedatectl&lt;/code>コマンドは&lt;code>systemd&lt;/code>に含まれるコマンドで、CentOS7以降、Ubuntu15.04以降で採用されている。&lt;/p></description><enclosure url="https://atsum.in/linux/timedatectl/img/thumbnail.png" type="image/png"/></item><item><title>hostnamectlでホスト名を変更する</title><link>https://atsum.in/linux/hostnamectl/</link><pubDate>Sun, 25 Jun 2023 21:57:45 +0900</pubDate><guid>https://atsum.in/linux/hostnamectl/</guid><description>&lt;h2 id="hostnamectlコマンドでホスト名を変更する">hostnamectlコマンドでホスト名を変更する&lt;/h2>
&lt;h3 id="ホスト名の変更">ホスト名の変更&lt;/h3>
&lt;p>&lt;code>sysmemd&lt;/code>が導入されているLinuxディストリビューションでは&lt;code>hostnamectl&lt;/code>コマンドでホスト名を変更できる。&lt;/p>
&lt;div class="highlight">&lt;pre tabindex="0" class="chroma">&lt;code class="language-shell" data-lang="shell">&lt;span class="line">&lt;span class="cl">$ sudo hostnamectl set-hostname 新しいホスト名
&lt;/span>&lt;/span>&lt;/code>&lt;/pre>&lt;/div>&lt;p>例えば&lt;code>foo.example.com&lt;/code>というホスト名にする場合は以下のようになる。&lt;/p></description><enclosure url="https://atsum.in/linux/hostnamectl/img/thumbnail.png" type="image/png"/></item><item><title>【macOS】CLIでカスタムKeyChainを削除する</title><link>https://atsum.in/mac/delete-custom-keychain/</link><pubDate>Tue, 06 Jun 2023 00:08:30 +0900</pubDate><guid>https://atsum.in/mac/delete-custom-keychain/</guid><description>&lt;h2 id="カスタムkeychainの削除">カスタムKeyChainの削除&lt;/h2>
&lt;p>カスタムKeyChainをコマンドで削除するには&lt;code>security&lt;/code>コマンドを使って以下のように実行する。&lt;/p>
&lt;div class="highlight">&lt;pre tabindex="0" class="chroma">&lt;code class="language-shell" data-lang="shell">&lt;span class="line">&lt;span class="cl">$ security delete-keychain &amp;lt;keychain&amp;gt;
&lt;/span>&lt;/span>&lt;/code>&lt;/pre>&lt;/div>&lt;p>&lt;img src="img/custom-keychain.png" alt="カスタムKeyChain">&lt;/p>
&lt;p>上記のようにtest-keychain-dbというカスタムKeyChainがある場合は以下のように実行する。&lt;/p></description><enclosure url="https://atsum.in/mac/delete-custom-keychain/img/thumbnail.png" type="image/png"/></item><item><title>【Linux】シングルクオート内でシングルクォートをエスケープする</title><link>https://atsum.in/linux/single-quote-escape/</link><pubDate>Mon, 05 Jun 2023 00:35:21 +0900</pubDate><guid>https://atsum.in/linux/single-quote-escape/</guid><description>&lt;h2 id="シングルクオート内でシングルクォートを書く">シングルクオート内でシングルクォートを書く&lt;/h2>
&lt;p>コマンドやシェルスクリプトにおいて、シングルクオート内でシングルクォートを書くには&lt;code>'\''&lt;/code>と書く。&lt;/p>
&lt;div class="highlight">&lt;pre tabindex="0" class="chroma">&lt;code class="language-shell" data-lang="shell">&lt;span class="line">&lt;span class="cl">$ &lt;span class="nb">echo&lt;/span> &lt;span class="s1">&amp;#39;It&amp;#39;&lt;/span>&lt;span class="se">\&amp;#39;&lt;/span>&lt;span class="s1">&amp;#39;s me&amp;#39;&lt;/span>
&lt;/span>&lt;/span>&lt;span class="line">&lt;span class="cl">It&lt;span class="err">&amp;#39;&lt;/span>s me
&lt;/span>&lt;/span>&lt;/code>&lt;/pre>&lt;/div>&lt;h2 id="ダブルクオート内の場合はエスケープ不要">ダブルクオート内の場合はエスケープ不要&lt;/h2>
&lt;p>ダブルクオート内の場合はエスケープしなくてよい。&lt;/p></description><enclosure url="https://atsum.in/linux/single-quote-escape/img/thumbnail.png" type="image/png"/></item><item><title>【Android,Kotlin】requestPermissionsのDeprecated warningの対応方法</title><link>https://atsum.in/android/request-permissions-deprecated/</link><pubDate>Thu, 04 May 2023 15:30:44 +0900</pubDate><guid>https://atsum.in/android/request-permissions-deprecated/</guid><description>&lt;h2 id="従来の権限リクエスト">従来の権限リクエスト&lt;/h2>
&lt;p>Androidでカメラなどの権限リクエストは以下の形式になっていた。&lt;/p>
&lt;ol>
&lt;li>Fragment#requestPermissions() を呼び出すとダイアログを表示&lt;/li>
&lt;li>許可・不許可をユーザーが選択する&lt;/li>
&lt;li>Framgment#onRequestPermissionsResult() がコールバックで呼ばれる&lt;/li>
&lt;/ol>
&lt;p>コードでは以下のように実装する。&lt;/p></description><enclosure url="https://atsum.in/android/request-permissions-deprecated/img/thumbnail.png" type="image/png"/></item><item><title>Bundlerのディレクトリから使用されていないバージョンのGemを削除する</title><link>https://atsum.in/ruby/bundle-clean/</link><pubDate>Sun, 30 Apr 2023 21:59:23 +0900</pubDate><guid>https://atsum.in/ruby/bundle-clean/</guid><description>&lt;p>Ruby on Railsで開発をしているとBundlerのディレクトリに使用されていないバージョンのGemが溜まっていく。&lt;br>
それなりにディスクを消費するので古いバージョンのGemは削除したい。&lt;/p></description><enclosure url="https://atsum.in/ruby/bundle-clean/img/thumbnail.png" type="image/png"/></item><item><title>【Mac】コマンドラインで画像ファイルを最適化: ImageOptim-CLI</title><link>https://atsum.in/mac/imageoptim-cli/</link><pubDate>Sun, 30 Apr 2023 15:36:14 +0900</pubDate><guid>https://atsum.in/mac/imageoptim-cli/</guid><description>&lt;h2 id="画像ファイルの圧縮">画像ファイルの圧縮&lt;/h2>
&lt;p>このブログでも画像ファイルを使用しているが、画像ファイルはできるだけ容量を小さくしたい。&lt;br>
&lt;a href="https://apps.apple.com/jp/app/id1450716465" target="_blank" rel="noopener nofollow">ImageOptim&lt;/a>
は画像ファイルを手軽に軽量かできるGUIツール。&lt;br>
GUIツールは自動化に向かないのでこれをコマンドラインで実行したい。&lt;/p></description><enclosure url="https://atsum.in/mac/imageoptim-cli/img/thumbnail.png" type="image/png"/></item><item><title>【Terraform】planの結果をファイルに保存するときにエスケープシーケンス(カラー)を消す</title><link>https://atsum.in/terraform/plan-no-color/</link><pubDate>Sun, 30 Apr 2023 01:54:32 +0900</pubDate><guid>https://atsum.in/terraform/plan-no-color/</guid><description>&lt;h2 id="terraform-planの結果のエスケープシーケンス">terraform planの結果のエスケープシーケンス&lt;/h2>
&lt;p>terraform planの結果をファイルへ保存するとエスケープシーケンスが残ってしまう。&lt;/p>
&lt;div class="highlight">&lt;pre tabindex="0" class="chroma">&lt;code class="language-shell" data-lang="shell">&lt;span class="line">&lt;span class="cl">$ terraform plan &amp;gt; plan.txt
&lt;/span>&lt;/span>&lt;span class="line">&lt;span class="cl">$ less plan
&lt;/span>&lt;/span>&lt;span class="line">&lt;span class="cl">ESC&lt;span class="o">[&lt;/span>0mESC&lt;span class="o">[&lt;/span>1mdata.aws_iam_policy_document.instance_profile_assume_role: Reading...ESC&lt;span class="o">[&lt;/span>0mESC&lt;span class="o">[&lt;/span>0m
&lt;/span>&lt;/span>&lt;span class="line">&lt;span class="cl">ESC&lt;span class="o">[&lt;/span>0mESC&lt;span class="o">[&lt;/span>1mdata.aws_iam_policy_document.instance_profile_assume_role: Read &lt;span class="nb">complete&lt;/span> after 0s &lt;span class="o">[&lt;/span>&lt;span class="nv">id&lt;/span>&lt;span class="o">=&lt;/span>1903849331&lt;span class="o">]&lt;/span>ESC&lt;span class="o">[&lt;/span>0m
&lt;/span>&lt;/span>&lt;span class="line">&lt;span class="cl">
&lt;/span>&lt;/span>&lt;span class="line">&lt;span class="cl">Terraform used the selected providers to generate the following execution
&lt;/span>&lt;/span>&lt;span class="line">&lt;span class="cl">plan. Resource actions are indicated with the following symbols:
&lt;/span>&lt;/span>&lt;span class="line">&lt;span class="cl"> ESC&lt;span class="o">[&lt;/span>32m+ESC&lt;span class="o">[&lt;/span>0m create
&lt;/span>&lt;/span>&lt;span class="line">&lt;span class="cl">ESC&lt;span class="o">[&lt;/span>0m
&lt;/span>&lt;/span>&lt;span class="line">&lt;span class="cl">Terraform will perform the following actions:
&lt;/span>&lt;/span>&lt;span class="line">&lt;span class="cl">.
&lt;/span>&lt;/span>&lt;span class="line">&lt;span class="cl">.
&lt;/span>&lt;/span>&lt;span class="line">&lt;span class="cl">.
&lt;/span>&lt;/span>&lt;/code>&lt;/pre>&lt;/div>&lt;h2 id="terraform-plan--no-colorでエスケープシーケンスを消す">terraform plan -no-colorでエスケープシーケンスを消す&lt;/h2>
&lt;p>&lt;code>-no-color&lt;/code>オプションを付加するとエスケープシーケンスが消える。&lt;/p></description><enclosure url="https://atsum.in/terraform/plan-no-color/img/thumbnail.png" type="image/png"/></item><item><title>systemdのユニット設定を編集する</title><link>https://atsum.in/linux/systemctl-edit/</link><pubDate>Sat, 29 Apr 2023 16:17:51 +0900</pubDate><guid>https://atsum.in/linux/systemctl-edit/</guid><description>&lt;h2 id="systemd-edit-full-ユニット名">systemd edit &amp;ndash;full ユニット名&lt;/h2>
&lt;p>&lt;code>systemctl edit --full ユニット名&lt;/code>でユニットファイルを編集できる。&lt;/p>
&lt;div class="highlight">&lt;pre tabindex="0" class="chroma">&lt;code class="language-shell" data-lang="shell">&lt;span class="line">&lt;span class="cl">$ sudo systemctl edit --full ユニット名.service
&lt;/span>&lt;/span>&lt;/code>&lt;/pre>&lt;/div>&lt;p>&lt;code>.serevice&lt;/code>は省略できる。&lt;/p>
&lt;div class="highlight">&lt;pre tabindex="0" class="chroma">&lt;code class="language-shell" data-lang="shell">&lt;span class="line">&lt;span class="cl">$ sudo systemctl edit --full ユニット名
&lt;/span>&lt;/span>&lt;/code>&lt;/pre>&lt;/div>&lt;p>上記コマンドを実行するとユニットの設定ファイルがエディタで開かれる。&lt;/p></description><enclosure url="https://atsum.in/linux/systemctl-edit/img/thumbnail.png" type="image/png"/></item><item><title>【Mac】networkQualityコマンドでネットワーク速度の測定</title><link>https://atsum.in/mac/network-quality/</link><pubDate>Sat, 29 Apr 2023 09:48:15 +0900</pubDate><guid>https://atsum.in/mac/network-quality/</guid><description>&lt;h2 id="networkqualityコマンド">networkQualityコマンド&lt;/h2>
&lt;p>&lt;code>networkQuality&lt;/code>コマンドはネットワークの速度を測定するコマンド。&lt;/p>
&lt;p>macOS 12 Monterey以降で使える。&lt;/p>
&lt;div class="highlight">&lt;pre tabindex="0" class="chroma">&lt;code class="language-shell" data-lang="shell">&lt;span class="line">&lt;span class="cl">$ &lt;span class="nv">networkQuality&lt;/span>
&lt;/span>&lt;/span>&lt;span class="line">&lt;span class="cl">&lt;span class="o">====&lt;/span> &lt;span class="nv">SUMMARY&lt;/span> &lt;span class="o">====&lt;/span>
&lt;/span>&lt;/span>&lt;span class="line">&lt;span class="cl">Uplink capacity: 82.130 Mbps
&lt;/span>&lt;/span>&lt;span class="line">&lt;span class="cl">Downlink capacity: 23.997 Mbps
&lt;/span>&lt;/span>&lt;span class="line">&lt;span class="cl">Responsiveness: Low &lt;span class="o">(&lt;/span>&lt;span class="m">45&lt;/span> RPM&lt;span class="o">)&lt;/span>
&lt;/span>&lt;/span>&lt;span class="line">&lt;span class="cl">Idle Latency: 12.042 milliseconds
&lt;/span>&lt;/span>&lt;/code>&lt;/pre>&lt;/div>&lt;p>Uplink capacityはアップロード速度、Downlink capacityはダウンロード速度。&lt;/p></description><enclosure url="https://atsum.in/mac/network-quality/img/thumbnail.png" type="image/png"/></item><item><title>【firewalld】拒否したときにログを出力する</title><link>https://atsum.in/linux/firewalld-denied-log/</link><pubDate>Sat, 22 Apr 2023 13:23:16 +0900</pubDate><guid>https://atsum.in/linux/firewalld-denied-log/</guid><description>&lt;p>&lt;code>firewalld&lt;/code>をインストールしているリバースプロキシやロードバランサー配下のWebサーバーに
HTTPリクエストが届かなかった場合に、&lt;code>firewalld&lt;/code>が拒否しているのか、前段のサーバーが止めているのか把握しづらいことがある。&lt;/p></description><enclosure url="https://atsum.in/linux/firewalld-denied-log/img/thumbnail.png" type="image/png"/></item><item><title>【Prometheus】node_exporter で err=couldn't get SNTP reply: read udp... の対処法</title><link>https://atsum.in/linux/node-exporter-error/</link><pubDate>Sat, 22 Apr 2023 11:11:09 +0900</pubDate><guid>https://atsum.in/linux/node-exporter-error/</guid><description>&lt;h2 id="症状と原因">症状と原因&lt;/h2>
&lt;p>&lt;code>node_exporter&lt;/code>で以下のようなエラーが出力される場合、&lt;code>node_exporter&lt;/code>からローカルの&lt;code>NTP&lt;/code>サーバーにアクセスできないのが原因。&lt;/p></description><enclosure url="https://atsum.in/linux/node-exporter-error/img/thumbnail.png" type="image/png"/></item><item><title>【Docker】不要なコンテナ、イメージ、ネットワーク、ボリュームの一括削除</title><link>https://atsum.in/linux/docker-sweep/</link><pubDate>Thu, 20 Apr 2023 08:10:00 +0900</pubDate><guid>https://atsum.in/linux/docker-sweep/</guid><description>&lt;p>公開されているDockerイメージを試したりしているといつの間にか不要なイメージでディスク容量が圧迫されてしまう。&lt;br>
不要なイメージ、コンテナ、ネットワーク、ボリュームを一括削除する方法をまとめる。&lt;/p></description><enclosure url="https://atsum.in/linux/docker-sweep/img/thumbnail.png" type="image/png"/></item><item><title>【Git】マージ済みブランチの一覧と一括削除</title><link>https://atsum.in/linux/git-delete-merged/</link><pubDate>Wed, 19 Apr 2023 22:09:11 +0900</pubDate><guid>https://atsum.in/linux/git-delete-merged/</guid><description>&lt;h2 id="マージ済みブランチの一覧">マージ済みブランチの一覧&lt;/h2>
&lt;h3 id="現在のブランチにマージ済みのブランチ">現在のブランチにマージ済みのブランチ&lt;/h3>
&lt;p>以下のようなコミットツリーで&lt;code>main&lt;/code>ブランチをcheckoutしている状態とする。&lt;/p>
&lt;div class="highlight">&lt;pre tabindex="0" class="chroma">&lt;code class="language-bash" data-lang="bash">&lt;span class="line">&lt;span class="cl">* &lt;span class="m">1733330&lt;/span> ← main&lt;span class="o">(&lt;/span>現在checkoutしているブランチ&lt;span class="o">)&lt;/span>
&lt;/span>&lt;/span>&lt;span class="line">&lt;span class="cl">&lt;span class="p">|&lt;/span>&lt;span class="se">\
&lt;/span>&lt;/span>&lt;/span>&lt;span class="line">&lt;span class="cl">&lt;span class="se">&lt;/span>&lt;span class="p">|&lt;/span> * faa9689 ← branch2
&lt;/span>&lt;/span>&lt;span class="line">&lt;span class="cl">* &lt;span class="p">|&lt;/span> db084b3
&lt;/span>&lt;/span>&lt;span class="line">&lt;span class="cl">&lt;span class="p">|&lt;/span>&lt;span class="se">\|&lt;/span>
&lt;/span>&lt;/span>&lt;span class="line">&lt;span class="cl">&lt;span class="p">|&lt;/span> * a493c0a ← branch1
&lt;/span>&lt;/span>&lt;span class="line">&lt;span class="cl">&lt;span class="p">|&lt;/span>/
&lt;/span>&lt;/span>&lt;span class="line">&lt;span class="cl">* 6221a00 init
&lt;/span>&lt;/span>&lt;/code>&lt;/pre>&lt;/div>&lt;p>現在のブランチ(&lt;code>main&lt;/code>ブランチ)にマージ済みのブランチ一覧を表示するには&lt;code>--merged&lt;/code>オプションを使って以下のように実行する。&lt;/p></description><enclosure url="https://atsum.in/linux/git-delete-merged/img/thumbnail.png" type="image/png"/></item><item><title>【AWS】Cloud Init(User Data)のログを確認する</title><link>https://atsum.in/aws/cloud-init-log/</link><pubDate>Sat, 15 Apr 2023 20:47:18 +0900</pubDate><guid>https://atsum.in/aws/cloud-init-log/</guid><description>&lt;h2 id="cloud-initで実行したuser-dataスクリプトの実行ログ">Cloud Initで実行したUser Dataスクリプトの実行ログ&lt;/h2>
&lt;p>AWS EC2のUser Dataとして設定したスクリプトに不備がある場合など、デバッグをしたい場合にログを確認する必要がある。&lt;br>
Cloud InitによるUser Dataスクリプトの実行ログは&lt;code>/var/log/cloud-init-output.log&lt;/code>に出力される。&lt;/p></description><enclosure url="https://atsum.in/aws/cloud-init-log/img/thumbnail.png" type="image/png"/></item><item><title>【Terraform】dynamicブロックで条件分岐する</title><link>https://atsum.in/terraform/dynamic-swtich/</link><pubDate>Sat, 15 Apr 2023 17:09:38 +0900</pubDate><guid>https://atsum.in/terraform/dynamic-swtich/</guid><description>&lt;h2 id="条件によってブロックを出し分ける">条件によってブロックを出し分ける&lt;/h2>
&lt;p>Terraformの&lt;code>dynamic&lt;/code>ブロックを使うと条件によってブロックを出し分けできる。&lt;/p>
&lt;p>例えば環境が&lt;code>production&lt;/code>の場合は&lt;code>aws_instance&lt;/code>に&lt;code>metadata_options&lt;/code>を設定する場合を考える。&lt;/p></description><enclosure url="https://atsum.in/terraform/dynamic-swtich/img/thumbnail.png" type="image/png"/></item><item><title>【VSCode】「このフォルダー内のファイルの作成者を信頼しますか?」を回避する設定</title><link>https://atsum.in/vscode/ignore-trust/</link><pubDate>Sat, 15 Apr 2023 09:12:32 +0900</pubDate><guid>https://atsum.in/vscode/ignore-trust/</guid><description>&lt;h2 id="作成者の確認画面">作成者の確認画面&lt;/h2>
&lt;p>VS Code 1.57以降、VSCodeでフォルダを開いたときに、以下のようなメッセージが表示されるようになった。&lt;/p>
&lt;p>&lt;img src="img/trust.png" alt="このフォルダー内のファイルの作成者を信頼しますか?">&lt;/p>
&lt;p>信頼すれば通常通り編集やデバッグなどができるようになる。&lt;br>
信頼しない場合は編集やデバッグなどができなくなる。&lt;/p></description><enclosure url="https://atsum.in/vscode/ignore-trust/img/thumbnail.png" type="image/png"/></item><item><title>【VSCode】不要なオススメの拡張を毎回通知しないようにする</title><link>https://atsum.in/vscode/ignore-recomendation/</link><pubDate>Fri, 14 Apr 2023 23:27:53 +0900</pubDate><guid>https://atsum.in/vscode/ignore-recomendation/</guid><description>&lt;h2 id="オススメの拡張">オススメの拡張&lt;/h2>
&lt;p>VSCodeでファイルを開いたときに、そのファイルの拡張子に合わせてオススメの拡張を通知してくれる機能がある。&lt;/p>
&lt;p>例えばC言語のファイルを開いたとき、VSCodeにC言語用の拡張がインストールされていなければ以下のようなメッセージが通知される。&lt;/p></description><enclosure url="https://atsum.in/vscode/ignore-recomendation/img/thumbnail.png" type="image/png"/></item><item><title>Github Copilot Cli: コマンドを教えてくれるコマンド</title><link>https://atsum.in/linux/github-copilot-cli/</link><pubDate>Thu, 13 Apr 2023 22:44:59 +0900</pubDate><guid>https://atsum.in/linux/github-copilot-cli/</guid><description>&lt;h2 id="waiting-listに登録する">waiting listに登録する&lt;/h2>
&lt;p>2023年4月現在はwaiting listに登録する必要がある。&lt;/p>
&lt;p>&lt;a href="https://githubnext.com/projects/copilot-cli/">Copilot for CLI&lt;/a>のページにアクセスし、Waiting Listに登録する。&lt;/p></description><enclosure url="https://atsum.in/linux/github-copilot-cli/img/thumbnail.png" type="image/png"/></item><item><title>journalctlでsystemdで起動したサービスのログを見る</title><link>https://atsum.in/linux/journalctl/</link><pubDate>Thu, 13 Apr 2023 21:30:26 +0900</pubDate><guid>https://atsum.in/linux/journalctl/</guid><description>&lt;h2 id="journald">journald&lt;/h2>
&lt;p>&lt;code>systemd&lt;/code>のコンポーネントの1つで、&lt;code>systemd&lt;/code>で管理されているサービスのログを管理する。
正確には&lt;code>systemd-journald&lt;/code>というデーモンがログを管理している。&lt;/p></description><enclosure url="https://atsum.in/linux/journalctl/img/thumbnail.png" type="image/png"/></item><item><title>【VSCode】Javaの引数に表示される引数名のヒントを消す</title><link>https://atsum.in/vscode/java-inlay-hints/</link><pubDate>Sat, 08 Apr 2023 20:05:58 +0900</pubDate><guid>https://atsum.in/vscode/java-inlay-hints/</guid><description>&lt;h2 id="inlay-hints">inlay hints&lt;/h2>
&lt;p>VSCodeにJava拡張を入れると引数にリテラルを渡すときに引数名が表示される。&lt;/p>
&lt;p>&lt;img src="img/inlay-hint.png" alt="inlay hint">&lt;/p>
&lt;p>上記画像では&lt;code>println&lt;/code>メソッドに&lt;code>&amp;quot;Hello, World&amp;quot;&lt;/code>という文字列リテラルを渡しているので、
&lt;code>println&lt;/code>メソッドの引数名である&lt;code>x&lt;/code>が表示されている。&lt;/p></description><enclosure url="https://atsum.in/vscode/java-inlay-hints/img/thumbnail.png" type="image/png"/></item><item><title>curlのresolveオプションでDNSを回避してIPアドレスを直接指定する</title><link>https://atsum.in/linux/curl-resolve/</link><pubDate>Fri, 07 Apr 2023 22:29:32 +0900</pubDate><guid>https://atsum.in/linux/curl-resolve/</guid><description>&lt;h2 id="curl-の-resolve-オプション">curl の &amp;ndash;resolve オプション&lt;/h2>
&lt;p>curlの&lt;code>--resolve&lt;/code>オプションはノスト名をDNSで名前解決せずに直接IPを指定できる。&lt;/p>
&lt;p>以下のような場面で使える。&lt;/p>
&lt;ul>
&lt;li>DNSで複数のIPを返された場合に、そのうちの1つのIPを確実に指定したい場合&lt;/li>
&lt;li>ドメインのDNSにそのホスト名が登録されていない場合&lt;/li>
&lt;li>IPアドレスを直接指定してDNSのキャッシュを回避したい場合&lt;/li>
&lt;/ul>
&lt;h2 id="使い方">使い方&lt;/h2>
&lt;p>&lt;code>--resolve&lt;/code>オプションの引数は「ホスト名:ポート番号:IPアドレス」の形式で指定する。&lt;/p></description><enclosure url="https://atsum.in/linux/curl-resolve/img/thumbnail.png" type="image/png"/></item><item><title>Github Actions で前ステップの値を参照する</title><link>https://atsum.in/linux/github-actions-previous-output/</link><pubDate>Fri, 07 Apr 2023 08:44:33 +0900</pubDate><guid>https://atsum.in/linux/github-actions-previous-output/</guid><description>&lt;h2 id="前ステップの値を参照する">前ステップの値を参照する&lt;/h2>
&lt;h3 id="後ステップで参照するための設定">後ステップで参照するための設定&lt;/h3>
&lt;p>参照されるステップは以下のようにする。&lt;/p>
&lt;ul>
&lt;li>後続のステップから参照するために&lt;code>id&lt;/code>をつける。&lt;/li>
&lt;li>&lt;code>変数名=値&lt;/code> を &lt;code>echo&lt;/code> して &lt;code>$GITHUB_OUTPUT&lt;/code> に出力する&lt;/li>
&lt;/ul>
&lt;p>例として以下のように記述する。&lt;/p></description><enclosure url="https://atsum.in/linux/github-actions-previous-output/img/thumbnail.png" type="image/png"/></item><item><title>オンラインサービスに頼らずGhostscriptでPDFをコマンドラインから圧縮する</title><link>https://atsum.in/linux/gs-pdf-compress/</link><pubDate>Thu, 06 Apr 2023 22:41:28 +0900</pubDate><guid>https://atsum.in/linux/gs-pdf-compress/</guid><description>&lt;h2 id="macでghostscriptをインストールする">MacでGhostscriptをインストールする&lt;/h2>
&lt;p>準備としてbrewでghostscriptをインストールする。&lt;/p>
&lt;div class="highlight">&lt;pre tabindex="0" class="chroma">&lt;code class="language-shell" data-lang="shell">&lt;span class="line">&lt;span class="cl">$ brew install ghostscript
&lt;/span>&lt;/span>&lt;/code>&lt;/pre>&lt;/div>&lt;h2 id="ghostscriptでpdfを圧縮するコマンド">GhostscriptでPDFを圧縮するコマンド&lt;/h2>
&lt;p>以下のコマンドで指定したPDFファイルを圧縮する。&lt;/p>
&lt;div class="highlight">&lt;pre tabindex="0" class="chroma">&lt;code class="language-shell" data-lang="shell">&lt;span class="line">&lt;span class="cl">$ gs -sDEVICE&lt;span class="o">=&lt;/span>pdfwrite &lt;span class="se">\
&lt;/span>&lt;/span>&lt;/span>&lt;span class="line">&lt;span class="cl">&lt;span class="se">&lt;/span> -dCompatibilityLevel&lt;span class="o">=&lt;/span>1.4 &lt;span class="se">\
&lt;/span>&lt;/span>&lt;/span>&lt;span class="line">&lt;span class="cl">&lt;span class="se">&lt;/span> -dPDFSETTINGS&lt;span class="o">=&lt;/span>/ebook &lt;span class="se">\
&lt;/span>&lt;/span>&lt;/span>&lt;span class="line">&lt;span class="cl">&lt;span class="se">&lt;/span> -dNOPAUSE &lt;span class="se">\
&lt;/span>&lt;/span>&lt;/span>&lt;span class="line">&lt;span class="cl">&lt;span class="se">&lt;/span> -q &lt;span class="se">\
&lt;/span>&lt;/span>&lt;/span>&lt;span class="line">&lt;span class="cl">&lt;span class="se">&lt;/span> -dBATCH &lt;span class="se">\
&lt;/span>&lt;/span>&lt;/span>&lt;span class="line">&lt;span class="cl">&lt;span class="se">&lt;/span> -sOutputFile&lt;span class="o">=&lt;/span>出力ファイルパス.pdf &lt;span class="se">\
&lt;/span>&lt;/span>&lt;/span>&lt;span class="line">&lt;span class="cl">&lt;span class="se">&lt;/span> 入力ファイルパス.pdf
&lt;/span>&lt;/span>&lt;/code>&lt;/pre>&lt;/div>&lt;h2 id="各オプションの説明">各オプションの説明&lt;/h2>
&lt;h3 id="-sdevice">-sDEVICE&lt;/h3>
&lt;p>変換したい出力ファイル形式に応じたデバイスを選択する。&lt;/p></description><enclosure url="https://atsum.in/linux/gs-pdf-compress/img/thumbnail.png" type="image/png"/></item><item><title>【AWS CLI】CloudWatch Logsのログをtail -fする</title><link>https://atsum.in/aws/logs-tail-follow/</link><pubDate>Wed, 05 Apr 2023 01:20:05 +0900</pubDate><guid>https://atsum.in/aws/logs-tail-follow/</guid><description>&lt;h2 id="cloudwatch-logsのログをリアルタイムに確認する">CloudWatch Logsのログをリアルタイムに確認する&lt;/h2>
&lt;p>CloudWatch Logsのログをリアルタイムに確認したい(tail -fのように実行したい)場合、&lt;code>aws logs tail&lt;/code>コマンドに&lt;code>--follow&lt;/code>オプションを指定する。&lt;/p></description><enclosure url="https://atsum.in/aws/logs-tail-follow/img/thumbnail.png" type="image/png"/></item><item><title>【Mac】シェルスクリプトでちょっとした効果音を鳴らす(afplay)</title><link>https://atsum.in/mac/aflplay-sound-effect/</link><pubDate>Sun, 02 Apr 2023 23:49:48 +0900</pubDate><guid>https://atsum.in/mac/aflplay-sound-effect/</guid><description>&lt;h2 id="シェルスクリプトが終わったときにちょっとした効果音を鳴らしたい">シェルスクリプトが終わったときにちょっとした効果音を鳴らしたい&lt;/h2>
&lt;p>時間がかかるスクリプトを実行した場合、実行が終わるまでは他の作業をしたい。&lt;br>
しかし他の作業に熱中しているとスクリプトが終わったかことに気づかないことがある。&lt;br>
そこでスクリプトが終わったときにちょっとした効果音を鳴らすようにすると便利。&lt;/p></description><enclosure url="https://atsum.in/mac/aflplay-sound-effect/img/thumbnail.png" type="image/png"/></item><item><title>【Kotlin】TemporalAdjustersで月末月初の日付を取得</title><link>https://atsum.in/android/temporal-adjusters/</link><pubDate>Sun, 02 Apr 2023 14:33:04 +0900</pubDate><guid>https://atsum.in/android/temporal-adjusters/</guid><description>&lt;h2 id="temporaladjusters">TemporalAdjusters&lt;/h2>
&lt;p>Date-Time APIの&lt;code>TemporalAdjusters&lt;/code>を使うと、日付オブジェクトをお手軽に変換できる。&lt;/p>
&lt;p>&lt;code>LocalDate&lt;/code>のインスタンスメソッド&lt;code>with&lt;/code>に&lt;code>TemporalAdjusters&lt;/code>を渡す。&lt;/p></description><enclosure url="https://atsum.in/android/temporal-adjusters/img/thumbnail.png" type="image/png"/></item><item><title>cut コマンドで後ろから n 番目を取得する</title><link>https://atsum.in/linux/cut-rev/</link><pubDate>Sun, 02 Apr 2023 08:13:51 +0900</pubDate><guid>https://atsum.in/linux/cut-rev/</guid><description>&lt;h2 id="cut-コマンドで後ろから数えたフィールドを取得したい">cut コマンドで後ろから数えたフィールドを取得したい&lt;/h2>
&lt;p>以下のようなデータにカンマを含む場合はダブルクオートで囲って区切り文字とは区別するようなCSVファイルを考える。&lt;/p></description><enclosure url="https://atsum.in/linux/cut-rev/img/thumbnail.png" type="image/png"/></item><item><title>【VSCode】Java開発用の設定</title><link>https://atsum.in/vscode/java/</link><pubDate>Sat, 01 Apr 2023 21:45:08 +0900</pubDate><guid>https://atsum.in/vscode/java/</guid><description>&lt;h2 id="vscodeのjava拡張機能をインストールする">VSCodeのJava拡張機能をインストールする&lt;/h2>
&lt;p>以下の手順でVSCodeのJava拡張機能をインストールする。&lt;/p>
&lt;ol>
&lt;li>VSCodeを起動する&lt;/li>
&lt;li>Extension Pack for Javaを検索する&lt;br>
&lt;img src="img/search.png" alt="Extension Pack for Javaを検索">&lt;/li>
&lt;li>インストールする&lt;br>
&lt;img src="img/install.png" alt="Extension Pack for Javaをインストール">&lt;/li>
&lt;/ol>
&lt;p>Extension Pack for Javaは拡張のセットでVSCodeでのJava開発に必要な拡張を一括でインストールできる。&lt;br>
含まれる拡張は以下の通り。&lt;/p></description><enclosure url="https://atsum.in/vscode/java/img/thumbnail.png" type="image/png"/></item><item><title>VSCodeでvimを使う</title><link>https://atsum.in/vscode/vim/</link><pubDate>Sat, 01 Apr 2023 19:29:12 +0900</pubDate><guid>https://atsum.in/vscode/vim/</guid><description>&lt;h2 id="拡張のインストール">拡張のインストール&lt;/h2>
&lt;p>VSCodeでvimを使うためには、まずVSCodeの拡張機能である「Vim」をインストールする必要がある。&lt;/p>
&lt;p>拡張機能をインストールするには、VSCodeを開いて、左側のメニューバーから「拡張機能」をクリックし、「Vim」を検索してインストールする。&lt;/p></description><enclosure url="https://atsum.in/vscode/vim/img/thumbnail.png" type="image/png"/></item><item><title>【VSCode】ファイルを比較して差分(Diff)を表示する</title><link>https://atsum.in/vscode/diff/</link><pubDate>Sat, 01 Apr 2023 11:59:01 +0900</pubDate><guid>https://atsum.in/vscode/diff/</guid><description>&lt;p>VSCodeにはファイルの差分(diff)を確認する方法が複数ある。本記事では標準機能でのファイル比較、codeコマンドからの起動、Local Historyによる過去の内容との比較、Gitの差分表示、拡張機能によるフォルダや文字列の比較を解説する。&lt;/p></description><enclosure url="https://atsum.in/vscode/diff/img/thumbnail.png" type="image/png"/></item><item><title>vscodeをコマンドで起動する</title><link>https://atsum.in/vscode/code-command/</link><pubDate>Sat, 01 Apr 2023 11:11:28 +0900</pubDate><guid>https://atsum.in/vscode/code-command/</guid><description>&lt;h2 id="準備-codeコマンドのインストール">準備: codeコマンドのインストール&lt;/h2>
&lt;p>VSCodeを起動するための&lt;code>code&lt;/code>コマンドを使用するには、以下の手順に従ってインストールする。&lt;/p>
&lt;ol>
&lt;li>VSCodeを起動する&lt;/li>
&lt;li>&lt;code>Ctrl + Shift + P&lt;/code>を押してコマンドパレットを開く&lt;/li>
&lt;li>&lt;code>Shell Command: Install 'code' command in PATH&lt;/code>を選択する&lt;/li>
&lt;/ol>
&lt;p>これで、&lt;code>code&lt;/code>コマンドを使用できるようになる。&lt;/p></description><enclosure url="https://atsum.in/vscode/code-command/img/thumbnail.png" type="image/png"/></item><item><title>【AWS】管理ポリシーReadOnlyAccessにはscheduler:GetSchedule権限が無い</title><link>https://atsum.in/aws/event-bridge-read-only-access/</link><pubDate>Sat, 01 Apr 2023 09:32:02 +0900</pubDate><guid>https://atsum.in/aws/event-bridge-read-only-access/</guid><description>&lt;h2 id="readonlyaccessポリシーを付与した権限でeventbridge-schedulerを参照する操作をすると権限エラー">ReadOnlyAccessポリシーを付与した権限でEventBridge Schedulerを参照する操作をすると権限エラー&lt;/h2>
&lt;p>&lt;code>ReadOnlyAccess&lt;/code>ポリシーを付与したロールを使ってOIDCで認証し、Github Actionsで&lt;code>terraform plan&lt;/code>を実行すると
EventBridge Schedulerの参照でエラーとなった。&lt;/p></description><enclosure url="https://atsum.in/aws/event-bridge-read-only-access/img/thumbnail.png" type="image/png"/></item><item><title>【Terraform】failure configuring LB attributes: InvalidConfigurationRequest: Access Denied for bucket: の対処法</title><link>https://atsum.in/terraform/alb-s3-permission/</link><pubDate>Fri, 31 Mar 2023 07:00:30 +0900</pubDate><guid>https://atsum.in/terraform/alb-s3-permission/</guid><description>&lt;h2 id="albのログをs3に保存するときにパーミッションエラー">ALBのログをS3に保存するときにパーミッションエラー&lt;/h2>
&lt;p>terraformでALBのログをS3に保存する設定を記述し、適用しようとしたら以下の様なエラーが発生した。&lt;/p>
&lt;div class="highlight">&lt;pre tabindex="0" class="chroma">&lt;code class="language-shell" data-lang="shell">&lt;span class="line">&lt;span class="cl">Error: Failure configuring LB attributes: InvalidConfigurationRequest:
&lt;/span>&lt;/span>&lt;span class="line">&lt;span class="cl">Access Denied &lt;span class="k">for&lt;/span> bucket: foo-alb-log. Please check S3bucket permission
&lt;/span>&lt;/span>&lt;span class="line">&lt;span class="cl"> status code: 400, request id: xxxxxxxx-xxxx-xxxx-xxxx-xxxxxxxxxxxx
&lt;/span>&lt;/span>&lt;span class="line">&lt;span class="cl"> on alb.tf line 1, in resource &lt;span class="s2">&amp;#34;aws_lb&amp;#34;&lt;/span> &lt;span class="s2">&amp;#34;example&amp;#34;&lt;/span>:
&lt;/span>&lt;/span>&lt;span class="line">&lt;span class="cl"> 1: resource &lt;span class="s2">&amp;#34;aws_lb&amp;#34;&lt;/span> &lt;span class="s2">&amp;#34;example&amp;#34;&lt;/span> &lt;span class="o">{&lt;/span>
&lt;/span>&lt;/span>&lt;/code>&lt;/pre>&lt;/div>&lt;h2 id="原因">原因&lt;/h2>
&lt;p>上記エラーの原因はメッセージの通り、パーミッションが付与されていないため。&lt;br>
バケットにアクセスログを書き込む許可をALBに与える必要がある。&lt;/p></description><enclosure url="https://atsum.in/terraform/alb-s3-permission/img/thumbnail.png" type="image/png"/></item><item><title>【Terraform】TF_LOG変数でデバッグログを出して原因を特定する</title><link>https://atsum.in/terraform/tf-log/</link><pubDate>Fri, 31 Mar 2023 06:03:20 +0900</pubDate><guid>https://atsum.in/terraform/tf-log/</guid><description>&lt;h2 id="tf_log変数">TF_LOG変数&lt;/h2>
&lt;p>&lt;code>terraform&lt;/code>コマンドで問題が起きたときに表示されるエラーメッセージでは情報が足りず、何が起きているのか分からないときがある。&lt;/p>
&lt;p>そのようなときは&lt;code>TF_LOG&lt;/code>変数でデバッグレベルを指定すると各レベルに応じて出力が増える。&lt;/p></description><enclosure url="https://atsum.in/terraform/tf-log/img/thumbnail.png" type="image/png"/></item><item><title>GuardDutyで1件だけ検出結果サンプルを発行する</title><link>https://atsum.in/aws/guard-duty-gen-result/</link><pubDate>Wed, 29 Mar 2023 21:52:28 +0900</pubDate><guid>https://atsum.in/aws/guard-duty-gen-result/</guid><description>&lt;p>GuardDutyを有効にして通知の設定をすると、その通知が正しく動くか確認するために検出結果サンプルを発行したくなる。&lt;/p>
&lt;p>AWSのWebコンソール画面のGuardDutyの設定画面から検出結果サンプルを発行できる。
しかしさまざまなパターンのサンプルを生成するため、大量のサンプルが発行され、不必要に通知が送られてしまう。&lt;/p></description><enclosure url="https://atsum.in/aws/guard-duty-gen-result/img/thumbnail.png" type="image/png"/></item><item><title>AWS CLI で S3 のファイルを cat したい</title><link>https://atsum.in/aws/cli-s3-cat/</link><pubDate>Wed, 29 Mar 2023 19:29:24 +0900</pubDate><guid>https://atsum.in/aws/cli-s3-cat/</guid><description>&lt;p>S3に置かれているファイルをgrepでフィルターしたいだけ、のような場合に
&lt;code>aws s3 cp&lt;/code>コマンドでダウンロードしたりする。&lt;br>
このとき作業後にダウンロードしたファイルを削除しなければならずひと手間増える。&lt;/p></description><enclosure url="https://atsum.in/aws/cli-s3-cat/img/thumbnail.png" type="image/png"/></item><item><title>aws-vaultでアクセスキーを平文で保存せずにAWSにコマンドでアクセスする</title><link>https://atsum.in/aws/aws-vault/</link><pubDate>Sun, 26 Mar 2023 20:35:46 +0900</pubDate><guid>https://atsum.in/aws/aws-vault/</guid><description>&lt;p>aws configureでアクセスキーを保存するとアクセスキーは ~/.aws/credentialsに保存される。しかし、この方法では平文で保存されるのでアクセスキーが漏洩した場合にセキュリティ上のリスクがある。&lt;/p></description><enclosure url="https://atsum.in/aws/aws-vault/img/thumbnail.png" type="image/png"/></item><item><title>【Terraform】default_tagsでプロジェクトで作成したリソースを識別しやすくする</title><link>https://atsum.in/terraform/default-tags/</link><pubDate>Sun, 26 Mar 2023 11:34:05 +0900</pubDate><guid>https://atsum.in/terraform/default-tags/</guid><description>&lt;p>AWSでインフラを構築するとAWSのリソースがたくさんできるので、どのリソースがどの環境・プロジェクトのリソースなのかがひと目ではわからなくなる。&lt;br>
例えばsubnetはどのVPCに紐づくか、どのルートテーブルを紐づけているかなどはIDを丁寧にたどっていけば確認できるが面倒。&lt;/p></description><enclosure url="https://atsum.in/terraform/default-tags/img/thumbnail.png" type="image/png"/></item><item><title>【PostgreSQL】text 型のカラムに json 型としてクエリする</title><link>https://atsum.in/database/postgresql-json-operator/</link><pubDate>Sat, 25 Mar 2023 15:52:19 +0900</pubDate><guid>https://atsum.in/database/postgresql-json-operator/</guid><description>&lt;h2 id="postgresqlのtext型のカラムにjson型としてクエリする">PostgreSQLのtext型のカラムにjson型としてクエリする&lt;/h2>
&lt;p>以下のデータからJSONデータを抽出したテーブルを表示する。&lt;br>
ここで&lt;code>setting&lt;/code>カラムの型は&lt;code>text&lt;/code>とする。&lt;/p>
&lt;div class="highlight">&lt;pre tabindex="0" class="chroma">&lt;code class="language-sql" data-lang="sql">&lt;span class="line">&lt;span class="cl">&lt;span class="o">#&lt;/span>&lt;span class="w"> &lt;/span>&lt;span class="k">select&lt;/span>&lt;span class="w"> &lt;/span>&lt;span class="o">*&lt;/span>&lt;span class="w"> &lt;/span>&lt;span class="k">from&lt;/span>&lt;span class="w"> &lt;/span>&lt;span class="n">settings&lt;/span>&lt;span class="p">;&lt;/span>&lt;span class="w">
&lt;/span>&lt;/span>&lt;/span>&lt;span class="line">&lt;span class="cl">&lt;span class="w"> &lt;/span>&lt;span class="n">id&lt;/span>&lt;span class="w"> &lt;/span>&lt;span class="o">|&lt;/span>&lt;span class="w"> &lt;/span>&lt;span class="n">setting&lt;/span>&lt;span class="w">
&lt;/span>&lt;/span>&lt;/span>&lt;span class="line">&lt;span class="cl">&lt;span class="w">&lt;/span>&lt;span class="c1">----+------------------------------
&lt;/span>&lt;/span>&lt;/span>&lt;span class="line">&lt;span class="cl">&lt;span class="c1">&lt;/span>&lt;span class="w"> &lt;/span>&lt;span class="mi">1&lt;/span>&lt;span class="w"> &lt;/span>&lt;span class="o">|&lt;/span>&lt;span class="w"> &lt;/span>&lt;span class="err">{&lt;/span>&lt;span class="s2">&amp;#34;foo&amp;#34;&lt;/span>&lt;span class="p">:&lt;/span>&lt;span class="w"> &lt;/span>&lt;span class="s2">&amp;#34;bar&amp;#34;&lt;/span>&lt;span class="p">,&lt;/span>&lt;span class="w"> &lt;/span>&lt;span class="s2">&amp;#34;baz&amp;#34;&lt;/span>&lt;span class="p">:&lt;/span>&lt;span class="w"> &lt;/span>&lt;span class="s2">&amp;#34;qux&amp;#34;&lt;/span>&lt;span class="err">}&lt;/span>&lt;span class="w">
&lt;/span>&lt;/span>&lt;/span>&lt;span class="line">&lt;span class="cl">&lt;span class="w"> &lt;/span>&lt;span class="mi">2&lt;/span>&lt;span class="w"> &lt;/span>&lt;span class="o">|&lt;/span>&lt;span class="w"> &lt;/span>&lt;span class="err">{&lt;/span>&lt;span class="s2">&amp;#34;foo&amp;#34;&lt;/span>&lt;span class="p">:&lt;/span>&lt;span class="w"> &lt;/span>&lt;span class="s2">&amp;#34;aaa&amp;#34;&lt;/span>&lt;span class="p">,&lt;/span>&lt;span class="w"> &lt;/span>&lt;span class="s2">&amp;#34;baz&amp;#34;&lt;/span>&lt;span class="p">:&lt;/span>&lt;span class="w"> &lt;/span>&lt;span class="s2">&amp;#34;bbb&amp;#34;&lt;/span>&lt;span class="err">}&lt;/span>&lt;span class="w">
&lt;/span>&lt;/span>&lt;/span>&lt;/code>&lt;/pre>&lt;/div>&lt;p>settingカラムのJSONデータの、&amp;ldquo;foo&amp;rdquo;, &amp;ldquo;baz&amp;quot;キーをカラム名とした値を取得しテーブルとして表示するには
例えば以下のようなSQLを実行する。&lt;/p></description><enclosure url="https://atsum.in/database/postgresql-json-operator/img/thumbnail.png" type="image/png"/></item><item><title>watchコマンドを使ってコマンドを定期的実行して監視する</title><link>https://atsum.in/linux/watch/</link><pubDate>Sat, 25 Mar 2023 10:41:04 +0900</pubDate><guid>https://atsum.in/linux/watch/</guid><description>&lt;h2 id="watchコマンドとは">watchコマンドとは&lt;/h2>
&lt;p>&lt;code>watch&lt;/code>コマンドは指定したコマンドを一定間隔で実行し、結果を表示するコマンド。&lt;/p>
&lt;p>実行するコマンドは&lt;code>watch&lt;/code>コマンドの引数に指定する。&lt;/p>
&lt;div class="highlight">&lt;pre tabindex="0" class="chroma">&lt;code class="language-shell" data-lang="shell">&lt;span class="line">&lt;span class="cl">$ watch コマンド
&lt;/span>&lt;/span>&lt;/code>&lt;/pre>&lt;/div>&lt;p>例えば以下のコマンドで、現在のフォルダでlsを実行した結果を監視できる。&lt;/p></description><enclosure url="https://atsum.in/linux/watch/img/thumbnail.png" type="image/png"/></item><item><title>【Terraform】Session Manager でログイン可能な EC2 を建てる</title><link>https://atsum.in/terraform/ec2-session-manager/</link><pubDate>Thu, 23 Mar 2023 00:13:32 +0900</pubDate><guid>https://atsum.in/terraform/ec2-session-manager/</guid><description>&lt;p>AWSのSession Managerを使用すると、EC2インスタンスへSSHの鍵をやりとりすることなくAWSのユーザー権限でリモートアクセスできるようになる。&lt;/p></description><enclosure url="https://atsum.in/terraform/ec2-session-manager/img/thumbnail.png" type="image/png"/></item><item><title>AWS CLIの結果をlessで開くのを一時的にオフにする方法</title><link>https://atsum.in/aws/cli-less/</link><pubDate>Wed, 22 Mar 2023 00:22:07 +0900</pubDate><guid>https://atsum.in/aws/cli-less/</guid><description>&lt;h2 id="方法1-awsconfig-で-cli_pager-を指定する">方法1: ~/.aws/config で cli_pager を指定する&lt;/h2>
&lt;p>AWS CLIの設定ファイルである&lt;code>~/.aws/config&lt;/code>ファイルで&lt;code>cli_pager&lt;/code>を設定でAWS CLIの結果を表示するのに使うpagerを指定できます。
この&lt;code>cli_pager&lt;/code>を空にするとpagerを使わなくなります。&lt;br>
以下は、&lt;code>cli_pager&lt;/code>を無効にする設定例です。&lt;/p></description><enclosure url="https://atsum.in/aws/cli-less/img/thumbnail.png" type="image/png"/></item><item><title>IMDSv2必須のときはgoofysでS3をマウントできなくなる</title><link>https://atsum.in/aws/goofys-with-imdsv2/</link><pubDate>Tue, 21 Mar 2023 20:00:54 +0900</pubDate><guid>https://atsum.in/aws/goofys-with-imdsv2/</guid><description>&lt;h2 id="goofysとは">goofysとは&lt;/h2>
&lt;p>goofysはS3をフォルダとしてマウントできるミドルウェア。&lt;/p>
&lt;a href="https://github.com/kahing/goofys" target="_blank" rel="noopener nofollow">kahing/goofys: a high-performance, POSIX-ish Amazon S3 file system written in Go&lt;/a>
&lt;p>mountコマンドやfstabを使ってS3の任意のパスをフォルダとしてマウントできて便利。&lt;/p></description><enclosure url="https://atsum.in/aws/goofys-with-imdsv2/img/thumbnail.png" type="image/png"/></item><item><title>【Terraform】EC2インスタンスでIMDSv2を必須にする</title><link>https://atsum.in/terraform/ec2-imdsv2/</link><pubDate>Tue, 21 Mar 2023 18:43:15 +0900</pubDate><guid>https://atsum.in/terraform/ec2-imdsv2/</guid><description>&lt;p>この記事ではTerraformを使用してEC2インスタンスでIMDSv2を必須にする方法について説明します。&lt;/p>
&lt;h2 id="imdsv2とは">IMDSv2とは&lt;/h2>
&lt;p>IMDSv2（Instance Metadata Service version 2）はAWS EC2インスタンスにおいてメタデータとユーザーデータを取得するためのサービスです。
IMDSv2はメタデータの取得にPUTやトークンを指定したGETヘッダーを使用します。&lt;/p></description><enclosure url="https://atsum.in/terraform/ec2-imdsv2/img/thumbnail.png" type="image/png"/></item><item><title>【Terraform】UserDataを変えただけで既存EC2インスタンスが再起動するのをignore_changesで避ける</title><link>https://atsum.in/terraform/ignore-changes-of-user-data/</link><pubDate>Sat, 18 Mar 2023 21:23:00 +0900</pubDate><guid>https://atsum.in/terraform/ignore-changes-of-user-data/</guid><description>&lt;h2 id="terraformでec2のuserdataを変えると再起動する">TerraformでEC2のUserDataを変えると再起動する&lt;/h2>
&lt;p>EC2インスタンスを作成する際、&lt;code>resource &amp;quot;aws_instance&amp;quot;&lt;/code> を使用するとUserDataを変更するとEC2インスタンスが再起動します。&lt;/p>
&lt;p>モジュールを作成して、新しいインスタンスを作成するときにUserDataを変更したい場合に問題が発生します。&lt;/p></description><enclosure url="https://atsum.in/terraform/ignore-changes-of-user-data/img/thumbnail.png" type="image/png"/></item><item><title>【Terraform】aws_iam_policy_documentデータソースの使い方</title><link>https://atsum.in/terraform/aws-iam-policy-document/</link><pubDate>Sun, 12 Mar 2023 09:50:17 +0900</pubDate><guid>https://atsum.in/terraform/aws-iam-policy-document/</guid><description>&lt;p>TerraformでAWS IAMポリシーとして設定するJSONはテキストで書くと構文チェックやエディタによる補完などができません。
そこで&lt;code>aws_iam_policy_document&lt;/code>データソースを使うと便利です。
この記事では&lt;code>aws_iam_policy_document&lt;/code>データソースの使い方について説明します。&lt;/p></description><enclosure url="https://atsum.in/terraform/aws-iam-policy-document/img/thumbnail.png" type="image/png"/></item><item><title>【AWS】Chatbotで送信できない場合の確認方法：サポートしているサービスとログの確認方法</title><link>https://atsum.in/aws/supported-by-chatbot/</link><pubDate>Sat, 11 Mar 2023 21:21:39 +0900</pubDate><guid>https://atsum.in/aws/supported-by-chatbot/</guid><description>&lt;h2 id="snsのテストメッセージはchatbotで送信できない">SNSのテストメッセージはChatbotで送信できない&lt;/h2>
&lt;h3 id="現象">現象&lt;/h3>
&lt;p>AWS Chatbotの動作確認のために、接続されているAmazon SNSからテストメッセージを送ると送信できない。&lt;/p>
&lt;p>AWSコンソール画面でChatbotに接続されているSNSの画面を開き、テストメッセージの発行ボタンで送信しても何も通知されない。&lt;/p></description><enclosure url="https://atsum.in/aws/supported-by-chatbot/img/thumbnail.png" type="image/png"/></item><item><title>【Terraform】AWS ChatbotでSlack通知する</title><link>https://atsum.in/terraform/chatbot/</link><pubDate>Sat, 11 Mar 2023 19:24:52 +0900</pubDate><guid>https://atsum.in/terraform/chatbot/</guid><description>&lt;h2 id="前提条件">前提条件&lt;/h2>
&lt;ul>
&lt;li>AWSアカウントを持っていること&lt;/li>
&lt;li>Slackアカウントを持っていること(管理者権限)&lt;/li>
&lt;li>Terraformがインストールされていること&lt;/li>
&lt;/ul>
&lt;h2 id="事前準備aws-chatbotをでチャットクライアントを作成する">【事前準備】AWS Chatbotをでチャットクライアントを作成する&lt;/h2>
&lt;h3 id="aws-chatbot-と-slack-のワークスペースの接続の許可">AWS Chatbot と Slack のワークスペースの接続の許可&lt;/h3>
&lt;p>AWS Chatbotコンソールにアクセスし、[Get started]をクリックします。&lt;/p></description><enclosure url="https://atsum.in/terraform/chatbot/img/thumbnail.png" type="image/png"/></item><item><title>Git pushで一時的に別のSSHキーを指定する方法</title><link>https://atsum.in/linux/git-specify-key/</link><pubDate>Sat, 25 Feb 2023 13:47:32 +0900</pubDate><guid>https://atsum.in/linux/git-specify-key/</guid><description>&lt;h2 id="背景">背景&lt;/h2>
&lt;p>SSH認証でGitを使用してリモートリポジトリにプッシュするときGitコマンドはリポジトリへアクセスするために必要な秘密鍵を使用して認証する。&lt;/p></description><enclosure url="https://atsum.in/linux/git-specify-key/img/thumbnail.png" type="image/png"/></item><item><title>Mac純正アプリでカラーコードを調べる (Digital Color Meter)</title><link>https://atsum.in/mac/digital-color-meter/</link><pubDate>Thu, 23 Feb 2023 19:32:24 +0900</pubDate><guid>https://atsum.in/mac/digital-color-meter/</guid><description>&lt;h2 id="macでカラーコードを調べる">Macでカラーコードを調べる&lt;/h2>
&lt;p>Macで画面上の特定の点のカラーコードを調べたければ純正アプリのDigital Color Meterを使用する。&lt;/p>
&lt;h2 id="digital-color-meter">Digital Color Meter&lt;/h2>
&lt;p>Digital Color MeterはApplicationフォルダの中のUtility(ユーティリティ)フォルダの中にある。&lt;/p></description><enclosure url="https://atsum.in/mac/digital-color-meter/img/thumbnail.png" type="image/png"/></item><item><title>Apache Bench (ab コマンド) で Length で Failed する場合は -l オプションをつける</title><link>https://atsum.in/linux/apache-bench-failed-by-length/</link><pubDate>Sat, 28 Jan 2023 22:33:59 +0900</pubDate><guid>https://atsum.in/linux/apache-bench-failed-by-length/</guid><description>&lt;h2 id="abコマンドはレスポンスのバイト数が変わるとfailedとしてレポートする">abコマンドはレスポンスのバイト数が変わるとFailedとしてレポートする&lt;/h2>
&lt;p>Webアプリケーションなど動的なページに対してabコマンドを実行すると、
リクエスト間でバイト数が異なるとFailedとしてレポートされる。&lt;/p>
&lt;p>例えば適当なアプリを作って以下のように2クライアントで10アクセスしてみる。&lt;/p></description><enclosure url="https://atsum.in/linux/apache-bench-failed-by-length/img/thumbnail.png" type="image/png"/></item><item><title>さくらのVPSのRocky Linux 8でtarが無い時の対処法</title><link>https://atsum.in/linux/tar-on-rocky/</link><pubDate>Sat, 21 Jan 2023 21:33:59 +0900</pubDate><guid>https://atsum.in/linux/tar-on-rocky/</guid><description>&lt;h2 id="さくらのvpsのrocky-linux-8にはtarコマンドがインストールされていない">さくらのVPSのRocky Linux 8にはtarコマンドがインストールされていない&lt;/h2>
&lt;p>さくらのVPSのインストールOSでRocky Linux 8を選択し、
OS上でtarコマンドを実行しようとしたらエラーが発生した。&lt;/p></description><enclosure url="https://atsum.in/linux/tar-on-rocky/img/thumbnail.png" type="image/png"/></item><item><title>Rocky Linux 8 で LANG=ja_JP.UTF-8 の設定にも関わらず、日本語ファイル名が文字化けする場合の対処法</title><link>https://atsum.in/linux/install-lang-on-rocky/</link><pubDate>Sat, 21 Jan 2023 19:32:12 +0900</pubDate><guid>https://atsum.in/linux/install-lang-on-rocky/</guid><description>&lt;h2 id="問題">問題&lt;/h2>
&lt;p>さくらのVPSでインストールOSにRocky Linux 8を選択し、
日本語ファイル名が置かれたフォルダで&lt;code>ls&lt;/code>コマンドを実行すると文字化けした。&lt;/p>
&lt;p>以下の2点を確認しても文字化けは修正できなかった。&lt;/p></description><enclosure url="https://atsum.in/linux/install-lang-on-rocky/img/thumbnail.png" type="image/png"/></item><item><title>【Terraform】"Principal": "*" を指定する方法</title><link>https://atsum.in/terraform/principal-any/</link><pubDate>Sat, 14 Jan 2023 07:42:16 +0900</pubDate><guid>https://atsum.in/terraform/principal-any/</guid><description>&lt;h2 id="aws_iam_policy_documentデータソースのprincipals">aws_iam_policy_documentデータソースのprincipals&lt;/h2>
&lt;p>&lt;code>aws_iam_policy_document&lt;/code>データソースの&lt;code>principals&lt;/code>は&lt;code>type&lt;/code>と&lt;code>identifiers&lt;/code>が必須項目で以下のように記述する。&lt;/p></description><enclosure url="https://atsum.in/terraform/principal-any/img/thumbnail.png" type="image/png"/></item><item><title>sedで&amp;(アンパサンド)に置換したければエスケープが必要</title><link>https://atsum.in/linux/sed-ampersand/</link><pubDate>Tue, 27 Dec 2022 08:15:19 +0900</pubDate><guid>https://atsum.in/linux/sed-ampersand/</guid><description>&lt;h2 id="sedで置き換える文字にアンパサンドを使う場合はエスケープが必要">sedで置き換える文字に&amp;amp;(アンパサンド)を使う場合はエスケープが必要&lt;/h2>
&lt;h3 id="を使うと意図通りでない文字列に置き換わる">&amp;amp;を使うと意図通りでない文字列に置き換わる&lt;/h3>
&lt;p>例えば&lt;code>abc&lt;/code>という文字列を&lt;code>a&amp;amp;c&lt;/code>に置き換えたいと思って以下のコマンドを実行しても何も変わらない。&lt;/p>
&lt;div class="highlight">&lt;pre tabindex="0" class="chroma">&lt;code class="language-shell" data-lang="shell">&lt;span class="line">&lt;span class="cl">$ &lt;span class="nb">echo&lt;/span> &lt;span class="s2">&amp;#34;abc&amp;#34;&lt;/span> &lt;span class="p">|&lt;/span> sed &lt;span class="s2">&amp;#34;s/b/&amp;amp;/&amp;#34;&lt;/span>
&lt;/span>&lt;/span>&lt;span class="line">&lt;span class="cl">abc
&lt;/span>&lt;/span>&lt;/code>&lt;/pre>&lt;/div>&lt;p>他にもHTTPパラメータを見つけてその後ろに&lt;code>&amp;amp;&lt;/code>でパラメータを追加したい、みたいなときに
&lt;code>sed &amp;quot;s/foo=xxx/foo=xxx&amp;amp;bar=yyy/&amp;quot;&lt;/code>のように書くとうまくいかない。&lt;/p></description><enclosure url="https://atsum.in/linux/sed-ampersand/img/thumbnail.png" type="image/png"/></item><item><title>cronのコマンド部に%(パーセント記号)を使いたければエスケープが必要</title><link>https://atsum.in/linux/cron-percent/</link><pubDate>Mon, 26 Dec 2022 21:17:40 +0900</pubDate><guid>https://atsum.in/linux/cron-percent/</guid><description>&lt;h2 id="cron-のコマンド部の--記号はエスケープが必要">cron のコマンド部の % 記号はエスケープが必要&lt;/h2>
&lt;h3 id="-記号を含むコマンドでエラーとなる場合">% 記号を含むコマンドでエラーとなる場合&lt;/h3>
&lt;p>cronで、ランダムな秒数スリープしてからコマンドを実行する、のような記述を以下の様に記述した。&lt;/p></description><enclosure url="https://atsum.in/linux/cron-percent/img/thumbnail.png" type="image/png"/></item><item><title>【AWS】AWS CLI と jq コマンドでインスタンスIDとホスト名の対応関係の一覧を取得する</title><link>https://atsum.in/aws/name-instance-id-map/</link><pubDate>Sat, 17 Dec 2022 10:44:40 +0900</pubDate><guid>https://atsum.in/aws/name-instance-id-map/</guid><description>&lt;h2 id="ホスト名とインスタンスidのマップを作る">ホスト名とインスタンスIDのマップを作る&lt;/h2>
&lt;p>Session Managerでリモートログインするときなど、EC2のインスタンスIDを欲しい場合がある。&lt;br>
インスタンスIDよりもホスト名のほうが覚えやすいのでホスト名からインスタンスIDを手軽に特定できるようにしておくと便利。&lt;/p></description><enclosure url="https://atsum.in/aws/name-instance-id-map/img/thumbnail.png" type="image/png"/></item><item><title>【VSCode】テキストの折り返し表示(自動改行)の設定とショートカット</title><link>https://atsum.in/vscode/word-wrap/</link><pubDate>Thu, 01 Dec 2022 00:04:17 +0900</pubDate><guid>https://atsum.in/vscode/word-wrap/</guid><description>&lt;p>本記事ではVisual Studio Code（以下、VSCode）でテキストを折り返して表示する方法を解説する。&lt;/p>
&lt;p>長い行を自動改行して表示する基本的な設定から、折り返し位置の指定やショートカットキーの変更まで幅広く網羅する。&lt;/p></description><enclosure url="https://atsum.in/vscode/word-wrap/img/thumbnail.png" type="image/png"/></item><item><title>>> でzsh: no such file or directory:エラーが出る場合の対処</title><link>https://atsum.in/linux/noclobber/</link><pubDate>Sun, 20 Nov 2022 20:13:36 +0900</pubDate><guid>https://atsum.in/linux/noclobber/</guid><description>&lt;h2 id="-で追記できない">&amp;raquo; で追記できない&lt;/h2>
&lt;p>zshで&lt;code>&amp;gt;&amp;gt;&lt;/code>による標準出力のファイルへの追記をしようとするとエラーになった。&lt;/p>
&lt;div class="highlight">&lt;pre tabindex="0" class="chroma">&lt;code class="language-bash" data-lang="bash">&lt;span class="line">&lt;span class="cl">$ ls &amp;gt;&amp;gt; result.txt
&lt;/span>&lt;/span>&lt;span class="line">&lt;span class="cl">zsh: no such file or directory: result.txt
&lt;/span>&lt;/span>&lt;/code>&lt;/pre>&lt;/div>&lt;p>出力先ファイルが無い場合にこのエラーが発生した。&lt;/p></description><enclosure url="https://atsum.in/linux/noclobber/img/thumbnail.png" type="image/png"/></item><item><title>【Terraform】AWSのアカウントIDを取得する(aws_caller_identityデータソース)</title><link>https://atsum.in/terraform/account-id/</link><pubDate>Wed, 09 Nov 2022 07:25:27 +0900</pubDate><guid>https://atsum.in/terraform/account-id/</guid><description>&lt;p>本記事ではTerraformを使用してAWSのアカウントIDを取得する方法について説明します。
専用のデータソースを利用すると実行しているユーザーのアカウントIDを簡単に取得できます。&lt;/p></description><enclosure url="https://atsum.in/terraform/account-id/img/thumbnail.png" type="image/png"/></item><item><title>【macOS】HomebrewでRedisをインストールする</title><link>https://atsum.in/mac/install-redis/</link><pubDate>Sun, 30 Oct 2022 12:11:15 +0900</pubDate><guid>https://atsum.in/mac/install-redis/</guid><description>&lt;h2 id="前提">前提&lt;/h2>
&lt;ul>
&lt;li>macOS Monterey 12.6&lt;/li>
&lt;li>Homebrew 3.6.7&lt;/li>
&lt;/ul>
&lt;h2 id="インストール手順">インストール手順&lt;/h2>
&lt;h3 id="インストールできるredisのバージョンの確認">インストールできるRedisのバージョンの確認&lt;/h3>
&lt;p>インストール可能なRedisのバージョンを確認するには&lt;code>brew search&lt;/code>を使用する。&lt;/p>
&lt;div class="highlight">&lt;pre tabindex="0" class="chroma">&lt;code class="language-shell" data-lang="shell">&lt;span class="line">&lt;span class="cl">$ brew search &lt;span class="nv">redis&lt;/span>
&lt;/span>&lt;/span>&lt;span class="line">&lt;span class="cl">&lt;span class="o">==&lt;/span>&amp;gt; Formulae
&lt;/span>&lt;/span>&lt;span class="line">&lt;span class="cl">hiredis redis redis@3.2 redis@6.2 redo
&lt;/span>&lt;/span>&lt;span class="line">&lt;span class="cl">iredis redis-leveldb redis@4.0 redir
&lt;/span>&lt;/span>&lt;/code>&lt;/pre>&lt;/div>&lt;p>&lt;code>@バージョン&lt;/code>がついているものはそのバージョンがインストールされる。&lt;/p></description><enclosure url="https://atsum.in/mac/install-redis/img/thumbnail.png" type="image/png"/></item><item><title>yumコマンドでrpmパッケージのダウンロードだけする</title><link>https://atsum.in/linux/yumdownloader/</link><pubDate>Tue, 25 Oct 2022 23:20:15 +0900</pubDate><guid>https://atsum.in/linux/yumdownloader/</guid><description>&lt;h2 id="環境">環境&lt;/h2>
&lt;p>yumコマンドでパッケージ管理されるRedhat系OS。(CentOS, AlmaLinux, Rocky Linux, Amazon Linuxなど)&lt;/p>
&lt;h2 id="yumdownloader-コマンド">yumdownloader コマンド&lt;/h2>
&lt;p>yumコマンドでインストールされるrpmパッケージをダウンロードだけしたい場合は&lt;code>yumdownloader&lt;/code>コマンドを使用する。&lt;/p></description><enclosure url="https://atsum.in/linux/yumdownloader/img/thumbnail.png" type="image/png"/></item><item><title>【AWS CLI】S3のファイル数と合計サイズを取得する</title><link>https://atsum.in/aws/s3-count-sum-recursively/</link><pubDate>Sat, 15 Oct 2022 18:11:18 +0900</pubDate><guid>https://atsum.in/aws/s3-count-sum-recursively/</guid><description>&lt;h2 id="s3のファイル数と合計サイズを取得するコマンド">S3のファイル数と合計サイズを取得するコマンド&lt;/h2>
&lt;p>&lt;code>aws s3 ls&lt;/code> コマンドのオプションとして、&lt;code>--recursive --human --sum&lt;/code> オプションをつける。&lt;/p>
&lt;div class="highlight">&lt;pre tabindex="0" class="chroma">&lt;code class="language-shell" data-lang="shell">&lt;span class="line">&lt;span class="cl">$ aws s3 ls s3://バケット名/path/to/folder --recursive --sum --human
&lt;/span>&lt;/span>&lt;span class="line">&lt;span class="cl">.
&lt;/span>&lt;/span>&lt;span class="line">&lt;span class="cl">.
&lt;/span>&lt;/span>&lt;span class="line">&lt;span class="cl">.
&lt;/span>&lt;/span>&lt;span class="line">&lt;span class="cl">
&lt;/span>&lt;/span>&lt;span class="line">&lt;span class="cl">Total Objects: &lt;span class="m">3204&lt;/span> ← ファイル数
&lt;/span>&lt;/span>&lt;span class="line">&lt;span class="cl"> Total Size: 1.1 GiB ← 合計サイズ
&lt;/span>&lt;/span>&lt;/code>&lt;/pre>&lt;/div>&lt;h2 id="オプションの説明">オプションの説明&lt;/h2>
&lt;p>各オプションの意味は以下の通り。&lt;/p></description><enclosure url="https://atsum.in/aws/s3-count-sum-recursively/img/thumbnail.png" type="image/png"/></item><item><title>【AWS】EC2インスタンス内で自身が所属するAvailability Zoneをcurlで取得する</title><link>https://atsum.in/aws/get-availability-zone/</link><pubDate>Mon, 10 Oct 2022 22:32:56 +0900</pubDate><guid>https://atsum.in/aws/get-availability-zone/</guid><description>&lt;h2 id="availability-zoneをcurlで取得">Availability Zoneをcurlで取得&lt;/h2>
&lt;p>EC2のインスタンスにSSHなどでログインし、OS上で以下を実行。&lt;/p>
&lt;div class="highlight">&lt;pre tabindex="0" class="chroma">&lt;code class="language-shell" data-lang="shell">&lt;span class="line">&lt;span class="cl">$ curl -s 169.254.169.254/latest/meta-data/placement/availability-zone
&lt;/span>&lt;/span>&lt;span class="line">&lt;span class="cl">ap-northeast-1a
&lt;/span>&lt;/span>&lt;/code>&lt;/pre>&lt;/div></description><enclosure url="https://atsum.in/aws/get-availability-zone/img/thumbnail.png" type="image/png"/></item><item><title>【AWS】AWS CLIでParameter Storeから値を取得する</title><link>https://atsum.in/aws/aws-cli-parameter-store/</link><pubDate>Mon, 10 Oct 2022 22:05:10 +0900</pubDate><guid>https://atsum.in/aws/aws-cli-parameter-store/</guid><description>&lt;h2 id="parameter-storeから値を取得するコマンド">Parameter Storeから値を取得するコマンド&lt;/h2>
&lt;div class="highlight">&lt;pre tabindex="0" class="chroma">&lt;code class="language-shell" data-lang="shell">&lt;span class="line">&lt;span class="cl">$ aws ssm get-parameter --name キー
&lt;/span>&lt;/span>&lt;/code>&lt;/pre>&lt;/div>&lt;p>以下のようなJSONが返ってくる。&lt;/p>
&lt;div class="highlight">&lt;pre tabindex="0" class="chroma">&lt;code class="language-json" data-lang="json">&lt;span class="line">&lt;span class="cl">&lt;span class="p">{&lt;/span>
&lt;/span>&lt;/span>&lt;span class="line">&lt;span class="cl"> &lt;span class="nt">&amp;#34;Parameter&amp;#34;&lt;/span>&lt;span class="p">:&lt;/span> &lt;span class="p">{&lt;/span>
&lt;/span>&lt;/span>&lt;span class="line">&lt;span class="cl"> &lt;span class="nt">&amp;#34;Name&amp;#34;&lt;/span>&lt;span class="p">:&lt;/span> &lt;span class="s2">&amp;#34;キー&amp;#34;&lt;/span>&lt;span class="p">,&lt;/span>
&lt;/span>&lt;/span>&lt;span class="line">&lt;span class="cl"> &lt;span class="nt">&amp;#34;Type&amp;#34;&lt;/span>&lt;span class="p">:&lt;/span> &lt;span class="s2">&amp;#34;String&amp;#34;&lt;/span>&lt;span class="p">,&lt;/span>
&lt;/span>&lt;/span>&lt;span class="line">&lt;span class="cl"> &lt;span class="nt">&amp;#34;Value&amp;#34;&lt;/span>&lt;span class="p">:&lt;/span> &lt;span class="s2">&amp;#34;値&amp;#34;&lt;/span>&lt;span class="p">,&lt;/span>
&lt;/span>&lt;/span>&lt;span class="line">&lt;span class="cl"> &lt;span class="nt">&amp;#34;Version&amp;#34;&lt;/span>&lt;span class="p">:&lt;/span> &lt;span class="mi">1&lt;/span>&lt;span class="p">,&lt;/span>
&lt;/span>&lt;/span>&lt;span class="line">&lt;span class="cl"> &lt;span class="nt">&amp;#34;LastModifiedDate&amp;#34;&lt;/span>&lt;span class="p">:&lt;/span> &lt;span class="s2">&amp;#34;...&amp;#34;&lt;/span>&lt;span class="p">,&lt;/span>
&lt;/span>&lt;/span>&lt;span class="line">&lt;span class="cl"> &lt;span class="nt">&amp;#34;ARN&amp;#34;&lt;/span>&lt;span class="p">:&lt;/span> &lt;span class="s2">&amp;#34;...&amp;#34;&lt;/span>&lt;span class="p">,&lt;/span>
&lt;/span>&lt;/span>&lt;span class="line">&lt;span class="cl"> &lt;span class="nt">&amp;#34;DataType&amp;#34;&lt;/span>&lt;span class="p">:&lt;/span> &lt;span class="s2">&amp;#34;text&amp;#34;&lt;/span>
&lt;/span>&lt;/span>&lt;span class="line">&lt;span class="cl"> &lt;span class="p">}&lt;/span>
&lt;/span>&lt;/span>&lt;span class="line">&lt;span class="cl">&lt;span class="p">}&lt;/span>
&lt;/span>&lt;/span>&lt;/code>&lt;/pre>&lt;/div>&lt;p>値は&lt;code>Parameter.Value&lt;/code>に格納されているので値だけ取り出したければ&lt;code>--query&lt;/code>オプションと&lt;code>--output&lt;/code>オプションを指定して以下のように取得できる。&lt;/p></description><enclosure url="https://atsum.in/aws/aws-cli-parameter-store/img/thumbnail.png" type="image/png"/></item><item><title>【AWS】AWS CLIでアカウントIDを取得する</title><link>https://atsum.in/aws/aws-cli-account-id/</link><pubDate>Mon, 10 Oct 2022 20:13:57 +0900</pubDate><guid>https://atsum.in/aws/aws-cli-account-id/</guid><description>&lt;h2 id="アカウントid">アカウントID&lt;/h2>
&lt;p>AWSのアカウントIDは右上のメニューから確認できる12桁の数字。&lt;/p>
&lt;p>&lt;img src="img/aws-account-id.png" alt="アカウントID">&lt;/p>
&lt;h2 id="aws-cliでアカウントidを取得する">AWS CLIでアカウントIDを取得する&lt;/h2>
&lt;p>&lt;code>aws sts get-caller-identity&lt;/code>コマンドで取得できる。&lt;/p></description><enclosure url="https://atsum.in/aws/aws-cli-account-id/img/thumbnail.png" type="image/png"/></item><item><title>lsコマンドで更新日時を秒まで表示する</title><link>https://atsum.in/linux/ls-seconds/</link><pubDate>Sat, 08 Oct 2022 21:32:27 +0900</pubDate><guid>https://atsum.in/linux/ls-seconds/</guid><description>&lt;h2 id="ls--lコマンドは標準では秒までの表示">ls -lコマンドは標準では秒までの表示&lt;/h2>
&lt;p>&lt;code>ls&lt;/code>コマンドの&lt;code>-l&lt;/code>オプションで更新日時が表示される。&lt;/p>
&lt;div class="highlight">&lt;pre tabindex="0" class="chroma">&lt;code class="language-shell" data-lang="shell">&lt;span class="line">&lt;span class="cl">$ ls -l
&lt;/span>&lt;/span>&lt;span class="line">&lt;span class="cl">total &lt;span class="m">0&lt;/span>
&lt;/span>&lt;/span>&lt;span class="line">&lt;span class="cl">-rw-r--r-- &lt;span class="m">1&lt;/span> root root &lt;span class="m">0&lt;/span> Oct &lt;span class="m">8&lt;/span> 12:38 foo.txt
&lt;/span>&lt;/span>&lt;/code>&lt;/pre>&lt;/div>&lt;p>以下の部分。&lt;/p>
&lt;p>&lt;img src="img/ls-l.png" alt="ls -l">&lt;/p>
&lt;h2 id="linuxの場合">Linuxの場合&lt;/h2>
&lt;h3 id="time-styleオプションで秒まで指定して表示する">&amp;ndash;time-styleオプションで秒まで指定して表示する&lt;/h3>
&lt;p>&lt;code>--time-style&lt;/code>オプションで更新日時のフォーマットを指定できる。&lt;br>
このフォーマットに秒も指定できるので以下の様に指定すれば秒まで表示できる。&lt;/p></description><enclosure url="https://atsum.in/linux/ls-seconds/img/thumbnail.png" type="image/png"/></item><item><title>IntelliJ IDEA で複数の Maven プロジェクトを1つのウインドウで開く手順</title><link>https://atsum.in/java/intellij-idea-multi-module/</link><pubDate>Tue, 04 Oct 2022 22:58:47 +0900</pubDate><guid>https://atsum.in/java/intellij-idea-multi-module/</guid><description>&lt;h2 id="intellij-ideaで複数プロジェクトを一度に開きたい">IntelliJ IDEAで複数プロジェクトを一度に開きたい&lt;/h2>
&lt;p>モジュール化してMavenプロジェクトを複数作っているときに、それぞれのプロジェクトごとにIntelliJ IDEAのウインドウを開くのは面倒となる。&lt;br>
1つのウインドウで開かないと別モジュールのコードにジャンプできない。&lt;/p></description><enclosure url="https://atsum.in/java/intellij-idea-multi-module/img/thumbnail.png" type="image/png"/></item><item><title>【Android,Kotlin】enable/disableの状態やpressした状態のときにUIの色を変える</title><link>https://atsum.in/android/stateful-drawable/</link><pubDate>Wed, 31 Aug 2022 21:06:41 +0900</pubDate><guid>https://atsum.in/android/stateful-drawable/</guid><description>&lt;h2 id="状態で色を変える">状態で色を変える&lt;/h2>
&lt;p>AndroidのViewはenable/disableの状態や、pressした状態で色や形などを変更できる。&lt;/p>
&lt;p>例としてテキストに対して以下のように作成できる。&lt;/p></description><enclosure url="https://atsum.in/android/stateful-drawable/img/thumbnail.png" type="image/png"/></item><item><title>複数回のコマンドの標準出力をまとめて一度にリダイレクトする</title><link>https://atsum.in/linux/multi-command-at-once/</link><pubDate>Sun, 28 Aug 2022 18:22:53 +0900</pubDate><guid>https://atsum.in/linux/multi-command-at-once/</guid><description>&lt;h2 id="複数回のコマンドを同じファイルにリダイレクト">複数回のコマンドを同じファイルにリダイレクト&lt;/h2>
&lt;p>以下のようなシェルスクリプトを書いた場合、同じファイルをコマンドの回数だけオープンすることになり
無駄が生じる。&lt;/p>
&lt;div class="highlight">&lt;pre tabindex="0" class="chroma">&lt;code class="language-bash" data-lang="bash">&lt;span class="line">&lt;span class="cl">&lt;span class="cp">#!/bin/sh
&lt;/span>&lt;/span>&lt;/span>&lt;span class="line">&lt;span class="cl">&lt;span class="cp">&lt;/span>
&lt;/span>&lt;/span>&lt;span class="line">&lt;span class="cl">&lt;span class="nb">echo&lt;/span> foo &amp;gt;&amp;gt; a.txt
&lt;/span>&lt;/span>&lt;span class="line">&lt;span class="cl">&lt;span class="nb">echo&lt;/span> bar &amp;gt;&amp;gt; a.txt
&lt;/span>&lt;/span>&lt;span class="line">&lt;span class="cl">&lt;span class="nb">echo&lt;/span> baz &amp;gt;&amp;gt; a.txt
&lt;/span>&lt;/span>&lt;/code>&lt;/pre>&lt;/div>&lt;p>&lt;a href="https://github.com/koalaman/shellcheck">shellcheck&lt;/a>にかけると以下の違反が検出される。&lt;/p></description><enclosure url="https://atsum.in/linux/multi-command-at-once/img/thumbnail.png" type="image/png"/></item><item><title>【Android,Kotlin】端末に保存されたファイルかカメラ撮影から画像選択できるようにする</title><link>https://atsum.in/android/chooser-activity-result-contract/</link><pubDate>Sat, 27 Aug 2022 21:46:24 +0900</pubDate><guid>https://atsum.in/android/chooser-activity-result-contract/</guid><description>&lt;h2 id="ファイル選択orカメラ撮影で画像を選択できるようにしたい">ファイル選択orカメラ撮影で画像を選択できるようにしたい&lt;/h2>
&lt;p>こういうやつ。&lt;/p>
&lt;p>&lt;img src="img/chooser.png" alt="chooser">&lt;/p>
&lt;p>カメラで撮った写真を使う場合と端末のファイルを利用する場合でそれぞれ単体の実装は以下の記事を参照。&lt;/p>
&lt;ul>
&lt;li>カメラ:
&lt;ul>
&lt;li>&lt;a href="https://atsum.in/android/take-picture/">端末で写真を撮って表示する&lt;/a>&lt;/li>
&lt;/ul>
&lt;/li>
&lt;li>ファイル選択:
&lt;ul>
&lt;li>&lt;a href="https://atsum.in/android/get-content/">GetContentで端末に保存された画像ファイルを選択して表示する&lt;/a>&lt;/li>
&lt;li>&lt;a href="https://atsum.in/android/open-document/">OpenDocumentで端末内の画像ファイルを選択して表示する&lt;/a>&lt;/li>
&lt;/ul>
&lt;/li>
&lt;/ul>
&lt;h2 id="実装">実装&lt;/h2>
&lt;h3 id="自作activityresultcontract">自作ActivityResultContract&lt;/h3>
&lt;p>ボトムシートとしてファイル選択、カメラ撮影から選択できるようにするための&lt;code>ActivityResultContract&lt;/code>を作成する。&lt;/p></description><enclosure url="https://atsum.in/android/chooser-activity-result-contract/img/thumbnail.png" type="image/png"/></item><item><title>【Android,Kotlin】OpenDocumentで端末内の画像ファイルを選択して表示する</title><link>https://atsum.in/android/open-document/</link><pubDate>Tue, 23 Aug 2022 07:51:42 +0900</pubDate><guid>https://atsum.in/android/open-document/</guid><description>&lt;h2 id="アプリのイメージ">アプリのイメージ&lt;/h2>
&lt;p>端末に保存されている画像を選択したい。&lt;/p>
&lt;p>&lt;img src="img/app-image.gif" alt="アプリイメージ">&lt;/p>
&lt;p>関連: &lt;a href="https://atsum.in/android/get-content">【Android,Kotlin】GetContentで端末に保存された画像ファイルを選択して表示する&lt;/a>&lt;/p>
&lt;h2 id="実装">実装&lt;/h2>
&lt;h3 id="レイアウト">レイアウト&lt;/h3>
&lt;p>&lt;code>ImageView&lt;/code>とボタンを設置しておく。&lt;/p>
&lt;div class="highlight">&lt;pre tabindex="0" class="chroma">&lt;code class="language-kotlin" data-lang="kotlin">&lt;span class="line">&lt;span class="cl">&lt;span class="p">&amp;lt;?&lt;/span>&lt;span class="n">xml&lt;/span> &lt;span class="n">version&lt;/span>&lt;span class="p">=&lt;/span>&lt;span class="s2">&amp;#34;1.0&amp;#34;&lt;/span> &lt;span class="n">encoding&lt;/span>&lt;span class="p">=&lt;/span>&lt;span class="s2">&amp;#34;utf-8&amp;#34;&lt;/span>&lt;span class="p">?&amp;gt;&lt;/span>
&lt;/span>&lt;/span>&lt;span class="line">&lt;span class="cl">&lt;span class="p">&amp;lt;&lt;/span>&lt;span class="n">androidx&lt;/span>&lt;span class="p">.&lt;/span>&lt;span class="n">constraintlayout&lt;/span>&lt;span class="p">.&lt;/span>&lt;span class="n">widget&lt;/span>&lt;span class="p">.&lt;/span>&lt;span class="n">ConstraintLayout&lt;/span>
&lt;/span>&lt;/span>&lt;span class="line">&lt;span class="cl"> &lt;span class="n">android&lt;/span>&lt;span class="p">:&lt;/span>&lt;span class="n">layout_width&lt;/span>&lt;span class="p">=&lt;/span>&lt;span class="s2">&amp;#34;match_parent&amp;#34;&lt;/span>
&lt;/span>&lt;/span>&lt;span class="line">&lt;span class="cl"> &lt;span class="n">android&lt;/span>&lt;span class="p">:&lt;/span>&lt;span class="n">layout_height&lt;/span>&lt;span class="p">=&lt;/span>&lt;span class="s2">&amp;#34;match_parent&amp;#34;&lt;/span>&lt;span class="p">&amp;gt;&lt;/span>
&lt;/span>&lt;/span>&lt;span class="line">&lt;span class="cl"> &lt;span class="p">&amp;lt;&lt;/span>&lt;span class="n">ImageView&lt;/span>
&lt;/span>&lt;/span>&lt;span class="line">&lt;span class="cl"> &lt;span class="n">android&lt;/span>&lt;span class="p">:&lt;/span>&lt;span class="n">id&lt;/span>&lt;span class="p">=&lt;/span>&lt;span class="s2">&amp;#34;@+id/imageView&amp;#34;&lt;/span>
&lt;/span>&lt;/span>&lt;span class="line">&lt;span class="cl"> &lt;span class="n">android&lt;/span>&lt;span class="p">:&lt;/span>&lt;span class="n">layout_width&lt;/span>&lt;span class="p">=&lt;/span>&lt;span class="s2">&amp;#34;match_parent&amp;#34;&lt;/span>
&lt;/span>&lt;/span>&lt;span class="line">&lt;span class="cl"> &lt;span class="n">android&lt;/span>&lt;span class="p">:&lt;/span>&lt;span class="n">layout_height&lt;/span>&lt;span class="p">=&lt;/span>&lt;span class="s2">&amp;#34;300dp&amp;#34;&lt;/span>
&lt;/span>&lt;/span>&lt;span class="line">&lt;span class="cl"> &lt;span class="n">app&lt;/span>&lt;span class="p">:&lt;/span>&lt;span class="n">layout_constraintTop_toTopOf&lt;/span>&lt;span class="p">=&lt;/span>&lt;span class="s2">&amp;#34;parent&amp;#34;&lt;/span>
&lt;/span>&lt;/span>&lt;span class="line">&lt;span class="cl"> &lt;span class="n">app&lt;/span>&lt;span class="p">:&lt;/span>&lt;span class="n">layout_constraintStart_toStartOf&lt;/span>&lt;span class="p">=&lt;/span>&lt;span class="s2">&amp;#34;parent&amp;#34;&lt;/span>
&lt;/span>&lt;/span>&lt;span class="line">&lt;span class="cl"> &lt;span class="n">app&lt;/span>&lt;span class="p">:&lt;/span>&lt;span class="n">layout_constraintEnd_toEndOf&lt;/span>&lt;span class="p">=&lt;/span>&lt;span class="s2">&amp;#34;parent&amp;#34;&lt;/span>&lt;span class="p">/&amp;gt;&lt;/span>
&lt;/span>&lt;/span>&lt;span class="line">&lt;span class="cl"> &lt;span class="p">&amp;lt;&lt;/span>&lt;span class="n">Button&lt;/span>
&lt;/span>&lt;/span>&lt;span class="line">&lt;span class="cl"> &lt;span class="n">android&lt;/span>&lt;span class="p">:&lt;/span>&lt;span class="n">id&lt;/span>&lt;span class="p">=&lt;/span>&lt;span class="s2">&amp;#34;@+id/button&amp;#34;&lt;/span>
&lt;/span>&lt;/span>&lt;span class="line">&lt;span class="cl"> &lt;span class="n">android&lt;/span>&lt;span class="p">:&lt;/span>&lt;span class="n">layout_width&lt;/span>&lt;span class="p">=&lt;/span>&lt;span class="s2">&amp;#34;wrap_content&amp;#34;&lt;/span>
&lt;/span>&lt;/span>&lt;span class="line">&lt;span class="cl"> &lt;span class="n">android&lt;/span>&lt;span class="p">:&lt;/span>&lt;span class="n">layout_height&lt;/span>&lt;span class="p">=&lt;/span>&lt;span class="s2">&amp;#34;wrap_content&amp;#34;&lt;/span>
&lt;/span>&lt;/span>&lt;span class="line">&lt;span class="cl"> &lt;span class="n">android&lt;/span>&lt;span class="p">:&lt;/span>&lt;span class="n">text&lt;/span>&lt;span class="p">=&lt;/span>&lt;span class="s2">&amp;#34;@string/next&amp;#34;&lt;/span>
&lt;/span>&lt;/span>&lt;span class="line">&lt;span class="cl"> &lt;span class="n">app&lt;/span>&lt;span class="p">:&lt;/span>&lt;span class="n">layout_constraintEnd_toEndOf&lt;/span>&lt;span class="p">=&lt;/span>&lt;span class="s2">&amp;#34;parent&amp;#34;&lt;/span>
&lt;/span>&lt;/span>&lt;span class="line">&lt;span class="cl"> &lt;span class="n">app&lt;/span>&lt;span class="p">:&lt;/span>&lt;span class="n">layout_constraintStart_toStartOf&lt;/span>&lt;span class="p">=&lt;/span>&lt;span class="s2">&amp;#34;parent&amp;#34;&lt;/span>
&lt;/span>&lt;/span>&lt;span class="line">&lt;span class="cl"> &lt;span class="n">app&lt;/span>&lt;span class="p">:&lt;/span>&lt;span class="n">layout_constraintTop_toBottomOf&lt;/span>&lt;span class="p">=&lt;/span>&lt;span class="s2">&amp;#34;@id/imageView&amp;#34;&lt;/span>
&lt;/span>&lt;/span>&lt;span class="line">&lt;span class="cl"> &lt;span class="p">/&amp;gt;&lt;/span>
&lt;/span>&lt;/span>&lt;span class="line">&lt;span class="cl">&lt;span class="p">&amp;lt;/&lt;/span>&lt;span class="n">androidx&lt;/span>&lt;span class="p">.&lt;/span>&lt;span class="n">constraintlayout&lt;/span>&lt;span class="p">.&lt;/span>&lt;span class="n">widget&lt;/span>&lt;span class="p">.&lt;/span>&lt;span class="n">ConstraintLayout&lt;/span>&lt;span class="p">&amp;gt;&lt;/span>
&lt;/span>&lt;/span>&lt;/code>&lt;/pre>&lt;/div>&lt;h3 id="fragmentviewmodel">Fragment/ViewModel&lt;/h3>
&lt;p>フィールドに&lt;code>registerForActivityResult&lt;/code>で&lt;code>ActivityResultContracts.OpenDocument()&lt;/code>のlauncherを作る。&lt;/p></description><enclosure url="https://atsum.in/android/open-document/img/thumbnail.png" type="image/png"/></item><item><title>【Android,Kotlin】端末で写真を撮って表示する</title><link>https://atsum.in/android/take-picture/</link><pubDate>Tue, 23 Aug 2022 07:10:03 +0900</pubDate><guid>https://atsum.in/android/take-picture/</guid><description>&lt;h2 id="アプリのイメージ">アプリのイメージ&lt;/h2>
&lt;p>カメラアプリで写真を撮って表示したい。&lt;/p>
&lt;p>&lt;img src="img/app-image.gif" alt="アプリイメージ">&lt;/p>
&lt;h2 id="実装">実装&lt;/h2>
&lt;h3 id="レイアウト">レイアウト&lt;/h3>
&lt;p>&lt;code>ImageView&lt;/code>とボタンを設置しておく。&lt;/p>
&lt;div class="highlight">&lt;pre tabindex="0" class="chroma">&lt;code class="language-kotlin" data-lang="kotlin">&lt;span class="line">&lt;span class="cl">&lt;span class="p">&amp;lt;?&lt;/span>&lt;span class="n">xml&lt;/span> &lt;span class="n">version&lt;/span>&lt;span class="p">=&lt;/span>&lt;span class="s2">&amp;#34;1.0&amp;#34;&lt;/span> &lt;span class="n">encoding&lt;/span>&lt;span class="p">=&lt;/span>&lt;span class="s2">&amp;#34;utf-8&amp;#34;&lt;/span>&lt;span class="p">?&amp;gt;&lt;/span>
&lt;/span>&lt;/span>&lt;span class="line">&lt;span class="cl">&lt;span class="p">&amp;lt;&lt;/span>&lt;span class="n">androidx&lt;/span>&lt;span class="p">.&lt;/span>&lt;span class="n">constraintlayout&lt;/span>&lt;span class="p">.&lt;/span>&lt;span class="n">widget&lt;/span>&lt;span class="p">.&lt;/span>&lt;span class="n">ConstraintLayout&lt;/span>
&lt;/span>&lt;/span>&lt;span class="line">&lt;span class="cl"> &lt;span class="n">android&lt;/span>&lt;span class="p">:&lt;/span>&lt;span class="n">layout_width&lt;/span>&lt;span class="p">=&lt;/span>&lt;span class="s2">&amp;#34;match_parent&amp;#34;&lt;/span>
&lt;/span>&lt;/span>&lt;span class="line">&lt;span class="cl"> &lt;span class="n">android&lt;/span>&lt;span class="p">:&lt;/span>&lt;span class="n">layout_height&lt;/span>&lt;span class="p">=&lt;/span>&lt;span class="s2">&amp;#34;match_parent&amp;#34;&lt;/span>&lt;span class="p">&amp;gt;&lt;/span>
&lt;/span>&lt;/span>&lt;span class="line">&lt;span class="cl"> &lt;span class="p">&amp;lt;&lt;/span>&lt;span class="n">ImageView&lt;/span>
&lt;/span>&lt;/span>&lt;span class="line">&lt;span class="cl"> &lt;span class="n">android&lt;/span>&lt;span class="p">:&lt;/span>&lt;span class="n">id&lt;/span>&lt;span class="p">=&lt;/span>&lt;span class="s2">&amp;#34;@+id/imageView&amp;#34;&lt;/span>
&lt;/span>&lt;/span>&lt;span class="line">&lt;span class="cl"> &lt;span class="n">android&lt;/span>&lt;span class="p">:&lt;/span>&lt;span class="n">layout_width&lt;/span>&lt;span class="p">=&lt;/span>&lt;span class="s2">&amp;#34;match_parent&amp;#34;&lt;/span>
&lt;/span>&lt;/span>&lt;span class="line">&lt;span class="cl"> &lt;span class="n">android&lt;/span>&lt;span class="p">:&lt;/span>&lt;span class="n">layout_height&lt;/span>&lt;span class="p">=&lt;/span>&lt;span class="s2">&amp;#34;300dp&amp;#34;&lt;/span>
&lt;/span>&lt;/span>&lt;span class="line">&lt;span class="cl"> &lt;span class="n">app&lt;/span>&lt;span class="p">:&lt;/span>&lt;span class="n">layout_constraintTop_toTopOf&lt;/span>&lt;span class="p">=&lt;/span>&lt;span class="s2">&amp;#34;parent&amp;#34;&lt;/span>
&lt;/span>&lt;/span>&lt;span class="line">&lt;span class="cl"> &lt;span class="n">app&lt;/span>&lt;span class="p">:&lt;/span>&lt;span class="n">layout_constraintStart_toStartOf&lt;/span>&lt;span class="p">=&lt;/span>&lt;span class="s2">&amp;#34;parent&amp;#34;&lt;/span>
&lt;/span>&lt;/span>&lt;span class="line">&lt;span class="cl"> &lt;span class="n">app&lt;/span>&lt;span class="p">:&lt;/span>&lt;span class="n">layout_constraintEnd_toEndOf&lt;/span>&lt;span class="p">=&lt;/span>&lt;span class="s2">&amp;#34;parent&amp;#34;&lt;/span>&lt;span class="p">/&amp;gt;&lt;/span>
&lt;/span>&lt;/span>&lt;span class="line">&lt;span class="cl"> &lt;span class="p">&amp;lt;&lt;/span>&lt;span class="n">Button&lt;/span>
&lt;/span>&lt;/span>&lt;span class="line">&lt;span class="cl"> &lt;span class="n">android&lt;/span>&lt;span class="p">:&lt;/span>&lt;span class="n">id&lt;/span>&lt;span class="p">=&lt;/span>&lt;span class="s2">&amp;#34;@+id/button&amp;#34;&lt;/span>
&lt;/span>&lt;/span>&lt;span class="line">&lt;span class="cl"> &lt;span class="n">android&lt;/span>&lt;span class="p">:&lt;/span>&lt;span class="n">layout_width&lt;/span>&lt;span class="p">=&lt;/span>&lt;span class="s2">&amp;#34;wrap_content&amp;#34;&lt;/span>
&lt;/span>&lt;/span>&lt;span class="line">&lt;span class="cl"> &lt;span class="n">android&lt;/span>&lt;span class="p">:&lt;/span>&lt;span class="n">layout_height&lt;/span>&lt;span class="p">=&lt;/span>&lt;span class="s2">&amp;#34;wrap_content&amp;#34;&lt;/span>
&lt;/span>&lt;/span>&lt;span class="line">&lt;span class="cl"> &lt;span class="n">android&lt;/span>&lt;span class="p">:&lt;/span>&lt;span class="n">text&lt;/span>&lt;span class="p">=&lt;/span>&lt;span class="s2">&amp;#34;@string/next&amp;#34;&lt;/span>
&lt;/span>&lt;/span>&lt;span class="line">&lt;span class="cl"> &lt;span class="n">app&lt;/span>&lt;span class="p">:&lt;/span>&lt;span class="n">layout_constraintEnd_toEndOf&lt;/span>&lt;span class="p">=&lt;/span>&lt;span class="s2">&amp;#34;parent&amp;#34;&lt;/span>
&lt;/span>&lt;/span>&lt;span class="line">&lt;span class="cl"> &lt;span class="n">app&lt;/span>&lt;span class="p">:&lt;/span>&lt;span class="n">layout_constraintStart_toStartOf&lt;/span>&lt;span class="p">=&lt;/span>&lt;span class="s2">&amp;#34;parent&amp;#34;&lt;/span>
&lt;/span>&lt;/span>&lt;span class="line">&lt;span class="cl"> &lt;span class="n">app&lt;/span>&lt;span class="p">:&lt;/span>&lt;span class="n">layout_constraintTop_toBottomOf&lt;/span>&lt;span class="p">=&lt;/span>&lt;span class="s2">&amp;#34;@id/imageView&amp;#34;&lt;/span>
&lt;/span>&lt;/span>&lt;span class="line">&lt;span class="cl"> &lt;span class="p">/&amp;gt;&lt;/span>
&lt;/span>&lt;/span>&lt;span class="line">&lt;span class="cl">&lt;span class="p">&amp;lt;/&lt;/span>&lt;span class="n">androidx&lt;/span>&lt;span class="p">.&lt;/span>&lt;span class="n">constraintlayout&lt;/span>&lt;span class="p">.&lt;/span>&lt;span class="n">widget&lt;/span>&lt;span class="p">.&lt;/span>&lt;span class="n">ConstraintLayout&lt;/span>&lt;span class="p">&amp;gt;&lt;/span>
&lt;/span>&lt;/span>&lt;/code>&lt;/pre>&lt;/div>&lt;h3 id="cacheフォルダへの書き込みを許可する">cacheフォルダへの書き込みを許可する&lt;/h3>
&lt;p>外部のカメラアプリがアプリの&lt;code>cache&lt;/code>フォルダへ書き込み、アプリはそれを画面に表示する。&lt;/p></description><enclosure url="https://atsum.in/android/take-picture/img/thumbnail.png" type="image/png"/></item><item><title>【Android,Kotlin】GetContentで端末に保存された画像ファイルを選択して表示する</title><link>https://atsum.in/android/get-content/</link><pubDate>Tue, 23 Aug 2022 01:04:32 +0900</pubDate><guid>https://atsum.in/android/get-content/</guid><description>&lt;h2 id="アプリのイメージ">アプリのイメージ&lt;/h2>
&lt;p>端末に保存されている画像を選択したい。&lt;/p>
&lt;p>&lt;img src="img/app-image.gif" alt="アプリイメージ">&lt;/p>
&lt;p>関連: &lt;a href="https://atsum.in/android/open-document">【Android,Kotlin】OpenDocumentで端末内の画像ファイルを選択して表示する&lt;/a>&lt;/p>
&lt;h2 id="実装">実装&lt;/h2>
&lt;h3 id="レイアウト">レイアウト&lt;/h3>
&lt;p>&lt;code>ImageView&lt;/code>とボタンを設置しておく。&lt;/p>
&lt;div class="highlight">&lt;pre tabindex="0" class="chroma">&lt;code class="language-kotlin" data-lang="kotlin">&lt;span class="line">&lt;span class="cl">&lt;span class="p">&amp;lt;?&lt;/span>&lt;span class="n">xml&lt;/span> &lt;span class="n">version&lt;/span>&lt;span class="p">=&lt;/span>&lt;span class="s2">&amp;#34;1.0&amp;#34;&lt;/span> &lt;span class="n">encoding&lt;/span>&lt;span class="p">=&lt;/span>&lt;span class="s2">&amp;#34;utf-8&amp;#34;&lt;/span>&lt;span class="p">?&amp;gt;&lt;/span>
&lt;/span>&lt;/span>&lt;span class="line">&lt;span class="cl">&lt;span class="p">&amp;lt;&lt;/span>&lt;span class="n">androidx&lt;/span>&lt;span class="p">.&lt;/span>&lt;span class="n">constraintlayout&lt;/span>&lt;span class="p">.&lt;/span>&lt;span class="n">widget&lt;/span>&lt;span class="p">.&lt;/span>&lt;span class="n">ConstraintLayout&lt;/span>
&lt;/span>&lt;/span>&lt;span class="line">&lt;span class="cl"> &lt;span class="n">android&lt;/span>&lt;span class="p">:&lt;/span>&lt;span class="n">layout_width&lt;/span>&lt;span class="p">=&lt;/span>&lt;span class="s2">&amp;#34;match_parent&amp;#34;&lt;/span>
&lt;/span>&lt;/span>&lt;span class="line">&lt;span class="cl"> &lt;span class="n">android&lt;/span>&lt;span class="p">:&lt;/span>&lt;span class="n">layout_height&lt;/span>&lt;span class="p">=&lt;/span>&lt;span class="s2">&amp;#34;match_parent&amp;#34;&lt;/span>&lt;span class="p">&amp;gt;&lt;/span>
&lt;/span>&lt;/span>&lt;span class="line">&lt;span class="cl"> &lt;span class="p">&amp;lt;&lt;/span>&lt;span class="n">ImageView&lt;/span>
&lt;/span>&lt;/span>&lt;span class="line">&lt;span class="cl"> &lt;span class="n">android&lt;/span>&lt;span class="p">:&lt;/span>&lt;span class="n">id&lt;/span>&lt;span class="p">=&lt;/span>&lt;span class="s2">&amp;#34;@+id/imageView&amp;#34;&lt;/span>
&lt;/span>&lt;/span>&lt;span class="line">&lt;span class="cl"> &lt;span class="n">android&lt;/span>&lt;span class="p">:&lt;/span>&lt;span class="n">layout_width&lt;/span>&lt;span class="p">=&lt;/span>&lt;span class="s2">&amp;#34;match_parent&amp;#34;&lt;/span>
&lt;/span>&lt;/span>&lt;span class="line">&lt;span class="cl"> &lt;span class="n">android&lt;/span>&lt;span class="p">:&lt;/span>&lt;span class="n">layout_height&lt;/span>&lt;span class="p">=&lt;/span>&lt;span class="s2">&amp;#34;300dp&amp;#34;&lt;/span>
&lt;/span>&lt;/span>&lt;span class="line">&lt;span class="cl"> &lt;span class="n">app&lt;/span>&lt;span class="p">:&lt;/span>&lt;span class="n">layout_constraintTop_toTopOf&lt;/span>&lt;span class="p">=&lt;/span>&lt;span class="s2">&amp;#34;parent&amp;#34;&lt;/span>
&lt;/span>&lt;/span>&lt;span class="line">&lt;span class="cl"> &lt;span class="n">app&lt;/span>&lt;span class="p">:&lt;/span>&lt;span class="n">layout_constraintStart_toStartOf&lt;/span>&lt;span class="p">=&lt;/span>&lt;span class="s2">&amp;#34;parent&amp;#34;&lt;/span>
&lt;/span>&lt;/span>&lt;span class="line">&lt;span class="cl"> &lt;span class="n">app&lt;/span>&lt;span class="p">:&lt;/span>&lt;span class="n">layout_constraintEnd_toEndOf&lt;/span>&lt;span class="p">=&lt;/span>&lt;span class="s2">&amp;#34;parent&amp;#34;&lt;/span>&lt;span class="p">/&amp;gt;&lt;/span>
&lt;/span>&lt;/span>&lt;span class="line">&lt;span class="cl"> &lt;span class="p">&amp;lt;&lt;/span>&lt;span class="n">Button&lt;/span>
&lt;/span>&lt;/span>&lt;span class="line">&lt;span class="cl"> &lt;span class="n">android&lt;/span>&lt;span class="p">:&lt;/span>&lt;span class="n">id&lt;/span>&lt;span class="p">=&lt;/span>&lt;span class="s2">&amp;#34;@+id/button&amp;#34;&lt;/span>
&lt;/span>&lt;/span>&lt;span class="line">&lt;span class="cl"> &lt;span class="n">android&lt;/span>&lt;span class="p">:&lt;/span>&lt;span class="n">layout_width&lt;/span>&lt;span class="p">=&lt;/span>&lt;span class="s2">&amp;#34;wrap_content&amp;#34;&lt;/span>
&lt;/span>&lt;/span>&lt;span class="line">&lt;span class="cl"> &lt;span class="n">android&lt;/span>&lt;span class="p">:&lt;/span>&lt;span class="n">layout_height&lt;/span>&lt;span class="p">=&lt;/span>&lt;span class="s2">&amp;#34;wrap_content&amp;#34;&lt;/span>
&lt;/span>&lt;/span>&lt;span class="line">&lt;span class="cl"> &lt;span class="n">android&lt;/span>&lt;span class="p">:&lt;/span>&lt;span class="n">text&lt;/span>&lt;span class="p">=&lt;/span>&lt;span class="s2">&amp;#34;@string/next&amp;#34;&lt;/span>
&lt;/span>&lt;/span>&lt;span class="line">&lt;span class="cl"> &lt;span class="n">app&lt;/span>&lt;span class="p">:&lt;/span>&lt;span class="n">layout_constraintEnd_toEndOf&lt;/span>&lt;span class="p">=&lt;/span>&lt;span class="s2">&amp;#34;parent&amp;#34;&lt;/span>
&lt;/span>&lt;/span>&lt;span class="line">&lt;span class="cl"> &lt;span class="n">app&lt;/span>&lt;span class="p">:&lt;/span>&lt;span class="n">layout_constraintStart_toStartOf&lt;/span>&lt;span class="p">=&lt;/span>&lt;span class="s2">&amp;#34;parent&amp;#34;&lt;/span>
&lt;/span>&lt;/span>&lt;span class="line">&lt;span class="cl"> &lt;span class="n">app&lt;/span>&lt;span class="p">:&lt;/span>&lt;span class="n">layout_constraintTop_toBottomOf&lt;/span>&lt;span class="p">=&lt;/span>&lt;span class="s2">&amp;#34;@id/imageView&amp;#34;&lt;/span>
&lt;/span>&lt;/span>&lt;span class="line">&lt;span class="cl"> &lt;span class="p">/&amp;gt;&lt;/span>
&lt;/span>&lt;/span>&lt;span class="line">&lt;span class="cl">&lt;span class="p">&amp;lt;/&lt;/span>&lt;span class="n">androidx&lt;/span>&lt;span class="p">.&lt;/span>&lt;span class="n">constraintlayout&lt;/span>&lt;span class="p">.&lt;/span>&lt;span class="n">widget&lt;/span>&lt;span class="p">.&lt;/span>&lt;span class="n">ConstraintLayout&lt;/span>&lt;span class="p">&amp;gt;&lt;/span>
&lt;/span>&lt;/span>&lt;/code>&lt;/pre>&lt;/div>&lt;h3 id="fragmentviewmodel">Fragment/ViewModel&lt;/h3>
&lt;p>フィールドに&lt;code>registerForActivityResult&lt;/code>で&lt;code>ActivityResultContracts.GetContent()&lt;/code>のlauncherを作る。&lt;/p></description><enclosure url="https://atsum.in/android/get-content/img/thumbnail.png" type="image/png"/></item><item><title>【Android,Kotlin】Kotlinらしいダウンキャスト</title><link>https://atsum.in/android/cast-by-context/</link><pubDate>Mon, 22 Aug 2022 21:54:57 +0900</pubDate><guid>https://atsum.in/android/cast-by-context/</guid><description>&lt;h2 id="ダウンキャストが必要となる例">ダウンキャストが必要となる例&lt;/h2>
&lt;div class="highlight">&lt;pre tabindex="0" class="chroma">&lt;code class="language-kotlin" data-lang="kotlin">&lt;span class="line">&lt;span class="cl">&lt;span class="k">open&lt;/span> &lt;span class="k">class&lt;/span> &lt;span class="nc">Super&lt;/span> &lt;span class="p">{}&lt;/span>
&lt;/span>&lt;/span>&lt;span class="line">&lt;span class="cl">&lt;span class="k">class&lt;/span> &lt;span class="nc">A&lt;/span> &lt;span class="p">:&lt;/span> &lt;span class="n">Super&lt;/span>&lt;span class="p">()&lt;/span> &lt;span class="p">{&lt;/span>
&lt;/span>&lt;/span>&lt;span class="line">&lt;span class="cl"> &lt;span class="k">fun&lt;/span> &lt;span class="nf">f&lt;/span>&lt;span class="p">()&lt;/span> &lt;span class="p">{}&lt;/span>
&lt;/span>&lt;/span>&lt;span class="line">&lt;span class="cl">&lt;span class="p">}&lt;/span>
&lt;/span>&lt;/span>&lt;span class="line">&lt;span class="cl">
&lt;/span>&lt;/span>&lt;span class="line">&lt;span class="cl">&lt;span class="k">val&lt;/span> &lt;span class="py">x&lt;/span>&lt;span class="p">:&lt;/span> &lt;span class="n">Super&lt;/span> &lt;span class="p">=&lt;/span> &lt;span class="n">A&lt;/span>&lt;span class="p">()&lt;/span>
&lt;/span>&lt;/span>&lt;span class="line">&lt;span class="cl">&lt;span class="n">x&lt;/span>&lt;span class="p">.&lt;/span>&lt;span class="n">f&lt;/span>&lt;span class="p">()&lt;/span> &lt;span class="c1">// x は Super なので f メソッドがわからずエラー:
&lt;/span>&lt;/span>&lt;/span>&lt;/code>&lt;/pre>&lt;/div>&lt;h2 id="ifis演算子で分岐する">if+is演算子で分岐する&lt;/h2>
&lt;p>Kotlinでは実行箇所の文脈によって自動的に推論されてダウンキャストされる。&lt;/p>
&lt;p>例えば上記例では &lt;code>if (x is A)&lt;/code> でチェックすると、そのなかでは&lt;code>x&lt;/code>は&lt;code>A&lt;/code>のインスタンスであると判断されるので
&lt;code>A&lt;/code>クラスのインスタンスメソッド&lt;code>f()&lt;/code>が呼べるようになる。&lt;/p></description><enclosure url="https://atsum.in/android/cast-by-context/img/thumbnail.png" type="image/png"/></item><item><title>【Android,Kotlin】KtlintでKotlinコードのチェック</title><link>https://atsum.in/android/ktlint/</link><pubDate>Sun, 21 Aug 2022 21:19:33 +0900</pubDate><guid>https://atsum.in/android/ktlint/</guid><description>&lt;h2 id="ktlint">Ktlint&lt;/h2>
&lt;p>&lt;a href="https://ktlint.github.io/">Ktlint&lt;/a>はKotlin用のlinter。&lt;/p>
&lt;p>本記事ではビルド設定(Gradle)に組み込んで使用する。&lt;/p>
&lt;h2 id="appbuildgradleに設定を追加する">app/build.gradleに設定を追加する&lt;/h2>
&lt;div class="highlight" filename="app/build.gradle">&lt;pre tabindex="0" class="chroma">&lt;code class="language-gradle" data-lang="gradle">&lt;span class="line">&lt;span class="cl">&lt;span class="n">configurations&lt;/span> &lt;span class="o">{&lt;/span>
&lt;/span>&lt;/span>&lt;span class="line">&lt;span class="cl"> &lt;span class="n">ktlint&lt;/span>
&lt;/span>&lt;/span>&lt;span class="line">&lt;span class="cl">&lt;span class="o">}&lt;/span>
&lt;/span>&lt;/span>&lt;span class="line">&lt;span class="cl">
&lt;/span>&lt;/span>&lt;span class="line">&lt;span class="cl">&lt;span class="n">dependencies&lt;/span> &lt;span class="o">{&lt;/span>
&lt;/span>&lt;/span>&lt;span class="line">&lt;span class="cl"> &lt;span class="o">...&lt;/span>
&lt;/span>&lt;/span>&lt;span class="line">&lt;span class="cl"> &lt;span class="c1">// バージョンは本家を確認すること https://github.com/pinterest/ktlint
&lt;/span>&lt;/span>&lt;/span>&lt;span class="line">&lt;span class="cl">&lt;span class="c1">&lt;/span> &lt;span class="n">ktlint&lt;/span> &lt;span class="s2">&amp;#34;com.pinterest:ktlint:0.48.2&amp;#34;&lt;/span>
&lt;/span>&lt;/span>&lt;span class="line">&lt;span class="cl">&lt;span class="o">}&lt;/span>
&lt;/span>&lt;/span>&lt;span class="line">&lt;span class="cl">
&lt;/span>&lt;/span>&lt;span class="line">&lt;span class="cl">&lt;span class="c1">// lintタスクを追加
&lt;/span>&lt;/span>&lt;/span>&lt;span class="line">&lt;span class="cl">&lt;span class="c1">&lt;/span>&lt;span class="n">task&lt;/span> &lt;span class="nf">ktlint&lt;/span>&lt;span class="o">(&lt;/span>&lt;span class="nl">type:&lt;/span> &lt;span class="n">JavaExec&lt;/span>&lt;span class="o">,&lt;/span> &lt;span class="nl">group:&lt;/span> &lt;span class="s2">&amp;#34;verification&amp;#34;&lt;/span>&lt;span class="o">)&lt;/span> &lt;span class="o">{&lt;/span>
&lt;/span>&lt;/span>&lt;span class="line">&lt;span class="cl"> &lt;span class="n">description&lt;/span> &lt;span class="o">=&lt;/span> &lt;span class="s2">&amp;#34;Check Kotlin code style.&amp;#34;&lt;/span>
&lt;/span>&lt;/span>&lt;span class="line">&lt;span class="cl"> &lt;span class="n">classpath&lt;/span> &lt;span class="o">=&lt;/span> &lt;span class="n">configurations&lt;/span>&lt;span class="o">.&lt;/span>&lt;span class="na">ktlint&lt;/span>
&lt;/span>&lt;/span>&lt;span class="line">&lt;span class="cl"> &lt;span class="n">main&lt;/span> &lt;span class="o">=&lt;/span> &lt;span class="s2">&amp;#34;com.pinterest.ktlint.Main&amp;#34;&lt;/span>
&lt;/span>&lt;/span>&lt;span class="line">&lt;span class="cl"> &lt;span class="n">args&lt;/span> &lt;span class="s2">&amp;#34;src/**/*.kt&amp;#34;&lt;/span>
&lt;/span>&lt;/span>&lt;span class="line">&lt;span class="cl">&lt;span class="o">}&lt;/span>
&lt;/span>&lt;/span>&lt;span class="line">&lt;span class="cl">&lt;span class="n">check&lt;/span>&lt;span class="o">.&lt;/span>&lt;span class="na">dependsOn&lt;/span> &lt;span class="n">ktlint&lt;/span>
&lt;/span>&lt;/span>&lt;span class="line">&lt;span class="cl">
&lt;/span>&lt;/span>&lt;span class="line">&lt;span class="cl">&lt;span class="c1">// フォーマットタスクを追加
&lt;/span>&lt;/span>&lt;/span>&lt;span class="line">&lt;span class="cl">&lt;span class="c1">&lt;/span>&lt;span class="n">task&lt;/span> &lt;span class="nf">ktlintFormat&lt;/span>&lt;span class="o">(&lt;/span>&lt;span class="nl">type:&lt;/span> &lt;span class="n">JavaExec&lt;/span>&lt;span class="o">,&lt;/span> &lt;span class="nl">group:&lt;/span> &lt;span class="s2">&amp;#34;formatting&amp;#34;&lt;/span>&lt;span class="o">)&lt;/span> &lt;span class="o">{&lt;/span>
&lt;/span>&lt;/span>&lt;span class="line">&lt;span class="cl"> &lt;span class="n">description&lt;/span> &lt;span class="o">=&lt;/span> &lt;span class="s2">&amp;#34;Fix Kotlin code style deviations.&amp;#34;&lt;/span>
&lt;/span>&lt;/span>&lt;span class="line">&lt;span class="cl"> &lt;span class="n">classpath&lt;/span> &lt;span class="o">=&lt;/span> &lt;span class="n">configurations&lt;/span>&lt;span class="o">.&lt;/span>&lt;span class="na">ktlint&lt;/span>
&lt;/span>&lt;/span>&lt;span class="line">&lt;span class="cl"> &lt;span class="n">main&lt;/span> &lt;span class="o">=&lt;/span> &lt;span class="s2">&amp;#34;com.pinterest.ktlint.Main&amp;#34;&lt;/span>
&lt;/span>&lt;/span>&lt;span class="line">&lt;span class="cl"> &lt;span class="n">args&lt;/span> &lt;span class="s2">&amp;#34;-F&amp;#34;&lt;/span>&lt;span class="o">,&lt;/span> &lt;span class="s2">&amp;#34;src/**/*.kt&amp;#34;&lt;/span>
&lt;/span>&lt;/span>&lt;span class="line">&lt;span class="cl">&lt;span class="o">}&lt;/span>
&lt;/span>&lt;/span>&lt;/code>&lt;/pre>&lt;/div>&lt;p>&lt;code>args&lt;/code>に指定しているパスはプロジェクトの環境に合わせる。&lt;/p></description><enclosure url="https://atsum.in/android/ktlint/img/thumbnail.png" type="image/png"/></item><item><title>【HUGO】シンタックスハイライトのスタイルを変更する</title><link>https://atsum.in/hugo/source-code-highlight-style/</link><pubDate>Sun, 21 Aug 2022 14:36:10 +0900</pubDate><guid>https://atsum.in/hugo/source-code-highlight-style/</guid><description>&lt;h2 id="デフォルトのハイライトが視認性が悪い">デフォルトのハイライトが視認性が悪い&lt;/h2>
&lt;p>hugoで作られた当サイトのソースコードハイライトでコントラスト比の悪いところがあり、
見づらい箇所がところどころあるのでスタイルを変更したい。&lt;/p></description><enclosure url="https://atsum.in/hugo/source-code-highlight-style/img/thumbnail.png" type="image/png"/></item><item><title>【Java】Files.list()の戻り値Stream&lt;Path>はclose()が必要</title><link>https://atsum.in/java/close-files-list/</link><pubDate>Sun, 21 Aug 2022 13:50:32 +0900</pubDate><guid>https://atsum.in/java/close-files-list/</guid><description>&lt;h2 id="javaniofileslistpathでリストアップしたらクローズしないといけない">java.nio.Files.list(Path)でリストアップしたらクローズしないといけない&lt;/h2>
&lt;p>&lt;a href="https://docs.oracle.com/javase/jp/8/docs/api/java/nio/file/Files.html#list-java.nio.file.Path-">java.nio.Files.list(Path)&lt;/a>で指定したディレクトリ直下のファイルのパス一覧を&lt;code>Stream&amp;lt;Path&amp;gt;&lt;/code>型で取得できる&lt;/p>
&lt;div class="highlight">&lt;pre tabindex="0" class="chroma">&lt;code class="language-java" data-lang="java">&lt;span class="line">&lt;span class="cl">&lt;span class="n">Stream&lt;/span>&lt;span class="o">&amp;lt;&lt;/span>&lt;span class="n">Path&lt;/span>&lt;span class="o">&amp;gt;&lt;/span>&lt;span class="w"> &lt;/span>&lt;span class="n">paths&lt;/span>&lt;span class="w"> &lt;/span>&lt;span class="o">=&lt;/span>&lt;span class="w"> &lt;/span>&lt;span class="n">Files&lt;/span>&lt;span class="p">.&lt;/span>&lt;span class="na">list&lt;/span>&lt;span class="p">(&lt;/span>&lt;span class="n">Paths&lt;/span>&lt;span class="p">.&lt;/span>&lt;span class="na">get&lt;/span>&lt;span class="p">(&lt;/span>&lt;span class="s">&amp;#34;/path/to/directory&amp;#34;&lt;/span>&lt;span class="p">));&lt;/span>&lt;span class="w">
&lt;/span>&lt;/span>&lt;/span>&lt;/code>&lt;/pre>&lt;/div>&lt;p>このメソッドの戻り値をcloseしないと&lt;code>Too many open files&lt;/code>でエラーが発生するようになる。&lt;/p>
&lt;h2 id="javaniofileslistpathの戻り値をcloseする">java.nio.Files.list(Path)の戻り値をcloseする&lt;/h2>
&lt;p>&lt;code>Stream&amp;lt;T&amp;gt;&lt;/code>インタフェースの親インタフェース&lt;code>BaseStream&amp;lt;T&amp;gt;&lt;/code>は、さらに親が&lt;code>AutoClosable&lt;/code>インタフェースなので
try-with-resoucesで確実に閉じることができる。&lt;/p></description><enclosure url="https://atsum.in/java/close-files-list/img/thumbnail.png" type="image/png"/></item><item><title>【Android,Kotlin】SoundPoolクラスを利用して効果音を鳴らす</title><link>https://atsum.in/android/sound-feedback/</link><pubDate>Sat, 20 Aug 2022 23:48:26 +0900</pubDate><guid>https://atsum.in/android/sound-feedback/</guid><description>&lt;h2 id="soundpoolクラスを利用する">SoundPoolクラスを利用する&lt;/h2>
&lt;p>本記事では&lt;a href="https://developer.android.com/reference/android/media/SoundPool">SoundPool&lt;/a>クラスを利用して効果音を鳴らす。&lt;/p>
&lt;p>&lt;code>SoundPool&lt;/code>クラスはあらかじめ音声ファイルをデコードしてメモリに持っておく仕組みになっていてレイテンシが小さい。&lt;br>
速いフィードバックが求められる効果音の再生に向いている。&lt;/p></description><enclosure url="https://atsum.in/android/sound-feedback/img/thumbnail.png" type="image/png"/></item><item><title>【Android,Kotlin】Null許容型(?)をunwrapするパターン</title><link>https://atsum.in/android/unwrap-optional/</link><pubDate>Fri, 19 Aug 2022 23:43:20 +0900</pubDate><guid>https://atsum.in/android/unwrap-optional/</guid><description>&lt;h2 id="null許容型をunwrapしたい">Null許容型をunwrapしたい&lt;/h2>
&lt;p>Null許容型をnon-nullableな型のメソッドの引数にわたすとき困ることがある。&lt;/p>
&lt;div class="highlight">&lt;pre tabindex="0" class="chroma">&lt;code class="language-kotlin" data-lang="kotlin">&lt;span class="line">&lt;span class="cl">&lt;span class="k">fun&lt;/span> &lt;span class="nf">f&lt;/span>&lt;span class="p">(&lt;/span>&lt;span class="n">foo&lt;/span>&lt;span class="p">:&lt;/span> &lt;span class="n">Foo&lt;/span>&lt;span class="p">)&lt;/span> &lt;span class="p">{&lt;/span> &lt;span class="err">…&lt;/span> &lt;span class="p">}&lt;/span>
&lt;/span>&lt;/span>&lt;span class="line">&lt;span class="cl">
&lt;/span>&lt;/span>&lt;span class="line">&lt;span class="cl">&lt;span class="k">var&lt;/span> &lt;span class="py">foo&lt;/span>&lt;span class="p">:&lt;/span> &lt;span class="n">Foo&lt;/span>&lt;span class="p">?&lt;/span> &lt;span class="p">=&lt;/span> &lt;span class="err">…&lt;/span>
&lt;/span>&lt;/span>&lt;span class="line">&lt;span class="cl">&lt;span class="k">fun&lt;/span> &lt;span class="nf">g&lt;/span>&lt;span class="p">()&lt;/span> &lt;span class="p">{&lt;/span>
&lt;/span>&lt;/span>&lt;span class="line">&lt;span class="cl"> &lt;span class="n">f&lt;/span>&lt;span class="p">(&lt;/span>&lt;span class="n">foo&lt;/span>&lt;span class="p">)&lt;/span> &lt;span class="c1">// コンパイルエラー
&lt;/span>&lt;/span>&lt;/span>&lt;span class="line">&lt;span class="cl">&lt;span class="c1">&lt;/span>&lt;span class="p">}&lt;/span>
&lt;/span>&lt;/span>&lt;/code>&lt;/pre>&lt;/div>&lt;p>メソッド&lt;code>f&lt;/code>の引数はNull許容型ではないので、&lt;code>Foo?&lt;/code>型の変数を引数に書くとコンパイルエラーとなる。&lt;/p></description><enclosure url="https://atsum.in/android/unwrap-optional/img/thumbnail.png" type="image/png"/></item><item><title>【Android,Kotlin】ConstraintLayoutでビューがどうしても重複するときに確認すること</title><link>https://atsum.in/android/overwrap-layout/</link><pubDate>Fri, 19 Aug 2022 21:33:47 +0900</pubDate><guid>https://atsum.in/android/overwrap-layout/</guid><description>&lt;h2 id="0dp--制約に合致--制約を満たす最大サイズ">0dp = 制約に合致 = 制約を満たす最大サイズ&lt;/h2>
&lt;p>Androidで調べ物をしていてよく&lt;code>0dp&lt;/code>という指定を見かけることがある。&lt;/p>
&lt;p>制約で高さや幅を決めたいときに指定するんだろうな、というイメージはあったが、
ちゃんと調べると公式できちんと説明が書かれていた。&lt;/p></description><enclosure url="https://atsum.in/android/overwrap-layout/img/thumbnail.png" type="image/png"/></item><item><title>【Android,Kotlin】'VIBRATOR_SERVICE: String' is deprecated. Deprecated in Java への対処</title><link>https://atsum.in/android/deprecate-vibrator-service/</link><pubDate>Fri, 19 Aug 2022 00:14:09 +0900</pubDate><guid>https://atsum.in/android/deprecate-vibrator-service/</guid><description>&lt;h2 id="vibrator_service-string-is-deprecated-deprecated-in-java">&amp;lsquo;VIBRATOR_SERVICE: String&amp;rsquo; is deprecated. Deprecated in Java&lt;/h2>
&lt;p>以下の様なコードを書いているとdeprecated warningが出る。&lt;/p>
&lt;div class="highlight">&lt;pre tabindex="0" class="chroma">&lt;code class="language-kotlin" data-lang="kotlin">&lt;span class="line">&lt;span class="cl">&lt;span class="k">val&lt;/span> &lt;span class="py">vibrator&lt;/span> &lt;span class="p">=&lt;/span> &lt;span class="n">context&lt;/span>&lt;span class="p">.&lt;/span>&lt;span class="n">getSystemService&lt;/span>&lt;span class="p">(&lt;/span>&lt;span class="nc">Context&lt;/span>&lt;span class="p">.&lt;/span>&lt;span class="n">VIBRATOR_SERVICE&lt;/span>&lt;span class="p">)&lt;/span> &lt;span class="k">as&lt;/span>&lt;span class="p">?&lt;/span> &lt;span class="n">Vibrator&lt;/span>
&lt;/span>&lt;/span>&lt;/code>&lt;/pre>&lt;/div>&lt;p>メッセージは&lt;/p>
&lt;pre tabindex="0">&lt;code>&amp;#39;VIBRATOR_SERVICE: String&amp;#39; is deprecated. Deprecated in Java
&lt;/code>&lt;/pre>&lt;p>で、&lt;code>Context.VIBRATOR_SERVICE&lt;/code>はdeprecatedになったので置き換えてくれという内容。&lt;/p></description><enclosure url="https://atsum.in/android/deprecate-vibrator-service/img/thumbnail.png" type="image/png"/></item><item><title>【Android,Kotlin】Navigation Component利用時に戻るボタンで確認ダイアログを出す</title><link>https://atsum.in/android/confirm-before-return/</link><pubDate>Thu, 18 Aug 2022 22:11:44 +0900</pubDate><guid>https://atsum.in/android/confirm-before-return/</guid><description>&lt;h2 id="編集画面で保存せずに戻るときに確認ダイアログを出したい">編集画面で保存せずに戻るときに確認ダイアログを出したい&lt;/h2>
&lt;p>ユーザー入力を伴う画面で戻るボタンをクリックしたとき、編集内容が消えてしまうのを通知して、
ユーザーに本当に戻るか、画面にとどまるかを選択させたい。&lt;/p></description><enclosure url="https://atsum.in/android/confirm-before-return/img/thumbnail.png" type="image/png"/></item><item><title>【Android,Kotlin】onOptionsItemSelectedでtrueを返すとホームボタンが反応しなくなる</title><link>https://atsum.in/android/cannot-return-by-home-button/</link><pubDate>Thu, 18 Aug 2022 21:06:35 +0900</pubDate><guid>https://atsum.in/android/cannot-return-by-home-button/</guid><description>&lt;h2 id="ホームボタン戻るボタンをクリックしても反応しない事象が発生">ホームボタン(戻るボタン)をクリックしても反応しない事象が発生&lt;/h2>
&lt;p>&lt;code>Navigation Component&lt;/code>を利用時、戻るボタンをクリックしても前の画面に戻れない場合がある。&lt;/p>
&lt;p>&lt;img src="img/home-button.png" alt="ホームボタン">&lt;/p>
&lt;h2 id="原因-fragmentonoptionsitemselectedでtrueを返している">原因: Fragment#onOptionsItemSelectedでtrueを返している&lt;/h2>
&lt;p>ホームボタンはデフォルトで戻るはずなので、もし戻らないとしたらホームボタンクリック時の処理を止める
コードが書かれている可能性がある。&lt;/p></description><enclosure url="https://atsum.in/android/cannot-return-by-home-button/img/thumbnail.png" type="image/png"/></item><item><title>【Android,Kotlin】コンテンツURIからMIME typeを取得する</title><link>https://atsum.in/android/mimetype-by-content-url/</link><pubDate>Thu, 18 Aug 2022 00:54:06 +0900</pubDate><guid>https://atsum.in/android/mimetype-by-content-url/</guid><description>&lt;h2 id="contentのuriからそのファイルのmime-typeを取得する">content://〜のURIからそのファイルのMIME typeを取得する&lt;/h2>
&lt;p>&lt;code>ContentProvider&lt;/code>を使うなどしてAndroid端末内のファイルを取得するとき、&lt;code>content://〜&lt;/code>形式のコンテンツURIとして得られる。&lt;/p></description><enclosure url="https://atsum.in/android/mimetype-by-content-url/img/thumbnail.png" type="image/png"/></item><item><title>【Android,Kotlin】RecyclerView#onBindViewHolderでイベントリスナを登録すると重複して実行されることがある</title><link>https://atsum.in/android/event-listener-in-recycler-view/</link><pubDate>Tue, 16 Aug 2022 00:25:09 +0900</pubDate><guid>https://atsum.in/android/event-listener-in-recycler-view/</guid><description>&lt;h2 id="recyclerviewonbindviewholderでイベントリスナを登録するときの注意">RecyclerView#onBindViewHolderでイベントリスナを登録するときの注意&lt;/h2>
&lt;p>&lt;code>RecyclerView#onBindViewHolder&lt;/code>で&lt;code>ViewHolder&lt;/code>内の要素に対してイベントリスナを登録するときは注意が必要。&lt;/p>
&lt;p>&lt;code>RecyclerView&lt;/code>は&lt;code>ViewHolder&lt;/code>がいくつあっても画面に見えている部分だけインスタンス化されている。&lt;br>
スクロールによって&lt;code>ViewHolder&lt;/code>が隠れるのと同時に新しい&lt;code>ViewHolder&lt;/code>が表示され、そのとき隠れた&lt;code>ViewHolder&lt;/code>が使い回される。&lt;/p></description><enclosure url="https://atsum.in/android/event-listener-in-recycler-view/img/thumbnail.png" type="image/png"/></item><item><title>【Android】開発時のみhttp(≠https)による通信を許可する</title><link>https://atsum.in/android/network-security-config/</link><pubDate>Mon, 15 Aug 2022 20:58:32 +0900</pubDate><guid>https://atsum.in/android/network-security-config/</guid><description>&lt;h2 id="開発中のwebアプリをローカルに立ち上げて接続したい">開発中のWebアプリをローカルに立ち上げて接続したい&lt;/h2>
&lt;p>ホストOSに開発中のWebアプリを立ち上げてエミュレータから接続したい。&lt;/p>
&lt;p>開発時はhttpであることがほとんどなので、アプリからhttpで接続したいが、
Android 9以降はHTTP通信がデフォルトでは許可されない。&lt;/p></description><enclosure url="https://atsum.in/android/network-security-config/img/thumbnail.png" type="image/png"/></item><item><title>【Android】エミュレータでホストOSのWebサーバに接続する</title><link>https://atsum.in/android/access-host/</link><pubDate>Mon, 15 Aug 2022 19:06:59 +0900</pubDate><guid>https://atsum.in/android/access-host/</guid><description>&lt;h2 id="ホストosに立ち上がっているwebサーバーにエミュレータから接続したい">ホストOSに立ち上がっているWebサーバーにエミュレータから接続したい&lt;/h2>
&lt;p>WebアプリとAndroidアプリを開発していて、開発中のWebアプリにAndroidアプリから接続したい場合がある。&lt;/p>
&lt;p>Android端末から見て&lt;code>localhost&lt;/code>はAndroid OSのlocalhostのことなので、ホストOSに接続できない。&lt;/p></description><enclosure url="https://atsum.in/android/access-host/img/thumbnail.png" type="image/png"/></item><item><title>【Android,Kotlin】RecyclerViewで指定した行にスクロールする</title><link>https://atsum.in/android/scroll-recyclerview/</link><pubDate>Sun, 14 Aug 2022 23:29:03 +0900</pubDate><guid>https://atsum.in/android/scroll-recyclerview/</guid><description>&lt;h2 id="スクロールする">スクロールする&lt;/h2>
&lt;p>指定した&lt;code>position&lt;/code>まで移動するには&lt;code>RecyclerView#scrollToPosition&lt;/code>を使用する。
以下のコードで&lt;code>position&lt;/code>が10の位置までスクロールする。&lt;/p></description><enclosure url="https://atsum.in/android/scroll-recyclerview/img/thumbnail.png" type="image/png"/></item><item><title>【Android,kotlin】Coilでインターネット上の画像を表示する</title><link>https://atsum.in/android/coil/</link><pubDate>Sun, 14 Aug 2022 16:43:55 +0900</pubDate><guid>https://atsum.in/android/coil/</guid><description>&lt;h2 id="coil">Coil&lt;/h2>
&lt;p>&lt;a href="https://coil-kt.github.io/coil/">Coil&lt;/a>はKotlin Coroutineを利用した画像表示用ライブラリ。&lt;/p>
&lt;p>OkHttp、Okio、AndroidXを利用していてKotlinのAndroidプロジェクトと相性がいい。&lt;/p></description><enclosure url="https://atsum.in/android/coil/img/thumbnail.png" type="image/png"/></item><item><title>【Android,Kotlin】テキストラベルにツールチップを表示する</title><link>https://atsum.in/android/tooltip-text/</link><pubDate>Sun, 14 Aug 2022 14:19:32 +0900</pubDate><guid>https://atsum.in/android/tooltip-text/</guid><description>&lt;h2 id="textviewのツールチップ">TextViewのツールチップ&lt;/h2>
&lt;p>Androidでは長押しするとツールチップを表示できる。&lt;/p>
&lt;p>&lt;img src="img/tooltip.gif" alt="ツールチップの例">&lt;/p>
&lt;h2 id="textviewにツールチップを追加する">TextViewにツールチップを追加する&lt;/h2>
&lt;p>ツールチップに表示したいテキストを&lt;code>android:tooltipText&lt;/code>に指定する。
(簡単のためレイアウト関係の属性は省略している。)&lt;/p></description><enclosure url="https://atsum.in/android/tooltip-text/img/thumbnail.png" type="image/png"/></item><item><title>【Android,Kotlin】正規表現でテキストマッチ</title><link>https://atsum.in/android/regex-matches/</link><pubDate>Sun, 14 Aug 2022 11:09:33 +0900</pubDate><guid>https://atsum.in/android/regex-matches/</guid><description>&lt;h2 id="matcherを作ってmatchesを呼び出す">Matcherを作ってmatches()を呼び出す&lt;/h2>
&lt;div class="highlight">&lt;pre tabindex="0" class="chroma">&lt;code class="language-kotlin" data-lang="kotlin">&lt;span class="line">&lt;span class="cl">&lt;span class="nc">Pattern&lt;/span>&lt;span class="p">.&lt;/span>&lt;span class="n">compile&lt;/span>&lt;span class="p">(&lt;/span>&lt;span class="n">正規表現文字列&lt;/span>&lt;span class="p">).&lt;/span>&lt;span class="n">matcher&lt;/span>&lt;span class="p">(&lt;/span>&lt;span class="n">確認したい文字列&lt;/span>&lt;span class="p">).&lt;/span>&lt;span class="n">matches&lt;/span>&lt;span class="p">()&lt;/span>
&lt;/span>&lt;/span>&lt;/code>&lt;/pre>&lt;/div>&lt;p>例&lt;/p>
&lt;div class="highlight" filename="例">&lt;pre tabindex="0" class="chroma">&lt;code class="language-kotlin" data-lang="kotlin">&lt;span class="line">&lt;span class="cl">&lt;span class="nc">Pattern&lt;/span>&lt;span class="p">.&lt;/span>&lt;span class="n">compile&lt;/span>&lt;span class="p">(&lt;/span>&lt;span class="s2">&amp;#34;^https:.*&amp;#34;&lt;/span>&lt;span class="p">).&lt;/span>&lt;span class="n">matcher&lt;/span>&lt;span class="p">(&lt;/span>&lt;span class="s2">&amp;#34;https://example.com&amp;#34;&lt;/span>&lt;span class="p">).&lt;/span>&lt;span class="n">matches&lt;/span>&lt;span class="p">()&lt;/span>
&lt;/span>&lt;/span>&lt;/code>&lt;/pre>&lt;/div>&lt;h2 id="メールアドレスのフォーマットを確認する">メールアドレスのフォーマットを確認する&lt;/h2>
&lt;p>&lt;code>android.util.Patterns&lt;/code>にいくつか用意された&lt;code>Pattern&lt;/code>が用意されているので、
よくあるチェックは自分で作らなくてもできる。&lt;/p></description><enclosure url="https://atsum.in/android/regex-matches/img/thumbnail.png" type="image/png"/></item><item><title>【Android,Kotlin】ダイアログ外のクリックで閉じないようにする</title><link>https://atsum.in/android/dialog-set-cancellable/</link><pubDate>Sun, 14 Aug 2022 10:22:09 +0900</pubDate><guid>https://atsum.in/android/dialog-set-cancellable/</guid><description>&lt;h2 id="ダイアログのokボタンクリックを強制したい">ダイアログのOKボタンクリックを強制したい&lt;/h2>
&lt;p>ダイアログはデフォルト設定では枠外のクリックで閉じてしまうので、
OKボタンクリック時になにか重要な処理を実行している場合、その処理が実行されずに困る。&lt;/p></description><enclosure url="https://atsum.in/android/dialog-set-cancellable/img/thumbnail.png" type="image/png"/></item><item><title>【Android,Kotlin】full-kotlinなライブラリBalloonで簡単に吹き出しを表示する</title><link>https://atsum.in/android/balloon/</link><pubDate>Sat, 13 Aug 2022 21:20:07 +0900</pubDate><guid>https://atsum.in/android/balloon/</guid><description>&lt;h2 id="吹き出しを表示したい">吹き出しを表示したい&lt;/h2>
&lt;p>テキストボックスに入力内容の説明やエラーの表示などの目的で吹き出しを表示したい。&lt;/p>
&lt;p>&lt;img src="img/balloon.png" alt="吹き出しの表示">&lt;/p>
&lt;h2 id="sckydovesballoon">sckydoves/Balloon&lt;/h2>
&lt;p>&lt;a href="https://github.com/skydoves/Balloon">sckydoves/Balloon&lt;/a>はfull-Kotlinで書かれた
吹き出しを表示するためのライブラリ。&lt;/p>
&lt;p>Kotlinらしいコードで書ける。&lt;/p></description><enclosure url="https://atsum.in/android/balloon/img/thumbnail.png" type="image/png"/></item><item><title>【Android,Kotlin】テキストの入力状態に応じてボタンを無効化する</title><link>https://atsum.in/android/disable-button-by-edit-text/</link><pubDate>Sat, 13 Aug 2022 18:00:59 +0900</pubDate><guid>https://atsum.in/android/disable-button-by-edit-text/</guid><description>&lt;h2 id="テキストの入力状態でボタンを有効無効化する">テキストの入力状態でボタンを有効・無効化する&lt;/h2>
&lt;p>テキストボックスに入力したときだけ押せるボタンを作りたい。&lt;br>
(空のときはdisable、文字があるときはenableにしたい。)&lt;/p>
&lt;p>&lt;img src="img/example.gif" alt="動作例">&lt;/p>
&lt;h2 id="実装手順">実装手順&lt;/h2>
&lt;p>テキストボックスは双方向バインディングで&lt;code>LiveData&lt;/code>と連携されている前提とする。&lt;/p></description><enclosure url="https://atsum.in/android/disable-button-by-edit-text/img/thumbnail.png" type="image/png"/></item><item><title>【Android,Kotlin】双方向・単方向データバインディングの実装手順</title><link>https://atsum.in/android/data-binding/</link><pubDate>Sat, 13 Aug 2022 14:52:18 +0900</pubDate><guid>https://atsum.in/android/data-binding/</guid><description>&lt;p>毎回ググるのでメモ。
以下手順。&lt;/p>
&lt;h2 id="appbuildgradleのbuildfeaturesを設定">app/build.gradleのbuildFeaturesを設定&lt;/h2>
&lt;p>&lt;code>app/build.gradle&lt;/code>の&lt;code>buildFeatures&lt;/code>に&lt;code>dataBinding true&lt;/code>を追加する。&lt;/p>
&lt;div class="highlight" filename="app/build.gradle">&lt;pre tabindex="0" class="chroma">&lt;code class="language-gradle" data-lang="gradle">&lt;span class="line">&lt;span class="cl">&lt;span class="n">buildFeatures&lt;/span> &lt;span class="o">{&lt;/span>
&lt;/span>&lt;/span>&lt;span class="line">&lt;span class="cl"> &lt;span class="n">viewBinding&lt;/span> &lt;span class="kc">true&lt;/span>
&lt;/span>&lt;/span>&lt;span class="line">&lt;span class="cl"> &lt;span class="n">dataBinding&lt;/span> &lt;span class="kc">true&lt;/span> &lt;span class="c1">// これを追加
&lt;/span>&lt;/span>&lt;/span>&lt;span class="line">&lt;span class="cl">&lt;span class="c1">&lt;/span>&lt;span class="o">}&lt;/span>
&lt;/span>&lt;/span>&lt;/code>&lt;/pre>&lt;/div>&lt;h2 id="livedataを持つviewmodelの作成">LiveDataを持つViewModelの作成&lt;/h2>
&lt;p>&lt;code>LiveData&lt;/code>をフィールドに持つ&lt;code>ViewModel&lt;/code>を作成しておく。&lt;br>
今回は&lt;code>someText&lt;/code>という名前で追加。&lt;/p></description><enclosure url="https://atsum.in/android/data-binding/img/thumbnail.png" type="image/png"/></item><item><title>【Android,Kotlin】Navigation Componentで画面遷移時にキーボードを閉じる</title><link>https://atsum.in/android/close-keyboard-with-transition/</link><pubDate>Sat, 13 Aug 2022 11:17:23 +0900</pubDate><guid>https://atsum.in/android/close-keyboard-with-transition/</guid><description>&lt;h2 id="画面遷移時にキーボードを閉じる">画面遷移時にキーボードを閉じる&lt;/h2>
&lt;p>&lt;a href="https://developer.android.com/reference/androidx/navigation/NavController#addOnDestinationChangedListener(androidx.navigation.NavController.OnDestinationChangedListener)">NavController#addOnDestinationChangedListener&lt;/a>で画面遷移時にフックしてキーボードを閉じる。&lt;/p>
&lt;div class="highlight">&lt;pre tabindex="0" class="chroma">&lt;code class="language-kotlin" data-lang="kotlin">&lt;span class="line">&lt;span class="cl">&lt;span class="k">class&lt;/span> &lt;span class="nc">MainActivity&lt;/span> &lt;span class="p">:&lt;/span> &lt;span class="n">AppCompatActivity&lt;/span>&lt;span class="p">()&lt;/span> &lt;span class="p">{&lt;/span>
&lt;/span>&lt;/span>&lt;span class="line">&lt;span class="cl"> &lt;span class="k">override&lt;/span> &lt;span class="k">fun&lt;/span> &lt;span class="nf">onCreate&lt;/span>&lt;span class="p">(&lt;/span>&lt;span class="n">savedInstanceState&lt;/span>&lt;span class="p">:&lt;/span> &lt;span class="n">Bundle&lt;/span>&lt;span class="p">?)&lt;/span> &lt;span class="p">{&lt;/span>
&lt;/span>&lt;/span>&lt;span class="line">&lt;span class="cl"> &lt;span class="o">..&lt;/span>&lt;span class="p">.&lt;/span>
&lt;/span>&lt;/span>&lt;span class="line">&lt;span class="cl">
&lt;/span>&lt;/span>&lt;span class="line">&lt;span class="cl"> &lt;span class="k">val&lt;/span> &lt;span class="py">navController&lt;/span> &lt;span class="p">=&lt;/span> &lt;span class="n">findNavController&lt;/span>&lt;span class="p">(&lt;/span>&lt;span class="nc">R&lt;/span>&lt;span class="p">.&lt;/span>&lt;span class="n">id&lt;/span>&lt;span class="p">.&lt;/span>&lt;span class="n">nav_host_fragment_content_main&lt;/span>&lt;span class="p">)&lt;/span>
&lt;/span>&lt;/span>&lt;span class="line">&lt;span class="cl"> &lt;span class="n">appBarConfiguration&lt;/span> &lt;span class="p">=&lt;/span> &lt;span class="n">AppBarConfiguration&lt;/span>&lt;span class="p">(&lt;/span>&lt;span class="n">navController&lt;/span>&lt;span class="p">.&lt;/span>&lt;span class="n">graph&lt;/span>&lt;span class="p">)&lt;/span>
&lt;/span>&lt;/span>&lt;span class="line">&lt;span class="cl"> &lt;span class="n">setupActionBarWithNavController&lt;/span>&lt;span class="p">(&lt;/span>&lt;span class="n">navController&lt;/span>&lt;span class="p">,&lt;/span> &lt;span class="n">appBarConfiguration&lt;/span>&lt;span class="p">)&lt;/span>
&lt;/span>&lt;/span>&lt;span class="line">&lt;span class="cl">
&lt;/span>&lt;/span>&lt;span class="line">&lt;span class="cl"> &lt;span class="n">navController&lt;/span>&lt;span class="p">.&lt;/span>&lt;span class="n">addOnDestinationChangedListener&lt;/span> &lt;span class="p">{&lt;/span> &lt;span class="n">_&lt;/span>&lt;span class="p">,&lt;/span> &lt;span class="n">_&lt;/span>&lt;span class="p">,&lt;/span> &lt;span class="n">_&lt;/span> &lt;span class="o">-&amp;gt;&lt;/span>
&lt;/span>&lt;/span>&lt;span class="line">&lt;span class="cl"> &lt;span class="n">currentFocus&lt;/span>&lt;span class="o">?.&lt;/span>&lt;span class="n">also&lt;/span> &lt;span class="p">{&lt;/span> &lt;span class="n">view&lt;/span> &lt;span class="o">-&amp;gt;&lt;/span>
&lt;/span>&lt;/span>&lt;span class="line">&lt;span class="cl"> &lt;span class="k">val&lt;/span> &lt;span class="py">manager&lt;/span> &lt;span class="p">=&lt;/span> &lt;span class="n">getSystemService&lt;/span>&lt;span class="p">(&lt;/span>&lt;span class="nc">Context&lt;/span>&lt;span class="p">.&lt;/span>&lt;span class="n">INPUT_METHOD_SERVICE&lt;/span>&lt;span class="p">)&lt;/span> &lt;span class="k">as&lt;/span> &lt;span class="n">InputMethodManager&lt;/span>
&lt;/span>&lt;/span>&lt;span class="line">&lt;span class="cl"> &lt;span class="n">manager&lt;/span>&lt;span class="p">.&lt;/span>&lt;span class="n">hideSoftInputFromWindow&lt;/span>&lt;span class="p">(&lt;/span>&lt;span class="n">view&lt;/span>&lt;span class="p">.&lt;/span>&lt;span class="n">windowToken&lt;/span>&lt;span class="p">,&lt;/span> &lt;span class="m">0&lt;/span>&lt;span class="p">)&lt;/span>
&lt;/span>&lt;/span>&lt;span class="line">&lt;span class="cl"> &lt;span class="p">}&lt;/span>
&lt;/span>&lt;/span>&lt;span class="line">&lt;span class="cl"> &lt;span class="p">}&lt;/span>
&lt;/span>&lt;/span>&lt;span class="line">&lt;span class="cl"> &lt;span class="p">}&lt;/span>
&lt;/span>&lt;/span>&lt;span class="line">&lt;span class="cl">&lt;span class="p">}&lt;/span>
&lt;/span>&lt;/span>&lt;/code>&lt;/pre>&lt;/div>&lt;p>&lt;code>getSystemService(Context.INPUT_METHOD_SERVICE)&lt;/code>で&lt;code>InputMethodManager&lt;/code>を取得し、&lt;a href="https://developer.android.com/reference/android/view/inputmethod/InputMethodManager#hideSoftInputFromWindow(android.os.IBinder,%20int)">hideSoftInputFromWindow&lt;/a>を呼び出してキーボードを閉じる。&lt;/p></description><enclosure url="https://atsum.in/android/close-keyboard-with-transition/img/thumbnail.png" type="image/png"/></item><item><title>【Android】任意のビューにRipple Effectをつける</title><link>https://atsum.in/android/ripple-effect/</link><pubDate>Sat, 13 Aug 2022 00:01:55 +0900</pubDate><guid>https://atsum.in/android/ripple-effect/</guid><description>&lt;h2 id="ripple-effectとは">Ripple Effectとは&lt;/h2>
&lt;p>Ripple Effect(リップルエフェクト)は以下の様なクリック時の波紋が広がるような効果。&lt;/p>
&lt;p>&lt;img src="img/ripple-effect.gif" alt="ripple effect">&lt;/p>
&lt;p>ボタンはデフォルトでこの効果がついている。&lt;/p></description><enclosure url="https://atsum.in/android/ripple-effect/img/thumbnail.png" type="image/png"/></item><item><title>【Android,Kotlin】前画面のFragmentに値を返すsetFragmentResult/setFragmentResultListener</title><link>https://atsum.in/android/fragment-result/</link><pubDate>Fri, 12 Aug 2022 20:11:54 +0900</pubDate><guid>https://atsum.in/android/fragment-result/</guid><description>&lt;h2 id="navigation-componentでの画面勘のデータのやり取りの仕組み">Navigation Componentでの画面勘のデータのやり取りの仕組み&lt;/h2>
&lt;p>&lt;a href="https://developer.android.com/guide/navigation/navigation-getting-started?hl=ja">Navigation Component&lt;/a>で画面遷移に伴うデータのやり取りのうち、「次の画面」に渡す仕組みとして&lt;a href="https://developer.android.com/guide/navigation/navigation-getting-started?hl=ja#ensure_type-safety_by_using_safe_args">Safe args&lt;/a>が用意されている。&lt;/p></description><enclosure url="https://atsum.in/android/fragment-result/img/thumbnail.png" type="image/png"/></item><item><title>【Android,Kotlin】Kotlinには3項演算子がない</title><link>https://atsum.in/android/ternary-operator-alternative/</link><pubDate>Fri, 12 Aug 2022 01:28:37 +0900</pubDate><guid>https://atsum.in/android/ternary-operator-alternative/</guid><description>&lt;h2 id="javaの三項演算子">Javaの三項演算子&lt;/h2>
&lt;p>Javaでは以下の形で条件式が&lt;code>true&lt;/code>か&lt;code>false&lt;/code>かで真式か偽式を評価する式。&lt;/p>
&lt;div class="highlight" filename="Java">&lt;pre tabindex="0" class="chroma">&lt;code class="language-java" data-lang="java">&lt;span class="line">&lt;span class="cl">&lt;span class="n">条件式&lt;/span>&lt;span class="w"> &lt;/span>&lt;span class="o">?&lt;/span>&lt;span class="w"> &lt;/span>&lt;span class="n">真式&lt;/span>&lt;span class="w"> &lt;/span>&lt;span class="p">:&lt;/span>&lt;span class="w"> &lt;/span>&lt;span class="n">偽式&lt;/span>&lt;span class="w">
&lt;/span>&lt;/span>&lt;/span>&lt;/code>&lt;/pre>&lt;/div>&lt;p>例えば、&lt;code>a&lt;/code>、&lt;code>b&lt;/code>のうち小さい方として評価される式は以下のように記述できる。&lt;/p></description><enclosure url="https://atsum.in/android/ternary-operator-alternative/img/thumbnail.png" type="image/png"/></item><item><title>【Android】EditTextの入力を符号付き小数点ありの数値に限定する</title><link>https://atsum.in/android/number-decimal-edit-text/</link><pubDate>Thu, 11 Aug 2022 22:33:48 +0900</pubDate><guid>https://atsum.in/android/number-decimal-edit-text/</guid><description>&lt;h2 id="入力を符号付き小数点ありの数値にする">入力を符号付き小数点ありの数値にする&lt;/h2>
&lt;p>&lt;code>EditText&lt;/code>の入力を制限するには&lt;code>android:inputType&lt;/code>プロパティを指定する。&lt;/p>
&lt;p>符号付きの場合は&lt;code>numberSigned&lt;/code>、小数点ありの数値の場合は&lt;code>numberDecimal&lt;/code>を指定する。&lt;br>
符号付き＋小数点あり数値のように複数条件がある場合は&lt;code>|&lt;/code>でくっつけて書く。&lt;/p></description><enclosure url="https://atsum.in/android/number-decimal-edit-text/img/thumbnail.png" type="image/png"/></item><item><title>【Android,Kotlin】キーボードの右下のキーの変更方法</title><link>https://atsum.in/android/change-action-button/</link><pubDate>Thu, 11 Aug 2022 21:29:46 +0900</pubDate><guid>https://atsum.in/android/change-action-button/</guid><description>&lt;h2 id="アクションボタン">アクションボタン&lt;/h2>
&lt;p>Androidの&lt;code>EditText&lt;/code>にフォーカスしたとき表示されるキーボードの右下のキーをアクションボタンと言う。&lt;/p>
&lt;p>&lt;img src="img/default-action-button.png" alt="デフォルトのアクションボタン">&lt;/p>
&lt;h2 id="複数行テキストボックスのアクションボタンは改行">複数行テキストボックスのアクションボタンは改行&lt;/h2>
&lt;p>アクションボタンはフォーカスしている&lt;code>EditText&lt;/code>が改行を許可している場合(複数行の場合)は改行キーとなる。&lt;/p></description><enclosure url="https://atsum.in/android/change-action-button/img/thumbnail.png" type="image/png"/></item><item><title>【Android】RecyclerViewにスクロールバーをつける</title><link>https://atsum.in/android/recyclerview-scrollbar/</link><pubDate>Thu, 11 Aug 2022 20:33:39 +0900</pubDate><guid>https://atsum.in/android/recyclerview-scrollbar/</guid><description>&lt;h2 id="recyclerviewにスクロールバーをつける">RecyclerViewにスクロールバーをつける&lt;/h2>
&lt;p>レイアウトファイルで&lt;code>RecyclerView&lt;/code>に&lt;code>android:scrollbars=&amp;quot;vertical&amp;quot;&lt;/code>をつけると
スクロールバーが表示されるようになる。&lt;/p></description><enclosure url="https://atsum.in/android/recyclerview-scrollbar/img/thumbnail.png" type="image/png"/></item><item><title>【Android,Kotlin】MutableLiveData&lt;MutableList&lt;X>>を使わない</title><link>https://atsum.in/android/dont-use-list-of-mutable-live-data/</link><pubDate>Thu, 11 Aug 2022 16:35:19 +0900</pubDate><guid>https://atsum.in/android/dont-use-list-of-mutable-live-data/</guid><description>&lt;h2 id="mutablelistのmutablelivedataではなくlistのmutablelivedataにする">MutableListのMutableLiveDataではなくListのMutableLiveDataにする&lt;/h2>
&lt;div class="highlight">&lt;pre tabindex="0" class="chroma">&lt;code class="language-Kotlin" data-lang="Kotlin">&lt;span class="line">&lt;span class="cl">&lt;span class="n">MutableLiveData&lt;/span>&lt;span class="p">&amp;lt;&lt;/span>&lt;span class="n">MutableList&lt;/span>&lt;span class="p">&amp;lt;&lt;/span>&lt;span class="n">Int&lt;/span>&lt;span class="p">&amp;gt;&amp;gt;&lt;/span>
&lt;/span>&lt;/span>&lt;/code>&lt;/pre>&lt;/div>&lt;p>のような&lt;code>LiveData&lt;/code>を使う場合、&lt;code>MutableList&lt;/code>の&lt;code>add&lt;/code>メソッドなど要素を追加・削除するメソッドを呼び出して
更新しても、データの更新は通知されない。&lt;/p></description><enclosure url="https://atsum.in/android/dont-use-list-of-mutable-live-data/img/thumbnail.png" type="image/png"/></item><item><title>【Android,Kotlin】lifecycleOwnerを渡さないとデータバインディングが動かない</title><link>https://atsum.in/android/lifecycle-owner-data-binding/</link><pubDate>Thu, 11 Aug 2022 15:58:54 +0900</pubDate><guid>https://atsum.in/android/lifecycle-owner-data-binding/</guid><description>&lt;h2 id="lifecycleownerのセットを忘れるとデータバインディングが連動しない">lifecycleOwnerのセットを忘れるとデータバインディングが連動しない&lt;/h2>
&lt;p>&lt;code>LiveData&lt;/code>を持った&lt;code>ViewModel&lt;/code>を使ってデータバインディングを使う場合、&lt;code>Fragment&lt;/code>で
以下のように&lt;code>ViewModel&lt;/code>とレイアウトを紐づける。&lt;/p></description><enclosure url="https://atsum.in/android/lifecycle-owner-data-binding/img/thumbnail.png" type="image/png"/></item><item><title>【Android,Kotlin】'getColor(Int): Int' is deprecated. Deprecated in Javaの対応方法</title><link>https://atsum.in/android/get-color-is-deprecated-in-java/</link><pubDate>Thu, 11 Aug 2022 15:35:12 +0900</pubDate><guid>https://atsum.in/android/get-color-is-deprecated-in-java/</guid><description>&lt;h2 id="getcolorintはdeprecated">getColor(int)はDeprecated&lt;/h2>
&lt;p>&lt;a href="https://developer.android.com/reference/android/content/res/Resources#getColor(int)">getColor(int)&lt;/a>はDeprecatedになった。&lt;/p>
&lt;p>以下のようなコードを書くと&lt;code>'getColor(Int): Int' is deprecated. Deprecated in Java&lt;/code>とワーニングが表示される。&lt;/p>
&lt;div class="highlight">&lt;pre tabindex="0" class="chroma">&lt;code class="language-kotlin" data-lang="kotlin">&lt;span class="line">&lt;span class="cl">&lt;span class="n">context&lt;/span>&lt;span class="p">.&lt;/span>&lt;span class="n">resources&lt;/span>&lt;span class="p">.&lt;/span>&lt;span class="n">getColor&lt;/span>&lt;span class="p">(&lt;/span>&lt;span class="nc">R&lt;/span>&lt;span class="p">.&lt;/span>&lt;span class="n">color&lt;/span>&lt;span class="p">.&lt;/span>&lt;span class="n">foo&lt;/span>&lt;span class="p">)&lt;/span>
&lt;/span>&lt;/span>&lt;/code>&lt;/pre>&lt;/div>&lt;h2 id="代わりにgetcolorint-resourcesthemeを使う">代わりにgetColor(int, Resources.Theme)を使う&lt;/h2>
&lt;p>1引数の&lt;code>getColor(int)&lt;/code>の代わりに2引数の&lt;a href="https://developer.android.com/reference/android/content/res/Resources#getColor(int,%20android.content.res.Resources.Theme)">getColor(int, Resources.Theme)&lt;/a>を使う。&lt;/p></description><enclosure url="https://atsum.in/android/get-color-is-deprecated-in-java/img/thumbnail.png" type="image/png"/></item><item><title>【Android】EditText の下線を消す</title><link>https://atsum.in/android/remove-edit-text-underline/</link><pubDate>Thu, 11 Aug 2022 14:33:43 +0900</pubDate><guid>https://atsum.in/android/remove-edit-text-underline/</guid><description>&lt;h2 id="edittextの下線">EditTextの下線&lt;/h2>
&lt;p>&lt;code>EditText&lt;/code>はデフォルトで下線が表示されている。&lt;/p>
&lt;div class="highlight">&lt;pre tabindex="0" class="chroma">&lt;code class="language-xml" data-lang="xml">&lt;span class="line">&lt;span class="cl">&lt;span class="nt">&amp;lt;EditText&lt;/span>
&lt;/span>&lt;/span>&lt;span class="line">&lt;span class="cl"> &lt;span class="na">android:layout_width=&lt;/span>&lt;span class="s">&amp;#34;match_parent&amp;#34;&lt;/span>
&lt;/span>&lt;/span>&lt;span class="line">&lt;span class="cl"> &lt;span class="na">android:layout_height=&lt;/span>&lt;span class="s">&amp;#34;wrap_content&amp;#34;&lt;/span> &lt;span class="nt">/&amp;gt;&lt;/span>
&lt;/span>&lt;/span>&lt;/code>&lt;/pre>&lt;/div>&lt;p>&lt;img src="img/edit-text-with-underline.png" alt="下線ありのEditText">&lt;/p>
&lt;h2 id="edittextの下線を消す">EditTextの下線を消す&lt;/h2>
&lt;p>&lt;code>EditText&lt;/code>の&lt;code>android:backgound&lt;/code>プロパティを&lt;code>@null&lt;/code>にすると下線が消える。&lt;/p></description><enclosure url="https://atsum.in/android/remove-edit-text-underline/img/thumbnail.png" type="image/png"/></item><item><title>【Android,Kotlin】requireContext()でクラッシュするパターンと対応</title><link>https://atsum.in/android/crash-by-require-context/</link><pubDate>Thu, 11 Aug 2022 01:14:54 +0900</pubDate><guid>https://atsum.in/android/crash-by-require-context/</guid><description>&lt;h2 id="fragmentのrequirecontext">FragmentのrequireContext()&lt;/h2>
&lt;p>&lt;code>Fragment&lt;/code>の&lt;code>getContext()&lt;/code>はnullableだが、&lt;code>requireContext()&lt;/code>メソッドでnullableではない値が取得できる。&lt;/p></description><enclosure url="https://atsum.in/android/crash-by-require-context/img/thumbnail.png" type="image/png"/></item><item><title>【Kotlin】Kotlinのnullチェックで早期return</title><link>https://atsum.in/android/null-check-early-return/</link><pubDate>Thu, 11 Aug 2022 00:17:28 +0900</pubDate><guid>https://atsum.in/android/null-check-early-return/</guid><description>&lt;h2 id="普通のnullチェック">普通のnullチェック&lt;/h2>
&lt;p>メソッドの冒頭で&lt;code>null&lt;/code>かどうかをチェックして以下のように処理する。&lt;/p>
&lt;ul>
&lt;li>&lt;code>null&lt;/code>なら&lt;code>return&lt;/code>する&lt;/li>
&lt;li>&lt;code>null&lt;/code>でないなら処理する&lt;/li>
&lt;/ul>
&lt;p>例えば&lt;code>nullable&lt;/code>な数値の足し算は以下のようになる。&lt;/p></description><enclosure url="https://atsum.in/android/null-check-early-return/img/thumbnail.png" type="image/png"/></item><item><title>【Android,Kotlin】メニューの処理をMenuProviderにする</title><link>https://atsum.in/android/menu-provider/</link><pubDate>Tue, 09 Aug 2022 21:35:09 +0900</pubDate><guid>https://atsum.in/android/menu-provider/</guid><description>&lt;p>Navigation ComponentでFragmentからメニューを表示する場合。&lt;/p>
&lt;h2 id="メニューの古い作りかた">メニューの古い作りかた&lt;/h2>
&lt;p>&lt;code>Navigation Component&lt;/code>使用時に&lt;code>Fragment&lt;/code>でApp Barのメニューを作るには以下の手順で実装していた。&lt;/p></description><enclosure url="https://atsum.in/android/menu-provider/img/thumbnail.png" type="image/png"/></item><item><title>【Kotlin】Pair のリストを Map にする</title><link>https://atsum.in/android/kotlin-pair-list-to-map/</link><pubDate>Mon, 08 Aug 2022 01:01:25 +0900</pubDate><guid>https://atsum.in/android/kotlin-pair-list-to-map/</guid><description>&lt;h2 id="pair-のリストを-map-に変換する">Pair のリストを Map に変換する&lt;/h2>
&lt;p>&lt;a href="https://kotlinlang.org/api/latest/jvm/stdlib/kotlin.sequences/associate.html">associate メソッド&lt;/a>を利用すれば簡潔に書ける。&lt;/p>
&lt;p>&lt;a href="https://kotlinlang.org/api/latest/jvm/stdlib/kotlin.sequences/associate.html">associate メソッド&lt;/a>は「Pairを返す無名関数」を引数にとって、&lt;code>Map&lt;/code>を返す関数。&lt;/p>
&lt;div class="highlight">&lt;pre tabindex="0" class="chroma">&lt;code class="language-kotlin" data-lang="kotlin">&lt;span class="line">&lt;span class="cl">&lt;span class="k">val&lt;/span> &lt;span class="py">pairs&lt;/span> &lt;span class="p">=&lt;/span> &lt;span class="n">listOf&lt;/span>&lt;span class="p">(&lt;/span>&lt;span class="s2">&amp;#34;a&amp;#34;&lt;/span> &lt;span class="n">to&lt;/span> &lt;span class="m">1&lt;/span>&lt;span class="p">,&lt;/span> &lt;span class="s2">&amp;#34;b&amp;#34;&lt;/span> &lt;span class="n">to&lt;/span> &lt;span class="m">2&lt;/span>&lt;span class="p">)&lt;/span>
&lt;/span>&lt;/span>&lt;span class="line">&lt;span class="cl">&lt;span class="k">val&lt;/span> &lt;span class="py">map&lt;/span> &lt;span class="p">=&lt;/span> &lt;span class="n">pairs&lt;/span>&lt;span class="p">.&lt;/span>&lt;span class="n">associate&lt;/span> &lt;span class="p">{&lt;/span> &lt;span class="k">it&lt;/span> &lt;span class="p">}&lt;/span>
&lt;/span>&lt;/span>&lt;span class="line">&lt;span class="cl">&lt;span class="n">println&lt;/span>&lt;span class="p">(&lt;/span>&lt;span class="n">map&lt;/span>&lt;span class="p">)&lt;/span> &lt;span class="c1">// =&amp;gt; {a=1, b=2}
&lt;/span>&lt;/span>&lt;/span>&lt;/code>&lt;/pre>&lt;/div>&lt;h2 id="オブジェクトのリストを-map-に変換する">オブジェクトのリストを Map に変換する&lt;/h2>
&lt;p>&lt;code>Pair&lt;/code>を返す無名関数を渡せばいいので、任意のオブジェクトに対しては以下のようにすればよい。&lt;/p></description><enclosure url="https://atsum.in/android/kotlin-pair-list-to-map/img/thumbnail.png" type="image/png"/></item><item><title>【Android,Kotlin】メニューの状態の動的更新</title><link>https://atsum.in/android/dynamic-menu/</link><pubDate>Sun, 07 Aug 2022 20:43:36 +0900</pubDate><guid>https://atsum.in/android/dynamic-menu/</guid><description>&lt;h2 id="メニューの状態更新の流れ">メニューの状態更新の流れ&lt;/h2>
&lt;p>流れは以下の通り。&lt;/p>
&lt;ol>
&lt;li>メニューの作成時に状態を設定する&lt;/li>
&lt;li>メニューを更新したいタイミングでメニューを&lt;code>Activity#invalidateOptionsMenu()&lt;/code>を呼んでinvalidateする&lt;/li>
&lt;/ol>
&lt;p>メニューをinvalidateすれば1.の処理が再度走るので、1.で設定したい状態にする。&lt;/p></description><enclosure url="https://atsum.in/android/dynamic-menu/img/thumbnail.png" type="image/png"/></item><item><title>【Android,Kotlin】Navigaton Component使用時に特定FragmentのApp Barのホームボタンを✕にする</title><link>https://atsum.in/android/change-home-button/</link><pubDate>Sun, 07 Aug 2022 13:24:43 +0900</pubDate><guid>https://atsum.in/android/change-home-button/</guid><description>&lt;h2 id="手順">手順&lt;/h2>
&lt;h3 id="resource-managerでマークを追加する">Resource Managerで✕マークを追加する&lt;/h3>
&lt;p>&lt;a href="https://atsum.in/android/add-vector-assets/">【Android Studio】Vector Assetsの追加手順&lt;/a>を参考に✕マークを追加する。&lt;/p>
&lt;p>close選択する。&lt;/p>
&lt;p>&lt;img src="img/asset-studio.png" alt="✕マークの追加">&lt;/p>
&lt;h3 id="fragmentoncreateview-でホームボタンを差し替える">Fragment#onCreateView でホームボタンを差し替える&lt;/h3>
&lt;div class="highlight">&lt;pre tabindex="0" class="chroma">&lt;code class="language-kotlin" data-lang="kotlin">&lt;span class="line">&lt;span class="cl">&lt;span class="p">(&lt;/span>&lt;span class="n">activity&lt;/span> &lt;span class="k">as&lt;/span>&lt;span class="p">?&lt;/span> &lt;span class="n">AppCompatActivity&lt;/span>&lt;span class="p">)&lt;/span>
&lt;/span>&lt;/span>&lt;span class="line">&lt;span class="cl"> &lt;span class="o">?.&lt;/span>&lt;span class="n">supportActionBar&lt;/span>
&lt;/span>&lt;/span>&lt;span class="line">&lt;span class="cl"> &lt;span class="o">?.&lt;/span>&lt;span class="n">setHomeAsUpIndicator&lt;/span>&lt;span class="p">(&lt;/span>&lt;span class="nc">R&lt;/span>&lt;span class="p">.&lt;/span>&lt;span class="n">drawable&lt;/span>&lt;span class="p">.&lt;/span>&lt;span class="n">ic_baseline_close_24&lt;/span>&lt;span class="p">)&lt;/span>
&lt;/span>&lt;/span>&lt;/code>&lt;/pre>&lt;/div></description><enclosure url="https://atsum.in/android/change-home-button/img/thumbnail.png" type="image/png"/></item><item><title>【Android Studio】Vector Assetsの追加手順</title><link>https://atsum.in/android/add-vector-assets/</link><pubDate>Sun, 07 Aug 2022 12:09:56 +0900</pubDate><guid>https://atsum.in/android/add-vector-assets/</guid><description>&lt;h2 id="手順">手順&lt;/h2>
&lt;h3 id="resource-manager-の追加メニューから-vector-asset-を選択">Resource Manager の追加メニューから Vector Asset を選択&lt;/h3>
&lt;p>&lt;img src="img/resource-manager-menu.png" alt="Resource Managerのメニュー">&lt;/p>
&lt;h3 id="clip-artボタンをクリック">Clip Artボタンをクリック&lt;/h3>
&lt;p>&lt;img src="img/select-clip-art-button.png" alt="Clip Artボタンをクリック">&lt;/p>
&lt;h3 id="アイコンを選択">アイコンを選択&lt;/h3>
&lt;p>&lt;img src="img/select-icon-dialog.png" alt="アイコンを選択">&lt;/p>
&lt;h3 id="nextをクリック">Nextをクリック&lt;/h3>
&lt;p>&lt;img src="img/click-next.png" alt="Nextをクリック">&lt;/p>
&lt;h3 id="finishをクリック">Finishをクリック&lt;/h3>
&lt;p>&lt;img src="img/click-finish.png" alt="Finishをクリック">&lt;/p>
&lt;p>以上で追加完了。
Resource Managerを見ると追加できているのが確認できる。&lt;/p></description><enclosure url="https://atsum.in/android/add-vector-assets/img/thumbnail.png" type="image/png"/></item><item><title>【Android,Kotlin】DialogFragmentでRecyclerViewのdividerをセットしても表示されない</title><link>https://atsum.in/android/dialog-fragment-divider/</link><pubDate>Sun, 07 Aug 2022 00:32:41 +0900</pubDate><guid>https://atsum.in/android/dialog-fragment-divider/</guid><description>&lt;h2 id="dialogfragment内のrecyclerviewでdividerが表示されない">DialogFragment内のRecyclerViewでdividerが表示されない&lt;/h2>
&lt;p>普段RecyclerViewの行間の仕切り線を以下の様なコードで表示している。
(addItemDecoration)&lt;/p>
&lt;div class="highlight">&lt;pre tabindex="0" class="chroma">&lt;code class="language-kotlin" data-lang="kotlin">&lt;span class="line">&lt;span class="cl">&lt;span class="n">recyclerView&lt;/span>&lt;span class="p">.&lt;/span>&lt;span class="n">apply&lt;/span> &lt;span class="p">{&lt;/span>
&lt;/span>&lt;/span>&lt;span class="line">&lt;span class="cl"> &lt;span class="k">this&lt;/span>&lt;span class="p">.&lt;/span>&lt;span class="n">layoutManager&lt;/span> &lt;span class="p">=&lt;/span> &lt;span class="n">linearLayoutManager&lt;/span>
&lt;/span>&lt;/span>&lt;span class="line">&lt;span class="cl"> &lt;span class="k">this&lt;/span>&lt;span class="p">.&lt;/span>&lt;span class="n">adapter&lt;/span> &lt;span class="p">=&lt;/span> &lt;span class="n">adapter&lt;/span>
&lt;/span>&lt;/span>&lt;span class="line">&lt;span class="cl"> &lt;span class="k">this&lt;/span>&lt;span class="p">.&lt;/span>&lt;span class="n">addItemDecoration&lt;/span>&lt;span class="p">(&lt;/span>
&lt;/span>&lt;/span>&lt;span class="line">&lt;span class="cl"> &lt;span class="n">DividerItemDecoration&lt;/span>&lt;span class="p">(&lt;/span>&lt;span class="n">context&lt;/span>&lt;span class="p">,&lt;/span> &lt;span class="n">linearLayoutManager&lt;/span>&lt;span class="p">.&lt;/span>&lt;span class="n">orientation&lt;/span>&lt;span class="p">)&lt;/span>
&lt;/span>&lt;/span>&lt;span class="line">&lt;span class="cl"> &lt;span class="p">)&lt;/span>
&lt;/span>&lt;/span>&lt;span class="line">&lt;span class="cl">&lt;span class="p">}&lt;/span>
&lt;/span>&lt;/span>&lt;/code>&lt;/pre>&lt;/div>&lt;p>ActivityやFragmentの場合はこれでオーケーだが、DialogFragmentやBottomSheetDialogFragment内で利用しているときは表示されない。&lt;/p></description><enclosure url="https://atsum.in/android/dialog-fragment-divider/img/thumbnail.png" type="image/png"/></item><item><title>【Android,Kotlin】回転時に画面が初期化するのをなんとかする</title><link>https://atsum.in/android/config-changes/</link><pubDate>Sat, 06 Aug 2022 16:51:20 +0900</pubDate><guid>https://atsum.in/android/config-changes/</guid><description>&lt;h2 id="画面回転時の-android-アプリの-activity-処理">画面回転時の Android アプリの Activity 処理&lt;/h2>
&lt;p>Androidアプリは画面回転時にActivityの再生成処理が走る。
そのため、実装によっては例えばユーザーが入力した情報などが画面の回転によって消えてしまう。
途中まで入力した情報が消えてしまうとそれまでの労力が無駄となりユーザーにとってはとても煩わしい。&lt;/p></description><enclosure url="https://atsum.in/android/config-changes/img/thumbnail.png" type="image/png"/></item></channel></rss>