プログラミングに関する忘備録
都度更新!
windowsのショートカット
- IMEの辞書登録 Ctrl + F7
python pip
インストールされているライブラリを表示する
pip freeze
git command
【用語】
- 作業ツリー:Gitで管理されたディレクトリ(と含まれるファイル)のこと
git show HEAD^:presentation.pptx > temp.pptx #ひとつ前のコミットを別ファイルとして取りだし
git add -A 全ての変更をステージング
git commit -m "コメント" ステージングした変更をコミット
git push リモートに反映
git reset --soft "HEAD^" コミットの削除 --softは変更はそのままにするという意味
git clean -f 追跡されていないすべてのファイルを削除します。
git clean -df 追跡されていないすべてのファイルとディレクトリを削除します。
git checkout . 作業ツリーを戻す(すべて)
git checkout branch_name 既存のブランチに切り替えます。
git checkout -b ブランチ名 ブランチを作成して作成したブランチを現在にする
git branch どのブランチが現在かを確認
git branch -d ブランチ名 ブランチを削除する
git branch -m new_name 現在のブランチの名前を変更します。
git push origin :branch_name リモートブランチを削除します。
コマンドプロンプト
jupyter notebook %jupyter_home% フォルダを指定してjupyterを起動
%sikuli_home%/runsikulix.cmd -r ***.sikuli >>***Log.txt sikuliスクリプトを起動 log.txtにログを出す
bush command
ps ux | grep fess "fess"を含む自分が立ち上げているプロセスを表示
kill プロセスid プロセスを終了
kill -9 プロセスid プロセスを強制終了
正規表現
サルにもわかる正規表現入門 https://www.mnet.ne.jp/~nakama/
.: なんでもいい1文字
.*: なんでもいい文字の連続
| : いずれかの文字列
[ ] : 指定した文字のどれか
VScodeで引数を渡してデバッグする
.vscode\launch.json の中に"args":["arg1", "arg2"]を追加する。これで、"arg1", "arg2"が引数として渡される。上記設定の上、uke.pyを実行すると、"arg1", "arg2"がプリント出力される
{
// IntelliSense を使用して利用可能な属性を学べます。
// 既存の属性の説明をホバーして表示します。
// 詳細情報は次を確認してください: https://go.microsoft.com/fwlink/?linkid=830387
"version": "0.2.0",
"configurations": [
{
"name": "Python: Current File",
"type": "python",
"request": "launch",
"program": "${file}",
"console": "integratedTerminal",
"args":["arg1", "arg2"]
}
]
}
import sys
param = sys.argv
print(param[1])
print(param[2])
VS Codeショートカット
- コマンドパレット F1 または Ctrl+Shift+P
- viewの拡大/縮小 Ctrl + / Ctrl -
- エクスプローラを表示 Ctrl+Shift+E
- 関数の説明(パラメーター ヒント)を表示 Ctrl+Shift+Space
- 入力候補 Ctrl+Space
VS codeのマルチカーソル
- Ctrl + D で選択中のキーワードを一件ずつ選択していく。Ctrl + K -> Ctrl + Dで1件飛ばせる
VS codeで正規表現を使って置換
検索文字列 print("(.*)")
置換 print("$1これを足します")
print("任意の文字列")がprint("任意の文字列これを足します")に変わります。便利!
VS notesのセットアップ
ファイル → ユーザ設定 → 設定 → ユーザ → 拡張機能 → VSNotes configuration
b. スニペットの登録
[Code]> [基本設定] > [ユーザースニペット] で、markdown.jsonを開き、下記を追加
※vsnote_template_xxxのxxxの部分がテンプレートの名前になる。あとの設定でxxxを登録する
"vsnote_template_base": {
"prefix": "vsnote_template_base",
"body": [
"---",
"tags:",
"\t- base",
"---",
"\n# $TM_FILENAME_BASE\n",
"$1",
],
"description": "base Template",
}
c. 初期のファイル名とスニペットの登録
上記のページで、右上のアイコンをクリックして、jsonの設定を開いて、下記を追加

スニペットは、vsnotes.templatesで上記のxxxを入力。例ではbase
,
"vsnotes.noteTitleConvertSpaces": " ",
"vsnotes.defaultNoteTitle": "{dt} {title}.{ext}",
"vsnotes.tokens": [
{
"type": "datetime",
"token": "{dt}",
"format": "YYYY-MM-DD",
"description": "Insert formatted datetime."
},
{
"type": "title",
"token": "{title}",
"description": "Insert note title from input box.",
"format": "Untitled"
},
{
"type": "extension",
"token": "{ext}",
"description": "Insert file extension.",
"format": "md"
}
],
"vsnotes.templates": [
"base",
]
