Last active
February 28, 2023 16:43
-
-
Save SmartFinn/bbf51e8b9c6d75527e00f22b238e23f8 to your computer and use it in GitHub Desktop.
description
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
[[snippets]] | |
description = "Pull and merge GitHub PR" | |
command = "git pull origin pull/<issue_number>/head" | |
tag = ["git", "github"] | |
output = "" | |
[[snippets]] | |
description = "Featch GitHub PR" | |
command = "git fetch origin pull/<issue_number>/head:<new_branch_name>" | |
tag = ["git", "github"] | |
output = "" | |
[[snippets]] | |
description = "Find broken symlinks" | |
command = "find <dir=.> -xtype l" | |
tag = ["shell"] | |
output = "" | |
[[snippets]] | |
description = "Delete an element from SVG" | |
command = "xmlstarlet ed -N s=http://www.w3.org/2000/svg --delete \"/s:svg/s:defs/s:style[@id='current-color-scheme']\" <file>" | |
tag = ["shell", "svg", "xml"] | |
output = "" | |
[[snippets]] | |
description = "Delete an element from SVG (w/o namespace)" | |
command = "xmlstarlet ed --delete \"/_:svg/_:defs/_:style[@id='current-color-scheme']\" <file>" | |
tag = ["shell", "svg", "xml"] | |
output = "" | |
[[snippets]] | |
description = "Delete a remote branch" | |
command = "git push origin --delete <remote_branch>" | |
tag = ["git", "github"] | |
output = "" | |
[[snippets]] | |
description = "Find symlinks to target file" | |
command = "find -L . -samefile <file>" | |
tag = ["shell"] | |
output = "" | |
[[snippets]] | |
description = "Cleanup local git repository" | |
command = "git reflog expire --all --expire=now; git gc --prune=now --aggressive" | |
tag = ["git"] | |
output = "" | |
[[snippets]] | |
description = "Uninstall system app w/o root" | |
command = "adb shell pm list packages | peco | sed 's/^package://' | xargs -I{} adb shell pm uninstall --user 0 '{}'" | |
tag = ["adb", "android"] | |
output = "" | |
[[snippets]] | |
description = "Restore config file from the deb package" | |
command = "dpkg -i --force-confmiss <deb_file>" | |
tag = ["shell", "apt"] | |
output = "" | |
[[snippets]] | |
description = "Restore config file from the package (apt version)" | |
command = "apt-get install --reinstall -o Dpkg::Options::=\"--force-confmiss\" <package>" | |
tag = ["shell", "apt"] | |
output = "" | |
[[snippets]] | |
description = "Find deleted file in the commit history" | |
command = "git log --all --full-history -- <file>" | |
tag = ["git"] | |
output = "" | |
[[snippets]] | |
description = "Restore deleted file into your working copy" | |
command = "git checkout <sha>^ -- <file>" | |
tag = ["git"] | |
output = "" | |
[[snippets]] | |
description = "Run tftp server" | |
command = "sudo dnsmasq -d -u \"$USER\" -p0 -i <interface=eth0> --enable-tftp --tftp-root=$HOME/tftp" | |
tag = ["shell", "tftp"] | |
output = "" | |
[[snippets]] | |
description = "Delete remote branch in the local git repository" | |
command = "git branch -r -d <remote_branch>" | |
tag = ["git"] | |
output = "" | |
[[snippets]] | |
description = "Show expiration date of SSL certificate" | |
command = "echo | openssl s_client -connect <domain>:<port=443> 2>/dev/null | openssl x509 -dates -noout" | |
tag = ["shell"] | |
output = "" | |
[[snippets]] | |
description = "Force update cache of fonts" | |
command = "fc-cache -f -v" | |
tag = ["shell", "fonts"] | |
output = "" | |
[[snippets]] | |
description = "Adjust color temperature for GNOME Night Light" | |
command = "gsettings set org.gnome.settings-daemon.plugins.color night-light-temperature <temp=4200>" | |
tag = ["gnome"] | |
output = "" | |
[[snippets]] | |
description = "Show the weather" | |
command = "wget -qO- wttr.in/<location=47.7548,37.228> | less -S" | |
tag = ["shell", "service"] | |
output = "" | |
[[snippets]] | |
description = "Export variables from dotenv file" | |
command = "export $(grep -v '^#' .env | xargs)" | |
tag = ["shell"] | |
output = "" | |
[[snippets]] | |
description = "Print horizontal line" | |
command = "printf '%*s\\n' \"${COLUMNS:-$(tput cols)}\" '' | tr ' ' -" | |
tag = ["shell"] | |
output = "" | |
[[snippets]] | |
description = "Go to project root" | |
command = "cd \"$(git rev-parse --show-toplevel)\"" | |
tag = ["git", "shell"] | |
output = "" | |
[[snippets]] | |
description = "List only untracked files" | |
command = "git ls-files --others --exclude-standard" | |
tag = ["git"] | |
output = "" | |
[[snippets]] | |
description = "Validate SVG files in the current directory" | |
command = "find . -type f -name '*.svg' -exec xmlstarlet validate --list-bad '{}' \\;" | |
tag = ["shell", "svg"] | |
output = "" | |
[[snippets]] | |
description = "List uncommitted files" | |
command = "git ls-files --modified --others --exclude-standard" | |
tag = ["git"] | |
output = "" | |
[[snippets]] | |
description = "Turn off monitor" | |
command = "xset dpms force off" | |
tag = ["shell", "dev"] | |
output = "" | |
[[snippets]] | |
description = "Find circular symlinks" | |
command = "find . -follow -printf \"\"" | |
tag = ["shell", "find"] | |
output = "" | |
[[snippets]] | |
description = "Undo 'git reset'" | |
command = "git reset HEAD@{1}" | |
tag = ["git"] | |
output = "" | |
[[snippets]] | |
description = "Import a git repo as branch" | |
command = "git remote add <BRANCH_NAME> <URI_TO_REPO>; git fetch <BRANCH_NAME>" | |
tag = ["git"] | |
output = "" | |
[[snippets]] | |
description = "Backup GPT partition table to a file" | |
command = "sudo sgdisk --backup=<FILE> <DEV>" | |
tag = ["shell"] | |
output = "" | |
[[snippets]] | |
description = "Restore GPT partition table from a file" | |
command = "sudo sgdisk --load-backup=<FILE> <DEV>" | |
tag = ["shell"] | |
output = "" | |
[[snippets]] | |
description = "Change file encoding" | |
command = "iconv -f <from=cp1251> -t <to=utf-8> <file>" | |
tag = ["shell"] | |
output = "" | |
[[snippets]] | |
description = "Find files that have been modified in the past N hours" | |
command = "find <dir=.> -type f -newermt \"now -<N=2 hours>\"" | |
tag = ["shell", "find"] | |
output = "" | |
[[snippets]] | |
description = "Find files with modification time older than N days" | |
command = "find <dir=.> -type f -not -newermt \"now -<N=7 days>\"" | |
tag = ["shell", "find"] | |
output = "" | |
[[snippets]] | |
description = "HDD/SSD benchmark" | |
command = "fio --loops=5 --size=1000m --filename=<FILEPATH> \\\n\t--stonewall --ioengine=libaio --direct=1 \\\n\t--name=Seqread --bs=1m --rw=read \\\n\t--name=Seqwrite --bs=1m --rw=write \\\n\t--name=512Kread --bs=512k --rw=randread \\\n\t--name=512Kwrite --bs=512k --rw=randwrite \\\n\t--name=4kQD32read --bs=4k --iodepth=32 --rw=randread \\\n\t--name=4kQD32write --bs=4k --iodepth=32 --rw=randwrite" | |
tag = ["ssh", "hdd", "benchmark"] | |
output = "" | |
[[snippets]] | |
description = "Compare two directories" | |
command = "diff -qr <dir1=.> <dir2=.>" | |
tag = ["shell", "diff"] | |
output = "" | |
[[snippets]] | |
description = "Export subpath of dconf database to a file" | |
command = "dconf dump <DIR=/org/gnome/desktop/> > <FILE>.dconf" | |
tag = ["shell", "dconf"] | |
output = "" | |
[[snippets]] | |
description = "Import subpath to dconf database from a file" | |
command = "dconf load <DIR=/org/gnome/desktop/> < <FILE>.dconf" | |
tag = ["shell", "dconf"] | |
output = "" | |
[[snippets]] | |
description = "Reset subpath of dconf database to default values" | |
command = "dconf reset -f <DIR=/org/gnome/desktop/>" | |
tag = ["shell", "dconf"] | |
output = "" | |
[[snippets]] | |
description = "Find fragmented files that have more than 10 extents" | |
command = "find . -type f -exec filefrag '{}' \\; | grep -E '[1-9][0-9]+ extents? found'" | |
tag = ["shell", "fs"] | |
output = "" | |
[[snippets]] | |
description = "Add a user to a group" | |
command = "sudo usermod -a -G <GROUP=docker> <USER=$USER>" | |
tag = ["system"] | |
output = "" | |
[[snippets]] | |
description = "Remove a user from a group" | |
command = "sudo gpasswd -d <USER=$USER> <GROUP=sudo>" | |
tag = ["system"] | |
output = "" | |
[[snippets]] | |
description = "Remove file from Git history" | |
command = "git filter-branch --force --index-filter \"git rm --cached --ignore-unmatch <FILE>\" --prune-empty --tag-name-filter cat -- --all" | |
tag = ["shell", "git"] | |
output = "" | |
[[snippets]] | |
description = "Convert webpage to PDF file" | |
command = "chrome --headless --disable-gpu --print-to-pdf <SITE=https://google.com>" | |
tag = ["shell"] | |
output = "" | |
[[snippets]] | |
description = "Removes all archived journal files contain no data older than the specified timespan" | |
command = "sudo journalctl --vacuum-time=<DAYS=7d>" | |
tag = ["shell", "systemd"] | |
output = "" | |
[[snippets]] | |
description = "Install Fedora 32 in chroot environment" | |
command = "dnf --releasever=32 --installroot=/mnt groupinstall core" | |
tag = ["dnf", "chroot"] | |
output = "" | |
[[snippets]] | |
description = "Check what processes are listening" | |
command = "ss --no-header -pltun | awk '{print $2,$1,$5,$7}' | column -t" | |
tag = ["shell", "network", "iproute", "ss"] | |
output = "" | |
[[snippets]] | |
description = "Cleanup vim undo files" | |
command = "pushd ~/.cache/vim/undo; for f in *; do fp=\"${f:gs/%/\\//}\"; test -f \"$fp\" || rm -v \"$f\"; done; popd" | |
tag = ["shell", "vim"] | |
output = "" | |
[[snippets]] | |
description = "The fastest way to delete large numbers of files" | |
command = "mkdir empty && rsync -r --delete empty/ <DIR> && rmdir <DIR>" | |
tag = ["shell", "rsync"] | |
output = "" | |
[[snippets]] | |
description = "List of processes with uses swap" | |
command = "for file in /proc/*/status ; do awk '/VmSwap|Name/{printf $2 \" \" $3}END{ print \"\"}' $file; done | sort -k 2 -n -r | less" | |
tag = ["shell", "swap", "memory"] | |
output = "" | |
[[snippets]] | |
description = "Convert SVG to PNG with Inkscape and parallel" | |
command = "parallel inkscape -z -e \"<OUT_DIR=.>/{1/.}_{2}.png\" -w \"{2}\" -h \"{2}\" \"{1}\" ::: *.svg ::: 32 40 48 64" | |
tag = ["shell", "parallel", "svg"] | |
output = "" | |
[[snippets]] | |
description = "Open new pull request on GitHub for current branch" | |
command = "git pull-request --browse --edit --file .github/PULL_REQUEST_TEMPLATE.md" | |
tag = ["git"] | |
output = "" | |
[[snippets]] | |
description = "find a process that using port" | |
command = "lsof -i :<port number>" | |
tag = ["network", "port", "tcp", "udp"] | |
output = "" | |
[[snippets]] | |
description = "create a new google app script" | |
command = "clasp create <new-script-title>" | |
tag = ["clasp", "google-script", "gas"] | |
output = "" | |
[[snippets]] | |
description = "clone an existing app script project into the current directory" | |
command = "clasp clone <scriptId>" | |
tag = ["clasp", "google-script", "gas"] | |
output = "" | |
[[snippets]] | |
description = "creates an immutable version of the script that can be deployed" | |
command = "clasp version <description>" | |
tag = ["clasp", "google-script", "gas"] | |
output = "" | |
[[snippets]] | |
description = "deploy a version of your script to Gsuite" | |
command = "clasp deploy <version> <description>" | |
tag = ["clasp", "google-script", "gas"] | |
output = "" | |
[[snippets]] | |
description = "undeploy the selected script" | |
command = "clasp undeploy <deploymentId>" | |
tag = ["clasp", "google-script", "gas"] | |
output = "" | |
[[snippets]] | |
description = "updates an existing deployment with a new version and description" | |
command = "clasp redeploy <deploymentId> <version> <description>" | |
tag = ["clasp", "google-script", "gas"] | |
output = "" | |
[[snippets]] | |
description = "opens the script in the Apps Scripts editor (editor is launched as a new tab in the default browser)" | |
command = "clasp open" | |
tag = ["clasp", "google-script", "gas"] | |
output = "" | |
[[snippets]] | |
description = "Encrypt file with OpenSSL" | |
command = "openssl aes-256-cbc -pbkdf2 -e -in <DECFILE> -out <ENCFILE>" | |
tag = ["openssl"] | |
output = "" | |
[[snippets]] | |
description = "Decrypt file with OpenSSL" | |
command = "openssl aes-256-cbc -pbkdf2 -d -in <ENCFILE> -out <DECFILE>" | |
tag = ["openssl"] | |
output = "" | |
[[snippets]] | |
description = "Test socks proxy" | |
command = "curl -x socks://<user:login>@<proxy=openwrt:1080> <host=ifconfig.co>" | |
tag = ["network", "socks", "proxy"] | |
output = "" | |
[[snippets]] | |
description = "Benchmark zsh startup" | |
command = "for i in {1..10}; do time zsh -i -c exit; done" | |
tag = ["zsh", "bench"] | |
output = "" | |
[[snippets]] | |
description = "Run tshark over ssh" | |
command = "ssh <host> \"sudo /usr/sbin/tcpdump -i <interface=any> -U -w - port not 22\" | tshark -i -" | |
tag = ["network", "tcpdump", "tshark"] | |
output = "" | |
[[snippets]] | |
description = "TCP port forwarding over SSH" | |
command = "ssh -L <LOCAL_PORT>:localhost:<REMOTE_PORT> <REMOTE_HOST>" | |
tag = ["ssh", "network"] | |
output = "" | |
[[snippets]] | |
description = "SOCKS proxy over SSH" | |
command = "ssh -D <LOCAL_PORT> -C <REMOTE_HOST>" | |
tag = ["ssh", "network"] | |
output = "" | |
[[snippets]] | |
description = "List imported RPM GPG keys" | |
command = "rpm -q gpg-pubkey --qf '%{NAME}-%{VERSION}-%{RELEASE}\\t%{SUMMARY}\\n'" | |
tag = ["dnf", "rpm", "system"] | |
output = "" | |
[[snippets]] | |
description = "List flatpak runtime dependencies" | |
command = "flatpak list --app --columns=application,runtime" | |
tag = ["flatpak"] | |
output = "" | |
[[snippets]] | |
description = "Remove unused dependencies" | |
command = "flatpak remove --unused" | |
tag = ["flatpak"] | |
output = "" | |
[[snippets]] | |
description = "Export docker volume to a tarball" | |
command = "docker run --rm -v <VOLUME_NAME>:/volume <IMAGE=alpine:latest> sh -c \"tar -C /volume -cOzf - .\" > <VOLUME_NAME>-export.tar.gz" | |
tag = ["docker", "shell"] | |
output = "" | |
[[snippets]] | |
description = "pacman: list user installed packages" | |
command = "pacman -Qqett" | |
tag = ["pacman"] | |
output = "" | |
[[snippets]] | |
description = "pacman: remove all cached versions of uninstalled packages" | |
command = "sudo pacman -Sc" | |
tag = ["pacman"] | |
output = "" | |
[[snippets]] | |
description = "pacman: completely remove all packages from the cache" | |
command = "sudo pacman -Scc" | |
tag = ["pacman"] | |
output = "" | |
[[snippets]] | |
description = "Trim video" | |
command = "ffmpeg -i <INPUT_FILE> -ss <START_POSITION=00:01:00> -t <DURATION=00:02:00> -c copy <OUTPUT_FILE>" | |
tag = ["ffmpeg"] | |
output = "" | |
[[snippets]] | |
description = "Create a video from images" | |
command = "ffmpeg -framerate <FRAME_RATE=10> -pattern_type glob -i '<INPUT_FILES=*.jpg>' -c:v libx264 <OUTPUT_FILE>" | |
tag = ["ffmpeg"] | |
output = "" | |
[[snippets]] | |
description = "Video stabilization" | |
command = "ffmpeg -i \"<INPUT_FILE>\" -vf vidstabdetect=shakiness=10:accuracy=15:result=\"mytransforms.trf\" -f null -; ffmpeg -i \"<INPUT_FILE>\" -vf vidstabtransform=input=\"mytransforms.trf\":smoothing=10:optalgo=avg,unsharp=5:5:0.8:3:3:0.4 \"deshake_<INPUT_FILE>\"" | |
tag = ["ffmpeg"] | |
output = "" | |
[[snippets]] | |
description = "Generate random HEX color" | |
command = "hexdump -n 3 -v -e # 3/1 %02X \\n /dev/urandom" | |
tag = ["shell"] | |
output = "" | |
[[snippets]] | |
description = "Boot into an ephemeral snapshot of the host system" | |
command = "sudo systemd-nspawn --directory \"<ROOT_TREE=/>\" --ephemeral --boot --bind-ro=/run/systemd/resolve:/run/systemd/resolve --bind=/home:/home --overlay=+/home::/home" | |
tag = ["systemd", "shell"] | |
output = "" | |
[[snippets]] | |
description = "List opened ports" | |
command = "lsof -P -i -n" | |
tag = ["shell", "network"] | |
output = "" | |
[[snippets]] | |
description = "Fix incorrect date in the metadata" | |
command = "exiftool -time:all+=1:30:00 ." | |
tag = ["shell", "exif"] | |
output = "" | |
[[snippets]] | |
description = "Save the original filename in the metadata" | |
command = "exiftool -OriginalFileName<filename ." | |
tag = ["shell", "exif"] | |
output = "" | |
[[snippets]] | |
description = "Delete all lines between two matching patterns (incl)" | |
command = "sed '/^# BEGIN/,/^# END/d' <FILE>" | |
tag = ["shell", "sed"] | |
output = "" | |
[[snippets]] | |
description = "Delete all lines between two matching patterns (excl)" | |
command = "sed '/^# BEGIN/,/^# END/{//!d;};' <FILE>" | |
tag = ["shell", "sed"] | |
output = "" | |
[[snippets]] | |
description = "Remove duplicates in a text file" | |
command = "awk '!(count[$0]++)' <old.txt> > <new.txt>" | |
tag = ["awk", "text"] | |
output = "" | |
[[snippets]] | |
description = "Sort strings by length" | |
command = "awk '{print length, $0}' <old.txt> | sort -n | cut -d -f2- > <new.txt>" | |
tag = ["awk", "text"] | |
output = "" | |
[[snippets]] | |
description = "Remove all blank lines in a text file" | |
command = "egrep -v \"^[[:space:]]*$\" <old.txt> > <new.txt>" | |
tag = ["text"] | |
output = "" | |
[[snippets]] | |
description = "Get outbond interface name for default route" | |
command = "ip -4 route list 0/0 | cut -d' ' -f5" | |
tag = ["network", "shell"] | |
output = "" | |
[[snippets]] | |
description = "Check web server (healthcheck)" | |
command = "wget --no-verbose --tries=1 --spider <HOST=http://127.0.0.1:8000>" | |
tag = ["shell"] | |
output = "" | |
[[snippets]] | |
description = "Convert file to JSON array splitted by newline" | |
command = "cat <FILE> | jq -R -s -c split(\"\\n\") | map(select(length > 0))" | |
tag = ["shell", "jq", "text"] | |
output = "" | |
[[snippets]] | |
description = "Remove the last commit" | |
command = "git reset --hard HEAD~" | |
tag = ["git", "shell"] | |
output = "" | |
[[snippets]] | |
description = "Git: code searching" | |
command = "git rev-list --all | xargs git grep -F '<PATTERN>'" | |
tag = ["shell", "git"] | |
output = "" | |
[[snippets]] | |
description = "Log what files are accessed by Linux command" | |
command = "strace -fe trace=creat,open,openat,unlink,unlinkat <CMD> 2>strace.log" | |
tag = ["shell", "strace"] | |
output = "" | |
[[snippets]] | |
description = "Set datetime from filename" | |
command = "exiftool '-alldates<filename' −overwrite_original ." | |
tag = ["shell"] | |
output = "" | |
[[snippets]] | |
description = "Rename media file based on Exif datetime" | |
command = "exiftool '-filename<DatetimeOriginal' -d IMG_%Y%m%d_%H%M%S%%-c.%%e ." | |
tag = ["shell"] | |
output = "" |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment