Last active
December 7, 2022 11:08
-
-
Save schollz/044ded385a902a0455f4f9f5f9c66731 to your computer and use it in GitHub Desktop.
description
This file contains 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 = "Grep all files in a folder" | |
command = "grep -rn \"texthere\" ." | |
output = "" | |
[[snippets]] | |
description = "Sync only certain files using filters and rsync" | |
command = "rsync -rv --include '*/' --include '*something*' --exclude '*' --prune-empty-dirs Source/ Target/" | |
output = "" | |
[[snippets]] | |
description = "Search and replace in a bunch of files using sed" | |
command = "sed -i -e 's/SEARCHFOR/REPLACEMENT/g' *" | |
output = "" | |
[[snippets]] | |
description = "Search and replace in a bunch of files using sed, and create backups" | |
command = "sed -i.bak -e 's/SEARCHFOR/REPLACEMENT/g' *" | |
output = "" | |
[[snippets]] | |
description = "Search and replace strings in files, except certain folders" | |
command = "find . -type f ! -path \"./.git/*\" -exec sed -i 's/name1/name2/g' {} \\;" | |
output = "" | |
[[snippets]] | |
description = "List all files in a directory, fastest solution" | |
command = "tree -Ufain --noreport -o files.index" | |
output = "" | |
[[snippets]] | |
description = "Download a list of URLs into an organized folder, with cookies" | |
command = "wget -x --load-cookies=cookies.txt --no-clobber -i LIST_OF_URLS" | |
output = "" | |
[[snippets]] | |
description = "DOwnload youtube video as mp3" | |
command = "youtube-dl -x --audio-quality 2 --audio-format mp3 YOUTUBEURL" | |
output = "" | |
[[snippets]] | |
description = "Open a GUI program via SSH or CRON" | |
command = "export DISPLAY=:0 && /open/some/program" | |
output = "" | |
[[snippets]] | |
description = "CRON command to backup a file every 10 minutes" | |
command = "*/10 * * * * /bin/cp /some/file /some/other/file.backup$(date +%Y%m%d)" | |
output = "" | |
[[snippets]] | |
description = "Create a list of lines that are in the new file but not in the old file" | |
command = "grep -F -x -v -f list.old list.new > list.diff" | |
output = "" | |
[[snippets]] | |
description = "Run command over SSH" | |
command = "ssh user@server 'command'" | |
output = "" | |
[[snippets]] | |
description = "Sort datafile by first column in numerical order" | |
command = "sort -s -n -k 1,1 data.dat" | |
output = "" | |
[[snippets]] | |
description = "Word count of files of a particular type" | |
command = "find ./ -type f -name \"*work*\" -exec wc -w {} +" | |
output = "" | |
[[snippets]] | |
description = "Get only the changed lines between diffing two files" | |
command = "diff --new-line-format=\"\" --unchanged-line-format=\"\" urlsfull.txt urls1subset.txt > urlsfull-subset.txt" | |
output = "" | |
[[snippets]] | |
description = "Mirror a website" | |
command = "wget -r -np -N --convert-links --adjust-extension --header=\"Accept: text/html\" --user-agent=\"Mozilla/5.0 (Macintosh; Intel Mac OS X 10.8; rv:21.0) Gecko/20100101 Firefox/21.0\" website.com" | |
output = "" | |
[[snippets]] | |
description = "Hack swiping apps (requires Android Debug Bridge)" | |
command = "while true; do adb shell input tap 1000 2200; sleep .$[ ( $RANDOM % 10 ) + 1 ]s; done" | |
output = "" | |
[[snippets]] | |
description = "Resize images on ImagicMagick" | |
command = "convert -size 100x100 input.png -resize 100x100 +profile \"*\" output.jpg" | |
output = "" | |
[[snippets]] | |
description = "sudo su && cd / && tar -cvpzf backup.tar.gz --exclude=/backup.tar.gz --one-file-system /" | |
command = "Backup an entire filesystem" | |
output = "" | |
[[snippets]] | |
description = "sudo tar -xvpzf /path/to/backup.tar.gz -C /media/whatever --numeric-owner" | |
command = "Restore an entire filesystem" | |
output = "" | |
[[snippets]] | |
description = "Run a command in terminal every 10 seconds" | |
command = "while true; do; COMMAND; sleep 10; done" | |
output = "" | |
[[snippets]] | |
description = "Monitor progresss of inserting SQL statements into database" | |
command = "pv -atep -s $(du -BK data.sql | cut -f1) data.sql | sqlite3 data.db" | |
output = "" | |
[[snippets]] | |
description = "Delete the first column of a data" | |
command = "awk '!($1=\"\")' filename" | |
output = "" | |
[[snippets]] | |
description = "Pipe data into xmgrace" | |
command = "cat datafile | xmgrace -" | |
output = "" | |
[[snippets]] | |
description = "tar a big directory and show the progress http://bit.ly/2nBKQBK" | |
command = "SIZE=`du -sk www.goodreads.com | cut -f 1` && tar cf - www.goodreads.com | pv -atep -s ${SIZE}k > /media/zns/Media/www.goodreads.com.tar" | |
output = "" | |
[[snippets]] | |
description = "Remove .lzma extension from each file in a directory" | |
command = "for i in *.lzma; do; mv -- \"$i\" \"${i%.lzma}\"; done" | |
output = "" | |
[[snippets]] | |
description = "tar a file, with progress, onto a remote server" | |
command = "SIZE=`du -sk www.goodreads.com | cut -f 1` && tar cf - www.goodreads.com | pv -atep -s ${SIZE}k | ssh zns@home.cowyo.com \"cat > www.goodreads.com.tar\"" | |
output = "" | |
[[snippets]] | |
description = "untar a file and get progress bar, with decompression http://archive.is/lbVOo" | |
command = "pv -atep file.tgz | tar xzf - -C target_directory" | |
output = "" | |
[[snippets]] | |
description = "Measure read and write speed of a drive" | |
command = "dd if=/dev/zero of=/test/drive/output conv=fdatasync bs=384k count=1k; rm -f /test/drive/output" | |
output = "" | |
[[snippets]] | |
description = "Convert a bunch of images named final.untitled.00001.jpg to movie" | |
command = "ffmpeg -framerate 25 -i final.untitled.%05d.jpg output.mp4" | |
output = "" | |
[[snippets]] | |
description = "Reveal free space in bytes" | |
command = "df -k *" | |
output = "" | |
[[snippets]] | |
description = "split a file onto multiple USB sticks simultaneously https://z.cowyo.com/split-filter/view" | |
command = "cat www.goodreads.com.dell.tar | pv -atep -s ${SIZE}k | split -b 45966182400 -d - part --filter=./split-filter" | |
output = "" | |
[[snippets]] | |
description = "Find intersection between two lists of items" | |
command = "comm -12 <(cat 1.txt | sort) <(cat 2.txt | sort) > intersection.txt" | |
output = "" | |
[[snippets]] | |
description = "Get number of FILES in a directory using" | |
command = "tree --dirsfirst -UF . | tail -n1" | |
output = "" | |
[[snippets]] | |
description = "Remove all the docker images" | |
command = "docker rmi -f $(docker images -q)" | |
output = "" | |
[[snippets]] | |
description = "Count number of sentences in a file" | |
command = "tr -d -C . <data/news3.txt | wc -c" | |
output = "" | |
[[snippets]] | |
description = "Benchmark a command, see [here for installation](https://askubuntu.com/questions/50145/how-to-install-perf-monitoring-tool)" | |
command = "perf stat -r 50 -d CMD" | |
output = "" | |
[[snippets]] | |
description = "gpg encrypt a file using the armor" | |
command = "gpg --yes --armor --recipient \"THE NAME\" --trust-model always --encrypt FILE" | |
output = "" | |
[[snippets]] | |
description = "gpg decrypt a file" | |
command = "gpg --yes --decrypt FILE" | |
output = "" | |
[[snippets]] | |
description = "Put tor on for everything in the shell" | |
command = ". torsocks on" | |
output = "" | |
[[snippets]] | |
description = "Remove a directory with progress (replace 70000 with number of files)" | |
command = "rm -rv dir_to_remove | pv -l -s 700000 > logfile" | |
output = "" | |
[[snippets]] | |
description = "Untar part of an archive (\"home/foo/bar\" in the archive) to \"/\"" | |
command = "tar -C / -xvf foo.tar home/foo/bar" | |
output = "" | |
[[snippets]] | |
description = "Clone entire drive and show progress (use cat instead of pv for no progress)" | |
command = "pv /dev/sda > /dev/sdb" | |
output = "" | |
[[snippets]] | |
description = "Use xargs to run a command in parallel on files and save the result file in a different folder with the same name" | |
command = "find . -type f -print0 | xargs -0 -n1 -P4 -I {} sh -c 'pluck -a \"a\" -d \"b\" -l -1 -f {} -o out/`basename {}`.json'" | |
output = "" | |
[[snippets]] | |
description = "Run command in parallel and also print progress, when using a filelist" | |
command = "FIND=( find \"www.foodnetwork.com/recipes/ina-garten\" -type f ) && ${FIND[@]} -print0 | pv -0lps $(${FIND[@]} | wc -l) | xargs -0 -n1 -P4 -I {} sh -c 'pluck -c config.toml -f {} -o out/`basename {}`.json'" | |
output = "" | |
[[snippets]] | |
description = "Clone all repositories of an organization or user on Github" | |
command = "curl -s https://api.github.com/users/USER/repos?per_page=200 | python -c $'import json, sys, os\\nfor repo in json.load(sys.stdin): os.system(\"git clone \" + repo[\"ssh_url\"])'" | |
output = "" | |
[[snippets]] | |
description = "Convert website HTML to markdown and strip tags" | |
command = "pandoc -s -S -t markdown-raw_html -o website.md website.html" | |
output = "" | |
[[snippets]] | |
description = "Change all the extension from .old to .new" | |
command = "rename 's/.old/.new/' *.old" | |
output = "" | |
[[snippets]] | |
description = "Create low-resolution of PDF with ghostscript" | |
command = "gs -sDEVICE=pdfwrite -dCompatibilityLevel=1.4 -dPDFSETTINGS=/screen -dNOPAUSE -dQUIET -dBATCH -sOutputFile=PGK.pdf PGKv11.pdf" | |
output = "" | |
[[snippets]] | |
description = "Start auto-syncing webserver with browser-sync" | |
command = "browser-sync start --server --files . --index index.html" | |
output = "" | |
[[snippets]] | |
description = "Remove old docker stuff https://stackoverflow.com/questions/17236796/how-to-remove-old-docker-containers" | |
command = "docker ps --filter \"status=exited\" | grep 'weeks ago' | awk '{print $1}' | xargs --no-run-if-empty docker rm" | |
output = "" | |
[[snippets]] | |
description = "Docker remove all untagged images https://stackoverflow.com/questions/17236796/how-to-remove-old-docker-containers" | |
command = "docker images | grep \"<none>\" | awk '{print $3}' | xargs docker rmi" | |
output = "" | |
[[snippets]] | |
description = "Make an offline mirror of a website" | |
command = "wget --mirror --convert-links --adjust-extension --page-requisites --no-parent http://example.org" | |
output = "" | |
[[snippets]] | |
description = "Use IPFS locally while running `ipfs daemon` on someserver.com, by forwarding ports" | |
command = "ssh -L 8080:localhost:8080 -L 5001:localhost:5001 someserver.com" | |
output = "" | |
[[snippets]] | |
description = "Probe which devices are on the network and get the MAC addresses" | |
command = "arping -w 1 -f -I wlp3s0 192.168.0.23 | grep '\\[' | cut -d \"[\" -f2 | cut -d \"]\" -f1" | |
output = "" | |
[[snippets]] | |
description = "Resume a rsync/scp transfer from local to remote after it has been broken" | |
command = "rsync -P -e ssh local_file user@host:remote_file" | |
output = "" | |
[[snippets]] | |
description = "Find and delete files older than 7 days https://askubuntu.com/a/589224" | |
command = "find /path/to/ -type f -mtime +7 -name '*.gz' -execdir rm -- '{}' \\;" | |
output = "" | |
[[snippets]] | |
description = "Download a site in its entirity so that it works offline (gets other-domain assets as well)" | |
command = "wget --restrict-file-names=windows -k --adjust-extension --span-hosts --convert-links --backup-converted --page-requisites SITE" | |
output = "" | |
[[snippets]] | |
description = "Download a website for converting to ipfs" | |
command = "wget --recursive --level=1 --span-hosts -k --no-clobber --page-requisites --adjust-extension --span-hosts --convert-links --restrict-file-names=windows --domains macwright.org --no-parent https://macwright.org" | |
output = "" | |
[[snippets]] | |
description = "Resize a big JPG image from Google Photos to something smaller" | |
command = "convert -resize 1600 -strip -interlace Plane -gaussian-blur 0.05 -quality 55% in.jpg out.jpg" | |
output = "" | |
[[snippets]] | |
description = "SSH copy a file from a remote to local, with gzip to increase bandwidth transferred" | |
command = "ssh -p 22 user@server \"cat bigfile | gzip -9\" | gzip -d | pv -atep -s \"1g\" > bigfile" | |
output = "" |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment