setdefaultで辞書に無いキーと値をセットする[Python]

name_list = d = {}for name in name_list: len_name = len(name) head_name = name d.setdefault(name, ()).append((len_name, ...
Let’s Encryptで取得した証明書の無効化[AWS Lightsail]

「certbot」により、「Let’s Encrypt」で取得した証明書を削除する方法です。
証明書の無効化には、revokeコマンドを使います。
certbotの証明書ディレクトリを調べる「cer ...
別ディレクトリにあるクラスや関数をimportする方法

import部分で該当のクラス、関数があるパスを指定
import syssys.path.append("/home/ubuntu/script/hogehoge/")import hogehoge[Linux] historyに履歴を残さない方法

先に結論
HISTCONTROL=ignorespace
をコマンドラインに打ち込み、先頭にスペースを1つ入れて実行すると、入力したコマンドが履歴に残らなくなる。
Let’s encryptの自動更新[cron]

SSL更新を自動化するためにcronにコマンドの登録を行った。
まず crontab -eで編集画面を開いて、次の1行を打ち込んだ。
# 日曜(0)の0時0分に更新0 0 * * 0/usr/bin/sudo/usr ...WordPress-Multisiteは使わないほうが良い[AWS][Lightsail]

1つのWordpressインスタンスで複数ドメインのホームページを運用しようとしたのだが、大失敗だった。以下の手順に沿って、マルチサイト化できたのは良い。
だけど問題はその後だ。SSLの更新の時に、少しエラーが起こってイン ...
WordPress 右下のロゴを消す

# 削除のコマンドsudo/opt/bitnami/apps/wordpress/bnconfig --disable_banner 1# 再起動sudo/opt/bitnami/ctlscript.sh restart apache
...
Arduinoで火災報知機をつくってみた

家にある電気ストーブにオフタイマーが付いていなくて、ついついつけっぱなしにしてしまうことがあった。ときには8時間以上つけっぱなしにしていることがあって、その分の電気代もったいないし、火災の危険もあるためなんとかせねばならないと考えた。 ...
VGG16 pre-trainedの中間層を用いたモデル構築例[pytorch]

import osimport globimport randomimport numpy as npimport pandas as pdfrom sklearn.model_selection import train_test_spl ...
strでmaxをかけると直感と異なる動作になる[Python]

# 正規表現で文字列から数字を抽出していたときのことl = re.findall(r"(\d*)", "for 5-10 h")# 抽出されたリストにはstrで数字が入っているl>># maxで大きい方をとりたいmax(l)>>'5' # ...