A good start for Dockerfile
构建 Docker 镜像,这样开发调试都是与真实线上环境一致。 123456789# 查看所有镜像docker images# 从 Dockerfile 中构建一个镜像,并保存为 ubuntu:22.04,注意,「.」表示配置文件在当前目录docker build -t ubuntu:22.04 .# 启动镜像,一般会写成一个 shell 脚本docker run -it --rm -v /sacode:/worksapce 123456789101112131415161718192021222324252627282930313233343536# 基础镜像FROM ubuntu:22.04# 设置环境变量ENV DEBIAN_FRONTEND=noninteractive# 更新软件源并安装基础工具RUN apt-get update && apt-get install --no-install-recommends -y \ build-essential \ cmake \ gdb \ clang \ lldb \...
Read mail
当收到邮件时,终端会在登录后显示:”You have mail.”。 这时,可以使用 mail 命令阅读邮件: 12345678// 读信mail -N// 删除d *// 退出quit
Crontab 定时任务
crontab -e crontab -l */30 * * * * ps -ef | grep debugserver | xargs kill 每 30 分钟 kill hang 掉的进程
Upgrade Hexo to 7.0.0
vim package.json modify hexo version from 6.3.0 to 7.0.0 close files. run npm update then test, hexo clean hexo g hexo s hexo d
Git rebase
如果你正在 feature 分支上合作开发,并且你追踪的是上游的 feature 分支,当你要提 pr 时,发现落后 master 分支若干次提交, 那么,你可以这样: 12345678910111213141516171819# 之前 feature ==> upstream/feature# step 1git branch -u upstream/dev# 这时,在终端你可以看到 feature 分支落后 master 若干次提交;# step 2git pull -r# 如果没有冲突,你可以看到已经和 master 分支对齐了# 如果有冲突,可以解冲突、add、git rebase --continue 继续,直至全部对齐为止# step 3# 推到上游即可git push upstream -f # step 4# 再切回追踪的 feature 为上游git branch -u upstream/feature
CMake CPP
目录结构 12345CMakeLists.txt/src/include/lib/build 其中 CMakeLists.txt 内容如下: 123456789101112131415161718# CMake 最低版本号要求cmake_minimum_required (VERSION 2.8)# C++ 11 支持:qset(CMAKE_CXX_FLAGS "-std=c++11")# 项目信息project (my_demos)# 设置源码位置set(SRC ${PROJECT_SOURCE_DIR}/src/carrots.cpp)# 生成可执行文件的位置set(CMAKE_RUNTIME_OUTPUT_DIRECTORY ${PROJECT_SOURCE_DIR}/bin)# 指定生成目标add_executable(${PROJECT_NAME} ${SRC}) cd 到 build 目录下,生成 Makefile: 1cd build &&...
Debug with LLDB
First, compile codes with DSYM: 1g++ -g test.cpp -o test then, launch with LLDB Debugger: 1lldb test print codes: 1list(l) numbers set breakpoint: 1breakpoint set --file test.cpp --line 13 enable breakpoint: 1breakpoint enable 1 run program: 1run debug step-in: 1n continue to end: 1c
tar command
macOS 压缩gtar –exclude=.git –exclude=.gitignore –exclude=.DS_Store –exclude=build –exclude=.vscode –exclude=.gitattributes -czvf my_codes.tar.gz ./my_codes general linux 下压缩tar -czvf ./backup.tar.gz ./current_folder linux 下解压缩tar -xzvf ./backup.tar.gz –no-same-owner
2022-upgrade-my-blog-to-6.3.0-hexo
Recently I update my blog from 4.0.0 to 6.3.0 hexo.
How to read the book and write down note
俗话说,好记性,不如烂笔头。 当开始阅读时,第一次不定能理解所有内容,这时,笔记的作用就来了,笔记可以帮助你整理思路,日后再看书时,可以更进一步地理解之前没有理解了的内容。 笔记的另一个好处是,可以帮助学习者建立起费曼学习法的过程。 一个新知识,只有用浅显地语言再讲出来时,才能说明学习者真正地理解了。