<rss version="2.0" xmlns:atom="http://www.w3.org/2005/Atom"><channel><title>森羅万象テーブル – Programming</title><link>/blog/category/programming/</link><description>Recent content in Programming on 森羅万象テーブル</description><generator>Hugo -- gohugo.io</generator><language>ja</language><lastBuildDate>Fri, 11 Apr 2025 17:25:16 +0900</lastBuildDate><atom:link href="/blog/category/programming/index.xml" rel="self" type="application/rss+xml"/><item><title>Blog: Hugo：特定のページをsitemap.xmlから除外する方法</title><link>/blog/2025/04/11/hugo_how_to_exclude_certain_pages_from_sitemap.xml/</link><pubDate>Fri, 11 Apr 2025 17:25:16 +0900</pubDate><guid>/blog/2025/04/11/hugo_how_to_exclude_certain_pages_from_sitemap.xml/</guid><description>
&lt;p>※Hugo v0.125.0以降で利用可能な機能&lt;/p>
&lt;br>
&lt;h2 id="実装方法">実装方法&lt;/h2>
&lt;p>特定のページをsitemap.xmlから除外するには、該当ページのフロントマターに&lt;code>sitemap&lt;/code>パラメータを追加する。&lt;br>
これにより、検索エンジンのクローリングを効率的に制御可能。&lt;/p>
&lt;pre>&lt;code class="language-yaml">---
title: &amp;quot;除外したいページのタイトル&amp;quot;
sitemap:
disable: true
---
&lt;/code>&lt;/pre>
&lt;br>
&lt;h2 id="使用例">使用例&lt;/h2>
&lt;p>&lt;code>/content/mypage.md&lt;/code>のようなページをsitemap.xmlから除外する場合：&lt;/p>
&lt;pre>&lt;code class="language-yaml">---
title: &amp;quot;除外ページ&amp;quot;
sitemap:
disable: true
---
&lt;/code>&lt;/pre>
&lt;br>
&lt;h2 id="メリット">メリット&lt;/h2>
&lt;ul>
&lt;li>検索エンジンのクローリング効率の向上&lt;/li>
&lt;li>不要なページのインデックス化を防止&lt;/li>
&lt;li>サイトのSEOパフォーマンスの最適化&lt;/li>
&lt;/ul>
&lt;br>
&lt;h2 id="参考リンク">参考リンク&lt;/h2>
&lt;ul>
&lt;li>&lt;a href="https://gohugo.io/methods/page/sitemap/">Hugo公式ドキュメント - Page.Sitemap&lt;/a>&lt;/li>
&lt;/ul>
&lt;br>
&lt;h2 id="本記事について">本記事について&lt;/h2>
&lt;p>&lt;a title="Hugo：任意のPageをsitemap.xmlに載せない" href="https://www.tssol.net/blog/2025/03/04/hugo_exclude_page_from_sitemap/">Hugo：任意のPageをsitemap.xmlに載せない&lt;/a>&lt;br>
をベースに、AIが書いた記事です。&lt;/p></description></item><item><title>Blog: cat：コメントアウトしていない行のみを抽出 - Linuxコマンド入門</title><link>/blog/2025/04/09/extract_only_non-commented_lines_with_cat/</link><pubDate>Wed, 09 Apr 2025 14:46:42 +0900</pubDate><guid>/blog/2025/04/09/extract_only_non-commented_lines_with_cat/</guid><description>
&lt;p>タイトルとcatコマンドを渡して、AIに記事を書いてもらった。&lt;br>
※以下はAIが書いた記事です。&lt;/p>
&lt;hr>
&lt;br>
&lt;h2 id="概要">概要&lt;/h2>
&lt;p>設定ファイルやスクリプトファイルを扱う際、コメントアウトされていない行だけを確認したい場面は多いものです。&lt;br>
そんな時に役立つのが、&lt;code>cat&lt;/code>と&lt;code>grep&lt;/code>コマンドの組み合わせです。&lt;br>
この記事では、この便利なテクニックの使い方と応用例を解説します。&lt;/p>
&lt;br>
&lt;h2 id="基本的な使い方と構文">基本的な使い方と構文&lt;/h2>
&lt;p>最もシンプルな使い方は以下のコマンドです：&lt;/p>
&lt;pre>&lt;code class="language-bash">cat /path/to/file | grep -v \#
&lt;/code>&lt;/pre>
&lt;p>このコマンドの動作を詳しく見てみましょう：&lt;/p>
&lt;ol>
&lt;li>&lt;code>cat&lt;/code>コマンド：指定したファイルの内容を出力します&lt;/li>
&lt;li>パイプ（&lt;code>|&lt;/code>）：&lt;code>cat&lt;/code>の出力を&lt;code>grep&lt;/code>コマンドに渡します&lt;/li>
&lt;li>&lt;code>grep -v \#&lt;/code>：&lt;code>#&lt;/code>で始まる行（コメント行）を除外します&lt;/li>
&lt;/ol>
&lt;br>
&lt;h2 id="実践的な使用例設定ファイルの処理">実践的な使用例：設定ファイルの処理&lt;/h2>
&lt;p>実際の設定ファイルを例に、使い方を確認してみましょう：&lt;/p>
&lt;pre>&lt;code class="language-bash"># サーバー設定
PORT=1919
HOST=senpai
# データベース設定
DB_HOST=114.51.48.10
DB_USER=admin
# キャッシュ設定
CACHE_SIZE=810
&lt;/code>&lt;/pre>
&lt;p>このファイルからコメントを除外して必要な設定値だけを抽出するには：&lt;/p>
&lt;pre>&lt;code class="language-bash">cat config.conf | grep -v \#
&lt;/code>&lt;/pre>
&lt;p>実行結果：&lt;/p>
&lt;pre>&lt;code>PORT=1919
HOST=senpai
DB_HOST=114.51.48.10
DB_USER=admin
CACHE_SIZE=810
&lt;/code>&lt;/pre>
&lt;br>
&lt;h2 id="便利な応用テクニック高度な使用方法">便利な応用テクニック：高度な使用方法&lt;/h2>
&lt;ol>
&lt;li>&lt;strong>複数のコメント形式に対応&lt;/strong>&lt;/li>
&lt;/ol>
&lt;pre>&lt;code class="language-bash">cat file.txt | grep -v &amp;quot;^#&amp;quot; | grep -v &amp;quot;^//&amp;quot;
&lt;/code>&lt;/pre>
&lt;ol start="2">
&lt;li>&lt;strong>空行も除外&lt;/strong>&lt;/li>
&lt;/ol>
&lt;pre>&lt;code class="language-bash">cat file.txt | grep -v &amp;quot;^#&amp;quot; | grep -v &amp;quot;^$&amp;quot;
&lt;/code>&lt;/pre>
&lt;ol start="3">
&lt;li>&lt;strong>結果をファイルに保存&lt;/strong>&lt;/li>
&lt;/ol>
&lt;pre>&lt;code class="language-bash">cat file.txt | grep -v \# &amp;gt; output.txt
&lt;/code>&lt;/pre>
&lt;br>
&lt;h2 id="使用時の注意点とトラブルシューティング">使用時の注意点とトラブルシューティング&lt;/h2>
&lt;ul>
&lt;li>&lt;strong>Windows環境での注意&lt;/strong>：コマンドプロンプトでは&lt;code>findstr&lt;/code>コマンドを使用する必要がある場合があります&lt;/li>
&lt;li>&lt;strong>スペースを含むパス&lt;/strong>：ファイルパスにスペースが含まれる場合は、必ず引用符で囲んでください&lt;/li>
&lt;li>&lt;strong>大文字小文字の区別&lt;/strong>：必要に応じて&lt;code>grep&lt;/code>に&lt;code>-i&lt;/code>オプションを追加してください&lt;/li>
&lt;/ul>
&lt;br>
&lt;h2 id="まとめシェルスクリプトの効率化">まとめ：シェルスクリプトの効率化&lt;/h2>
&lt;p>&lt;code>cat&lt;/code>と&lt;code>grep&lt;/code>の組み合わせは、設定ファイルやスクリプトからコメントを除外する際の強力なツールです。&lt;br>
特に大きな設定ファイルを扱う際や、設定値の確認作業を行う際に重宝します。&lt;br>
このテクニックをマスターすることで、ファイル操作の効率が大幅に向上するでしょう。&lt;/p>
&lt;pre>&lt;code class="language-bash">cat /path/to/file | grep -v \#
&lt;/code>&lt;/pre></description></item><item><title>Blog: OSS版のNexusはPostgreSQLへのmigrationが出来ない</title><link>/blog/2025/04/08/oss_version_of_nexus_cannot_be_migrated_to_postgresql/</link><pubDate>Tue, 08 Apr 2025 18:47:54 +0900</pubDate><guid>/blog/2025/04/08/oss_version_of_nexus_cannot_be_migrated_to_postgresql/</guid><description>
&lt;h2 id="はじめに">はじめに&lt;/h2>
&lt;p>Nexus Repository ManagerのOSS版では、PostgreSQLへのデータベース移行がサポートされていないことが分かった。&lt;br>
以下に、試した際の手順と発生したエラーをまとめた。&lt;/p>
&lt;br>
&lt;h2 id="前提条件">前提条件&lt;/h2>
&lt;ul>
&lt;li>Database Migrator Utility for 3.70.x をダウンロード
&lt;ul>
&lt;li>&lt;a href="https://help.sonatype.com/en/orientdb-downloads.html#database-migrator-utility-for-3-70-x">https://help.sonatype.com/en/orientdb-downloads.html#database-migrator-utility-for-3-70-x&lt;/a>&lt;/li>
&lt;li>試したバージョン: 3.70.4&lt;br>
※移行対象のNexusと同一のバージョンを使用すること!!&lt;/li>
&lt;/ul>
&lt;/li>
&lt;/ul>
&lt;br>
&lt;h2 id="移行手順">移行手順&lt;/h2>
&lt;h3 id="1-postgresqlの準備">1. PostgreSQLの準備&lt;/h3>
&lt;h4 id="docker-compose設定">Docker Compose設定&lt;/h4>
&lt;pre>&lt;code class="language-yaml">services:
postgres:
image: postgres:17.4
ports:
- 5432:5432
environment:
POSTGRES_USER: nexus
POSTGRES_PASSWORD: xxxx
volumes:
- postgres-data:/var/lib/postgresql/data
nexus:
depends_on:
postgres:
condition: service_started
image: sonatype/nexus3:3.70.4
ports:
- 8081:8081
volumes:
- nexus-data:/nexus-data
volumes:
postgres-data: null
nexus-data: null
&lt;/code>&lt;/pre>
&lt;h3 id="2-nexusの設定変更">2. Nexusの設定変更&lt;/h3>
&lt;h4 id="nexus-storepropertiesの設定">nexus-store.propertiesの設定&lt;/h4>
&lt;pre>&lt;code class="language-properties">username=nexus
password=xxx
jdbcUrl=jdbc\:postgresql\://postgres\:5432/nexus
&lt;/code>&lt;/pre>
&lt;h4 id="所有者設定">所有者設定&lt;/h4>
&lt;pre>&lt;code class="language-bash">chown 200:200 /var/lib/docker/volumes/nexus_nexus-data/_data/etc/fabric/nexus-store.properties
&lt;/code>&lt;/pre>
&lt;h4 id="nexuspropertiesの設定">nexus.propertiesの設定&lt;/h4>
&lt;pre>&lt;code class="language-bash">echo &amp;quot;nexus.datastore.enabled=true&amp;quot; &amp;gt;&amp;gt; /var/lib/docker/volumes/nexus_nexus-data/_data/etc/nexus.properties
&lt;/code>&lt;/pre>
&lt;h3 id="3-バックアップの準備">3. バックアップの準備&lt;/h3>
&lt;pre>&lt;code class="language-bash">mkdir /var/lib/docker/volumes/nexus_nexus-data/_data/_backup
chown 200:200 /var/lib/docker/volumes/nexus_nexus-data/_data/_backup
&lt;/code>&lt;/pre>
&lt;h3 id="4-フルバックアップの取得">4. フルバックアップの取得&lt;/h3>
&lt;ol>
&lt;li>&lt;code>admin&lt;/code>でにログイン&lt;/li>
&lt;li>上部の歯車アイコンをクリック&lt;/li>
&lt;li>System &amp;gt; Tasks に移動&lt;/li>
&lt;li>Create task を選択&lt;/li>
&lt;li>Admin - Export Database for backup をクリックし、以下を設定する
&lt;ul>
&lt;li>Task name: 任意&lt;/li>
&lt;li>Backup location: &lt;code>/nexus-data/_backup&lt;/code>&lt;/li>
&lt;li>Task frequency: Manual&lt;/li>
&lt;/ul>
&lt;/li>
&lt;li>作成したTaskを選択し、&lt;code>Run&lt;/code>をクリックしてタスクを実行&lt;/li>
&lt;/ol>
&lt;h3 id="5-移行作業の実行">5. 移行作業の実行&lt;/h3>
&lt;h4 id="移行用コンテナの準備">移行用コンテナの準備&lt;/h4>
&lt;pre>&lt;code class="language-yaml"> java:
image: openjdk:11-ea-jdk
restart: unless-stopped
command: tail -f /dev/null
volumes:
- /var/lib/docker/volumes/nexus_nexus-data/_data/_backup:/work
&lt;/code>&lt;/pre>
&lt;h4 id="移行コマンドの実行">移行コマンドの実行&lt;/h4>
&lt;pre>&lt;code class="language-bash">java -Xmx16G -Xms16G -XX:+UseG1GC -XX:MaxDirectMemorySize=28672M -jar nexus-db-migrator-3.70.4-02.jar --migration_type=postgres --db_url=&amp;quot;jdbc:postgresql://postgres:5432/nexus?user=nexus&amp;amp;password=xxx&amp;quot; --add-exports java.base/sun.nio.ch=ALL-UNNAMED
&lt;/code>&lt;/pre>
&lt;br>
&lt;h2 id="結果">結果&lt;/h2>
&lt;p>上記のコマンドを実行した際、以下のエラーが発生した：&lt;/p>
&lt;pre>&lt;code>~省略~
17:14:46 [main] INFO c.s.n.d.m.l.ProvidingJobInfoListener - ------------------------------------------------------------
17:14:46 [main] INFO c.s.n.d.m.l.ProvidingJobInfoListener - Migration job finished with status FAILED.
17:14:46 [main] INFO c.s.n.d.m.l.ProvidingJobInfoListener - Detailed message: com.sonatype.nexus.db.migrator.exception.WrongNxrmEditionException: Migration to an external database requires Nexus Repository Manager Pro and is not supported for Nexus Repository Manager OSS instances.
17:14:46 [main] INFO c.s.n.d.m.l.ProvidingJobInfoListener - ------------------------------------------------------------
&lt;/code>&lt;/pre>
&lt;br>
&lt;h2 id="結論">結論&lt;/h2>
&lt;ul>
&lt;li>OSS版のNexus Repository Managerでは、PostgreSQLへのデータベース移行はサポートされてない&lt;/li>
&lt;li>3.70.x系ではH2データベースのみへ移行可能&lt;/li>
&lt;li>PostgreSQLへの移行には、Nexus Repository Manager Proライセンスが必要&lt;/li>
&lt;/ul>
&lt;br>
&lt;h2 id="参考リンク">参考リンク&lt;/h2>
&lt;blockquote>
&lt;p>Migrating From OrientDB to PostgreSQL&lt;br>
&lt;a href="https://help.sonatype.com/en/upgrading-to-nexus-repository-3-71-0-and-beyond.html#migrating-from-orientdb-to-postgresql-252162">https://help.sonatype.com/en/upgrading-to-nexus-repository-3-71-0-and-beyond.html#migrating-from-orientdb-to-postgresql-252162&lt;/a>&lt;/p>&lt;/blockquote>
&lt;blockquote>
&lt;p>Do I have to buy a Pro license to upgrade to version 3.71.0+?&lt;br>
&lt;a href="https://help.sonatype.com/en/upgrading-to-nexus-repository-3-71-0-and-beyond.html#UUID-7dff2da7-6b31-f525-7a91-a22de4fbd74e_bridgehead-idm234557900890996">https://help.sonatype.com/en/upgrading-to-nexus-repository-3-71-0-and-beyond.html#UUID-7dff2da7-6b31-f525-7a91-a22de4fbd74e_bridgehead-idm234557900890996&lt;/a>&lt;/p>&lt;/blockquote></description></item><item><title>Blog: Docker版のNexusを3.71.0以降へupgradeする</title><link>/blog/2025/04/06/upgrade-docker-nexus-to-3.71.0orlater/</link><pubDate>Sun, 06 Apr 2025 18:32:30 +0900</pubDate><guid>/blog/2025/04/06/upgrade-docker-nexus-to-3.71.0orlater/</guid><description>
&lt;p>Dockerイメージで動作させているNexus 3.70系を3.71.0以降のversionへupgradeするには、&lt;br>
upgradeする前にOrientDBをH2へ移行する必要がある。&lt;/p>
&lt;br>
&lt;h2 id="前提条件">前提条件&lt;/h2>
&lt;ul>
&lt;li>Nexusのversionが、3.70系の最新versionであること&lt;/li>
&lt;li>OrientDBからH2への移行時に、16GB以上のメモリが確保されていること&lt;/li>
&lt;/ul>
&lt;br>
&lt;h2 id="使用したnexusの状態">使用したNexusの状態&lt;/h2>
&lt;p>upgradeするNexusは、docker composeで運用している&lt;/p>
&lt;pre>&lt;code class="language-yaml">services:
nexus:
image: sonatype/nexus3:3.70.4
ports:
- 8081:8081
volumes:
- nexus-data:/nexus-data
volumes:
nexus-data: null
&lt;/code>&lt;/pre>
&lt;br>
&lt;h2 id="orientdbからh2への移行手順">OrientDBからH2への移行手順&lt;/h2>
&lt;h3 id="dbのbackup保存先ディレクトリを作成する">DBのbackup保存先ディレクトリを作成する&lt;/h3>
&lt;pre>&lt;code class="language-shell">mkdir /var/lib/docker/volumes/nexus_nexus-data/_data/_backup
&lt;/code>&lt;/pre>
&lt;pre>&lt;code class="language-shell">chown 200:200 /var/lib/docker/volumes/nexus_nexus-data/_data/_backup
&lt;/code>&lt;/pre>
&lt;h3 id="nexusへブラウザでアクセスしfull-backupを取得する">Nexusへブラウザでアクセスし、full backupを取得する&lt;/h3>
&lt;ul>
&lt;li>&lt;span class="marker">admin&lt;/span>でログイン&lt;/li>
&lt;li>上部の歯車アイコンをクリック&lt;/li>
&lt;li>System &amp;gt; Tasks&lt;/li>
&lt;li>Create task&lt;/li>
&lt;li>Admin - Export Database for backup
&lt;ul>
&lt;li>Task name: &lt;span class="marker">任意&lt;/span>&lt;/li>
&lt;li>Backup location: &lt;span class="marker">/nexus-data/_backup&lt;/span>&lt;/li>
&lt;li>⁠Task frequency: &lt;span class="marker">Manual&lt;/span>&lt;/li>
&lt;/ul>
&lt;/li>
&lt;li>作成したTaskを選択し、&lt;span class="marker">Run&lt;/span>をクリック&lt;/li>
&lt;li>Taskが完了したことを確認する&lt;/li>
&lt;/ul>
&lt;h3 id="nexusを停止する">Nexusを停止する&lt;/h3>
&lt;pre>&lt;code class="language-shell">docker compose down
&lt;/code>&lt;/pre>
&lt;h3 id="database-migrator-utilityを取得する">Database Migrator Utilityを取得する&lt;/h3>
&lt;p>移行作業に使用するjarファイルを取得し、backup保存先へ格納する&lt;/p>
&lt;pre>&lt;code class="language-shell">wget https://download.sonatype.com/nexus/nxrm3-migrator/nexus-db-migrator-3.70.4-02.jar -P /var/lib/docker/volumes/nexus_nexus-data/_data/_backup/
&lt;/code>&lt;/pre>
&lt;h3 id="dbの移行を実施する">DBの移行を実施する&lt;/h3>
&lt;p>OpenJDKのコンテナイメージを起動し、先ほど取得したjarファイルを使用してDBの移行を実施する&lt;/p>
&lt;pre>&lt;code class="language-shell">docker run --rm -it -v /var/lib/docker/volumes/nexus_nexus-data/_data:/work -w /work/_backup openjdk:11-ea-jdk bash
&lt;/code>&lt;/pre>
&lt;ul>
&lt;li>OpenJDKのコンテナ内で、Database Migrator Utilityを実行する&lt;/li>
&lt;/ul>
&lt;pre>&lt;code class="language-shell">java -Xmx16G -Xms16G -XX:+UseG1GC -XX:MaxDirectMemorySize=28672M -jar nexus-db-migrator-*.jar --migration_type=h2
&lt;/code>&lt;/pre>
&lt;pre>&lt;code class="language-text">17:55:40 [main] WARN c.s.n.d.migrator.MigratorApplication - Please ensure any Nexus Repository instance has been gracefully shut down before proceeding.
17:55:40 [main] INFO c.s.n.d.migrator.MigratorApplication - Do you want to continue [y/n]?
y
17:55:42 [main] INFO c.s.n.d.migrator.MigratorApplication - --content_migration parameter is absent. Setting it to true.
17:55:42 [main] INFO c.s.n.d.migrator.MigratorApplication - Force parameter wasn't found. Setting it to false by default.
17:55:42 [main] INFO c.s.n.d.migrator.MigratorApplication - ------------------------------------------------------------
17:55:42 [main] INFO c.s.n.d.migrator.MigratorApplication - Java version: Oracle Corporation 11
17:55:42 [main] INFO c.s.n.d.migrator.MigratorApplication - JVM arguments: -Xmx16G -Xms16G -XX:+UseG1GC -XX:MaxDirectMemorySize=28672M
17:55:42 [main] INFO c.s.n.d.migrator.MigratorApplication - Migrator arguments: --migration_type=h2 --content_migration=true --export_json=false --force=false
17:55:42 [main] INFO c.s.n.d.migrator.MigratorApplication - ------------------------------------------------------------
17:55:43 [main] INFO c.s.n.d.migrator.MigratorApplication - Starting MigratorApplication v3.70.4-02 using Java 11 on cf71fc0d4217 with PID 14 (/work/_backup/nexus-db-migrator-3.70.4-02.jar started by root in /work/_backup)
~省略~
17:55:51 [main] INFO c.s.n.d.m.l.ProvidingJobInfoListener - Migration job finished at Wed Mar 26 17:55:51 UTC 2025
17:55:51 [main] INFO c.s.n.d.m.l.ProvidingJobInfoListener - Migration job took 5 seconds to execute
17:55:51 [main] INFO c.s.n.d.m.l.ProvidingJobInfoListener - 2023 records were processed
17:55:51 [main] INFO c.s.n.d.m.l.ProvidingJobInfoListener - 3 records were filtered
17:55:51 [main] INFO c.s.n.d.m.l.ProvidingJobInfoListener - 0 records were skipped
17:55:51 [main] INFO c.s.n.d.m.l.ProvidingJobInfoListener - 2020 records were migrated
17:55:51 [main] INFO c.s.n.d.m.l.ProvidingJobInfoListener - Created 'Rebuild repository browse' and 'Rebuild repository search' tasks. They will automatically one-time run after starting your Nexus Repository instance.
17:55:51 [main] INFO c.s.n.d.m.l.ProvidingJobInfoListener - Migrated the following formats: [APT, COCOAPODS, CONAN, CONDA, DOCKER, GITLFS, GO, HELM, MAVEN2, NPM, NUGET, P2, PYPI, R, RAW, RUBYGEMS, YUM]
&lt;/code>&lt;/pre>
&lt;ul>
&lt;li>作成されたファイルを所定の場所へ移動する&lt;/li>
&lt;/ul>
&lt;pre>&lt;code class="language-shell">cp nexus.mv.db ../db/
&lt;/code>&lt;/pre>
&lt;pre>&lt;code class="language-shell">chown 200:200 ../db/nexus.mv.db
&lt;/code>&lt;/pre>
&lt;ul>
&lt;li>Nexusの設定ファイルを編集する&lt;/li>
&lt;/ul>
&lt;p>H2を使用するために必要な設定を実施する&lt;/p>
&lt;pre>&lt;code class="language-shell">echo &amp;quot;nexus.datastore.enabled=true&amp;quot; &amp;gt;&amp;gt; /work/etc/nexus.properties
&lt;/code>&lt;/pre>
&lt;ul>
&lt;li>OpenJDKコンテナを終了する&lt;/li>
&lt;/ul>
&lt;pre>&lt;code class="language-shell">exit
&lt;/code>&lt;/pre>
&lt;h3 id="nexusを起動する">Nexusを起動する&lt;/h3>
&lt;pre>&lt;code class="language-shell">docker compose up -d
&lt;/code>&lt;/pre>
&lt;p>Nexusのmigration taskが完了するのを待つ&lt;/p>
&lt;h3 id="h2が使用されていることを確認する">H2が使用されていることを確認する&lt;/h3>
&lt;p>Nexusへブラウザでアクセスし&lt;/p>
&lt;ul>
&lt;li>&lt;span class="marker">admin&lt;/span>でログイン&lt;/li>
&lt;li>上部の歯車アイコンをクリック&lt;/li>
&lt;li>System &amp;gt; Tasks&lt;/li>
&lt;li>filterで&lt;span class="marker">backup&lt;/span>で絞り込む
&lt;ul>
&lt;li>&lt;span class="marker">Admin - Backup H2 Database&lt;/span>&lt;br>
のtaskのみ存在することを確認する&lt;/li>
&lt;/ul>
&lt;/li>
&lt;/ul>
&lt;br>
&lt;h2 id="nexusをupgradeする">Nexusをupgradeする&lt;/h2>
&lt;h3 id="docker-composeの設定変更">docker composeの設定変更&lt;/h3>
&lt;p>使用するNexusのversionを変更する&lt;/p>
&lt;pre>&lt;code class="language-yaml">services:
nexus:
image: sonatype/nexus3:3.78.2
ports:
- 8081:8081
volumes:
- nexus-data:/nexus-data
volumes:
nexus-data: null
&lt;/code>&lt;/pre>
&lt;h3 id="nexusを起動する-1">Nexusを起動する&lt;/h3>
&lt;pre>&lt;code class="language-shell">docker compose up -d
&lt;/code>&lt;/pre>
&lt;p>Nexusのmigration taskが完了するのを待つ&lt;/p>
&lt;br>
&lt;h2 id="参考">参考&lt;/h2>
&lt;blockquote>
&lt;p>Migration Environment Prerequisite Requirements&lt;br>
&lt;a href="https://help.sonatype.com/en/upgrading-to-nexus-repository-3-71-0-and-beyond.html#migration-environment-prerequisite-requirements-252162">https://help.sonatype.com/en/upgrading-to-nexus-repository-3-71-0-and-beyond.html#migration-environment-prerequisite-requirements-252162&lt;/a>&lt;/p>&lt;/blockquote>
&lt;blockquote>
&lt;p>Migrating From OrientDB to H2&lt;br>
&lt;a href="https://help.sonatype.com/en/upgrading-to-nexus-repository-3-71-0-and-beyond.html#migrating-from-orientdb-to-h2-252162">https://help.sonatype.com/en/upgrading-to-nexus-repository-3-71-0-and-beyond.html#migrating-from-orientdb-to-h2-252162&lt;/a>&lt;/p>&lt;/blockquote></description></item><item><title>Blog: WindowsをAnsibleで操作する</title><link>/blog/2025/03/15/controlling_windows_with_ansible/</link><pubDate>Sat, 15 Mar 2025 19:01:20 +0900</pubDate><guid>/blog/2025/03/15/controlling_windows_with_ansible/</guid><description>
&lt;h2 id="概要">概要&lt;/h2>
&lt;p>Ansibleを使用して、Windowsマシンを操作するための最低限必要な設定と操作手順&lt;/p>
&lt;br>
&lt;h2 id="使用した環境">使用した環境&lt;/h2>
&lt;h3 id="操作したいマシンwindows">操作したいマシン(Windows)&lt;/h3>
&lt;ul>
&lt;li>Windows Server 2019&lt;/li>
&lt;li>OSを新規インストールした状態&lt;/li>
&lt;/ul>
&lt;h3 id="ansibleを実行するマシンlinux">Ansibleを実行するマシン(Linux)&lt;/h3>
&lt;ul>
&lt;li>操作対象ごとにAnsible実行環境を作成したいので、Ansible Navigator を使用する&lt;/li>
&lt;/ul>
&lt;blockquote>
&lt;p>Installing ansible-navigator with execution environment support&lt;br>
&lt;a href="https://ansible.readthedocs.io/projects/navigator/installation/">https://ansible.readthedocs.io/projects/navigator/installation/&lt;/a>&lt;/p>&lt;/blockquote>
&lt;ul>
&lt;li>Dockerをインストールしておく&lt;/li>
&lt;/ul>
&lt;br>
&lt;h2 id="windowsの設定">Windowsの設定&lt;/h2>
&lt;h3 id="穴開け用スクリプトを作成">穴開け用スクリプトを作成&lt;/h3>
&lt;p>AnsibleからWindowsにアクセスするための設定を行う。&lt;br>
&lt;a href="https://docs.ansible.com/ansible/latest/os_guide/windows_winrm.html#winrm-setup">https://docs.ansible.com/ansible/latest/os_guide/windows_winrm.html#winrm-setup&lt;/a>&lt;br>
を参考に、穴開け用のPowerShellスクリプトを作成する。&lt;br>
HTTPSでのみアクセスするため、穴開けはHTTPS用のみ実施する。&lt;/p>
&lt;ul>
&lt;li>¥path¥to¥HTTPS_listener.ps1&lt;/li>
&lt;/ul>
&lt;pre>&lt;code class="language-ps"># Create self signed certificate
$certParams = @{
CertStoreLocation = 'Cert:\LocalMachine\My'
DnsName = $env:COMPUTERNAME
NotAfter = (Get-Date).AddYears(1)
Provider = 'Microsoft Software Key Storage Provider'
Subject = &amp;quot;CN=$env:COMPUTERNAME&amp;quot;
}
$cert = New-SelfSignedCertificate @certParams
# Create HTTPS listener
$httpsParams = @{
ResourceURI = 'winrm/config/listener'
SelectorSet = @{
Transport = &amp;quot;HTTPS&amp;quot;
Address = &amp;quot;*&amp;quot;
}
ValueSet = @{
CertificateThumbprint = $cert.Thumbprint
Enabled = $true
}
}
New-WSManInstance @httpsParams
# Opens port 5986 for all profiles
$firewallParams = @{
Action = 'Allow'
Description = 'Inbound rule for Windows Remote Management via WS-Management. [TCP 5986]'
Direction = 'Inbound'
DisplayName = 'Windows Remote Management (HTTPS-In)'
LocalPort = 5986
Profile = 'Any'
Protocol = 'TCP'
}
New-NetFirewallRule @firewallParams
&lt;/code>&lt;/pre>
&lt;h3 id="windows上でスクリプトを実行">Windows上でスクリプトを実行&lt;/h3>
&lt;p>作成したPowerShellスクリプトを、操作したいWindowsマシンで実行する&lt;/p>
&lt;pre>&lt;code class="language-ps">PS C:\Users\Administrator\path\to&amp;gt; .\HTTPS_listener.ps1
&lt;/code>&lt;/pre>
&lt;pre>&lt;code class="language-ps">
wxf : http://schemas.xmlsoap.org/ws/2004/09/transfer
a : http://schemas.xmlsoap.org/ws/2004/08/addressing
w : http://schemas.dmtf.org/wbem/wsman/1/wsman.xsd
lang : ja-JP
Address : http://schemas.xmlsoap.org/ws/2004/08/addressing/role/anonymous
ReferenceParameters : ReferenceParameters
Caption :
Description : Inbound rule for Windows Remote Management via WS-Management. [TCP 5986]
ElementName : Windows Remote Management (HTTPS-In)
InstanceID : {f7c8f0c5-9b6e-4ffc-9264-74fcf9db2d4e}
CommonName :
PolicyKeywords :
Enabled : True
PolicyDecisionStrategy : 2
PolicyRoles :
ConditionListType : 3
CreationClassName : MSFT|FW|FirewallRule|{f7c8f0c5-9b6e-4ffc-9264-74fcf9db2d4e}
ExecutionStrategy : 2
Mandatory :
PolicyRuleName :
Priority :
RuleUsage :
SequencedActions : 3
SystemCreationClassName :
SystemName :
Action : Allow
Direction : Inbound
DisplayGroup :
DisplayName : Windows Remote Management (HTTPS-In)
EdgeTraversalPolicy : Block
EnforcementStatus : NotApplicable
LocalOnlyMapping : False
LooseSourceMapping : False
Owner :
Platforms : {}
PolicyStoreSource : PersistentStore
PolicyStoreSourceType : Local
PrimaryStatus : OK
Profiles : 0
RuleGroup :
Status : 規則は、ストアから正常に解析されました。 (65536)
StatusCode : 65536
PSComputerName :
Name : {f7c8f0c5-9b6e-4ffc-9264-74fcf9db2d4e}
ID : {f7c8f0c5-9b6e-4ffc-9264-74fcf9db2d4e}
Group :
Profile : Any
Platform : {}
LSM : False
&lt;/code>&lt;/pre>
&lt;br>
&lt;h2 id="ansibleの設定">Ansibleの設定&lt;/h2>
&lt;h3 id="ansible実行環境の設定">Ansible実行環境の設定&lt;/h3>
&lt;p>Ansible Navigatorを使用してAnsibleを実行する環境の設定を行う。&lt;br>
&lt;code>winrm&lt;/code>と&lt;code>psrp&lt;/code>の両方でWindowsへ接続可能なことを確認するため、&lt;br>
Pythonパッケージの&lt;code>pywinrm&lt;/code>と&lt;code>pypsrp&lt;/code>をインストールする。&lt;/p>
&lt;p>collectionは、Windowsの操作に使用するものをインストールする。&lt;/p>
&lt;ul>
&lt;li>/path/to/execution-environment.yml&lt;/li>
&lt;/ul>
&lt;pre>&lt;code class="language-yaml">version: 3
images:
base_image:
name: ghcr.io/ansible-community/community-ee-base:2.18.1-1
dependencies:
ansible_core:
package_pip: ansible-core
ansible_runner:
package_pip: ansible-runner
system:
- unzip
python:
- pywinrm
- pypsrp
galaxy:
collections:
- name: ansible.windows
- name: community.windows
&lt;/code>&lt;/pre>
&lt;ul>
&lt;li>
&lt;p>使用するcollectionの仕様&lt;/p>
&lt;blockquote>
&lt;p>&lt;a href="https://docs.ansible.com/ansible/latest/collections/ansible/windows/index.html#plugins-in-ansible-windows">https://docs.ansible.com/ansible/latest/collections/ansible/windows/index.html#plugins-in-ansible-windows&lt;/a>&lt;/p>&lt;/blockquote>
&lt;blockquote>
&lt;p>&lt;a href="https://docs.ansible.com/ansible/latest/collections/community/windows/index.html#plugins-in-community-windows">https://docs.ansible.com/ansible/latest/collections/community/windows/index.html#plugins-in-community-windows&lt;/a>&lt;/p>&lt;/blockquote>
&lt;/li>
&lt;/ul>
&lt;h3 id="ansible実行環境を作成">Ansible実行環境を作成&lt;/h3>
&lt;p>以下のコマンドで、Ansible実行環境のコンテナイメージを作成する&lt;/p>
&lt;pre>&lt;code class="language-shell">cd /path/to
ansible-builder build --tag local/ansible4win:2.18.1-1
&lt;/code>&lt;/pre>
&lt;h3 id="inventoryを作成">inventoryを作成&lt;/h3>
&lt;p>操作したいWindowsマシンのIPアドレス、認証情報の設定を行う。&lt;br>
&lt;code>winrm&lt;/code>を使用する場合と&lt;code>psrp&lt;/code>を使用する場合で設定が異なる。&lt;/p>
&lt;h4 id="winrm用">(winrm用)&lt;/h4>
&lt;ul>
&lt;li>/path/to/inventories/hosts&lt;/li>
&lt;/ul>
&lt;pre>&lt;code class="language-ini">[win]
&lt;span class="marker">114.51.48.10&lt;/span>
[win:vars]
ansible_user=&lt;span class="marker">administrator&lt;/span>
ansible_password=&lt;span class="marker">nandemo&lt;/span>
ansible_connection=winrm
ansible_winrm_transport=ntlm
ansible_winrm_server_cert_validation=ignore
&lt;/code>&lt;/pre>
&lt;h4 id="winrmの各種パラメータの仕様">winrmの各種パラメータの仕様&lt;/h4>
&lt;blockquote>
&lt;p>&lt;a href="https://ansible.fontein.de/collections/ansible/builtin/winrm_connection.html">https://ansible.fontein.de/collections/ansible/builtin/winrm_connection.html&lt;/a>&lt;/p>&lt;/blockquote>
&lt;h4 id="psrp用">(psrp用)&lt;/h4>
&lt;ul>
&lt;li>/path/to/inventories/hosts&lt;/li>
&lt;/ul>
&lt;pre>&lt;code class="language-ini">[win]
&lt;span class="marker">114.51.48.10&lt;/span>
[win:vars]
ansible_user=&lt;span class="marker">administrator&lt;/span>
ansible_password=&lt;span class="marker">nandemo&lt;/span>
ansible_connection=psrp
ansible_psrp_auth=ntlm
ansible_psrp_cert_validation=ignore
&lt;/code>&lt;/pre>
&lt;h4 id="psrpの各種パラメータの仕様">psrpの各種パラメータの仕様&lt;/h4>
&lt;blockquote>
&lt;p>&lt;a href="https://ansible.fontein.de/collections/ansible/builtin/psrp_connection.html">https://ansible.fontein.de/collections/ansible/builtin/psrp_connection.html&lt;/a>&lt;/p>&lt;/blockquote>
&lt;h3 id="playbookを作成">playbookを作成&lt;/h3>
&lt;p>Windows Serverを新規インストールした状態ではpingは通らないため、&lt;br>
動作確認用playbookは、&lt;code>whoami&lt;/code>コマンドを実行させ、その出力を表示する定義で作成した。&lt;/p>
&lt;ul>
&lt;li>/path/to/playbooks/cmd.yml&lt;/li>
&lt;/ul>
&lt;pre>&lt;code class="language-yaml">---
- hosts: all
gather_facts: false
tasks:
- name: Exec command
win_command: whoami
register: return_whoami
- name: Debug output
debug:
msg: &amp;quot;{{ return_whoami }}&amp;quot;
&lt;/code>&lt;/pre>
&lt;h3 id="ansible-navigatorの設定">Ansible Navigatorの設定&lt;/h3>
&lt;p>使用するAnsible実行環境の各種設定を行う。&lt;br>
Ansible Navigator実行時に、毎回inventoryを指定するのが面倒なので、使用するinventoryを指定しておく。&lt;/p>
&lt;ul>
&lt;li>/path/to/ansible-navigator.yml&lt;/li>
&lt;/ul>
&lt;pre>&lt;code class="language-yaml"># # cspell:ignore cmdline, workdir
---
ansible-navigator:
ansible:
inventory:
help: False
entries:
- ./inventories/hosts
execution-environment:
image: local/ansible4win:2.18.1-1
logging:
level: critical
mode: stdout
time-zone: Japan
&lt;/code>&lt;/pre>
&lt;br>
&lt;h2 id="ansible-navigatorでplaybookを実行">Ansible Navigatorでplaybookを実行&lt;/h2>
&lt;p>以下のコマンドでAnsibleを実行&lt;/p>
&lt;pre>&lt;code class="language-shell">ansible-navigator run --ep playbooks/cmd.yml
&lt;/code>&lt;/pre>
&lt;pre>&lt;code class="language-shell">PLAY [all] *************************************************************************************************************
TASK [Exec command] ****************************************************************************************************
changed: [114.51.48.10]
TASK [Debug output] ****************************************************************************************************
ok: [114.51.48.10] =&amp;gt; {
&amp;quot;msg&amp;quot;: {
&amp;quot;changed&amp;quot;: true,
&amp;quot;cmd&amp;quot;: &amp;quot;whoami&amp;quot;,
&amp;quot;delta&amp;quot;: &amp;quot;0:00:00.093775&amp;quot;,
&amp;quot;end&amp;quot;: &amp;quot;2025-02-19 08:06:18.816572&amp;quot;,
&amp;quot;failed&amp;quot;: false,
&amp;quot;rc&amp;quot;: 0,
&amp;quot;start&amp;quot;: &amp;quot;2025-02-19 08:06:18.722797&amp;quot;,
&amp;quot;stderr&amp;quot;: &amp;quot;&amp;quot;,
&amp;quot;stderr_lines&amp;quot;: [],
&amp;quot;stdout&amp;quot;: &amp;quot;win-24gakusei\\administrator\r\n&amp;quot;,
&amp;quot;stdout_lines&amp;quot;: [
&amp;quot;win-24gakusei\\administrator&amp;quot;
]
}
}
PLAY RECAP *************************************************************************************************************
114.51.48.10 : ok=2 changed=1 unreachable=0 failed=0 skipped=0 rescued=0 ignored=0
&lt;/code>&lt;/pre>
&lt;br>
&lt;h2 id="参考">参考&lt;/h2>
&lt;blockquote>
&lt;p>AnsibleでWindowsサーバーを設定してみた-環境準備編-&lt;br>
&lt;a href="https://blog.jbs.co.jp/entry/2023/05/30/135558">https://blog.jbs.co.jp/entry/2023/05/30/135558&lt;/a>&lt;/p>&lt;/blockquote></description></item><item><title>Blog: Hugo：任意のPageをsitemap.xmlに載せない</title><link>/blog/2025/03/04/hugo_exclude_page_from_sitemap/</link><pubDate>Tue, 04 Mar 2025 16:55:40 +0900</pubDate><guid>/blog/2025/03/04/hugo_exclude_page_from_sitemap/</guid><description>
&lt;h2 id="設定例">設定例&lt;/h2>
&lt;p>&lt;code>sitemap.xml&lt;/code>に載せたくないページに以下の設定を追加する&lt;/p>
&lt;pre>&lt;code class="language-text">---
sitemap:
disable: true
---
&lt;/code>&lt;/pre>
&lt;p>※&lt;code>Hugo v0.125.0&lt;/code> から指定可能&lt;/p>
&lt;br>
&lt;h3 id="参考">参考&lt;/h3>
&lt;blockquote>
&lt;p>&lt;a href="https://gohugo.io/methods/page/sitemap/">https://gohugo.io/methods/page/sitemap/&lt;/a>&lt;/p>&lt;/blockquote></description></item><item><title>Blog: Windows：SideloadlyでiPadにアプリをインストールする</title><link>/blog/2024/09/08/windows-install-app-to-ipad-with-sideloadly/</link><pubDate>Sun, 08 Sep 2024 01:02:43 +0900</pubDate><guid>/blog/2024/09/08/windows-install-app-to-ipad-with-sideloadly/</guid><description>
&lt;p>Windows環境にインストールしたSideloadlyを使用し、&lt;br>
iPadに.ipaファイルをインストールした際の手順&lt;/p>
&lt;br>
&lt;h2 id="任意microsoft-defenderに除外設定を追加">(任意)Microsoft Defenderに除外設定を追加&lt;/h2>
&lt;p>※管理者権限が必要&lt;br>
脆弱性が検出される.ipaファイルをインストールする際は、予め除外設定を実施しておく&lt;/p>
&lt;h3 id="windowsセキュリティを開く">Windowsセキュリティを開く&lt;/h3>
&lt;ul>
&lt;li>Windowsセキュリティ&lt;/li>
&lt;li>ウィルスと脅威の防止&lt;/li>
&lt;li>ウィルスと脅威の防止の設定 の&lt;code>設定の管理&lt;/code>&lt;/li>
&lt;li>除外 の&lt;code>除外の追加または削除&lt;/code>&lt;/li>
&lt;li>&lt;code>除外の追加&lt;/code>ボタン押下&lt;/li>
&lt;li>以下の設定で除外に追加
&lt;ul>
&lt;li>フォルダー&lt;/li>
&lt;li>&lt;code>C:\Users\&lt;span class="marker">ユーザー名&lt;/span>\AppData\Local\Temp&lt;/code>&lt;/li>
&lt;/ul>
&lt;/li>
&lt;/ul>
&lt;br>
&lt;h2 id="インストール手順">インストール手順&lt;/h2>
&lt;h3 id="windowssideloadlyを起動">(Windows)Sideloadlyを起動&lt;/h3>
&lt;h3 id="usbケーブルでwindowsとipadを繋ぐ">USBケーブルでWindowsとiPadを繋ぐ&lt;/h3>
&lt;h3 id="ipad端末を信頼する">(iPad)端末を信頼する&lt;/h3>
&lt;p>ポップが表示されるため、&lt;code>信頼&lt;/code>を押下&lt;/p>
&lt;h3 id="windowsipaファイルを選択">(Windows).ipaファイルを選択&lt;/h3>
&lt;p>インストールする.ipaファイルをSideloadlyにドラッグ＆ドロップする&lt;/p>
&lt;h3 id="windowssideloadlyにappleidを入力">(Windows)SideloadlyにAppleIDを入力&lt;/h3>
&lt;p>SideloadlyのAppleID入力欄にAppleIDを入力する&lt;/p>
&lt;h3 id="windowssideloadlyのstartを押下">(Windows)Sideloadlyの&lt;code>Start&lt;/code>を押下&lt;/h3>
&lt;h3 id="windowsappleidのパスワードを入力">(Windows)AppleIDのパスワードを入力&lt;/h3>
&lt;p>&lt;code>Start&lt;/code>を押下後、パスワード入力を求められるため、パスワードを入力する&lt;/p>
&lt;h3 id="ipadアプリがインストールされたことを確認">(iPad)アプリがインストールされたことを確認&lt;/h3></description></item><item><title>Blog: Windows：Sideloadlyのインストール手順</title><link>/blog/2024/09/07/windows-how-to-install-sideloadly/</link><pubDate>Sat, 07 Sep 2024 00:05:02 +0900</pubDate><guid>/blog/2024/09/07/windows-how-to-install-sideloadly/</guid><description>
&lt;p>iPadに.ipaファイルをインストールするために、&lt;br>
Windows環境にSideloadlyをインストールした際の手順&lt;/p>
&lt;br>
&lt;h2 id="前提条件">前提条件&lt;/h2>
&lt;ul>
&lt;li>Windows 11 Pro 23H2 64bit&lt;/li>
&lt;li>Sideloadly v0.50.3&lt;/li>
&lt;/ul>
&lt;br>
&lt;h2 id="インストール手順">インストール手順&lt;/h2>
&lt;h3 id="itunesをインストール">iTunesをインストール&lt;/h3>
&lt;p>iTunesは以下からダウンロードする&lt;/p>
&lt;blockquote>
&lt;p>&lt;a href="https://www.apple.com/itunes/download/win64">https://www.apple.com/itunes/download/win64&lt;/a>&lt;/p>&lt;/blockquote>
&lt;p>※Microsoft Store からインストールしないこと&lt;/p>
&lt;h3 id="icloudをインストール">iCloudをインストール&lt;/h3>
&lt;p>iCloudは以下からダウンロードする&lt;/p>
&lt;blockquote>
&lt;p>&lt;a href="https://updates.cdn-apple.com/2020/windows/001-39935-20200911-1A70AA56-F448-11EA-8CC0-99D41950005E/iCloudSetup.exe">https://updates.cdn-apple.com/2020/windows/001-39935-20200911-1A70AA56-F448-11EA-8CC0-99D41950005E/iCloudSetup.exe&lt;/a>&lt;/p>&lt;/blockquote>
&lt;p>※Microsoft Store からインストールしないこと&lt;/p>
&lt;h3 id="sideloadlyをインストール">Sideloadlyをインストール&lt;/h3>
&lt;p>Sideloadlyは以下からダウンロードする&lt;/p>
&lt;blockquote>
&lt;p>&lt;a href="https://sideloadly.io/SideloadlySetup64.exe">https://sideloadly.io/SideloadlySetup64.exe&lt;/a>&lt;/p>&lt;/blockquote>
&lt;h3 id="itunesでappleidにログイン">iTunesでAppleIDにログイン&lt;/h3>
&lt;p>※iCloudでログインしないこと&lt;/p>
&lt;h3 id="sideloadlyを起動">Sideloadlyを起動&lt;/h3>
&lt;p>Sideloadlyがエラー無しで起動することを確認する&lt;/p>
&lt;br>
&lt;h2 id="エラーが発生した場合">エラーが発生した場合&lt;/h2>
&lt;h3 id="microsoft-visual-c-2010-service-pack-1-redistributable-package-x64-をインストール">Microsoft Visual C++ 2010 Service Pack 1 Redistributable Package (x64) をインストール&lt;/h3>
&lt;p>以下からダウンロードする&lt;/p>
&lt;blockquote>
&lt;p>&lt;a href="https://download.microsoft.com/download/1/6/5/165255E7-1014-4D0A-B094-B6A430A6BFFC/vcredist_x64.exe">https://download.microsoft.com/download/1/6/5/165255E7-1014-4D0A-B094-B6A430A6BFFC/vcredist_x64.exe&lt;/a>&lt;/p>&lt;/blockquote>
&lt;h3 id="microsoft-visual-c-2013-redistributable-package-x64-をインストール">Microsoft Visual C++ 2013 Redistributable Package (x64) をインストール&lt;/h3>
&lt;p>以下からダウンロードする&lt;/p>
&lt;blockquote>
&lt;p>&lt;a href="https://download.microsoft.com/download/1/6/5/165255E7-1014-4D0A-B094-B6A430A6BFFC/vcredist_x64.exe">https://download.microsoft.com/download/1/6/5/165255E7-1014-4D0A-B094-B6A430A6BFFC/vcredist_x64.exe&lt;/a>&lt;/p>&lt;/blockquote>
&lt;br>
&lt;h2 id="参考">参考&lt;/h2>
&lt;h3 id="sideloadly起動時のエラー">Sideloadly起動時のエラー&lt;/h3>
&lt;p>Sideloadlyのみインストールし、Sideloadlyを起動した際に発生したエラー&lt;/p>
&lt;pre>&lt;code>---------------------------
Question
---------------------------
Local Anisette problem:&amp;lt;br/&amp;gt;
Redist install failed: Could not install VC Redist: exit status 3010&amp;lt;br/&amp;gt;
Please install it yourself! URL: https://aka.ms/highdpimfc2013x64enu&amp;lt;br/&amp;gt;
&amp;lt;br/&amp;gt;
Or please re-run Sideloadly as admin.&amp;lt;br/&amp;gt;
&amp;lt;br/&amp;gt;
&amp;lt;br/&amp;gt;
NOTICE: Something is wrong with iTunes DLLs on your system: Failed to load C:\Users\User\AppData\Local\Sideloadly\an\libxml2.dll: The specified module could not be found.&amp;lt;br/&amp;gt;
Please try the following steps one by one: &amp;lt;br/&amp;gt;
1. If this is the first time you see this error then try downloading files again (press Yes button below);&amp;lt;br/&amp;gt;
2. Make sure that &amp;lt;a href='https://www.apple.com/itunes/download/win64'&amp;gt;iTunes&amp;lt;/a&amp;gt; &amp;amp; &amp;lt;a href='https://updates.cdn-apple.com/2020/windows/001-39935-20200911-1A70AA56-F448-11EA-8CC0-99D41950005E/iCloudSetup.exe'&amp;gt;iCloud&amp;lt;/a&amp;gt; WEB versions are installed in your system (NOT from Microsoft Store!);&amp;lt;br/&amp;gt;
2a. If you had iTunes&amp;amp;iCloud from Microsoft Store then you should first FULLY uninstall them before installing non-MS versions;&amp;lt;br/&amp;gt;
3. (Re-)install &amp;lt;a href='https://download.microsoft.com/download/1/6/5/165255E7-1014-4D0A-B094-B6A430A6BFFC/vcredist_x64.exe'&amp;gt;Microsoft Visual C++ 2010 Service Pack 1 Redistributable Package (x64)&amp;lt;/a&amp;gt;;&amp;lt;br/&amp;gt;
4. (Re-)install &amp;lt;a href='https://aka.ms/highdpimfc2013x64enu'&amp;gt;Microsoft Visual C++ 2013 Redistributable Package (x64)&amp;lt;/a&amp;gt;;&amp;lt;br/&amp;gt;
5. Login to your Apple ID in iTunes but not in iCloud;&amp;lt;br/&amp;gt;
6. If all the above steps are performed but nothing helped then you may want to use Remote Anisette (available to our Patreon supporters) as it does not rely on your local system.xml err Failed to load C:\Users\User\AppData\Local\Sideloadly\an\libxml2.dll: The specified module could not be found.&amp;lt;br/&amp;gt;
Do you want to download it?&amp;lt;br/&amp;gt;
It's highly recommended to use local Anisette.
---------------------------
&amp;amp;Yes &amp;amp;No
---------------------------
&lt;/code>&lt;/pre></description></item><item><title>Blog: Windows：Faster Whisperを使用可能にする</title><link>/blog/2023/05/08/install-faster-whisper-on-windows/</link><pubDate>Mon, 08 May 2023 18:57:15 +0900</pubDate><guid>/blog/2023/05/08/install-faster-whisper-on-windows/</guid><description>
&lt;h2 id="概要">概要&lt;/h2>
&lt;p>Faster Whisper(&lt;a href="https://github.com/guillaumekln/faster-whisper">https://github.com/guillaumekln/faster-whisper&lt;/a>) をインストールし、&lt;br>
正常動作するところまでを確認(現時点の最新版である&lt;code>v0.5.1&lt;/code>を使用)&lt;br>
Faster Whisperは、OpenAIのWhisperを再実装し、Whisperより4倍速くなったらしい&lt;/p>
&lt;br>
&lt;h2 id="使用したpcのスペック">使用したPCのスペック&lt;/h2>
&lt;ul>
&lt;li>CPU：Core i7 11800H&lt;/li>
&lt;li>メモリ：16GB&lt;/li>
&lt;li>GPU：GeForce RTX 3070&lt;/li>
&lt;li>OS：Windows 11 Home&lt;/li>
&lt;/ul>
&lt;br>
&lt;h2 id="gpuを使用可能にするための準備">GPUを使用可能にするための準備&lt;/h2>
&lt;p>Faster Whisper の処理をGPUで実行するために必要なソフトウェアをインストールする&lt;/p>
&lt;h3 id="cuda-toolkitのダウンロード">CUDA Toolkitのダウンロード&lt;/h3>
&lt;p>CUDA Toolkit の最新バージョンは、&lt;code>12.X&lt;/code> 系 だが、&lt;br>
Faster Whisper は対応していないため、&lt;code>11.X&lt;/code> 系 をインストールする&lt;/p>
&lt;blockquote>
&lt;p>&lt;a href="https://developer.nvidia.com/cuda-11-8-0-download-archive">https://developer.nvidia.com/cuda-11-8-0-download-archive&lt;/a>&lt;/p>&lt;/blockquote>
&lt;p>から &lt;code>CUDA Toolkit 11.8&lt;/code> をダウンロードする&lt;/p>
&lt;ul>
&lt;li>Operating System：&lt;code>Windows&lt;/code>&lt;/li>
&lt;li>Architecture：&lt;code>x86_64&lt;/code>&lt;/li>
&lt;li>Version：&lt;code>11&lt;/code>&lt;/li>
&lt;li>Installer Type：&lt;code>exe(network)&lt;/code>&lt;/li>
&lt;/ul>
&lt;p>を選択し、インストーラーをダウンロードする&lt;/p>
&lt;h3 id="cuda-toolkitのインストール">CUDA Toolkitのインストール&lt;/h3>
&lt;p>ダウンロードしたインストーラーを実行し、&lt;code>CUDA Toolkit 11.8&lt;/code> をインストールする&lt;br>
(割と時間が掛かる)&lt;/p>
&lt;h3 id="zlibのダウンロード">Zlibのダウンロード&lt;/h3>
&lt;blockquote>
&lt;p>&lt;a href="https://www.winimage.com/zLibDll/zlib123dllx64.zip">https://www.winimage.com/zLibDll/zlib123dllx64.zip&lt;/a>&lt;/p>&lt;/blockquote>
&lt;p>から Zlib をダウンロードする&lt;/p>
&lt;h3 id="zlibの展開">Zlibの展開&lt;/h3>
&lt;p>ダウンロードしたzipファイルを展開し、&lt;code>zlibwapi.dll&lt;/code> を任意のディレクトリに格納する&lt;br>
(ここでは、&lt;code>C:\Program Files\Zlib&lt;/code> を使用する)&lt;/p>
&lt;h3 id="cudnnのダウンロード">cuDNNのダウンロード&lt;/h3>
&lt;p>※NVIDIA DEVELOPERアカウントが必要&lt;/p>
&lt;blockquote>
&lt;p>&lt;a href="https://developer.nvidia.com/cudnn">https://developer.nvidia.com/cudnn&lt;/a>&lt;/p>&lt;/blockquote>
&lt;p>から cuDNN をダウンロードする&lt;br>
CUDA 11.X 系 に対応したものをダウンロードする必要がある&lt;/p>
&lt;h3 id="cudnnの展開">cuDNNの展開&lt;/h3>
&lt;p>ダウンロードしたzipファイルを展開し、&lt;/p>
&lt;ul>
&lt;li>bin&lt;/li>
&lt;li>include&lt;/li>
&lt;li>lib&lt;/li>
&lt;/ul>
&lt;p>を任意のディレクトリに格納する
(ここでは、&lt;code>C:\Program Files\NVIDIA\CUDNN\v8.9&lt;/code> を使用する)&lt;/p>
&lt;h3 id="環境変数の追加">環境変数の追加&lt;/h3>
&lt;pre>&lt;code>control sysdm.cpl
&lt;/code>&lt;/pre>
&lt;p>を実行し、&lt;code>システムのプロパティ&lt;/code>ウィンドウを開く
&lt;br>&lt;br>
&lt;code>詳細設定&lt;/code>タブをクリックし、&lt;code>環境変数&lt;/code>ボタンを押下する
&lt;img src="https://www.tssol.net/media/20230508_01.png" alt="">
&lt;br>&lt;br>
システム環境変数の&lt;code>Path&lt;/code>を選択し、&lt;code>編集&lt;/code>ボタンを押下する
&lt;img src="https://www.tssol.net/media/20230508_02.png" alt="">
&lt;br>&lt;br>
環境変数に&lt;br>
・&lt;code>C:\Program Files\Zlib&lt;/code>&lt;br>
・&lt;code>C:\Program Files\NVIDIA\CUDNN\v8.9\bin&lt;/code>&lt;br>
を追加する&lt;br>
&lt;img src="https://www.tssol.net/media/20230508_03.png" alt="">&lt;/p>
&lt;br>
&lt;h2 id="faster-whisperの実行環境を作成">Faster Whisperの実行環境を作成&lt;/h2>
&lt;h3 id="pythonのインストール">Pythonのインストール&lt;/h3>
&lt;p>Python 3.10.11 を使用した&lt;/p>
&lt;blockquote>
&lt;p>Windows用Pythonのダウンロード先&lt;br>
&lt;a href="https://www.python.org/downloads/windows/">https://www.python.org/downloads/windows/&lt;/a>&lt;/p>&lt;/blockquote>
&lt;h3 id="venv環境を作成">venv環境を作成&lt;/h3>
&lt;pre>&lt;code>mkdir C:\work\faster_whisper
cd C:\work\faster_whisper
py -3.10 -m venv venv
&lt;/code>&lt;/pre>
&lt;h3 id="必要なpython-packageをインストール">必要なPython packageをインストール&lt;/h3>
&lt;pre>&lt;code>venv\Scripts\activate
pip install ctranslate2
pip install faster-whisper
&lt;/code>&lt;/pre>
&lt;br>
&lt;h2 id="faster-whisperの動作確認">Faster Whisperの動作確認&lt;/h2>
&lt;h3 id="動作確認用コード">動作確認用コード&lt;/h3>
&lt;pre>&lt;code class="language-python">from faster_whisper import WhisperModel
model_size = &amp;quot;large-v2&amp;quot;
# Run on GPU with FP16
model = WhisperModel(model_size, device=&amp;quot;cuda&amp;quot;, compute_type=&amp;quot;float16&amp;quot;)
# or run on GPU with INT8
# model = WhisperModel(model_size, device=&amp;quot;cuda&amp;quot;, compute_type=&amp;quot;int8_float16&amp;quot;)
# or run on CPU with INT8
# model = WhisperModel(model_size, device=&amp;quot;cpu&amp;quot;, compute_type=&amp;quot;int8&amp;quot;)
segments, info = model.transcribe(&amp;quot;stereo_diarization.wav&amp;quot;, beam_size=5)
print(&amp;quot;Detected language '%s' with probability %f&amp;quot; % (info.language, info.language_probability))
for segment in segments:
print(&amp;quot;[%.2fs -&amp;gt; %.2fs] %s&amp;quot; % (segment.start, segment.end, segment.text))
&lt;/code>&lt;/pre>
&lt;p>文字起こしする音源は、FasterWhisperのGitHubリポジトリ内のテストデータを使用した&lt;/p>
&lt;blockquote>
&lt;p>&lt;a href="https://github.com/guillaumekln/faster-whisper/raw/master/tests/data/stereo_diarization.wav">https://github.com/guillaumekln/faster-whisper/raw/master/tests/data/stereo_diarization.wav&lt;/a>&lt;/p>&lt;/blockquote>
&lt;h3 id="実行結果">実行結果&lt;/h3>
&lt;pre>&lt;code>Detected language 'en' with probability 0.999023
[0.00s -&amp;gt; 4.00s] He began a confused complaint against the wizard, who had vanished behind the curtain
[4.00s -&amp;gt; 4.72s] on the left.
&lt;/code>&lt;/pre>
&lt;br>
&lt;h2 id="参考">参考&lt;/h2>
&lt;h3 id="faster-whisper">Faster Whisper&lt;/h3>
&lt;blockquote>
&lt;p>&lt;a href="https://github.com/guillaumekln/faster-whisper">https://github.com/guillaumekln/faster-whisper&lt;/a>&lt;/p>&lt;/blockquote>
&lt;h3 id="cudnnのインストール手順">cuDNNのインストール手順&lt;/h3>
&lt;blockquote>
&lt;p>&lt;a href="https://docs.nvidia.com/deeplearning/cudnn/install-guide/index.html#install-windows">https://docs.nvidia.com/deeplearning/cudnn/install-guide/index.html#install-windows&lt;/a>&lt;/p>&lt;/blockquote></description></item><item><title>Blog: GitLab：BitBucketをMirroring repositoryに使用する</title><link>/blog/2023/03/02/gitlab-set-mirroring-repository-with-bitbucket/</link><pubDate>Thu, 02 Mar 2023 19:16:57 +0900</pubDate><guid>/blog/2023/03/02/gitlab-set-mirroring-repository-with-bitbucket/</guid><description>
&lt;h2 id="ミラーリングの設定を開く">ミラーリングの設定を開く&lt;/h2>
&lt;p>&lt;img src="https://www.tssol.net/media/20230301_01.jpg" alt="">&lt;/p>
&lt;h3 id="左側メニューのsettingsからrepositoryをクリックする">左側メニューの「Settings」から「Repository」をクリックする&lt;/h3>
&lt;br>
&lt;h3 id="mirroring-repositoriesの右側のexpandを押下">「Mirroring repositories」の右側の「Expand」を押下&lt;/h3>
&lt;p>&lt;br>&lt;br>&lt;/p>
&lt;h2 id="ミラーリング先を設定">ミラーリング先を設定&lt;/h2>
&lt;p>&lt;img src="https://www.tssol.net/media/20230301_02.jpg" alt="">&lt;/p>
&lt;h3 id="git-repository-url-に以下の形式でミラーリング先のリポジトリを指定する">Git repository URL に以下の形式でミラーリング先のリポジトリを指定する&lt;/h3>
&lt;pre>&lt;code>ssh://git@bitbucket.org/&lt;span class="marker">リポジトリ所有者名&lt;/span>/&lt;span class="marker">リポジトリ名&lt;/span>.git
&lt;/code>&lt;/pre>
&lt;p>※BitbucketのSSHからのgit cloneコマンドの&lt;br>
　先頭に「ssh://」を付け、&lt;span class="marker">リポジトリ所有者名&lt;/span>直前の「:」を「/」に変えたもの&lt;/p>
&lt;br>
&lt;h3 id="authentication-method-をssh-public-keyに設定">Authentication method を「SSH public key」に設定&lt;/h3>
&lt;br>
&lt;h3 id="mirror-repositoryボタンを押下">「Mirror repository」ボタンを押下&lt;/h3>
&lt;p>&lt;br>&lt;br>&lt;/p>
&lt;h2 id="ssh-public-key-の取得">SSH public key の取得&lt;/h2>
&lt;h3 id="画面が更新されたらmirrored-repositories一覧一番左のボタンcopy-ssh-public-keyを押下">画面が更新されたら、Mirrored repositories一覧、一番左のボタン「Copy SSH public key」を押下&lt;/h3>
&lt;p>&lt;img src="https://www.tssol.net/media/20230301_03.jpg" alt="">&lt;/p>
&lt;p>&lt;br>&lt;br>&lt;/p>
&lt;h2 id="bitbucketにssh-keyを追加">BitbucketにSSH keyを追加&lt;/h2>
&lt;h3 id="bitbucketのpersonal-settingsへ移動し左側メニューのssh-keysをクリックしadd-keyを押下">BitbucketのPersonal settingsへ移動し、左側メニューの「SSH keys」をクリックし、「Add key」を押下&lt;/h3>
&lt;p>&lt;img src="https://www.tssol.net/media/20230301_04.jpg" alt="">&lt;/p>
&lt;br>
&lt;h3 id="label-に何か入力しkey-にコピーした内容をペーストその後add-keyを押下">Label に何か入力し、Key にコピーした内容をペースト、その後「Add key」を押下&lt;/h3>
&lt;p>&lt;img src="https://www.tssol.net/media/20230301_05.jpg" alt="">&lt;/p>
&lt;p>&lt;br>&lt;br>&lt;/p>
&lt;h2 id="ミラーリングを実行">ミラーリングを実行&lt;/h2>
&lt;ul>
&lt;li>GitLabリポジトリへのコミット&lt;/li>
&lt;li>Repository Settings画面からミラーリング実行(Copy SSH public keyボタンのとなり)&lt;/li>
&lt;/ul>
&lt;p>等でBitbucketのリポジトリに対してミラーリングを実行できる&lt;/p></description></item><item><title>Blog: Django：HTTPレスポンスでファイルを返す</title><link>/blog/2021/02/20/django-send-file-in-http-response/</link><pubDate>Sat, 20 Feb 2021 19:32:13 +0900</pubDate><guid>/blog/2021/02/20/django-send-file-in-http-response/</guid><description>
&lt;h2 id="実装例">実装例&lt;/h2>
&lt;pre>&lt;code class="language-python">from django.http import FileResponse
from django.views.generic.base import View
class FileResponseView(View):
def get(self, request, *args, **kwargs):
response = FileResponse(open('&lt;span class="marker">送信するファイルのパス&lt;/span>', 'rb'))
response['content_type'] = '&lt;span class="marker">application/zip&lt;/span>'
response['Content-Disposition'] = 'attachment; filename=&lt;span class="marker">ファイル名&lt;/span>'
return response
&lt;/code>&lt;/pre></description></item><item><title>Blog: Debian系：pipでuwsgiをインストールする</title><link>/blog/2021/02/13/debian-install-uwsgi-with-pip/</link><pubDate>Sat, 13 Feb 2021 15:50:49 +0900</pubDate><guid>/blog/2021/02/13/debian-install-uwsgi-with-pip/</guid><description>
&lt;h2 id="必要なpackageのインストール">必要なpackageのインストール&lt;/h2>
&lt;h3 id="python2系でuwsgiを使用する場合">Python2系でuwsgiを使用する場合&lt;/h3>
&lt;pre>&lt;code class="language-shell">apt-get install -y gcc python2.7-dev
&lt;/code>&lt;/pre>
&lt;h3 id="python3系でuwsgiを使用する場合">Python3系でuwsgiを使用する場合&lt;/h3>
&lt;pre>&lt;code class="language-shell">apt-get install -y gcc python&lt;span class="marker">3&lt;/span>-dev
&lt;/code>&lt;/pre>
&lt;br>
&lt;h2 id="packageが不足している場合のエラー">packageが不足している場合のエラー&lt;/h2>
&lt;pre>&lt;code class="language-shell">pip install uwsgi
&lt;/code>&lt;/pre>
&lt;pre>&lt;code class="language-shell">Collecting uwsgi
Using cached https://files.pythonhosted.org/packages/a2/c9/a2d5737f63cd9df4317a4acc15d1ddf4952e28398601d8d7d706c16381e0/uwsgi-2.0.17.1.tar.gz
Building wheels for collected packages: uwsgi
Running setup.py bdist_wheel for uwsgi ... error
Complete output from command /usr/local/bin/python -u -c &amp;quot;import setuptools, tokenize;__file__='/tmp/pip-install-lbdb9gq3/uwsgi/setup.py';f=getattr(tokenize, 'open', open)(__file__);code=f.read().replace('\r\n', '\n');f.close();exec(compile(code, __file__, 'exec'))&amp;quot; bdist_wheel -d /tmp/pip-wheel-tabhcviq --python-tag cp36:
/usr/local/lib/python3.6/distutils/dist.py:261: UserWarning: Unknown distribution option: 'descriptions'
warnings.warn(msg)
running bdist_wheel
running build
running build_py
creating build
creating build/lib
copying uwsgidecorators.py -&amp;gt; build/lib
installing to build/bdist.linux-x86_64/wheel
running install
using profile: buildconf/default.ini
detected include path: ['/usr/lib/gcc/x86_64-linux-gnu/6/include', '/usr/local/include', '/usr/lib/gcc/x86_64-linux-gnu/6/include-fixed', '/usr/include']
Patching &amp;quot;bin_name&amp;quot; to properly install_scripts dir
detected CPU cores: 4
configured CFLAGS: -O2 -I. -Wall -D_LARGEFILE_SOURCE -D_FILE_OFFSET_BITS=64 -Wextra -Wno-unused-parameter -Wno-missing-field-initializers -DUWSGI_LOCK_USE_MUTEX -DUWSGI_EVENT_USE_EPOLL -DUWSGI_EVENT_TIMER_USE_TIMERFD -DUWSGI_EVENT_TIMER_USE_TIMERFD_NOINC -DUWSGI_EVENT_FILEMONITOR_USE_INOTIFY -DUWSGI_VERSION=&amp;quot;\&amp;quot;2.0.17.1\&amp;quot;&amp;quot; -DUWSGI_VERSION_BASE=&amp;quot;2&amp;quot; -DUWSGI_VERSION_MAJOR=&amp;quot;0&amp;quot; -DUWSGI_VERSION_MINOR=&amp;quot;17&amp;quot; -DUWSGI_VERSION_REVISION=&amp;quot;1&amp;quot; -DUWSGI_VERSION_CUSTOM=&amp;quot;\&amp;quot;\&amp;quot;&amp;quot; -DUWSGI_YAML -DUWSGI_PLUGIN_DIR=&amp;quot;\&amp;quot;.\&amp;quot;&amp;quot; -DUWSGI_DECLARE_EMBEDDED_PLUGINS=&amp;quot;UDEP(python);UDEP(gevent);UDEP(ping);UDEP(cache);UDEP(nagios);UDEP(rrdtool);UDEP(carbon);UDEP(rpc);UDEP(corerouter);UDEP(fastrouter);UDEP(http);UDEP(signal);UDEP(syslog);UDEP(rsyslog);UDEP(logsocket);UDEP(router_uwsgi);UDEP(router_redirect);UDEP(router_basicauth);UDEP(zergpool);UDEP(redislog);UDEP(mongodblog);UDEP(router_rewrite);UDEP(router_http);UDEP(logfile);UDEP(router_cache);UDEP(rawrouter);UDEP(router_static);UDEP(sslrouter);UDEP(spooler);UDEP(cheaper_busyness);UDEP(symcall);UDEP(transformation_tofile);UDEP(transformation_gzip);UDEP(transformation_chunked);UDEP(transformation_offload);UDEP(router_memcached);UDEP(router_redis);UDEP(router_hash);UDEP(router_expires);UDEP(router_metrics);UDEP(transformation_template);UDEP(stats_pusher_socket);&amp;quot; -DUWSGI_LOAD_EMBEDDED_PLUGINS=&amp;quot;ULEP(python);ULEP(gevent);ULEP(ping);ULEP(cache);ULEP(nagios);ULEP(rrdtool);ULEP(carbon);ULEP(rpc);ULEP(corerouter);ULEP(fastrouter);ULEP(http);ULEP(signal);ULEP(syslog);ULEP(rsyslog);ULEP(logsocket);ULEP(router_uwsgi);ULEP(router_redirect);ULEP(router_basicauth);ULEP(zergpool);ULEP(redislog);ULEP(mongodblog);ULEP(router_rewrite);ULEP(router_http);ULEP(logfile);ULEP(router_cache);ULEP(rawrouter);ULEP(router_static);ULEP(sslrouter);ULEP(spooler);ULEP(cheaper_busyness);ULEP(symcall);ULEP(transformation_tofile);ULEP(transformation_gzip);ULEP(transformation_chunked);ULEP(transformation_offload);ULEP(router_memcached);ULEP(router_redis);ULEP(router_hash);ULEP(router_expires);ULEP(router_metrics);ULEP(transformation_template);ULEP(stats_pusher_socket);&amp;quot;
*** uWSGI compiling server core ***
[thread 0][gcc -pthread] core/utils.o
[thread 1][gcc -pthread] core/protocol.o
[thread 2][gcc -pthread] core/socket.o
[thread 3][gcc -pthread] core/logging.o
In file included from core/utils.c:1:0:
./uwsgi.h:165:19: fatal error: stdio.h: No such file or directory
#include &amp;lt;stdio.h&amp;gt;
^
In file included from core/protocol.c:1:0:
./uwsgi.h:165:19: fatal error: stdio.h: No such file or directory
#include &amp;lt;stdio.h&amp;gt;
^
compilation terminated.
compilation terminated.
In file included from core/logging.c:2:0:
./uwsgi.h:165:19: fatal error: stdio.h: No such file or directory
#include &amp;lt;stdio.h&amp;gt;
^
compilation terminated.
In file included from core/socket.c:1:0:
./uwsgi.h:165:19: fatal error: stdio.h: No such file or directory
#include &amp;lt;stdio.h&amp;gt;
^
compilation terminated.
----------------------------------------
Failed building wheel for uwsgi
Running setup.py clean for uwsgi
Failed to build uwsgi
Installing collected packages: uwsgi
Running setup.py install for uwsgi ... error
Complete output from command /usr/local/bin/python -u -c &amp;quot;import setuptools, tokenize;__file__='/tmp/pip-install-lbdb9gq3/uwsgi/setup.py';f=getattr(tokenize, 'open', open)(__file__);code=f.read().replace('\r\n', '\n');f.close();exec(compile(code, __file__, 'exec'))&amp;quot; install --record /tmp/pip-record-rejxmt8l/install-record.txt --single-version-externally-managed --compile:
/usr/local/lib/python3.6/distutils/dist.py:261: UserWarning: Unknown distribution option: 'descriptions'
warnings.warn(msg)
running install
using profile: buildconf/default.ini
detected include path: ['/usr/lib/gcc/x86_64-linux-gnu/6/include', '/usr/local/include', '/usr/lib/gcc/x86_64-linux-gnu/6/include-fixed', '/usr/include']
Patching &amp;quot;bin_name&amp;quot; to properly install_scripts dir
detected CPU cores: 4
configured CFLAGS: -O2 -I. -Wall -D_LARGEFILE_SOURCE -D_FILE_OFFSET_BITS=64 -Wextra -Wno-unused-parameter -Wno-missing-field-initializers -DUWSGI_LOCK_USE_MUTEX -DUWSGI_EVENT_USE_EPOLL -DUWSGI_EVENT_TIMER_USE_TIMERFD -DUWSGI_EVENT_TIMER_USE_TIMERFD_NOINC -DUWSGI_EVENT_FILEMONITOR_USE_INOTIFY -DUWSGI_VERSION=&amp;quot;\&amp;quot;2.0.17.1\&amp;quot;&amp;quot; -DUWSGI_VERSION_BASE=&amp;quot;2&amp;quot; -DUWSGI_VERSION_MAJOR=&amp;quot;0&amp;quot; -DUWSGI_VERSION_MINOR=&amp;quot;17&amp;quot; -DUWSGI_VERSION_REVISION=&amp;quot;1&amp;quot; -DUWSGI_VERSION_CUSTOM=&amp;quot;\&amp;quot;\&amp;quot;&amp;quot; -DUWSGI_YAML -DUWSGI_PLUGIN_DIR=&amp;quot;\&amp;quot;.\&amp;quot;&amp;quot; -DUWSGI_DECLARE_EMBEDDED_PLUGINS=&amp;quot;UDEP(python);UDEP(gevent);UDEP(ping);UDEP(cache);UDEP(nagios);UDEP(rrdtool);UDEP(carbon);UDEP(rpc);UDEP(corerouter);UDEP(fastrouter);UDEP(http);UDEP(signal);UDEP(syslog);UDEP(rsyslog);UDEP(logsocket);UDEP(router_uwsgi);UDEP(router_redirect);UDEP(router_basicauth);UDEP(zergpool);UDEP(redislog);UDEP(mongodblog);UDEP(router_rewrite);UDEP(router_http);UDEP(logfile);UDEP(router_cache);UDEP(rawrouter);UDEP(router_static);UDEP(sslrouter);UDEP(spooler);UDEP(cheaper_busyness);UDEP(symcall);UDEP(transformation_tofile);UDEP(transformation_gzip);UDEP(transformation_chunked);UDEP(transformation_offload);UDEP(router_memcached);UDEP(router_redis);UDEP(router_hash);UDEP(router_expires);UDEP(router_metrics);UDEP(transformation_template);UDEP(stats_pusher_socket);&amp;quot; -DUWSGI_LOAD_EMBEDDED_PLUGINS=&amp;quot;ULEP(python);ULEP(gevent);ULEP(ping);ULEP(cache);ULEP(nagios);ULEP(rrdtool);ULEP(carbon);ULEP(rpc);ULEP(corerouter);ULEP(fastrouter);ULEP(http);ULEP(signal);ULEP(syslog);ULEP(rsyslog);ULEP(logsocket);ULEP(router_uwsgi);ULEP(router_redirect);ULEP(router_basicauth);ULEP(zergpool);ULEP(redislog);ULEP(mongodblog);ULEP(router_rewrite);ULEP(router_http);ULEP(logfile);ULEP(router_cache);ULEP(rawrouter);ULEP(router_static);ULEP(sslrouter);ULEP(spooler);ULEP(cheaper_busyness);ULEP(symcall);ULEP(transformation_tofile);ULEP(transformation_gzip);ULEP(transformation_chunked);ULEP(transformation_offload);ULEP(router_memcached);ULEP(router_redis);ULEP(router_hash);ULEP(router_expires);ULEP(router_metrics);ULEP(transformation_template);ULEP(stats_pusher_socket);&amp;quot;
*** uWSGI compiling server core ***
[thread 2][gcc -pthread] core/utils.o
[thread 1][gcc -pthread] core/protocol.o
[thread 0][gcc -pthread] core/socket.o
[thread 3][gcc -pthread] core/logging.o
In file included from core/utils.c:1:0:
./uwsgi.h:165:19: fatal error: stdio.h: No such file or directory
#include &amp;lt;stdio.h&amp;gt;
^
compilation terminated.
In file included from core/socket.c:1:0:
./uwsgi.h:165:19: fatal error: stdio.h: No such file or directory
#include &amp;lt;stdio.h&amp;gt;
^
compilation terminated.
In file included from core/logging.c:2:0:
./uwsgi.h:165:19: fatal error: stdio.h: No such file or directory
#include &amp;lt;stdio.h&amp;gt;
^
compilation terminated.
In file included from core/protocol.c:1:0:
./uwsgi.h:165:19: fatal error: stdio.h: No such file or directory
#include &amp;lt;stdio.h&amp;gt;
^
compilation terminated.
----------------------------------------
Command &amp;quot;/usr/local/bin/python -u -c &amp;quot;import setuptools, tokenize;__file__='/tmp/pip-install-lbdb9gq3/uwsgi/setup.py';f=getattr(tokenize, 'open', open)(__file__);code=f.read().replace('\r\n', '\n');f.close();exec(compile(code, __file__, 'exec'))&amp;quot; install --record /tmp/pip-record-rejxmt8l/install-record.txt --single-version-externally-managed --compile&amp;quot; failed with error code 1 in /tmp/pip-install-lbdb9gq3/uwsgi/
&lt;/code>&lt;/pre></description></item><item><title>Blog: Django：modelオブジェクトの1レコードをJSON用エスケープされたstrに変換</title><link>/blog/2021/02/06/django-transform-model-instance-to-json-string/</link><pubDate>Sat, 06 Feb 2021 12:13:18 +0900</pubDate><guid>/blog/2021/02/06/django-transform-model-instance-to-json-string/</guid><description>
&lt;h2 id="実装例その１">実装例その１&lt;/h2>
&lt;pre>&lt;code class="language-python">from django.core.serializers import serialize
from models import &lt;span class="marker">MyModel&lt;/span>
def model_to_json_str():
# 1レコードのみ取得
record = MyModel.objects.get(&lt;span class="marker">検索条件&lt;/span>)
# JSON形式のstrとして出力
# ※record を tuple に入れて渡すこと!!
return serialize('json', (record,))
# [{&amp;quot;model&amp;quot;: &amp;quot;myapp.mymodel&amp;quot;, &amp;quot;pk&amp;quot;: 5, &amp;quot;fields&amp;quot;: {&amp;quot;user&amp;quot;: &amp;quot;1&amp;quot;, &amp;quot;name&amp;quot;: &amp;quot;abc&amp;quot;, &amp;quot;created_date&amp;quot;: &amp;quot;2020-10-21T19:30:38.008&amp;quot;}}]
&lt;/code>&lt;/pre>
&lt;br>
&lt;h2 id="実装例その２">実装例その２&lt;/h2>
&lt;pre>&lt;code class="language-python">from json import dumps
from django.forms.models import model_to_dict
from models import &lt;span class="marker">MyModel&lt;/span>
def model_to_json_str():
# 1レコードのみ取得
record = MyModel.objects.get(&lt;span class="marker">検索条件&lt;/span>)
my_dict = {
'pk': record.pk,
'fields': model_to_dict(
record,
['user', 'name', 'created_date']
)
}
# JSON形式のstrとして出力
return dumps(my_dict)
# {&amp;quot;pk&amp;quot;: 5, &amp;quot;fields&amp;quot;: {&amp;quot;user&amp;quot;: &amp;quot;1&amp;quot;, &amp;quot;name&amp;quot;: &amp;quot;abc&amp;quot;, &amp;quot;created_date&amp;quot;: &amp;quot;2020-10-21T19:30:38.008&amp;quot;}}
&lt;/code>&lt;/pre>
&lt;h3 id="参考">参考&lt;/h3>
&lt;h4 id="model_to_dictの実装">model_to_dictの実装&lt;/h4>
&lt;pre>&lt;code class="language-python">def model_to_dict(instance, fields=None, exclude=None):
&amp;quot;&amp;quot;&amp;quot;
Return a dict containing the data in ``instance`` suitable for passing as
a Form's ``initial`` keyword argument.
``fields`` is an optional list of field names. If provided, return only the
named.
``exclude`` is an optional list of field names. If provided, exclude the
named from the returned dict, even if they are listed in the ``fields``
argument.
&amp;quot;&amp;quot;&amp;quot;
opts = instance._meta
data = {}
for f in chain(opts.concrete_fields, opts.private_fields, opts.many_to_many):
if not getattr(f, 'editable', False):
continue
if fields is not None and f.name not in fields:
continue
if exclude and f.name in exclude:
continue
data[f.name] = f.value_from_object(instance)
return data
&lt;/code>&lt;/pre></description></item><item><title>Blog: Python：OSコマンドを実行する</title><link>/blog/2021/01/30/python-execute-os-command/</link><pubDate>Sat, 30 Jan 2021 18:32:45 +0900</pubDate><guid>/blog/2021/01/30/python-execute-os-command/</guid><description>
&lt;h2 id="その１">その１&lt;/h2>
&lt;pre>&lt;code class="language-python">import shlex, subprocess
returncode = subprocess.call(shlex.split('&lt;span class="marker">実行コマンド&lt;/span>'))
&lt;/code>&lt;/pre>
&lt;p>※Python 3.5 より前のバージョンでも使用可能
※終了コードが取得可能&lt;/p>
&lt;h3 id="参考">参考&lt;/h3>
&lt;p>&lt;a href="https://docs.python.org/ja/3/library/subprocess.html#subprocess.call">https://docs.python.org/ja/3/library/subprocess.html#subprocess.call&lt;/a>&lt;/p>
&lt;br>
&lt;h2 id="その２">その２&lt;/h2>
&lt;pre>&lt;code class="language-python">import os
returncode = os.system('&lt;span class="marker">実行コマンド&lt;/span>')
&lt;/code>&lt;/pre>
&lt;p>※実行コマンドの出力は標準出力に出力される&lt;br>
※終了コードが取得可能&lt;/p>
&lt;br>
&lt;h2 id="その３">その３&lt;/h2>
&lt;pre>&lt;code class="language-python">import os
result = os.popen('&lt;span class="marker">実行コマンド&lt;/span>')
returncode = 0 if result.close() is None else result.close()
stdout = result.read().rstrip('\n')
&lt;/code>&lt;/pre>
&lt;p>※終了コード、標準出力が取得可能&lt;/p>
&lt;br>
&lt;h2 id="その４">その４&lt;/h2>
&lt;pre>&lt;code class="language-python">import subprocess
result = subprocess.run(&lt;span class="marker">実行コマンド(list型)&lt;/span>)
# 終了コード
result.returncode
# 標準出力
result.stdout
&lt;/code>&lt;/pre>
&lt;p>※Python3.5から使用可能
※終了コード、標準出力等が取得可能&lt;/p>
&lt;h3 id="参考-1">参考&lt;/h3>
&lt;p>&lt;a href="https://docs.python.org/ja/3/library/subprocess.html#subprocess.run">https://docs.python.org/ja/3/library/subprocess.html#subprocess.run&lt;/a>&lt;br>
&lt;a href="https://docs.python.org/ja/3/library/subprocess.html#subprocess.CompletedProcess">https://docs.python.org/ja/3/library/subprocess.html#subprocess.CompletedProcess&lt;/a>&lt;/p></description></item><item><title>Blog: Python：virtualenvwrapper の使い方</title><link>/blog/2021/01/23/python-how-to-use-virtualenvwrapper/</link><pubDate>Sat, 23 Jan 2021 18:20:55 +0900</pubDate><guid>/blog/2021/01/23/python-how-to-use-virtualenvwrapper/</guid><description>
&lt;h2 id="virtualenvwrapper-のインストール">virtualenvwrapper のインストール&lt;/h2>
&lt;h3 id="pip-でインストールを実施">pip でインストールを実施&lt;/h3>
&lt;pre>&lt;code class="language-shell">pip install virtualenvwrapper
&lt;/code>&lt;/pre>
&lt;h3 id="bashrc-またはetcbashrc-に以下を追加">.bashrc (または、/etc/bashrc) に以下を追加&lt;/h3>
&lt;pre>&lt;code class="language-shell">export WORKON_HOME=$HOME/.virtualenvs
. /usr/bin/virtualenvwrapper.sh
&lt;/code>&lt;/pre>
&lt;br>
&lt;h2 id="virtualenvwrapper-の使い方">virtualenvwrapper の使い方&lt;/h2>
&lt;h3 id="環境を作成">環境を作成&lt;/h3>
&lt;pre>&lt;code class="language-shell">mkvirtualenv &lt;span class="marker">環境名&lt;/span>
&lt;/code>&lt;/pre>
&lt;h3 id="環境一覧を参照">環境一覧を参照&lt;/h3>
&lt;pre>&lt;code class="language-shell">workon
&lt;/code>&lt;/pre>
&lt;h3 id="環境をactivate">環境をactivate&lt;/h3>
&lt;pre>&lt;code class="language-shell">workon &lt;span class="marker">環境名&lt;/span>
&lt;/code>&lt;/pre>
&lt;h3 id="環境をdeactivate">環境をdeactivate&lt;/h3>
&lt;pre>&lt;code class="language-shell">deactivate
&lt;/code>&lt;/pre>
&lt;h3 id="環境を削除">環境を削除&lt;/h3>
&lt;pre>&lt;code class="language-shell">rmvirtualenv &lt;span class="marker">環境名&lt;/span>
&lt;/code>&lt;/pre></description></item><item><title>Blog: Python：文字列からクラスを取得する</title><link>/blog/2021/01/16/python-get-class-from-str/</link><pubDate>Sat, 16 Jan 2021 17:50:05 +0900</pubDate><guid>/blog/2021/01/16/python-get-class-from-str/</guid><description>
&lt;h2 id="実装例">実装例&lt;/h2>
&lt;pre>&lt;code class="language-python">import importlib
def class_for_name(package_name, class_name):
'''
:param str package_name:
:param str class_name:
'''
# packageが見つからなければ ImportError が発生
m = importlib.import_module(package_name)
# classが見つからなければ AttributeError が発生
c = getattr(m, class_name)
return c
&lt;/code>&lt;/pre>
&lt;br>
&lt;h2 id="使用例">使用例&lt;/h2>
&lt;pre>&lt;code class="language-python"># コンストラクタを呼び出す
instance = class_for_name('mypackage.foo', 'MyClass')(val1, val2, ...)
&lt;/code>&lt;/pre></description></item><item><title>Blog: Java：byte配列を文字コード関連エラーを無視してStringに変換する</title><link>/blog/2021/01/05/java-change-bytearray-to-string/</link><pubDate>Tue, 05 Jan 2021 06:01:44 +0900</pubDate><guid>/blog/2021/01/05/java-change-bytearray-to-string/</guid><description>
&lt;h2 id="実装例">実装例&lt;/h2>
&lt;pre>&lt;code class="language-java">import java.nio.ByteBuffer;
import java.nio.charset.CodingErrorAction;
import java.nio.charset.StandardCharsets;
...
&lt;span class="marker">StandardCharsets.UTF_8&lt;/span>.newDecoder().onMalformedInput(
CodingErrorAction.IGNORE
).onUnmappableCharacter(
CodingErrorAction.IGNORE
).decode(
ByteBuffer.wrap(&lt;span class="marker">byte配列&lt;/span>)
).toString();
...
&lt;/code>&lt;/pre></description></item><item><title>Blog: 複数versionのPythonを使い分ける</title><link>/blog/2020/12/25/python-use-multiple-version-of-python/</link><pubDate>Fri, 25 Dec 2020 12:34:29 +0900</pubDate><guid>/blog/2020/12/25/python-use-multiple-version-of-python/</guid><description>
&lt;h2 id="windowsの場合">Windowsの場合&lt;/h2>
&lt;h3 id="凡例">凡例&lt;/h3>
&lt;pre>&lt;code class="language-shell">py -&lt;span class="marker">Pythonのversion&lt;/span> -m &lt;span class="marker">コマンド&lt;/span>
&lt;/code>&lt;/pre>
&lt;h3 id="使用例">使用例&lt;/h3>
&lt;h4 id="python38-で-venvを使用する">Python3.8 で venvを使用する&lt;/h4>
&lt;pre>&lt;code class="language-shell">py -3.8 -m venv ...
&lt;/code>&lt;/pre>
&lt;h4 id="python27-の-pip-を実行する">Python2.7 の pip を実行する&lt;/h4>
&lt;pre>&lt;code class="language-shell">py -2.7 -m pip ...
&lt;/code>&lt;/pre>
&lt;br>
&lt;h2 id="linuxの場合">Linuxの場合&lt;/h2>
&lt;h3 id="凡例-1">凡例&lt;/h3>
&lt;pre>&lt;code class="language-shell">python&lt;span class="marker">Pythonのversion&lt;/span> -m &lt;span class="marker">コマンド&lt;/span>
&lt;/code>&lt;/pre>
&lt;h3 id="使用例-1">使用例&lt;/h3>
&lt;h4 id="python38-で-venvを使用する-1">Python3.8 で venvを使用する&lt;/h4>
&lt;pre>&lt;code class="language-shell">python3.8 -m venv ...
&lt;/code>&lt;/pre>
&lt;h4 id="python27-の-pip-を実行する-1">Python2.7 の pip を実行する&lt;/h4>
&lt;pre>&lt;code class="language-shell">python2.7 -m pip ...
&lt;/code>&lt;/pre></description></item><item><title>Blog: Python：Exceptionのtype・エラー文言をロギングする</title><link>/blog/2020/12/15/python-logging-exceptions-type-and-message/</link><pubDate>Tue, 15 Dec 2020 12:29:37 +0900</pubDate><guid>/blog/2020/12/15/python-logging-exceptions-type-and-message/</guid><description>
&lt;h2 id="実装例">実装例&lt;/h2>
&lt;pre>&lt;code class="language-python">import logging
logger = logging.getLogger(__name__)
try:
# do something
except Exception as e:
logger.exception('%s: %s', type(e).__name__, e)
...
&lt;/code>&lt;/pre></description></item><item><title>Blog: Python：文字列をshellの引数で使えるようにエスケープする</title><link>/blog/2020/12/05/python-escape-string-for-use-with-shell/</link><pubDate>Sat, 05 Dec 2020 12:25:26 +0900</pubDate><guid>/blog/2020/12/05/python-escape-string-for-use-with-shell/</guid><description>
&lt;h2 id="凡例">凡例&lt;/h2>
&lt;pre>&lt;code class="language-python">import shlex
shlex.quote(&lt;span class="marker">文字列&lt;/span>)
&lt;/code>&lt;/pre>
&lt;p>※shellに渡す個々の引数に対して実行する必要がある&lt;/p>
&lt;h3 id="参考">参考&lt;/h3>
&lt;blockquote>
&lt;p>shlex &amp;mdash; 単純な字句解析&lt;br>
&lt;a href="https://docs.python.org/ja/3/library/shlex.html#shlex.quote">https://docs.python.org/ja/3/library/shlex.html#shlex.quote&lt;/a>&lt;/p>&lt;/blockquote></description></item><item><title>Blog: CentOS：CMakeをインストール</title><link>/blog/2020/11/25/centos-install-cmake/</link><pubDate>Wed, 25 Nov 2020 06:42:07 +0900</pubDate><guid>/blog/2020/11/25/centos-install-cmake/</guid><description>
&lt;h2 id="yum-でインストールする場合">yum でインストールする場合&lt;/h2>
&lt;pre>&lt;code class="language-shell">yum install -y cmake
&lt;/code>&lt;/pre>
&lt;br>
&lt;h2 id="アーカイブからインストールする場合">アーカイブからインストールする場合&lt;/h2>
&lt;pre>&lt;code class="language-shell">curl -SL https://github.com/Kitware/CMake/releases/download/v&lt;span class="marker">3.18.1&lt;/span>/cmake-&lt;span class="marker">3.18.1&lt;/span>-Linux-x86_64.tar.gz | tar -xzC /opt
ln -s /opt/cmake-&lt;span class="marker">3.18.1&lt;/span>-Linux-x86_64/bin/cmake /usr/bin/cmake
&lt;/code>&lt;/pre>
&lt;h3 id="アーカイブの取得先">アーカイブの取得先&lt;/h3>
&lt;blockquote>
&lt;p>&lt;a href="https://github.com/Kitware/CMake/releases">https://github.com/Kitware/CMake/releases&lt;/a>&lt;br>
&lt;a href="https://cmake.org/download/">https://cmake.org/download/&lt;/a>&lt;/p>&lt;/blockquote></description></item><item><title>Blog: CentOS：openjdk-devel・openjdk の違い</title><link>/blog/2020/11/15/centos-difference-between-openjdk-devel-and-openjdk/</link><pubDate>Sun, 15 Nov 2020 06:31:56 +0900</pubDate><guid>/blog/2020/11/15/centos-difference-between-openjdk-devel-and-openjdk/</guid><description>
&lt;p>java-&lt;span class="marker">XX&lt;/span>-openjdk パッケージと java-&lt;span class="marker">XX&lt;/span>
-openjdk-devel パッケージの違い&lt;/p>
&lt;p>openjdk は openjdk-devel に含まれている&lt;/p>
&lt;br>
&lt;h2 id="openjdk">openjdk&lt;/h2>
&lt;pre>&lt;code class="language-shell">yum install java-11-openjdk
&lt;/code>&lt;/pre>
&lt;pre>&lt;code class="language-shell">Installing:
java-11-openjdk x86_64 1:11.0.4.11-1.el7_7 updates 211 k
Installing for dependencies:
avahi-libs x86_64 0.6.31-19.el7 base 61 k
copy-jdk-configs noarch 3.3-10.el7_5 base 21 k
cups-libs x86_64 1:1.6.3-40.el7 base 358 k
dejavu-fonts-common noarch 2.33-6.el7 base 64 k
dejavu-sans-fonts noarch 2.33-6.el7 base 1.4 M
fontconfig x86_64 2.13.0-4.3.el7 base 254 k
fontpackages-filesystem noarch 1.44-8.el7 base 9.9 k
giflib x86_64 4.1.6-9.el7 base 40 k
java-11-openjdk-headless x86_64 1:11.0.4.11-1.el7_7 updates 39 M
javapackages-tools noarch 3.4.1-11.el7 base 73 k
libICE x86_64 1.0.9-9.el7 base 66 k
libSM x86_64 1.2.2-2.el7 base 39 k
libX11 x86_64 1.6.7-2.el7 base 607 k
libX11-common noarch 1.6.7-2.el7 base 164 k
libXau x86_64 1.0.8-2.1.el7 base 29 k
libXext x86_64 1.3.3-3.el7 base 39 k
libXi x86_64 1.7.9-1.el7 base 40 k
libXrender x86_64 0.9.10-1.el7 base 26 k
libXtst x86_64 1.2.3-1.el7 base 20 k
libfontenc x86_64 1.1.3-3.el7 base 31 k
libjpeg-turbo x86_64 1.2.90-8.el7 base 135 k
libxcb x86_64 1.13-1.el7 base 214 k
libxslt x86_64 1.1.28-5.el7 base 242 k
lksctp-tools x86_64 1.0.17-2.el7 base 88 k
pcsc-lite-libs x86_64 1.8.8-8.el7 base 34 k
python-javapackages noarch 3.4.1-11.el7 base 31 k
python-lxml x86_64 3.2.1-4.el7 base 758 k
ttmkfdir x86_64 3.0.9-42.el7 base 48 k
tzdata-java noarch 2019c-1.el7 updates 187 k
xorg-x11-font-utils x86_64 1:7.5-21.el7 base 104 k
xorg-x11-fonts-Type1 noarch 7.5-9.el7 base 521 k
&lt;/code>&lt;/pre>
&lt;br>
&lt;h2 id="openjdk-devel">openjdk-devel&lt;/h2>
&lt;pre>&lt;code class="language-shell">yum install java-11-openjdk-devel
&lt;/code>&lt;/pre>
&lt;pre>&lt;code class="language-shell">Installing:
java-11-openjdk-devel x86_64 1:11.0.4.11-1.el7_7 updates 3.3 M
Installing for dependencies:
avahi-libs x86_64 0.6.31-19.el7 base 61 k
copy-jdk-configs noarch 3.3-10.el7_5 base 21 k
cups-libs x86_64 1:1.6.3-40.el7 base 358 k
dejavu-fonts-common noarch 2.33-6.el7 base 64 k
dejavu-sans-fonts noarch 2.33-6.el7 base 1.4 M
fontconfig x86_64 2.13.0-4.3.el7 base 254 k
fontpackages-filesystem noarch 1.44-8.el7 base 9.9 k
giflib x86_64 4.1.6-9.el7 base 40 k
java-11-openjdk x86_64 1:11.0.4.11-1.el7_7 updates 211 k
java-11-openjdk-headless x86_64 1:11.0.4.11-1.el7_7 updates 39 M
javapackages-tools noarch 3.4.1-11.el7 base 73 k
libICE x86_64 1.0.9-9.el7 base 66 k
libSM x86_64 1.2.2-2.el7 base 39 k
libX11 x86_64 1.6.7-2.el7 base 607 k
libX11-common noarch 1.6.7-2.el7 base 164 k
libXau x86_64 1.0.8-2.1.el7 base 29 k
libXext x86_64 1.3.3-3.el7 base 39 k
libXi x86_64 1.7.9-1.el7 base 40 k
libXrender x86_64 0.9.10-1.el7 base 26 k
libXtst x86_64 1.2.3-1.el7 base 20 k
libfontenc x86_64 1.1.3-3.el7 base 31 k
libjpeg-turbo x86_64 1.2.90-8.el7 base 135 k
libxcb x86_64 1.13-1.el7 base 214 k
libxslt x86_64 1.1.28-5.el7 base 242 k
lksctp-tools x86_64 1.0.17-2.el7 base 88 k
pcsc-lite-libs x86_64 1.8.8-8.el7 base 34 k
python-javapackages noarch 3.4.1-11.el7 base 31 k
python-lxml x86_64 3.2.1-4.el7 base 758 k
ttmkfdir x86_64 3.0.9-42.el7 base 48 k
tzdata-java noarch 2019c-1.el7 updates 187 k
xorg-x11-font-utils x86_64 1:7.5-21.el7 base 104 k
xorg-x11-fonts-Type1 noarch 7.5-9.el7 base 521 k
&lt;/code>&lt;/pre></description></item><item><title>Blog: Java：オブジェクトのByte配列をプリミティブなbyte配列に変換する</title><link>/blog/2020/11/05/java-change-byteobject-to-byte/</link><pubDate>Thu, 05 Nov 2020 06:26:19 +0900</pubDate><guid>/blog/2020/11/05/java-change-byteobject-to-byte/</guid><description>
&lt;h2 id="maven設定">Maven設定&lt;/h2>
&lt;pre>&lt;code class="language-xml"> &amp;lt;dependency&amp;gt;
&amp;lt;groupId&amp;gt;org.apache.commons&amp;lt;/groupId&amp;gt;
&amp;lt;artifactId&amp;gt;commons-lang3&amp;lt;/artifactId&amp;gt;
&amp;lt;version&amp;gt;&lt;span class="marker">3.11&lt;/span>&amp;lt;/version&amp;gt;
&amp;lt;/dependency&amp;gt;
&lt;/code>&lt;/pre>
&lt;br>
&lt;h2 id="実装例">実装例&lt;/h2>
&lt;pre>&lt;code class="language-java">import org.apache.commons.lang.ArrayUtils;
Byte[] binaryObj;
...
byte[] binary = ArrayUtils.toPrimitive((Byte[]) binaryObj);
&lt;/code>&lt;/pre></description></item><item><title>Blog: Linux：rootユーザーでのssh接続を可能にする</title><link>/blog/2020/10/25/linux-enable-root-login-over-ssh/</link><pubDate>Sun, 25 Oct 2020 01:11:06 +0900</pubDate><guid>/blog/2020/10/25/linux-enable-root-login-over-ssh/</guid><description>
&lt;h2 id="root-ユーザーのパスワードを設定">root ユーザーのパスワードを設定&lt;/h2>
&lt;p>root ユーザーで以下のコマンドを実行する&lt;/p>
&lt;pre>&lt;code class="language-shell">passwd
&lt;/code>&lt;/pre>
&lt;br>
&lt;h2 id="設定ファイルの変更">設定ファイルの変更&lt;/h2>
&lt;p>sshの設定ファイルに以下の設定を行う&lt;/p>
&lt;h3 id="etcsshsshd_config">/etc/ssh/sshd_config&lt;/h3>
&lt;pre>&lt;code>PermitRootLogin yes
&lt;/code>&lt;/pre>
&lt;br>
&lt;h2 id="sshdサービスの再起動">sshdサービスの再起動&lt;/h2>
&lt;pre>&lt;code class="language-shell">service sshd restart
&lt;/code>&lt;/pre>
&lt;p>※「sshd」でサービスが見つからない場合は「ssh」を使用する&lt;/p></description></item><item><title>Blog: OpenSSL：1linerでランダムな16進数文字列を得る</title><link>/blog/2020/10/15/openssl-get-random-string-with-one-liner/</link><pubDate>Thu, 15 Oct 2020 02:30:52 +0900</pubDate><guid>/blog/2020/10/15/openssl-get-random-string-with-one-liner/</guid><description>
&lt;h2 id="凡例">凡例&lt;/h2>
&lt;pre>&lt;code class="language-shell">openssl rand -hex &lt;span class="marker">byte数&lt;/span>
&lt;/code>&lt;/pre>
&lt;br>
&lt;h2 id="16進数を64文字出力">16進数を64文字出力&lt;/h2>
&lt;h3 id="コマンド">コマンド&lt;/h3>
&lt;pre>&lt;code class="language-shell">openssl rand -hex 32
&lt;/code>&lt;/pre>
&lt;h3 id="出力例">出力例&lt;/h3>
&lt;pre>&lt;code>880e676a0f903c9a00820af91e2d1da398c7751286da2cb7f196c4e4f3995fdf
&lt;/code>&lt;/pre>
&lt;p>※1byteごとに 00~ff のいずれかが出力されるため、文字列長はbyte数の2倍となる&lt;/p></description></item><item><title>Blog: java.io.IOException: Cannot run program "bash": error=24, Too many open files</title><link>/blog/2020/10/05/java-ioexception-cannot-run-program-bash-error-24/</link><pubDate>Mon, 05 Oct 2020 09:35:12 +0900</pubDate><guid>/blog/2020/10/05/java-ioexception-cannot-run-program-bash-error-24/</guid><description>
&lt;h2 id="事象">事象&lt;/h2>
&lt;p>Javaで複数ファイルを開く処理を実行した際に以下のようなエラーが発生&lt;/p>
&lt;pre>&lt;code>...
Caused by: java.util.concurrent.ExecutionException: java.lang.RuntimeException: ERROR: Unrecoverable error when performing local command java.io.IOException: Cannot run program &amp;quot;bash&amp;quot;: error=24, Too many open files
at java.util.concurrent.FutureTask.report(FutureTask.java:122)
at java.util.concurrent.FutureTask.get(FutureTask.java:192)
at org.grep4j.core.executors.GrepTaskExecutor.execute(GrepTaskExecutor.java:48)
... 7 more
...
&lt;/code>&lt;/pre>
&lt;br>
&lt;h2 id="原因">原因&lt;/h2>
&lt;p>ファイルディスクリプタの上限値が不足しているため&lt;/p>
&lt;br>
&lt;h2 id="対策">対策&lt;/h2>
&lt;p>ファイルディスクリプタの上限値を増やす&lt;/p>
&lt;h3 id="現在のファイルディスクリプタ上限値の確認">現在のファイルディスクリプタ上限値の確認&lt;/h3>
&lt;pre>&lt;code class="language-shell">ulimit -n
&lt;/code>&lt;/pre>
&lt;pre>&lt;code>1024
&lt;/code>&lt;/pre>
&lt;h3 id="ファイルディスクリプタ上限値を設定">ファイルディスクリプタ上限値を設定&lt;/h3>
&lt;pre>&lt;code class="language-shell">ulimit -n &lt;span class="marker">ファイルディスクリプタ上限値&lt;/span>
&lt;/code>&lt;/pre></description></item><item><title>Blog: java.io.IOException: Cannot run program "bash": error=11, Resource temporarily unavailable</title><link>/blog/2020/09/25/java-ioexception-cannot-run-program-bash-error-11/</link><pubDate>Fri, 25 Sep 2020 09:35:12 +0900</pubDate><guid>/blog/2020/09/25/java-ioexception-cannot-run-program-bash-error-11/</guid><description>
&lt;h2 id="事象">事象&lt;/h2>
&lt;p>Javaで複数ファイルを開く処理を実行した際に以下のようなエラーが発生&lt;/p>
&lt;pre>&lt;code>...
Caused by: java.util.concurrent.ExecutionException: java.lang.RuntimeException: ERROR: Unrecoverable error when performing local command java.io.IOException: Cannot run program &amp;quot;bash&amp;quot;: error=11, Resource temporarily unavailable
at java.util.concurrent.FutureTask.report(FutureTask.java:122)
at java.util.concurrent.FutureTask.get(FutureTask.java:192)
at org.grep4j.core.executors.GrepTaskExecutor.execute(GrepTaskExecutor.java:48)
... 7 more
...
&lt;/code>&lt;/pre>
&lt;br>
&lt;h2 id="原因">原因&lt;/h2>
&lt;p>プロセス数の上限値が不足しているため&lt;/p>
&lt;br>
&lt;h2 id="対策">対策&lt;/h2>
&lt;p>プロセス数の上限値を増やす&lt;/p>
&lt;h3 id="現在のプロセス数上限値の確認">現在のプロセス数上限値の確認&lt;/h3>
&lt;pre>&lt;code class="language-shell">ulimit -u
&lt;/code>&lt;/pre>
&lt;pre>&lt;code>4096
&lt;/code>&lt;/pre>
&lt;h3 id="プロセス数上限値を設定">プロセス数上限値を設定&lt;/h3>
&lt;pre>&lt;code class="language-shell">ulimit -u &lt;span class="marker">プロセス数上限値&lt;/span>
&lt;/code>&lt;/pre></description></item><item><title>Blog: Windows 10：WSL 2 を使用可能にする</title><link>/blog/2020/09/15/how-to-use-wsl2/</link><pubDate>Tue, 15 Sep 2020 07:00:05 +0900</pubDate><guid>/blog/2020/09/15/how-to-use-wsl2/</guid><description>
&lt;blockquote>
&lt;p>Windows 10 用 Windows Subsystem for Linux のインストール ガイド&lt;br>
&lt;a href="https://docs.microsoft.com/ja-jp/windows/wsl/wsl2-install">https://docs.microsoft.com/ja-jp/windows/wsl/wsl2-install&lt;/a>&lt;/p>&lt;/blockquote>
&lt;br>
&lt;h2 id="windows-10-を-バージョン-2004-ビルド-19041-以降までupdate">Windows 10 を バージョン 2004 ビルド 19041 以降までupdate&lt;/h2>
&lt;p>現在のバージョンは以下のコマンドで確認可能&lt;/p>
&lt;pre>&lt;code>winver
&lt;/code>&lt;/pre>
&lt;h3 id="実行例">実行例&lt;/h3>
&lt;p>&lt;img src="https://www.tssol.net/media/20200915_01.png" alt="">&lt;/p>
&lt;br>
&lt;h2 id="カーネルコンポーネント更新プログラムを取得">カーネルコンポーネント更新プログラムを取得&lt;/h2>
&lt;p>&lt;a href="https://aka.ms/wsl2kernel">https://aka.ms/wsl2kernel&lt;/a>&lt;br>
からカーネルコンポーネントの更新に必要なプログラムを取得する&lt;br>
※Windows10を所定のupdateする前にインストールしてしまった場合は、&lt;br>
　一旦アンインストールし、update完了後に再インストールする&lt;/p>
&lt;br>
&lt;h2 id="インストール済みのディストリビューションのバージョン確認">インストール済みのディストリビューションのバージョン確認&lt;/h2>
&lt;p>現時点でインストールされている Linux ディストリビューションの WSL バージョンを確認する&lt;/p>
&lt;pre>&lt;code>wsl -l -v
&lt;/code>&lt;/pre>
&lt;pre>&lt;code> NAME STATE VERSION
* Ubuntu-18.04 Running 1
&lt;/code>&lt;/pre>
&lt;p>※カーネルコンポーネント更新プログラムが適用されていないと&lt;br>
　-v オプションが使えない&lt;/p>
&lt;br>
&lt;h2 id="インストール済みのディストリビューションを-wsl-2-に変換">インストール済みのディストリビューションを WSL 2 に変換&lt;/h2>
&lt;pre>&lt;code>wsl --set-version &lt;span class="marker">Ubuntu-18.04&lt;/span> 2
&lt;/code>&lt;/pre>
&lt;h3 id="カーネルコンポーネント更新プログラム未適用時の出力結果">カーネルコンポーネント更新プログラム未適用時の出力結果&lt;/h3>
&lt;pre>&lt;code>変換中です。この処理には数分かかることがあります...
WSL 2 を実行するには、カーネル コンポーネントの更新が必要です。詳細については https://aka.ms/wsl2kernel を参照してください
&lt;/code>&lt;/pre>
&lt;h3 id="カーネルコンポーネント更新プログラム適用時の出力結果">カーネルコンポーネント更新プログラム適用時の出力結果&lt;/h3>
&lt;pre>&lt;code>変換中です。この処理には数分かかることがあります...
WSL 2 との主な違いについては、https://aka.ms/wsl2 を参照してください
変換が完了しました。
&lt;/code>&lt;/pre>
&lt;br>
&lt;h2 id="wsl-2-を既定のアーキテクチャに設定する">WSL 2 を既定のアーキテクチャに設定する&lt;/h2>
&lt;p>新規にインストールした Linux ディストリビューションに設定される WSL バージョンを WSL 2 にする&lt;/p>
&lt;pre>&lt;code>wsl --set-default-version 2
&lt;/code>&lt;/pre>
&lt;pre>&lt;code>WSL 2 との主な違いについては、https://aka.ms/wsl2 を参照してください
&lt;/code>&lt;/pre>
&lt;br>
&lt;h2 id="任意windows-insider-program-に参加">(任意)Windows Insider Program に参加&lt;/h2>
&lt;blockquote>
&lt;p>&lt;a href="https://insider.windows.com/en-gb/getting-started/">https://insider.windows.com/en-gb/getting-started/&lt;/a>&lt;/p>&lt;/blockquote>
&lt;p>WSL 2 で Docker を使う場合は Windows Insider Program に参加しておく&lt;/p>
&lt;p>&lt;img src="https://www.tssol.net/media/20200915_02.png" alt="">&lt;/p>
&lt;br></description></item><item><title>Blog: Linux：最新のpipをインストールする</title><link>/blog/2020/09/05/linux-get-latest-pip/</link><pubDate>Sat, 05 Sep 2020 05:29:09 +0900</pubDate><guid>/blog/2020/09/05/linux-get-latest-pip/</guid><description>
&lt;h2 id="pip-がインストールされていない場合">pip がインストールされていない場合&lt;/h2>
&lt;pre>&lt;code class="language-shell">curl https://bootstrap.pypa.io/get-pip.py | sudo python
&lt;/code>&lt;/pre>
&lt;br>
&lt;h2 id="pip-がインストールされている場合">pip がインストールされている場合&lt;/h2>
&lt;pre>&lt;code class="language-shell">pip install -U pip
&lt;/code>&lt;/pre>
&lt;ul>
&lt;li>Python2系
&lt;ul>
&lt;li>Python 2.7.9 以降&lt;/li>
&lt;/ul>
&lt;/li>
&lt;li>Python3系
&lt;ul>
&lt;li>Python 3.4 以降&lt;/li>
&lt;/ul>
&lt;/li>
&lt;/ul>
&lt;p>であれば、&lt;code>pip&lt;/code> がインストールされているため、上記のコマンドで最新 version へ更新可能&lt;/p></description></item><item><title>Blog: Docker：コンテナ起動時に自動作成されたvolumeのみ削除する</title><link>/blog/2020/08/25/docker-remove-auto-generated-volumes-only/</link><pubDate>Tue, 25 Aug 2020 04:00:33 +0900</pubDate><guid>/blog/2020/08/25/docker-remove-auto-generated-volumes-only/</guid><description>
&lt;h2 id="volume一覧の例">volume一覧の例&lt;/h2>
&lt;pre>&lt;code class="language-shell">docker volume ls
&lt;/code>&lt;/pre>
&lt;pre>&lt;code>DRIVER VOLUME NAME
local 0b86b74a54e87cb152681c0ad043a9c4d1e5befbf2c40c21c1ba600a7de34bd6
local 0cfbe53c27101b4d69db10888933375c4b0d92cd861e7aeb773ebbef9c20fd4a
local 0eed9d89f6ee5ee7cb4b6aef31769f0f549052b9bc6ab43ed89b2c83e5b7490a
local 60db7cc46cd5ab4a43bbb463f9a5b3f5c903b0a1f4ed6cd6838de08abf91c1ad
local 73d36529b371dbc465cfb664ad5953542eba63899639cf2f82db85c77c44c227
local 87c805cb7f8245001773249c0552644cb5fcc1336ee1ed0acfec06b82b807504
local 757e9b691bfb3a83a2fe4b0e4a8dc9fa52830b3cc7cac97a4687a915035421fc
local 437715b0f39c74eb59a92378be8b6e604f7f35365a482c7e0b135be1090cb990
local 563283a29f203cfa03acac8b52b8de016aeecd6682f08a44a014bcf685f30eff
local a61fd5a1af35cf452a69f982006d7dbdf1610590867cb12891d988e02bd29783
local d88cfd70919ead0bf668ded74e954bef325c80b65d33a54b31f4ff2951a14b6d
local e223cf7c182e18e1e9e46580d36e6ec7a72a0572c97b0e57729a88011220cbb0
local e544f0af0447868a0d1858fae9f061a6e8d58de9aa867aaf41c5fe696ab64ff4
local eab87aa8733e11693403a674dcc3b63218f7db8b7ded03563ee5be19c12fd626
local fc79d2416bdae5a4c96a6dd550cccc02e933cca9c793110df6d72cf4761efb8a
local local_django
local local_postgres-data
local myvolume
local test_django
local test_py-libs
local test_postgres-data
local test_postgres-data_backups
&lt;/code>&lt;/pre>
&lt;h3 id="消したいvolume">消したいvolume&lt;/h3>
&lt;pre>&lt;code>local 0b86b74a54e87cb152681c0ad043a9c4d1e5befbf2c40c21c1ba600a7de34bd6
local 0cfbe53c27101b4d69db10888933375c4b0d92cd861e7aeb773ebbef9c20fd4a
local 0eed9d89f6ee5ee7cb4b6aef31769f0f549052b9bc6ab43ed89b2c83e5b7490a
local 60db7cc46cd5ab4a43bbb463f9a5b3f5c903b0a1f4ed6cd6838de08abf91c1ad
local 73d36529b371dbc465cfb664ad5953542eba63899639cf2f82db85c77c44c227
local 87c805cb7f8245001773249c0552644cb5fcc1336ee1ed0acfec06b82b807504
local 757e9b691bfb3a83a2fe4b0e4a8dc9fa52830b3cc7cac97a4687a915035421fc
local 437715b0f39c74eb59a92378be8b6e604f7f35365a482c7e0b135be1090cb990
local 563283a29f203cfa03acac8b52b8de016aeecd6682f08a44a014bcf685f30eff
local a61fd5a1af35cf452a69f982006d7dbdf1610590867cb12891d988e02bd29783
local d88cfd70919ead0bf668ded74e954bef325c80b65d33a54b31f4ff2951a14b6d
local e223cf7c182e18e1e9e46580d36e6ec7a72a0572c97b0e57729a88011220cbb0
local e544f0af0447868a0d1858fae9f061a6e8d58de9aa867aaf41c5fe696ab64ff4
local eab87aa8733e11693403a674dcc3b63218f7db8b7ded03563ee5be19c12fd626
local fc79d2416bdae5a4c96a6dd550cccc02e933cca9c793110df6d72cf4761efb8a
&lt;/code>&lt;/pre>
&lt;h3 id="消したくないvolume">消したくないvolume&lt;/h3>
&lt;pre>&lt;code>local local_django
local local_postgres-data
local myvolume
local test_django
local test_py-libs
local test_postgres-data
local test_postgres-data_backups
&lt;/code>&lt;/pre>
&lt;br>
&lt;h2 id="docker-volume-prune-だとニーズを満たせない">docker volume prune だとニーズを満たせない&lt;/h2>
&lt;pre>&lt;code class="language-shell">docker volume prune
&lt;/code>&lt;/pre>
&lt;p>だと、現時点で使用していないvolumeが削除されてしまうため、&lt;br>
消したくないvolumeも未使用であれば削除されてしまう&lt;/p>
&lt;blockquote>
&lt;p>docker volume prune&lt;br>
&lt;a href="https://docs.docker.com/engine/reference/commandline/volume_prune/">https://docs.docker.com/engine/reference/commandline/volume_prune/&lt;/a>&lt;/p>&lt;/blockquote>
&lt;br>
&lt;h2 id="削除対象のvolume名を抽出する">削除対象のvolume名を抽出する&lt;/h2>
&lt;p>自動で作成されたvolumeは&lt;/p>
&lt;ul>
&lt;li>volume名に「_」が含まれていない&lt;/li>
&lt;li>volume名が64文字&lt;/li>
&lt;/ul>
&lt;p>であるため&lt;/p>
&lt;pre>&lt;code class="language-shell">docker volume ls | grep -E &amp;quot;[^_]{64}&amp;quot; | awk '{print $2}'
&lt;/code>&lt;/pre>
&lt;p>で削除対象のvolume名を抽出できる&lt;/p>
&lt;h3 id="各コマンドの説明">各コマンドの説明&lt;/h3>
&lt;pre>&lt;code class="language-shell">grep -E &amp;quot;[^_]{64}&amp;quot;
&lt;/code>&lt;/pre>
&lt;p>「_」を含まず、volume名が64文字のものを抽出する&lt;/p>
&lt;br>
&lt;pre>&lt;code class="language-shell">awk '{print $2}'
&lt;/code>&lt;/pre>
&lt;p>出力結果からvolume名のみを抽出する&lt;br>
※awkは「&amp;quot;」ではなく「&amp;rsquo;」で文字列を囲む必要がある&lt;/p>
&lt;br>
&lt;h2 id="削除対象のvolumeを削除するコマンド">削除対象のvolumeを削除するコマンド&lt;/h2>
&lt;pre>&lt;code class="language-shell">for l in `docker volume ls | grep -E &amp;quot;[^_]{64}&amp;quot; | awk '{print $2}'`; do docker volume rm $l; done
&lt;/code>&lt;/pre></description></item><item><title>Blog: ModuleNotFoundError: No module named 'pip'</title><link>/blog/2020/08/15/python-module-not-found-error-nomodule-named-pip/</link><pubDate>Sat, 15 Aug 2020 03:45:15 +0900</pubDate><guid>/blog/2020/08/15/python-module-not-found-error-nomodule-named-pip/</guid><description>
&lt;h2 id="事象">事象&lt;/h2>
&lt;p>pipコマンド実行時に以下のようなエラーが発生&lt;/p>
&lt;pre>&lt;code class="language-shell">pip freeze
&lt;/code>&lt;/pre>
&lt;pre>&lt;code>Traceback (most recent call last):
File &amp;quot;/usr/local/bin/pip&amp;quot;, line 5, in &amp;lt;module&amp;gt;
from pip._internal.cli.main import main
ModuleNotFoundError: No module named 'pip'
&lt;/code>&lt;/pre>
&lt;br>
&lt;h2 id="原因">原因&lt;/h2>
&lt;p>インストールされているpipのversionが古いため&lt;/p>
&lt;br>
&lt;h2 id="対策">対策&lt;/h2>
&lt;p>以下のコマンドで最新のpipを取得する&lt;/p>
&lt;pre>&lt;code class="language-shell">curl https://bootstrap.pypa.io/get-pip.py | sudo python
&lt;/code>&lt;/pre></description></item><item><title>Blog: Windows：HyperでWSLを起動するための設定</title><link>/blog/2020/08/08/use-wsl-with-hyper/</link><pubDate>Sat, 08 Aug 2020 08:32:47 +0900</pubDate><guid>/blog/2020/08/08/use-wsl-with-hyper/</guid><description>
&lt;h2 id="設定ファイルの編集">設定ファイルの編集&lt;/h2>
&lt;pre>&lt;code>C:\Users\&lt;span class="marker">ユーザー名&lt;/span>\AppData\Roaming\Hyper\.hyper.js
&lt;/code>&lt;/pre>
&lt;h3 id="wslコマンドからディストリビューションを指定する場合">wslコマンドからディストリビューションを指定する場合&lt;/h3>
&lt;pre>&lt;code class="language-js">shell: `C:\\WINDOWS\\System32\\wsl.exe`,
&lt;/code>&lt;/pre>
&lt;pre>&lt;code class="language-js">shellArgs: ['~', '-d', '&lt;span class="marker">Ubuntu-18.04&lt;/span>'],
&lt;/code>&lt;/pre>
&lt;br>
&lt;h3 id="直接ディストリビューションを実行する場合">直接ディストリビューションを実行する場合&lt;/h3>
&lt;pre>&lt;code class="language-js">shell: `&lt;span class="marker">ubuntu1804.exe&lt;/span>`,
&lt;/code>&lt;/pre>
&lt;pre>&lt;code class="language-js">shellArgs: [],
&lt;/code>&lt;/pre></description></item><item><title>Blog: Windows：wsl.exe実行時に起動されるWSL Distributionを設定する</title><link>/blog/2020/08/01/set-wsl-default-distribution/</link><pubDate>Sat, 01 Aug 2020 08:47:18 +0900</pubDate><guid>/blog/2020/08/01/set-wsl-default-distribution/</guid><description>
&lt;h2 id="wsl-distributionの一覧を確認">WSL Distributionの一覧を確認&lt;/h2>
&lt;pre>&lt;code>wslconfig /l
&lt;/code>&lt;/pre>
&lt;h3 id="出力例">出力例&lt;/h3>
&lt;pre>&lt;code>Linux 用 Windows サブシステム ディストリビューション:
Ubuntu-18.04 (既定)
Ubuntu-20.04
&lt;/code>&lt;/pre>
&lt;p>※(既定) と表示されているものがwsl.exe実行時に起動される&lt;/p>
&lt;br>
&lt;h2 id="defaultで実行されるwsl-distributionを設定する">defaultで実行されるWSL Distributionを設定する&lt;/h2>
&lt;pre>&lt;code>wslconfig /s &lt;span class="marker">ディストリビューション名&lt;/span>
&lt;/code>&lt;/pre></description></item><item><title>Blog: VSCode：.md(Markdownファイル)内でEmmetを有効にする</title><link>/blog/2020/07/25/vscode-enable-emmet-on-markdown/</link><pubDate>Sat, 25 Jul 2020 08:42:35 +0900</pubDate><guid>/blog/2020/07/25/vscode-enable-emmet-on-markdown/</guid><description>
&lt;h2 id="settingsjson">settings.json&lt;/h2>
&lt;p>設定ファイル(settings.json)を以下のように変更する&lt;/p>
&lt;pre>&lt;code class="language-json"> ...
&amp;quot;emmet.excludeLanguages&amp;quot;: [],
&amp;quot;emmet.includeLanguages&amp;quot;: {&amp;quot;markdown&amp;quot;: &amp;quot;html&amp;quot;},
...
&lt;/code>&lt;/pre>
&lt;p>※&amp;ldquo;emmet.includeLanguages&amp;quot;だけだと有効にならなかった&lt;/p>
&lt;blockquote>
&lt;p>markdown not using emmet&lt;br>
&lt;a href="https://stackoverflow.com/questions/49956963/markdown-not-using-emmet">https://stackoverflow.com/questions/49956963/markdown-not-using-emmet&lt;/a>&lt;/p>&lt;/blockquote></description></item><item><title>Blog: Ubuntu：E: Unable to locate package &lt;package名></title><link>/blog/2020/07/18/ubuntu-unable-to-locate-package/</link><pubDate>Sat, 18 Jul 2020 09:06:09 +0900</pubDate><guid>/blog/2020/07/18/ubuntu-unable-to-locate-package/</guid><description>
&lt;h2 id="事象">事象&lt;/h2>
&lt;p>&lt;code>apt-get update&lt;/code> または &lt;code>apt update&lt;/code> を実行しても同様のエラーが発生する&lt;/p>
&lt;br>
&lt;h2 id="原因">原因&lt;/h2>
&lt;p>当該packageを含むrepositoryがAPTのデータ取得元設定リストに設定されていないため&lt;/p>
&lt;br>
&lt;h2 id="対策">対策&lt;/h2>
&lt;p>以下の手順で対処する&lt;/p>
&lt;h3 id="当該packageが属するrepositoryを確認">当該packageが属するrepositoryを確認&lt;/h3>
&lt;p>&lt;a href="https://packages.ubuntu.com/">https://packages.ubuntu.com/&lt;/a>&lt;br>
から当該packageを検索し、どのrepositoryに属するかを確認する&lt;/p>
&lt;ul>
&lt;li>例）xrdpの場合
&lt;img src="https://www.tssol.net/media/20200718_01.png" alt="">&lt;/li>
&lt;/ul>
&lt;p>※検索結果から、universe reposityに属することが分かる&lt;/p>
&lt;h3 id="repositoryをaptのデータ取得元設定リストに追加">repositoryをAPTのデータ取得元設定リストに追加&lt;/h3>
&lt;pre>&lt;code class="language-shell">add-apt-repository universe
&lt;/code>&lt;/pre>
&lt;h3 id="aptのデータ取得元設定リストを確認">APTのデータ取得元設定リストを確認&lt;/h3>
&lt;pre>&lt;code class="language-shell">cat /etc/apt/sources.list
&lt;/code>&lt;/pre>
&lt;pre>&lt;code>deb http://archive.ubuntu.com/ubuntu bionic main universe
deb http://archive.ubuntu.com/ubuntu bionic-security main universe
deb [arch=amd64] https://download.docker.com/linux/ubuntu bionic stable
# deb-src [arch=amd64] https://download.docker.com/linux/ubuntu bionic stable
deb http://archive.ubuntu.com/ubuntu bionic-updates main universe
&lt;/code>&lt;/pre></description></item><item><title>Blog: CircleCI：Firebaseにdeployする</title><link>/blog/2020/07/11/circleci-deploy-to-firebase/</link><pubDate>Sat, 11 Jul 2020 12:16:36 +0900</pubDate><guid>/blog/2020/07/11/circleci-deploy-to-firebase/</guid><description>
&lt;h2 id="実装例">実装例&lt;/h2>
&lt;h3 id="firebaserc">.firebaserc&lt;/h3>
&lt;pre>&lt;code class="language-json">{
&amp;quot;projects&amp;quot;: {
&amp;quot;default&amp;quot;: &amp;quot;&lt;span class="marker">integrated-oath-xxx&lt;/span>&amp;quot;
}
}
&lt;/code>&lt;/pre>
&lt;h3 id="firebasejson">firebase.json&lt;/h3>
&lt;pre>&lt;code class="language-json">{
&amp;quot;hosting&amp;quot;: {
&amp;quot;public&amp;quot;: &amp;quot;public&amp;quot;,
&amp;quot;ignore&amp;quot;: [
&amp;quot;firebase.json&amp;quot;,
&amp;quot;**/.*&amp;quot;,
&amp;quot;**/node_modules/**&amp;quot;
]
}
}
&lt;/code>&lt;/pre>
&lt;h3 id="circleciconfigymlorbs使用時">.circleci/config.yml(orbs使用時)&lt;/h3>
&lt;pre>&lt;code class="language-yaml">version: 2.1
orbs:
firebase-deploy: azdevs/firebase-deploy@1.0.0
jobs:
build:
docker:
- image: &lt;span class="marker">cibuilds/hugo:0.69.2&lt;/span>
steps:
- checkout
- ...
- persist_to_workspace:
root: ./
paths:
- public
- .firebaserc
- firebase.json
deploy:
docker:
- image: 'circleci/node:lts'
steps:
- attach_workspace:
at: ./
- firebase-deploy/deploy:
token: $FIREBASE_DEPLOY_TOKEN
workflows:
...
&lt;/code>&lt;/pre>
&lt;h3 id="circleciconfigymlorbs未使用時">.circleci/config.yml(orbs未使用時)&lt;/h3>
&lt;pre>&lt;code class="language-yaml">version: 2
jobs:
build:
docker:
- image: &lt;span class="marker">cibuilds/hugo:0.69.2&lt;/span>
steps:
- checkout
- ...
- persist_to_workspace:
root: ./
paths:
- public
- .firebaserc
- firebase.json
deploy:
docker:
- image: 'circleci/node:lts'
steps:
- attach_workspace:
at: ./
- run:
name: Install Firebase Tools
command: npm install --prefix=./firebase-deploy firebase-tools
- run:
name: Deploy to Firebase
command: ./firebase-deploy/node_modules/.bin/firebase deploy --token=$FIREBASE_DEPLOY_TOKEN -P default
workflows:
...
&lt;/code>&lt;/pre></description></item><item><title>Blog: firebase-tools：Error: Not in a Firebase app directory (could not locate firebase.json)</title><link>/blog/2020/07/04/firebase-tools-not-in-a-firebase-app-directory/</link><pubDate>Sat, 04 Jul 2020 12:30:40 +0900</pubDate><guid>/blog/2020/07/04/firebase-tools-not-in-a-firebase-app-directory/</guid><description>
&lt;h2 id="事象">事象&lt;/h2>
&lt;p>firebase deploy コマンド実行時に以下のエラーが発生&lt;/p>
&lt;pre>&lt;code>./firebase-deploy/node_modules/.bin/firebase deploy --token=$FIREBASE_DEPLOY_TOKEN -P default
&lt;/code>&lt;/pre>
&lt;pre>&lt;code>Error: Not in a Firebase app directory (could not locate firebase.json)
&lt;/code>&lt;/pre>
&lt;br>
&lt;h2 id="原因">原因&lt;/h2>
&lt;ul>
&lt;li>.firebaserc&lt;/li>
&lt;li>firebase.json&lt;/li>
&lt;/ul>
&lt;p>がカレントディレクトリに存在しないため&lt;/p>
&lt;br>
&lt;h2 id="対策">対策&lt;/h2>
&lt;ul>
&lt;li>.firebaserc&lt;/li>
&lt;li>firebase.json&lt;/li>
&lt;/ul>
&lt;p>をカレントディレクトリに追加する&lt;/p>
&lt;h3 id="firebaserc-設定例">.firebaserc 設定例&lt;/h3>
&lt;pre>&lt;code class="language-json">{
&amp;quot;projects&amp;quot;: {
&amp;quot;default&amp;quot;: &amp;quot;&lt;span class="marker">integrated-oath-xxx&lt;/span>&amp;quot;
}
}
&lt;/code>&lt;/pre>
&lt;h3 id="firebasejson-設定例">firebase.json 設定例&lt;/h3>
&lt;pre>&lt;code class="language-json">{
&amp;quot;hosting&amp;quot;: {
&amp;quot;public&amp;quot;: &amp;quot;public&amp;quot;,
&amp;quot;ignore&amp;quot;: [
&amp;quot;firebase.json&amp;quot;,
&amp;quot;**/.*&amp;quot;,
&amp;quot;**/node_modules/**&amp;quot;
]
}
}
&lt;/code>&lt;/pre></description></item><item><title>Blog: CircleCI：定期的にジョブを実行する</title><link>/blog/2020/06/27/circleci-run-job-regularly/</link><pubDate>Sat, 27 Jun 2020 01:33:23 +0900</pubDate><guid>/blog/2020/06/27/circleci-run-job-regularly/</guid><description>
&lt;h2 id="実装例">実装例&lt;/h2>
&lt;h3 id="毎日0900にジョブを実行">毎日09:00にジョブを実行&lt;/h3>
&lt;p>CircleCIはUTC(協定世界時)で動作しているため、JST(日本標準時)から9時間引いた時刻を設定する必要がある&lt;/p>
&lt;pre>&lt;code class="language-yaml">version: 2.1
workflows:
daily:
triggers:
- schedule:
cron: &amp;quot;0 0 * * *&amp;quot;
...
jobs:
...
jobs:
...
&lt;/code>&lt;/pre></description></item><item><title>Blog: Django：自作のエラー画面を使用する</title><link>/blog/2020/06/20/django-use-your-own-error-view/</link><pubDate>Sat, 20 Jun 2020 08:24:52 +0900</pubDate><guid>/blog/2020/06/20/django-use-your-own-error-view/</guid><description>
&lt;h2 id="凡例">凡例&lt;/h2>
&lt;h3 id="urlspy">urls.py&lt;/h3>
&lt;pre>&lt;code class="language-python">handler&lt;span class="marker">HTTPステータスコード&lt;/span> = '&lt;span class="marker">エラー画面出力用関数&lt;/span>'
&lt;/code>&lt;/pre>
&lt;br>
&lt;h2 id="実装例">実装例&lt;/h2>
&lt;h3 id="404エラー画面を自作">404エラー画面を自作&lt;/h3>
&lt;h4 id="urlspy-1">urls.py&lt;/h4>
&lt;pre>&lt;code class="language-python">handler404 = 'mysite.views.my_404_view'
&lt;/code>&lt;/pre>
&lt;p>※urls.py上のどこに書いてもよい&lt;/p></description></item><item><title>Blog: Django：ChoiceFieldの選択肢を設定する</title><link>/blog/2020/06/13/django-set-choices-in-choice-field/</link><pubDate>Sat, 13 Jun 2020 01:49:47 +0900</pubDate><guid>/blog/2020/06/13/django-set-choices-in-choice-field/</guid><description>
&lt;h2 id="実装例">実装例&lt;/h2>
&lt;h3 id="初期化時">初期化時&lt;/h3>
&lt;pre>&lt;code class="language-python">my_field = MyChoiceField(
...
choices=[
(&lt;span class="marker">optionのvalue&lt;/span>, &lt;span class="marker">optionのinnerText&lt;/span>),
...
]
)
&lt;/code>&lt;/pre>
&lt;h3 id="初期化時以外">初期化時以外&lt;/h3>
&lt;pre>&lt;code class="language-python">form.fields.get(&lt;span class="marker">フィールド名&lt;/span>))._set_choices(
[
(&lt;span class="marker">optionのvalue&lt;/span>, &lt;span class="marker">optionのinnerText&lt;/span>),
...
]
)
&lt;/code>&lt;/pre></description></item><item><title>Blog: Dockerfileのlintをする</title><link>/blog/2020/06/06/dockerfile-linter/</link><pubDate>Sat, 06 Jun 2020 00:17:25 +0900</pubDate><guid>/blog/2020/06/06/dockerfile-linter/</guid><description>
&lt;h2 id="linux">Linux&lt;/h2>
&lt;pre>&lt;code class="language-shell">docker run --rm -i hadolint/hadolint &amp;lt; &lt;span class="marker">Dockerfile&lt;/span>
&lt;/code>&lt;/pre>
&lt;br>
&lt;h2 id="windows">Windows&lt;/h2>
&lt;p>※Docker for Windows をインストールしていること&lt;/p>
&lt;pre>&lt;code class="language-shell">docker run --rm -i -v &lt;span class="marker">Dockerfileのあるディレクトリ&lt;/span>:/opt hadolint/hadolint hadolint &lt;span class="marker">/opt/Dockerfile&lt;/span>
&lt;/code>&lt;/pre>
&lt;br>
&lt;h2 id="lint-の警告一覧">lint の警告一覧&lt;/h2>
&lt;blockquote>
&lt;p>&lt;a href="https://github.com/hadolint/hadolint#rules">https://github.com/hadolint/hadolint#rules&lt;/a>&lt;/p>&lt;/blockquote></description></item><item><title>Blog: Linux：/usr/bin/ld: cannot find -lz</title><link>/blog/2020/05/30/ld-cannot-find-lz/</link><pubDate>Sat, 30 May 2020 19:44:58 +0900</pubDate><guid>/blog/2020/05/30/ld-cannot-find-lz/</guid><description>
&lt;h2 id="事象">事象&lt;/h2>
&lt;p>C/C++のソースコードのビルド時に以下のエラーが発生&lt;/p>
&lt;pre>&lt;code>...
/usr/bin/ld: cannot find -lz
collect2: error: ld returned 1 exit status
make: *** [my-package] Error 1
&lt;/code>&lt;/pre>
&lt;br>
&lt;h2 id="原因">原因&lt;/h2>
&lt;p>zlib がインストールされていないため&lt;/p>
&lt;br>
&lt;h2 id="対策">対策&lt;/h2>
&lt;p>zlib をインストールする&lt;/p>
&lt;h3 id="ubuntuの場合">Ubuntuの場合&lt;/h3>
&lt;pre>&lt;code class="language-shell">apt-get install zlib1g-dev
&lt;/code>&lt;/pre>
&lt;h3 id="centosの場合">CentOSの場合&lt;/h3>
&lt;pre>&lt;code class="language-shell">yum install zlib-devel
&lt;/code>&lt;/pre></description></item><item><title>Blog: Dockerfile内でファイルへ複数行書き込む処理をさせる</title><link>/blog/2020/05/27/write-multiple-lines-to-file-in-dockerfile/</link><pubDate>Wed, 27 May 2020 10:02:25 +0900</pubDate><guid>/blog/2020/05/27/write-multiple-lines-to-file-in-dockerfile/</guid><description>
&lt;h2 id="実装例">実装例&lt;/h2>
&lt;h3 id="dockerfile内でこれと同じことをやりたい">Dockerfile内でこれと同じことをやりたい&lt;/h3>
&lt;pre>&lt;code class="language-shell">cat &amp;lt;&amp;lt;EOF &amp;gt; /path/to/file
foo
bar
baz
EOF
&lt;/code>&lt;/pre>
&lt;h3 id="dockerfile内では-echo-を使う">Dockerfile内では echo を使う&lt;/h3>
&lt;pre>&lt;code class="language-docker">RUN echo &amp;quot;foo\n\
bar\n\
baz&amp;quot; &amp;gt;&amp;gt; /path/to/file
&lt;/code>&lt;/pre>
&lt;br>
&lt;h2 id="参考">参考&lt;/h2>
&lt;blockquote>
&lt;p>launch a CAT command unix into Dockerfile&lt;br>
&lt;a href="https://stackoverflow.com/questions/40359282/launch-a-cat-command-unix-into-dockerfile">https://stackoverflow.com/questions/40359282/launch-a-cat-command-unix-into-dockerfile&lt;/a>&lt;/p>&lt;/blockquote>
&lt;blockquote>
&lt;p>Multiline Dockerfile syntax&lt;br>
&lt;a href="https://github.com/moby/moby/issues/1799#issuecomment-124476047">https://github.com/moby/moby/issues/1799#issuecomment-124476047&lt;/a>&lt;/p>&lt;/blockquote></description></item><item><title>Blog: Python：汎用性の高いロギング設定</title><link>/blog/2020/05/23/python-common-logging-config/</link><pubDate>Sat, 23 May 2020 19:50:43 +0900</pubDate><guid>/blog/2020/05/23/python-common-logging-config/</guid><description>
&lt;h2 id="実装例">実装例&lt;/h2>
&lt;h3 id="logging設定">logging設定&lt;/h3>
&lt;pre>&lt;code class="language-python">from logging.config import dictConfig
import os
LOG_DIR = '&lt;span class="marker">ログ出力先ディレクトリのパス&lt;/span>'
if not os.path.exists(LOG_DIR):
os.mkdir(LOG_DIR)
LOGGING = {
# 「1」固定
'version': 1,
# 既存のロギング設定を無効にする
'disable_existing_loggers': True,
# formatter
'formatters': {
# メッセージと出力時刻のみ出力
'simple': {
'format': '[%(asctime)s]%(message)s',
},
# ログレベル、ファイルパス、行番号、関数名も出力
'detail': {
'format': '[%(asctime)s][%(levelname)s]%(pathname)s@%(lineno)d#%(funcName)s: %(message)s',
},
},
# handler
'handlers': {
# コンソール出力
'console': {
'level': 'DEBUG',
'class': 'logging.StreamHandler',
'formatter': 'detail',
},
# ファイル出力
'file': {
'level': 'DEBUG',
'class': 'logging.handlers.WatchedFileHandler',
'formatter': 'detail',
'filename': os.path.join(LOG_DIR, '[ログファイル名]'),
'encoding': 'UTF-8',
'delay': True,
},
},
# logger
'loggers': {
'': {
# コンソール出力、ファイル出力 を使う
'handlers': ['console', 'file', ],
'level': 'DEBUG',
'propagate': True,
},
'&lt;span class="marker">your package name&lt;/span>': {
'level': '&lt;span class="marker">DEBUG&lt;/span>',
'propagate': &lt;span class="marker">True&lt;/span>,
},
},
}
dictConfig(LOGGING)
&lt;/code>&lt;/pre>
&lt;h3 id="log出力">log出力&lt;/h3>
&lt;pre>&lt;code class="language-python">from logging import getLogger
logger = getLogger(__name__)
logger.info('foo')
&lt;/code>&lt;/pre></description></item><item><title>Blog: Python：正規表現の全行マッチを実行する</title><link>/blog/2020/05/16/python-all-line-regex-matching/</link><pubDate>Sat, 16 May 2020 09:27:27 +0900</pubDate><guid>/blog/2020/05/16/python-all-line-regex-matching/</guid><description>
&lt;h2 id="実装例">実装例&lt;/h2>
&lt;pre>&lt;code class="language-python">import re
with open('&lt;span class="marker">/path/to/file&lt;/span>') as f:
# ファイルから全行を取得(str型)
c = f.read()
# re.MULTILINE または re.M の指定必須
result = re.search(r'&lt;span class="marker">foo:[ ]&amp;#43;([^ ]&amp;#43;)\n&lt;/span>', c, re.M)
if result:
# do something
result.groups()
&lt;/code>&lt;/pre>
&lt;br>
&lt;h2 id="参考">参考&lt;/h2>
&lt;blockquote>
&lt;p>7.2. re — Regular expression operations&lt;br>
&lt;a href="https://docs.python.org/2.7/library/re.html#re.M">https://docs.python.org/2.7/library/re.html#re.M&lt;/a>&lt;br>
&lt;a href="https://docs.python.org/2.7/library/re.html#re.search">https://docs.python.org/2.7/library/re.html#re.search&lt;/a>&lt;/p>&lt;/blockquote></description></item><item><title>Blog: Unixtime(epoch)を取得する</title><link>/blog/2020/05/13/how-to-get-unixtime/</link><pubDate>Wed, 13 May 2020 08:45:01 +0900</pubDate><guid>/blog/2020/05/13/how-to-get-unixtime/</guid><description>
&lt;h2 id="shell">Shell&lt;/h2>
&lt;pre>&lt;code class="language-shell">date +%s
&lt;/code>&lt;/pre>
&lt;br>
&lt;h2 id="python">Python&lt;/h2>
&lt;pre>&lt;code class="language-python">import time
# Unixtime(epoch)がfloat型で返却される
time.time()
&lt;/code>&lt;/pre></description></item><item><title>Blog: Kibana：最大メモリのdefault設定値</title><link>/blog/2020/05/09/kibana-default-max-memory-limit/</link><pubDate>Sat, 09 May 2020 08:53:25 +0900</pubDate><guid>/blog/2020/05/09/kibana-default-max-memory-limit/</guid><description>
&lt;h2 id="version-70">Version 7.0~&lt;/h2>
&lt;p>Kibanaの最大メモリのdefault設定値は1.4GB&lt;/p>
&lt;br>
&lt;h2 id="参考">参考&lt;/h2>
&lt;blockquote>
&lt;p>Using Kibana in a production environment&lt;br>
&lt;a href="https://www.elastic.co/guide/en/kibana/master/production.html#memory">https://www.elastic.co/guide/en/kibana/master/production.html#memory&lt;/a>&lt;/p>&lt;/blockquote></description></item><item><title>Blog: Python：1linerでランダムな文字列を得る</title><link>/blog/2020/05/02/python-get-random-string-with-one-liner/</link><pubDate>Sat, 02 May 2020 03:52:06 +0900</pubDate><guid>/blog/2020/05/02/python-get-random-string-with-one-liner/</guid><description>
&lt;h2 id="uuidを出力">UUIDを出力&lt;/h2>
&lt;h3 id="uuid4">UUID4&lt;/h3>
&lt;pre>&lt;code>python -c &amp;quot;import uuid;print(uuid.uuid4())&amp;quot;
&lt;/code>&lt;/pre>
&lt;h3 id="出力例">出力例&lt;/h3>
&lt;pre>&lt;code>8766631b-5350-4269-8c75-817a506b6f96
&lt;/code>&lt;/pre>
&lt;br>
&lt;h2 id="ランダム文字列を出力">ランダム文字列を出力&lt;/h2>
&lt;h3 id="ランダムな40文字英字数字">ランダムな40文字(英字＋数字)&lt;/h3>
&lt;pre>&lt;code>python -c &amp;quot;import string;import secrets;print(''.join([secrets.choice(string.ascii_letters+string.digits) for i in range(&lt;span class="marker">40&lt;/span>)]))&amp;quot;
&lt;/code>&lt;/pre>
&lt;h3 id="出力例-1">出力例&lt;/h3>
&lt;pre>&lt;code>eWVZIX8VyxThN0DWVSxbauVZfmf0lMRHEaVvMOYo
&lt;/code>&lt;/pre></description></item><item><title>Blog: Python：ファイルのtimestampを取得する</title><link>/blog/2020/04/29/python-get-timestamp-of-file/</link><pubDate>Wed, 29 Apr 2020 04:02:38 +0900</pubDate><guid>/blog/2020/04/29/python-get-timestamp-of-file/</guid><description>
&lt;h2 id="実装例">実装例&lt;/h2>
&lt;pre>&lt;code class="language-python">import os
# epoch(Unixtime)がfloat型で返却される
os.path.getmtime('&lt;span class="marker">ファイルパス&lt;/span>')
&lt;/code>&lt;/pre>
&lt;br>
&lt;h2 id="参考">参考&lt;/h2>
&lt;blockquote>
&lt;p>10.1. os.path &amp;mdash; 共通のパス名操作&lt;br>
&lt;a href="https://docs.python.org/ja/2.7/library/os.path.html#os.path.getmtime">https://docs.python.org/ja/2.7/library/os.path.html#os.path.getmtime&lt;/a>&lt;/p>&lt;/blockquote></description></item><item><title>Blog: Java：セマフォ(Semaphore)の使い方</title><link>/blog/2020/04/25/java-how-to-use-semaphore/</link><pubDate>Sat, 25 Apr 2020 19:32:32 +0900</pubDate><guid>/blog/2020/04/25/java-how-to-use-semaphore/</guid><description>
&lt;p>セマフォ(Semaphore)を使用することにより、一度に実行されるスレッドの数を制限する&lt;/p>
&lt;br>
&lt;h2 id="実装例">実装例&lt;/h2>
&lt;h3 id="mypackagemyrunnablejava">mypackage.MyRunnable.java&lt;/h3>
&lt;p>スレッドで実行する処理&lt;/p>
&lt;pre>&lt;code class="language-java">package mypackage;
import java.util.concurrent.Semaphore;
public class MyRunnable implements Runnable {
private Semaphore semaphore;
private String[] args;
public MyRunnable(Semaphore s, String[] args) {
this.semaphore = s;
this.args = args;
}
private void execute(String[] args) {
// threadで実行する処理
...
}
@Override
public void run() {
// runメソッド内でセマフォの取得・解放を行う
try {
this.semaphore.acquire();
execute(this.args);
} catch (InterruptedException e) {
...
} finally {
this.semaphore.release();
}
}
}
&lt;/code>&lt;/pre>
&lt;h3 id="mypackagemainjava">mypackage.Main.java&lt;/h3>
&lt;p>スレッドを制御する処理&lt;/p>
&lt;pre>&lt;code class="language-java">package mypackage;
import java.util.ArrayList;
import java.util.concurrent.Semaphore;
public class Main {
public static void main(String[] args) {
// threadを4つまで起動する
Semaphore s = new Semaphore(&lt;span class="marker">4&lt;/span>, true);
ArrayList&amp;lt;Thread&amp;gt; thread_list = new ArrayList&amp;lt;Thread&amp;gt;();
// threadを起動
for (...) {
Thread t = new Thread(new MyRunnable(s, new String[] {...}));
t.start();
thread_list.add(t);
}
// threadの終了を待つ
for (Thread t: thread_list) {
try {
t.join();
} catch (InterruptedException e) {
...
}
}
}
}
&lt;/code>&lt;/pre></description></item></channel></rss>