COMMAND | sed -E "s/"$'\E'"\[([0-9]{1,2}(;[0-9]{1,2})*)?m//g" > FILE_NAME
COMMAND | sed -r 's/\x1b\[[0-9;]*m//g' | tee FILE_NAME
find . -name "*.py" -path "*/migrations/*" ! -name "__init__.py" | xargs rm -f
sh -c 'mkdir -p "$(dirname "$0")" && touch "$0"' src/aaa/bbb/ccc.ts
\ls | sort -n | awk '{ ext=$0; gsub(/^.*\./, "", ext); printf "mv %s %03d.%s\n", $0, NR, ext }' | sh
# \ls -tr | awk ... is also useful.
\ls | sort -n | awk -F'.' '{ printf "mv %s %03d.%s\n", $0, NR, $2}' | sh
\ls | sort -n | awk -F'.' '{ printf "mv %s %03d.%s\n", $0, NR+20, $2}' | sh
grep -rl TEXT DIR
du -sh ~/Library/*
du -h -d 1 -c -x ~/Library | sort -h
:!mkdir -p %:h
:set is hls[hlsearch]
:%s/\(amazon.co.jp\/\).*\/\(dp\/[0-9A-Za-z]\+\/\).*/\1\2/ge
:%s/\%x1b\[[0-9;]*m//g
:put! =expand('*') | g/^$/d | %s/\(.*\)\.\(.*\)/\='mv ' . submatch(0) . ' ' . printf('%03d', line('.')) . '.' . submatch(2)/ge | noh
:w !sh # unix
:w !cmd # windows
# ! execute shell command(s) in vim and r! put the result on vim
:r! ls -rlat | tr -s ' ' | cut -d ' ' -f 9 | grep -v -e '^\.*$'
:g/^$/d | %s/\(.*\)\.\(.*\)/\='mv ' . submatch(0) . ' ' . printf('%03d', line('.')) . '.' . submatch(2)/ge | noh
insert UUID by ex command.
:r !uuidgen|sed 's/.*/ "pk": "&",/'|tr "[A-Z]" "[a-z]"
insert UUID to :substitute
:%s/\(.*\)\t\(.*\)/\='{"pk":"' . system("uuidgen | tr -d '\n' | tr '[A-Z]' '[a-z]'") . '","fields":{"code":"' . submatch(1) . '","name":"' . submatch(2) . '"}},'
convert snake_case to camelCase
'%s/_\([a-z]\)/\u\1/ge
'<,'>s/_\([a-z]\)/\u\1/ge
git diff [TARGET_BRANCH] --name-status
git checkout [TARGET_BRANCH] -- `git diff --diff-filter=[FILTER] [TARGET_BRANCH] --name-only`
git remote prune --dry-run origin
and delete them via the following command.
git remote prune origin
git branch -v -r --no-merged
git branch -v -r --merged origin/[TARGET_BRANCH]
if you want to delete branches that are already merged into the master/main branch, you can delete all of them via the following command.
git branch --merged | grep -v -e master | xargs -I{} git branch -d {}
git branch -r --merged origin/master | grep -v -e master | sed -e 's/origin\///g' | xargs -I{} git branch -d {}
for branch in `git branch`; do git branch -r | sed -e 's;origin/;;g' | grep -ow "$branch" | uniq ; done
diff --changed-group-format='%<' --unchanged-group-format='' <(git branch | sed -e 's/^[ \*]*//') <(for branch in `git branch`; do git branch -r | sed -e 's;origin/;;g' | grep -ow "$branch" | uniq ; done) | xargs -I{} git branch -d {}
# or
diff --changed-group-format='%<' --unchanged-group-format='' <(git branch | sed -e 's/^[ \*]*//') <(git branch -r | sed -e 's;^.*origin/;;g') | xargs -I{} git branch -d {}
<(...)
is called process substitution. It converts the output of a command into a file-like object that diff can read from.
(`...`
is called command substitution.)
Unfotunatelly, Apple diff doesn't have --unchanged-group-format
option.
NixOS/nix#7286
# git fetch -p && diff --changed-group-format='%<' --unchanged-group-format='' <(git branch | sed -e 's/^[ \*]*//') <(git branch -r | sed -e 's;^.*origin/;;g') | xargs -I{} git branch -D {}
git fetch -p && (diff --changed-group-format='%<' --unchanged-group-format='' <(git branch | sed -e 's/^[ \*]*//') <(git branch -r | sed -e 's;^.*origin/;;g')) | xargs -I{} git branch -D {}
docker run —rm -d —net localnetwork_app_net -p 5432:5432 —name postgres -v ~/postgresql_data:/var/lib/postgresql/data -e POSTGRES_PASSWORD=password postgres:13.3
docker exec -it $(docker ps -q -f 'NAME=xxx') psql -U [USERNAME] [DB_NAME]
docker exec -i postgres psql -U postgres -c "CREATE USER dbuser WITH PASSWORD 'password'
docker exec -i postgres psql -U postgres -c "CREATE DATABASE postgresdb"
docker run postgres:13.8 pg_dump --data-only postgres://[USERNAME]:[PASSWORD]@[IP_ADDRESS]:[PORT]/[DB_NAME] > dump.sql
cat ./dump.sql | docker exec -i [CONTAINER_ID] psql -U [USERNAME] [DB_NAME]
# one liner
docker run postgres:13.8 pg_dump --data-only postgres://[USERNAME]:[PASSWORD]@[IP_ADDRESS]:[PORT]/[DB_NAME] | docker exec -i [CONTAINER_ID] psql -U [USERNAME] [DB_NAME]
docker run postgres:13.8 pg_dump --data-only postgres://[USERNAME]:[PASSWORD]@[IP_ADDRESS]:[PORT]/[DB_NAME] | docker exec -i $(docker ps -q -f 'NAME=xxx') psql -U [USERNAME] [DB_NAME]
# docker compose
docker compose exec -T [CONTAINER_NAME] pg_restore -cO -d [DB_NAME] -U [USER_NAME] -w < [DUMP_FILE]
docker compose exec -T [CONTAINER_NAME] psql -P pager=off -U [USER_NAME] -d [DB_NAME] -A -F, -w < ~/local/sample.sql | sed '$d'
docker compose exec -T [CONTAINER_NAME] psql -P pager=off -U [USER_NAME] -d [DB_NAME] -A -F, -w < ~/local/sample.sql | sed '$d' > sample.csv
docker exec -it [CONTAINER_NAME] mysql -u [USER_NAME] -p[PASSWORD] -N -e "SELECT TABLE_CATALOG, TABLE_SCHEMA, TABLE_NAME, COLUMN_NAME, COLUMN_DEFAULT, IS_NULLABLE, DATA_TYPE, CHARACTER_MAXIMUM_LENGTH, NUMERIC_PRECISION, NUMERIC_SCALE, DATETIME_PRECISION, CHARACTER_SET_NAME, COLLATION_NAME, COLUMN_TYPE, COLUMN_KEY FROM information_schema.columns where table_schema = '[SCHEMA_NAME]';
openssl rsautl -encrypt -pubin -oaep -inkey public.pem -in passwd.txt -out passwd.encrypted
base64 passwd.encrypted
echo -n "password1" | openssl rsautl -encrypt -pubin -oaep -inkey public.pem | base64
ffmpeg -i input.mp4 -vf scale=800:-1 -r 16.667 output.gif
filters="fps=12,scale=640:-1:flags=lanczos"
ffmpeg -i input.mp4 -vf "$filters,palettegen=stats_mode=diff" -y palette.png
ffmpeg -i input.mp4 -i palette.png -lavfi "$filters,paletteuse=dither=bayer:bayer_scale=5:diff_mode=rectangle" -y output.gif
# one liner
i="input.mp4"; p="palette.png"; o="output.gif"; f="fps=12,scale=1080:-1:flags=lanczos" && ffmpeg -i $i -vf "$f,palettegen=stats_mode=diff" -y $p && ffmpeg -i $i -i $p -lavfi "$filters,paletteuse=dither=bayer:bayer_scale=5:diff_mode=rectangle" -y $o
i="input.mp4";r=1.0;f="fps=12,scale=640:-1:flags=lanczos,setpts=PTS/$r";p=palette.png; ffmpeg -i $i -vf "$f,palettegen=stats_mode=diff" -af atempo=$r -y $p && ffmpeg -i $i -i $p -lavfi "$f,setpts=PTS/$r,paletteuse=dither=bayer:bayer_scale=5:diff_mode=rectangle" -af atempo=$r -y output.gif
# n times speed (1.5x, 2.0x, 4.0x)
i="input.mp4"; p="palette.png"; o="output.gif"; r=4.0; f="fps=12,scale=640:-1:flags=lanczos,setpts=PTS/$r"; ffmpeg -i $i -vf "$f,palettegen=stats_mode=diff" -af atempo=$r -y $p && ffmpeg -i $i -i $p -lavfi "$f,setpts=PTS/$r,paletteuse=dither=bayer:bayer_scale=5:diff_mode=rectangle" -af atempo=$r -y $o
According to the doc, The -lavfi
option is equivalent to -filter_complex.
See: Reference1, Reference2, Reference3
ffmpeg --ss [START_TIME e.g. 00:00:30] -i input.mp4 -t [DURATION e.g. 00:01:00 -vcodec copy -acodec copy -async 1 output.mp4
code --list-extensions | xargs -L 1 echo code --install-extension
code --install-extension [EXTENSION_ID]