Will's Blog

「离开世界之前 一切都是过程」

Command-line goodies

我整理了一些小而精的命令行工具,在编写 Bash 脚本的时候可能有奇效。 本文部分代码由 AI 生成 xargs 将标准输入(stdin)中的数据转换成命令行参数 1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 # 删除包含特定文本的所有文件 grep -rl "text" . | xargs rm # 删除所有空文件和空目录 find . -type f -empty -print0 | xargs -0 rm fi...

The power of grep, sed, and awk

Grep g/re/p: globally search for a regular expression and print matching lines Usage 1 grep [OPTION]... PATTERNS [FILE]... instructions from running grep --help PATTERNS can contain multiple patterns separated by newlines. When FILE is ‘-‘, read standard input. With no FILE, read ‘.’ ...

Bash Scripting Tricks

Special variables Syntax Description $0 Filename of current script $1-$9 The n^th^ argument $$ Process ID $# Number of arguments $* The list of arguments ...

FFmpeg Tricks

Scenarios Generate gif 1 ffmpeg -i <input_file> -ss <start_time> -t <length> -vf "fps=15,scale=-1:360:flags=spline,split[a][b];[a]palettegen[p];[b][p]paletteuse" <output_file> Generate thumbnail Generic 1 2 3 4 5 6 7 8 9 +-----+-----+-----+-----+ | 1 | ...

Kitty

Migrating to a new terminal emulator

The fast, feature-rich, GPU based terminal emulator Binary install 1 2 3 4 5 6 curl -L https://sw.kovidgoyal.net/kitty/installer.sh | sh /dev/stdin ln -s ~/.local/kitty.app/bin/kitty ~/.local/bin/ cp ~/.local/kitty.app/share/applications/kitty.desktop ~/.local/share/applications/ cp ~/.lo...

Lua Notes

Fundamentals Print and Comments 1 2 3 4 5 6 print("Hello World!") -- this is a one-line comment --[[ this is a multi-line comment it can go here ]] Math 1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 print(math.floor(2.345)) -- 2 print(math.ceil(2.345)) -- 3 print(math.max(2,3)) -- 3 print(math.mi...

(Neo)Vim Trick | Using Macros

Vim 编辑器中「宏」的使用

Macro is probably one of those hidden gems of (Neo)Vim, but most beginners don’t know the use cases although they know it’s powerful. Recording a macro is a great way to perform a one-time task, or to get things done quickly when you don’t want to mess with Vim script or mappings, or if you d...

有趣的英语习语 / 俚语

Interesting slangs and idioms

维基百科写道: Slang is vocabulary (words, phrases, and linguistic usages) of an informal register, common in spoken conversation but avoided in formal writing. It also sometimes refers to the languag...

MySQL Notes

Database operations List databases 1 SHOW DATABASES; Create database 1 CREATE DATABASE <database_name>; Delete database 1 DROP DATABASE <database_name>; Use database 1 USE <database_name>; Show current database 1 SELECT database(); Table opera...

Git Tricks Worth Knowing

使用 Git 的「奇技淫巧」

Restore / Reset Restore file change 1 git restore <filename> Reset all changes 1 git reset --hard HEAD Unstage 1 git restore --cached <filename> Restore accidental deletion before commit 1 git checkout HEAD <filename> Restore deleted file after co...