diffで改行コードの違いを無視する
diff --strip-trailing-cr LF.txt CRLF.txt
pythonの辞書型あれこれ
条件を指定して選び出す
値がNone以外の項目だけで新たな辞書を作る。
dic = {k:v for k,v in dic.items() if v != None}
応用で2つの辞書の差分(not in)、積(in)もできる。
dic = {k:v for k,v in softmachine.items() if k not in nucleus}
keyを指定して分けたい
指定keysで「選び出す」1
def dict_pick(src:dict, *keys) -> dict: ''' srcから指定されたkeyだけを取り出した辞書を返す srcにないkeyは除外される srcは変化しない ''' d = {} for k in keys & src.keys(): d[k] = src.get(k) return d >>> dict_pick(cactus, 'guitar', 'bass', 'drums') {'guitar' : 'Jim McCarty', 'bass' : 'Tim Bogert', 'drums' : 'Carmine Appice'}
指定keysで「抜き出す」、get
=>pop
def dict_pickout(src:dict, *keys) -> dict: ''' srcは変化する、指定された項目がsrcから削除される ''' d = {} for k in keys & src.keys(): d[k] = src.pop(k) return d >>> dict_pickout(jethrotull, 'vocal') {'vocal' : 'Ian Anderson'} >>> jethrotull.get('vocal') None # Ian Andersonが唯一無二なのさ
参考
-
「取り出す」という日本語は、元から取り出して別に移す(元からは消える)のだろうか?英語だとextract?、じゃあ元は残る場合は「選び出す」?<出す>と書くと残らない気がする。よく分からないので選び出す、抜き出す、pick, pick outと書いたが間違っていると思うので、求む正解。↩
brewで更新しようとしたら何か出た
更新しようとしたらなんか出た。
$ brew update
Error:
homebrew-core is a shallow clone.
homebrew-cask is a shallow clone.
To `brew update`, first run:
git -C /usr/local/Homebrew/Library/Taps/homebrew/homebrew-core fetch --unshallow
git -C /usr/local/Homebrew/Library/Taps/homebrew/homebrew-cask fetch --unshallow
These commands may take a few minutes to run due to the large size of the repositories.
This restriction has been made on GitHub's request because updating shallow
clones is an extremely expensive operation due to the tree layout and traffic of
Homebrew/homebrew-core and Homebrew/homebrew-cask. We don't do this for you
automatically to avoid repeatedly performing an expensive unshallow operation in
CI systems (which should instead be fixed to not use shallow clones). Sorry for
the inconvenience!
なにこれ。
今までHomebrewの更新はshallow cloneで行っていたが、GitHubの負荷が大きいため、完全なcloneに変更になった。
ので、今のshallowリポジトリを完全なものにするgit -C XXX fetch --unshallow
して、ね。
git -C /usr/local/Homebrew/Library/Taps/homebrew/homebrew-core fetch --unshallow
git -C /usr/local/Homebrew/Library/Taps/homebrew/homebrew-cask fetch --unshallow
ということらしい。
~は壊れているため開ません。ゴミ箱に入れる必要があります。
(Homebrew経由で入れた)Google Chromeを使おうとしたら出た。
まさにコレ。
macOSのセキュリティGatekeeperをOFFにする。
$ sudo apctl --master-disable //戻すときは--master-enable
password入力後、システム環境設定>セキュリティとプライバシー>すべてのアプリケーションを許可
が選択済みになり、開けるようになる。
markdownのページ内リンク
<a>
タグで名前付きアンカーを作って、アドレスを#
から指定する。
### h3 <a id='h3'></a> [h3へ](#h3)
見出しを<a>
タグの中に入れちゃうと、markdownが見出し認識しない。
brew-caskで入れたものを更新する
追加2020/11/20
$ brew upgrade --cask [--greedy] [FORMULA...]
brewから直接upgradeする。
以下古い。
$ brew cask upgrade [--dry-run]
ただし、バージョン情報を持たないもの(version: latest)や、自動更新機能がある(auto_updates true)アプリケーションは除外される。
含める場合は--greedy
をつける(=貪欲)
$ brew cask upgrade --greedy
個別にアップデートしたい場合は名前を指定する
$ brew cask upgrade chromedriver
brewから出来るようになった。
cask = (酒を入れる)大樽、桶