------------
分类: LINUX
2024-08-17 15:14:45
search/replace on selected/visual area/test
'<,'>s/\%V\ /\,0x/g
:version # show misc info
:scriptnames # show init scripts loaded
#Insert sequence
g/$/s//\=line('.')
g/^/s//\=line('.')
g/wqc/s//\=line('.')
g/wqc/s//\=line('.')-14/
set foldmethod=syntax
set foldmethod=indent
set foldnestmax=10
set nofoldenable
set foldlevel=2
set foldcolumn=4
- #quit screen and terminate all session in it
- screen -X -S screen_name quit
- #remove dup without sort:
- awk '!a[$0]++' file
- #cmake compile_commands.json
- -DCMAKE_EXPORT_COMPILE_COMMANDS=True
- #check if bash script is sourced
- (return 0 2>/dev/null) && sourced=1 || sourced=0
- #Colors: https://www.cnblogs.com/unclemac/p/12783387.html
renice {
#!/bin/sh
if [[ x$1 = x--wrap ]]; then
echo "my pid: $$"
echo "params: $@"
shift
renice -n -20 -p $$
exe=$(realpath $0)
exec $exe $@
fi
echo "my pid x: $$"
echo "params: $@"
}
- git push origin --delete BranchName
- git push origin feature-branch:feature-branch
- git clone -b --single-branch
- # disable core.compression
- git config --global core.compression 0
- # clone only head
- git clone --depth 1 url
- # fetch all
- git fetch --unshallow
- # check with pull
- git pull --all
fix 'unable to update local ref' {
git gc --prune=now
git pull
git remote prune origin
}
git show-branch --merge-base
git merge-base branch2 branch3
- #
- wsl network when vpn {
#ref: https://blog.csdn.net/whuisland/article/details/125026163
#ref:
set metrics by admin@powershell {
Get-NetAdapter | Where-Object {$_.InterfaceDescription -Match "Cisco AnyConnect"} | Set-NetIPInterface -InterfaceMetric 6000
Get-NetIPInterface -InterfaceAlias "vEthernet (WSL)" | Set-NetIPInterface -InterfaceMetric 1
}
##The InterfaceMetric is a value associated with each adapter that determines the order of those adapters. This allows windows to determine which adapter to prefer over another one.
##By setting the interface metric of the Cisco adapter to 4000 and the metric of the WSL adapter to one, we allow the traffic from WSL to flow through the Cisco adapter. To be honest I do not exactly understand why this works but it does.
get_anyconnect_dns() {
local DNS_L=""
local L=""
local flg=0
while read L; do
if [[ flg -eq 0 ]]; then
if [[ x"$L" =~ x.*AnyConnect.*Adapter.* ]]; then
flg=1
fi
continue
fi
if [[ flg -eq 1 ]]; then
if [[ x"$L" =~ x.*DNS[[:space:]]+Server.*:[[:space:]]*([0-9]+\.[0-9]+\.[0-9]+\.[0-9]+).* ]]; then
flg=2
DNS_L=${BASH_REMATCH[1]}
fi
continue
fi
if [[ flg -eq 2 ]]; then
if [[ x"$L" =~ ^x[[:space:]]*([0-9]+\.[0-9]+\.[0-9]+\.[0-9]+).* ]]; then
DNS_L="$DNS_L ${BASH_REMATCH[1]}"
fi
break
fi
done
echo $DNS_L
}
{
echo '[network]'
echo 'generateResolvConf = false'
} > /etc/wsl.conf
for d in $(/mnt/c/Windows/system32//ipconfig.exe /all |tr -d '\r' |get_anyconnect_dns); do
echo "nameserver $d"
done > /etc/resolv.conf
}
- #
- ffmpeg {
for f in *.png; do
##apng -> gif
ffmpeg -i $f -f apng $f.gif
##scale to 0.5 and reserve transparency
ffmpeg -i $f.gif -filter_complex \
"[0:v] scale=iw/2:ih/2:flags=neighbor,split [a][b]; [a] palettegen=reserve_transparent=on:transparency_color=ffffff [p]; [b][p] paletteuse" ${f}2.gif
done
ffmpeg -i $f -vf "scale=iw/2:ih/2" ${f/.gif/}2.gif
- #compress
- ffmpeg -y -i 2_input.mp4 -c:a copy -c:v libx264 -profile:v high -r 30 -crf 30 -b:v 200k -s 1920x1080 -movflags +faststart 2_output.mp4 -hwaccel cuvid -threads 4
- #embed subtitle
ffmpeg.exe -i C:\Users\qingc\Desktop\菜根谭.mp4 -i C:\Users\qingc\Desktop\ 菜根谭.vtt -c:s mov_text -c:v copy -c:a copy cai-gen-tan.mp4
- }
学者以多方丧生
大道以歧路亡羊
佛者觉,菩萨者识
做佛容易,做菩萨难
根本智易得,差别智难求
离一切诸相,即名诸佛
能施一切法,名诸菩萨