20th November 2020 #amazonaffiliate #googleanalytics #privacy 本ブログではGoogle AnalyticsとAmazon Affiliateのリンクをいくつか利用していましたが、それらを削除しました。これにより、本サイトにお越しいただいた方を追跡することはなくなりました。また、過去のGoogle Analyticsログについても削除いたしました。
クッキーについては現在は、配信サーバであるCloudflareのクッキーのみでこちらは主に配信制御用のものです。
今回は特に何か問題があったための対処ではなく、もともと分析やアフィリエイトも活用していなかったことと、プライバシー保護は今後基本的なものとなるだろうとの考えからです。

もっと良い作用としてはサイトの表示スピードが速くなりました。WordPressからTumblrへ移行し、TumblrからGithub Pagesへ移行したことで数秒かかっていた表示が1秒台ぐらいに改善していました。今回配信インフラをGithub PagesからCloudflare Workersに変更したことが大きいですが、最後の一押しとしてGoogle Analyticsの削除でさらに高速化され表示時間は0.3秒程度になり、PageSpeedによる評価も無事100点をいただけました。
4th November 2020 #cli #dropbox #dropboxbusiness #toolbox #waterminttoolbox watermint toolboxではDropboxまたはDropbox Business用のコマンドを各種揃えています。今回はDropboxの個人アカウントまたはDropbox Businessチーム全体に対する共有リンクを操作するコマンドを紹介します。
共有リンクの一覧
チーム内の共有リンクをすべてレポートとして出力することで、監査や管理上の資料として利用できます。なお、このコマンドではチームメンバー全員の共有リンクを取得して一覧を作成しますので、チームメンバー数が多い場合には相応の時間がかかります。
詳細はマニュアルに記載していますが、最新版のプログラムをダウンロードして解凍し、次のようなコマンドを実行します。なお、例ではプログラムをデスクトップに解凍したことを想定しています。
WindowsではまずPowerShellを起動し、次のようなコマンドを実行します。(なお、PowerShellへの依存関係はなくコマンドプロンプトやバッチファイルからの起動でも動作します)
まずデスクトップフォルダに移動します。
続いてプログラムを実行します。
.\tbx.exe team sharedlink list
これでしばらく待つとレポートが作成されます。レポートファイルはCSV、xlsx、JSON形式の3種類出力され、画面上にレポートが作成されたパスが表示されます。レポートの書式についてはマニュアルを参照してください。
全体のチーム内の共有リンク有効期限を上書きする
このコマンドでは共有設定で、リンクを知っている人全員となっているチーム内の共有リンクに対して有効期限を上書きすることで実質的には公開リンクを削除できます。有効期限の指定方法は現時点からの日数、または指定した日時です。
たとえば有効期限を30日後に設定したい場合には次のように実行します。
.\tbx.exe team sharedlink update expiry -days 30
これで全ての公開共有リンクの有効期限を30日に上書きします。なお、有効期限が30日以内であるばあいには上書きしませんので、定期的にこのコマンドを実行してチーム全体の有効期限を管理することも可能です。
また、指定日時での有効期限指定も可能です。たとえば、年度末を有効期限としたい場合には次のように実行します。
.\tbx.exe team sharedlink update expiry -at 2021-04-01
このように -at
オプションに続けて日時を指定するとその日時で上書きします。 詳細はマニュアルをご参照ください。
28th July 2020 #cli #gmail #gmailapi #google #googleapi #toolbox #waterminttoolbox New Gmail-related commands have been added to the watermint toolbox. This allows you to get a list of emails from the command line, add/remove/rename labels, and add/remove filters.
% tbx services google mail label list
watermint toolbox 72.4.544
==========================
© 2016-2020 Takayuki Okazaki
Licensed under open source licenses. Use the `license` command for more detail.
Testing network connection...
Done
Opening the authorization URL:
https://accounts.google.com/o/oauth2/auth?client_id=xxxxxxxxxxx-xxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxx.apps.googleusercontent.com&redirect_uri=http%3A%2F%2Flocalhost%3A7800%2Fconnect%2Fauth&response_type=code&scope=https%3A%2F%2Fwww.googleapis.com%2Fauth%2Fgmail.labels&state=xxxxxxxx
Please press ENTER to open the auth page on the browser.
| name | type |
|------------------------------|--------|
| CHAT | system |
| SENT | system |
| INBOX | system |
| IMPORTANT | system |
| TRASH | system |
| DRAFT | system |
| SPAM | system |
| CATEGORY_FORUMS | system |
| CATEGORY_UPDATES | system |
| CATEGORY_PERSONAL | system |
| CATEGORY_PROMOTIONS | system |
| CATEGORY_SOCIAL | system |
| STARRED | system |
| UNREAD | system |
| services/google.com | user |
| services/accounts.google.com | user |
| services/youtube.com | user |
The report generated: /xxxxx/xxxxxxxx/.toolbox/jobs/20200727-074430.001/report/labels.csv
The report generated: /xxxxx/xxxxxxxx/.toolbox/jobs/20200727-074430.001/report/labels.json
The report generated: /xxxxx/xxxxxxxx/.toolbox/jobs/20200727-074430.001/report/labels.xlsx
If you want to use it, please use Release 72 or later.
I label and manage each source to some extent as I process a variety of emails. This is also a bit of a hassle when the number of source types increases, and I counted the number of labels in the command I created this time, and there are already 343 labels.
% tbx services google mail label list -output json | jq 'select(.type == "user") | .id ' | wc -l
343
I checked the number of filters created in the same way and found 474.
% tbx services google mail filter list -output json | wc -l
474
I have been making labels and filters by hand for several years now, but it’s getting tedious, so I made it possible to create labels and filters in batches based on certain conditions. So far, it’s not fully automated, but semi-automated once the CSV data file is created.
Create the source data for the label/filter you want to create.
There are two types of Gmail labels. (1) system labels that are automatically assigned by Gmail, such as INBOX and SPAM, and (2) user-defined user labels. In this time, I’m going to get the list of emails in INBOX and get the data with no user labels attached. In this case, I will add label conditions based on the destination address and source address of the email.
First of all, get the email data, get the source address, and make rules for each domain. I’ve omitted quite a bit, but I get the mail data in JSON format, process it with the jq command and output it as CSV. The first column is the query, the second column is the label to be added, and the third column is the label to be removed. The third column is not specified. If you want to archive automatically, you can do so by deleting INBOX.
% tbx services google mail message processed list -output json | jq -r 'select(.label_type_user | length ==0) | .from.address | ["from:"+., "services/"+capture("@(?<d>\\b([a-z0-9]+(-[a-z0-9]+)*\\.)+[a-z]{2,}\\b)").d] | @csv' | sort -u
"from:families-noreply@google.com","services/google.com"
"from:googlecommunityteam-noreply@google.com","services/google.com"
"from:no-reply@accounts.google.com","services/accounts.google.com"
"from:no-reply@google.com","services/google.com"
"from:noreply-purchases@youtube.com","services/youtube.com"
Create a batch filter based on this data. It also automatically creates any missing labels and applies them to the messages in the INBOX.
% tbx services google mail filter batch add -add-label-if-not-exist -apply-to-inbox-messages -peer waterlandpier -file ~/filters.csv
watermint toolbox `dev`
=======================
© 2016-2020 Takayuki Okazaki
Licensed under open source licenses. Use the `license` command for more detail.
Creating a filter: from:families-noreply@google.com
from:families-noreply@google.com: Updating message 1
from:families-noreply@google.com: Updating message 2
Creating a filter: from:googlecommunityteam-noreply@google.com
from:googlecommunityteam-noreply@google.com: Updating message 1
Creating a filter: from:no-reply@accounts.google.com
from:no-reply@accounts.google.com: Updating message 1
from:no-reply@accounts.google.com: Updating message 2
from:no-reply@accounts.google.com: Updating message 3
from:no-reply@accounts.google.com: Updating message 4
from:no-reply@accounts.google.com: Updating message 5
from:no-reply@accounts.google.com: Updating message 6
from:no-reply@accounts.google.com: Updating message 7
Creating a filter: from:no-reply@google.com
Creating a filter: from:noreply-purchases@youtube.com
from:noreply-purchases@youtube.com: Updating message 1
| status | reason | input.query | input.add_labels | input.delete_labels | result.id | result.criteria_from | result.criteria_to | result.criteria_subject | result.criteria_query | result.criteria_negated_query |
|--------|--------|---------------------------------------------|------------------------------|---------------------|----------------------------------------|----------------------|--------------------|-------------------------|---------------------------------------------|-------------------------------|
| 成功 | | from:families-noreply@google.com | services/google.com | | xxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxx | | | | from:families-noreply@google.com | |
| 成功 | | from:googlecommunityteam-noreply@google.com | services/google.com | | xxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxx | | | | from:googlecommunityteam-noreply@google.com | |
| 成功 | | from:no-reply@accounts.google.com | services/accounts.google.com | | xxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxx | | | | from:no-reply@accounts.google.com | |
| 成功 | | from:no-reply@google.com | services/google.com | | xxxxxxxxxxxxxxxx-xxxxxxxxxxxxxxxxxxxxx | | | | from:no-reply@google.com | |
| 成功 | | from:noreply-purchases@youtube.com | services/youtube.com | | xxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxx | | | | from:noreply-purchases@youtube.com | |
The report generated: /xxxxx/xxxxxxxx/.toolbox/jobs/20200726-223228.001/report/filters.csv
The report generated: /xxxxx/xxxxxxxx/.toolbox/jobs/20200726-223228.001/report/filters.json
The report generated: /xxxxx/xxxxxxxx/.toolbox/jobs/20200726-223228.001/report/filters.xlsx
The report generated: /xxxxx/xxxxxxxx/.toolbox/jobs/20200726-223228.001/report/messages.csv
The report generated: /xxxxx/xxxxxxxx/.toolbox/jobs/20200726-223228.001/report/messages.json
The report generated: /xxxxx/xxxxxxxx/.toolbox/jobs/20200726-223228.001/report/messages.xlsx
I don’t usually have time to create filters in batches, so I’m hoping this will make my email processing a little more efficient.
27th July 2020 #cli #gmail #gmailapi #google #googleapi #toolbox #waterminttoolbox watermint toolboxに新しくGmail関連のコマンドを追加しました。これにより、コマンドラインからメール一覧を取得したり、ラベルを追加・削除・名前変更したり、フィルタを追加・削除できるようになりました。
% tbx services google mail label list
watermint toolbox 72.4.544
==========================
© 2016-2020 Takayuki Okazaki
オープンソースライセンスのもと配布されています. 詳細は`license`コマンドでご覧ください.
ネットワーク接続をテストしています...
完了
認可URLを開きます:
https://accounts.google.com/o/oauth2/auth?client_id=xxxxxxxxxxx-xxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxx.apps.googleusercontent.com&redirect_uri=http%3A%2F%2Flocalhost%3A7800%2Fconnect%2Fauth&response_type=code&scope=https%3A%2F%2Fwww.googleapis.com%2Fauth%2Fgmail.labels&state=xxxxxxxx
ENTERを押してブラウザ上で認証ページを開いてください
| name | type |
|------------------------------|--------|
| CHAT | system |
| SENT | system |
| INBOX | system |
| IMPORTANT | system |
| TRASH | system |
| DRAFT | system |
| SPAM | system |
| CATEGORY_FORUMS | system |
| CATEGORY_UPDATES | system |
| CATEGORY_PERSONAL | system |
| CATEGORY_PROMOTIONS | system |
| CATEGORY_SOCIAL | system |
| STARRED | system |
| UNREAD | system |
| services/google.com | user |
| services/accounts.google.com | user |
| services/youtube.com | user |
レポートが作成されました: /xxxxx/xxxxxxxx/.toolbox/jobs/20200727-072609.001/report/labels.csv
レポートが作成されました: /xxxxx/xxxxxxxx/.toolbox/jobs/20200727-072609.001/report/labels.json
レポートが作成されました: /xxxxx/xxxxxxxx/.toolbox/jobs/20200727-072609.001/report/labels.xlsx
お試しになりたい場合はRelease 72以降をお使いください。
このコマンド群はおもにメールの整理整頓用に整備したもので、今回早速このコマンドを使ってメールを整理してみました。
私は様々なメールを処理する中である程度送信元ごとにラベルをつけて管理しています。これも送信元の種別が増えてくるとなかなか手間を感じてくるもので、今回作成したコマンドで数えてみたところラベル数は343個すでにあるようです。
% tbx services google mail label list -output json | jq 'select(.type == "user") | .id ' | wc -l
343
同様に作成済みフィルタ数を調べてみたところ474個ありました。
% tbx services google mail filter list -output json | wc -l
474
これまで数年かけてコツコツ手作業で作ってきましたが、流石にそろそろ面倒になってきたのでラベルやフィルタを一定の条件をもとに一括作成できるようにしました。今のところ、完全自動作成ではなく一度CSVデータファイルを作成した上での半自動化となっています。
作りたいラベル・フィルタの元データを作る
Gmailのラベルには2種類あります。(1) INBOXやSPAMなどGmailが自動的に付与するシステムラベル、(2) ユーザー定義のユーザーラベルです。今回はINBOXに入っているメール一覧を取得して、ユーザーラベルが付与されていないデータを取得します。今回はメールの宛先アドレスや送信元アドレスからラベル条件をつけていきます。
まずはメールデータを取得して送信元アドレスを取得し、ドメインごとにルールを作ることにしましょう。かなり省略してしまいましたが、メールデータをJSON形式で取得しjqコマンドで加工の上CSVとして出力しています。1列目がクエリ条件、2列目が追加するラベル、3列目が削除するラベルです。3列目は今回指定していませんが、たとえば自動的にアーカイブ処理したい場合はINBOXを削除すれば実現できます。
% tbx services google mail message processed list -output json | jq -r 'select(.label_type_user | length ==0) | .from.address | ["from:"+., "services/"+capture("@(?<d>\\b([a-z0-9]+(-[a-z0-9]+)*\\.)+[a-z]{2,}\\b)").d] | @csv' | sort -u
"from:families-noreply@google.com","services/google.com"
"from:googlecommunityteam-noreply@google.com","services/google.com"
"from:no-reply@accounts.google.com","services/accounts.google.com"
"from:no-reply@google.com","services/google.com"
"from:noreply-purchases@youtube.com","services/youtube.com"
このデータをもとにフィルタを一括作成します。また、不足しているラベルは自動作成し、INBOX内のメッセージにもラベルを適用します。
% tbx services google mail filter batch add -add-label-if-not-exist -apply-to-inbox-messages -peer waterlandpier -file ~/filters.csv
watermint toolbox 72.4.544
==========================
© 2016-2020 Takayuki Okazaki
オープンソースライセンスのもと配布されています. 詳細は`license`コマンドでご覧ください.
フィルタを作成しています: from:families-noreply@google.com
from:families-noreply@google.com: メッセージ 1を更新しています。
from:families-noreply@google.com: メッセージ 2を更新しています。
フィルタを作成しています: from:googlecommunityteam-noreply@google.com
from:googlecommunityteam-noreply@google.com: メッセージ 1を更新しています。
フィルタを作成しています: from:no-reply@accounts.google.com
from:no-reply@accounts.google.com: メッセージ 1を更新しています。
from:no-reply@accounts.google.com: メッセージ 2を更新しています。
from:no-reply@accounts.google.com: メッセージ 3を更新しています。
from:no-reply@accounts.google.com: メッセージ 4を更新しています。
from:no-reply@accounts.google.com: メッセージ 5を更新しています。
from:no-reply@accounts.google.com: メッセージ 6を更新しています。
from:no-reply@accounts.google.com: メッセージ 7を更新しています。
フィルタを作成しています: from:no-reply@google.com
フィルタを作成しています: from:noreply-purchases@youtube.com
from:noreply-purchases@youtube.com: メッセージ 1を更新しています。
| status | reason | input.query | input.add_labels | input.delete_labels | result.id | result.criteria_from | result.criteria_to | result.criteria_subject | result.criteria_query | result.criteria_negated_query |
|--------|--------|---------------------------------------------|------------------------------|---------------------|----------------------------------------|----------------------|--------------------|-------------------------|---------------------------------------------|-------------------------------|
| 成功 | | from:families-noreply@google.com | services/google.com | | xxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxx | | | | from:families-noreply@google.com | |
| 成功 | | from:googlecommunityteam-noreply@google.com | services/google.com | | xxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxx | | | | from:googlecommunityteam-noreply@google.com | |
| 成功 | | from:no-reply@accounts.google.com | services/accounts.google.com | | xxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxx | | | | from:no-reply@accounts.google.com | |
| 成功 | | from:no-reply@google.com | services/google.com | | xxxxxxxxxxxxxxxx-xxxxxxxxxxxxxxxxxxxxx | | | | from:no-reply@google.com | |
| 成功 | | from:noreply-purchases@youtube.com | services/youtube.com | | xxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxx | | | | from:noreply-purchases@youtube.com | |
レポートが作成されました: /xxxxx/xxxxxxxx/.toolbox/jobs/20200726-223228.001/report/filters.csv
レポートが作成されました: /xxxxx/xxxxxxxx/.toolbox/jobs/20200726-223228.001/report/filters.json
レポートが作成されました: /xxxxx/xxxxxxxx/.toolbox/jobs/20200726-223228.001/report/filters.xlsx
レポートが作成されました: /xxxxx/xxxxxxxx/.toolbox/jobs/20200726-223228.001/report/messages.csv
レポートが作成されました: /xxxxx/xxxxxxxx/.toolbox/jobs/20200726-223228.001/report/messages.json
レポートが作成されました: /xxxxx/xxxxxxxx/.toolbox/jobs/20200726-223228.001/report/messages.xlsx
フィルタを一括作成したいようなときは大抵時間がないので、これで少しでもメール処理の効率が上がればと思っています。
26th July 2020 #deepl #internationalization #omegat #translation DeepLというAI翻訳の精度が高いと評判なので、翻訳メモリソフトウエアOmegaTと組み合わせて試しています。

DeepLでOmegaTのようなCATツールを使うためにはAdvanced以上のプランへの契約が必要となるようです。Advanced以上のプランに申し込むとAPIキーを取得できます。
OmegaTでは標準的にDeepLをサポートしているので設定の「Machine Translation」→「DeepL」にチェック→「Configure」からAPIキーを設定すれば完了です。あとはMachine Translationウインドウを固定して使っていきます。翻訳された結果をそのまま適用する場合にはCmd+M (macOSの場合)で一発変換されます。
実際に使ってみた印象
評判通り良い点としては翻訳品質がかなり高い点が挙げられます。特に英語→日本語訳はほとんど修正せずとも読める文章に翻訳されます。日本語→英語訳については言語の特徴として主語が抜ける部分があり、主語が「We」で訳されるか「I」と訳されるかはその時々によります。
困ったところはタグの扱いがまだ苦手なようです。たとえばGo言語のテンプレートで使う {{.Name}}
のような表記について翻訳結果には開始の {{{
が {{{
と1文字増えたり、終了も}}}
と増えたりするケースが見られました。 OmegaTのTag Processingに次のような正規表現で登録し \{\{\.(\w+)\}\}
、正しく認識しているようですがこの辺りは改善を待つ格好となるでしょう。