开发工作常用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环境开发,可能对其他平台上的东西涉猎很少,需要补充的还有很多,如果大家觉得值得记录在此的,欢迎留言。我将不胜感激~~

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