# Go inside personal workspace folder
mkdir -p ~/workspace/cednore && cd ~/workspace/cednore
# Clone this gist
git clone [email protected]:a698954555ed680717b6a0832283bfdf.git useful-shell-snippets
# Clear recent files list on nautilus
rm ~/.local/share/recently-used.xbel
# Generate secure random strings
openssl rand -hex 16
openssl rand -base64 32
# Get local IP address of all docker containers
docker inspect -f "{{.Name}} - {{range .NetworkSettings.Networks}}{{.IPAddress}}{{end}}" $(docker ps -aq)
# Clean everything on your local docker environment
docker system df && docker system prune --all --volumes --force && docker system df
# Backup all docker images into a single tar file and save tag list file
docker save $(docker images -q) -o /path/to/save/dockers_images.tar
docker images | sed '1d' | awk '{print $1 " " $2 " " $3}' > dockers_images.list
# Restore docker images and tag them from tag list file
docker load -i /path/to/save/dockers_images.tar
while read REPOSITORY TAG IMAGE_ID
do
echo "== Tagging $REPOSITORY $TAG $IMAGE_ID =="
docker tag "$IMAGE_ID" "$REPOSITORY:$TAG"
done < dockers_images.list
# ls with numerical chmod permissions
ls -l | awk '{k=0;for(i=0;i<=8;i++)k+=((substr($1,i+2,1)~/[rwx]/) *2^(8-i));if(k)printf("%0o ",k);print}'
# Print bash colormap
for i in {0..255}; do print -Pn "%K{$i} %k%F{$i}${(l:3::0:)i}%f " ${${(M)$((i%6)):#3}:+$'\n'}; done
# Save clipboard contents to a png file
xclip -selection clipboard -t image/png -o filename.png
# Scan QR code from clipboard contents
xclip -selection clipboard -t image/png -o | zbarimg -
# Flush DNS cache
sudo systemd-resolve --flush-caches
Last active
July 1, 2022 23:37
-
-
Save cednore/a698954555ed680717b6a0832283bfdf to your computer and use it in GitHub Desktop.
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment