Posts in category “Tips”

git stash -S # stash staging changes only

git-stash-s.png

Don't change the inode when editing a file with Vim

I keep my config files on github, and I use hard-link for most of the config files. It's convenient, as I can check the new changes easily and submit some of the changes when necessary. However, the default behavior of vim troubles me. It always changed the inode when I save the config file!

tldr; the solution is: put the following line in your .vimrc

set backupcopy=yes

PS Though this way fixed Vim's behavior, I sadly found that git pull will change the config file's inode as well. So there is actually no feasible solution. I have abandoned this hard link approach. If you have better solutions to maintain all your config files in one repository, please let me know!

How to delete all bin/obj folders in a complex solution in GitBash

Sometimes we need to delete all the bin/obj folders in a solution to resolve issues in Rider or Visual Studio. I assume you already have your preferred method for this task, but I would like to share my approach here in case someone else is unaware of how to do it in GitBash or MSYS terminal:

#!/bin/bash

set -e

# Find and display directories to be deleted
find . \( -iname "bin" -o -iname "obj" \) -type d -print

# Prompt user for confirmation
read -p "The above folders are going to be deleted, are you sure? [Y/N]: " -n 1 -r
echo    # Move to a new line

# Delete directories if confirmed
if [[ $REPLY =~ ^[Yy]$ ]]; then
    find . \( -iname "bin" -o -iname "obj" \) -type d -exec rm -rfv {} +
    echo "Done"
else
    echo "No"
    exit 1
fi

不确定是不是真的有用,但还是记下来备忘

毕竟自己和父母都会老去,老年痴呆症离我们并不是很遥远。

读《最初的爱,最后的故事》时读到:

在老年痴呆症的早期,特别是对于素食主义者,检查他们血液中的维生素B12的水平,若发现大幅低于正常范围, 注射维生素B12看看效果。若有效果可适当加大剂量并定期补充维生素B12,有病例从痴呆状态复原,智力恢复正常,又健康的活了好几年。

Power shell: Start-Transcript and Stop-Transcript help you log a session.