ffmpegで動画を圧縮
概要
sice2021で動画を投稿する必要が有ったのですがファイル容量40MBまでとなっていました。 私のファイルは300MBだったので7割ほど容量の軽量化を行う必要が有りました。 そこで使用したのがffmpegコマンド!ということで備ぼる。
圧縮方法
ffmpeg -i file-name -c:a copy -c:v libx265 -crf 22 file-name-compress.mp4
以上です。
画面をコマンドでロックする
概要
基本、家のPC(ubuntu)のモニターなどはつけっぱにしたいのですが つけっぱだと親に怒られます。なんでつけっぱかと言うと面倒くさいからです。。。
やりかた
以下をインストール
sudo apt install gnome-screensaver
以下を.bashrcに追加
echo alias lo='gnome-screensaver-command -l' >> ~/.bashrc
sourceしたらlockを実行。
netplanで無線接続(メモ)
メモ
network: version: 2 renderer: NetworkManager wifis: wlan0: addresses: [192.168.100.149/24] dhcp4: false gateway4: 192.168.100.1 nameservers: addresses: - 192.168.100.1 search: [] access-points: "WAVLINK-2.4G": password: "karaagetabetai4!"
vscodeでclang-formatを使用する
概要
最近、formaterをgithub actionsで使うようになりました。先にそっち?って感じですよね。 手元でも動かせるようにしたのでやり方を備ぼる。
環境
・ubuntu 18.04
・vscode 1.58.2
やり方
1.clang-formatをインストール
sudo apt install clang-format-6.0
2.vscodeの拡張のClang-Formatを入れる
3.vscodeのsetting.jsonに保存時にフォーマットしてくれるように設定を追記する
---中略---- "clang-format.executable": "/usr/bin/clang-format-6.0", "editor.formatOnSave": true, "editor.formatOnType": false, "[cpp]": { "editor.defaultFormatter": "xaver.clang-format" }, }
4.ワークスペース下に.clang-formatのファイルを置く
.clang-formatの配置場所の例
.clang-formatの例
--- Language: Cpp # BasedOnStyle: Google AccessModifierOffset: -1 AlignAfterOpenBracket: Align AlignConsecutiveAssignments: false AlignConsecutiveDeclarations: false AlignEscapedNewlines: Left AlignOperands: true AlignTrailingComments: true AllowAllParametersOfDeclarationOnNextLine: true AllowShortBlocksOnASingleLine: false AllowShortCaseLabelsOnASingleLine: false AllowShortFunctionsOnASingleLine: All AllowShortIfStatementsOnASingleLine: true AllowShortLoopsOnASingleLine: true AlwaysBreakAfterDefinitionReturnType: None AlwaysBreakAfterReturnType: None AlwaysBreakBeforeMultilineStrings: true AlwaysBreakTemplateDeclarations: true BinPackArguments: true BinPackParameters: true BraceWrapping: AfterClass: true AfterControlStatement: true AfterEnum: true AfterFunction: true AfterNamespace: true AfterObjCDeclaration: true AfterStruct: true AfterUnion: true AfterExternBlock: true BeforeCatch: true BeforeElse: true IndentBraces: false # Unlike GNU style, do not indent braces SplitEmptyFunction: true SplitEmptyRecord: true SplitEmptyNamespace: true BreakBeforeBinaryOperators: None BreakBeforeBraces: Custom # See BraceWrapping section BreakBeforeInheritanceComma: false BreakBeforeTernaryOperators: true BreakConstructorInitializersBeforeComma: false BreakConstructorInitializers: BeforeColon BreakAfterJavaFieldAnnotations: false BreakStringLiterals: true ColumnLimit: 100 CommentPragmas: '^ IWYU pragma:' CompactNamespaces: false ConstructorInitializerAllOnOneLineOrOnePerLine: true ConstructorInitializerIndentWidth: 4 ContinuationIndentWidth: 4 Cpp11BracedListStyle: true DerivePointerAlignment: true DisableFormat: false ExperimentalAutoDetectBinPacking: false FixNamespaceComments: true ForEachMacros: - foreach - Q_FOREACH - BOOST_FOREACH IncludeBlocks: Preserve IncludeCategories: - Regex: '^<ext/.*\.(h|hh|hpp|cuh)>' Priority: 2 - Regex: '^<.*\.(h|hh|hpp|cuh)>' Priority: 1 - Regex: '^<.*' Priority: 2 - Regex: '.*' Priority: 3 IncludeIsMainRegex: '([-_](test|unittest))?$' IndentCaseLabels: true IndentPPDirectives: None IndentWidth: 2 IndentWrappedFunctionNames: false JavaScriptQuotes: Leave JavaScriptWrapImports: true KeepEmptyLinesAtTheStartOfBlocks: false MacroBlockBegin: '' MacroBlockEnd: '' MaxEmptyLinesToKeep: 1 NamespaceIndentation: None ObjCBlockIndentWidth: 2 ObjCSpaceAfterProperty: false ObjCSpaceBeforeProtocolList: false PenaltyBreakAssignment: 2 PenaltyBreakBeforeFirstCallParameter: 1 PenaltyBreakComment: 300 PenaltyBreakFirstLessLess: 120 PenaltyBreakString: 1000 PenaltyExcessCharacter: 1000000 PenaltyReturnTypeOnItsOwnLine: 200 PointerAlignment: Left # clang-format6 uses 'Delimiter' and clang-format7 uses 'Delimiters' as field. # RawStringFormats: # - Delimiter: pb # Language: TextProto # BasedOnStyle: google ReflowComments: true SortIncludes: true SortUsingDeclarations: true SpaceAfterCStyleCast: false SpaceAfterTemplateKeyword: true SpaceBeforeAssignmentOperators: true SpaceBeforeParens: ControlStatements SpaceInEmptyParentheses: false SpacesBeforeTrailingComments: 2 SpacesInAngles: false SpacesInContainerLiterals: true SpacesInCStyleCastParentheses: false SpacesInParentheses: false SpacesInSquareBrackets: false Standard: Auto TabWidth: 8 UseTab: Never
ctl+cとctl+\でプロセスを速攻落とせるらしい
概要
プロセスを速攻落とす方法を知ったので備ぼる
やりかた
ctl+cをターミナルで打った後にctl+\を打つ。
ctl+\だけでもできる。(オススメしない)
完了
例えば、今までctl+cで10秒ぐらい掛かってたgazeboのプロセスkillが 1秒で終わるようになる。
これは良いやり方なのか知らべてないが。。。。(たまにgazeboが上手く落ちないときがある)
gazeboのwindowが残ったままになる場合
killall gzclient
特定のtopicとかをクリップボードにコピーする方法
概要
トピックを毎回rostopic listで調べてカーソール使ってコピーしてペーストする作業って なんだかんだ面倒くさいです。クリップボードにコピー出来たらストレスフリーで良いのになと 思ってました。そんなことはやれるようになってるだろうと思って調べたら確かにできそうなコマンドが ありました。ということで備ぼります。
インストールするもの
sudo apt-get install xsel
実行コマンド
perl -pe 's/\n/ /' | xsel --clipboard --input
実例
roscore rostopic list | grep ros | perl -pe 's/\n/ /' | xsel --clipboard --input
コマンドが長いのでエイリアス
alias x="perl -pe 's/\n/ /' | xsel --clipboard --input"
⇩
roscore rostopic list | grep ros | x
優勝👑