開發工作常用Tips總結

引言

在日常開發過程中,開發者們會逐漸形成自己的一套開發習慣以及擅長工具。這裏我將開發過程中用到一些小的tip進行記錄,以便後面查詢與複習。

linux黃金命令

這裏主要涉及linux下的grepfind命令的使用。這兩個命令是遠程開發過程中的利器。

grep -irn "mAP" run_1.0.0.log

1016:Final mAP:0.84522 mAR:0.8887 acc:0.807415
10389:Final mAP:0.823055 mAR:0.838678 acc:0.845253

./run.sh > 1.log 2>&1 | tee 1.log

執行腳本,並將輸出寫入到1.log中,同時也在terminal中顯示

    images=$(find models/license  -name "*.png")
    for img in ${images}; do
        echo $img
        name=`basename $img`
        echo $name
        target="models/result/${name%.*}_result.jpg"
        echo $target
		crop_suffix=${target%_result.jpg}
        echo $crop_suffix
    done
models/license/6c047dacb7fe42be9fca9144d22ee5fa.png
6c047dacb7fe42be9fca9144d22ee5fa.png
models/result/6c047dacb7fe42be9fca9144d22ee5fa_result.jpg
models/result/6c047dacb7fe42be9fca9144d22ee5fa

去除文件行尾的空白

sed -i 's/[[:space:]]\+$//' filename

加強版,去除C++項目中的行尾空白 find . -type f \( -name '*.cpp' -o -name '*.c' -o -name '*.hpp' -o -name '*.h' -o -name '*.cu' -o -name '*.txt' \) -exec sed -i 's/[[:space:]]\+$//' {} +

git

gitconfig配置

[user]
	email = [email protected]
	name = xxxxx
[core]
	editor = vim

[alias]
	lg1 = log --graph --abbrev-commit --decorate --format=format:'%C(bold blue)%h%C(reset) - %C(bold green)(%ar)%C(reset) %C(white)%s%C(reset) %C(dim white)- %an%C(reset)%C(bold yellow)%d%C(reset)' --all
	lg2 = log --graph --abbrev-commit --decorate --format=format:'%C(bold blue)%h%C(reset) - %C(bold cyan)%aD%C(reset) %C(bold green)(%ar)%C(reset)%C(bold yellow)%d%C(reset)%n''          %C(white)%s%C(reset) %C(dim white)- %an%C(reset)' --all
	lg = !"git lg1"

使用git統計代碼信息

  1. 統計個人代碼量: git log --author="jartto" --pretty=tformat: --numstat | awk '{ add += $1; subs += $2; loc += $1 - $2 } END { printf "added lines: %s, removed lines: %s, total lines: %s", add, subs, loc }' -

  2. 貢獻值統計: git log --pretty='%aN' | sort -u | wc -log

  3. 查看排名前 5 的貢獻者: git log --pretty='%aN' | sort | uniq -c | sort -k1 -n -r | head -n 5

gdb

  1. 在gdb中打印STL容器中的內容

  2. android上使用gdb調試程序

結束語

由於我主要是在linux環境開發,可能對其他平臺上的東西涉獵很少,需要補充的還有很多,如果大家覺得值得記錄在此的,歡迎留言。我將不勝感激~~

發表評論
所有評論
還沒有人評論,想成為第一個評論的人麼? 請在上方評論欄輸入並且點擊發布.
相關文章