Collection of useful tools, aliases, shortcuts, etc. which come in handy.
/usr/share/dict/words
On macOS, the following allow for special characters (when the ABC - Extended keyboard is set):
| Accent | Sample | Keystrokes |
|---|---|---|
| Breve | Ŏ, ŏ | Option+b, X |
| Circumflex | Ŵ, ŵ | Option+6, X |
| Hacheck | Č, č | Option+v, X |
| Macron | Ō, ō | Option+a, X |
| Ring | Å, å | Option+k, A |
| Strikethrough Bar | ł, ɨ | Option+l, X |
| Subscript Dot | ṣ, ḍ | Option+x, X |
| Superscript Dot | ṡ, ḟ | Option+w, X |
Generate a Dot Graph Graphviz
dot -Tpng file.dot -o ruby-deps.png
dot -Tsvg file.dot -o ruby-deps.svg# Copy Data by Bouncing through intermediary:
< foo.tgz ssh <intermediary-ip> "ssh <destination-box> 'cat - > foo.tgz'"
# Copy data to a machine.
< file-name ssh dest "cat - > file-name"
# Copy data from a machine
> file-name ssh remote-host "cat - < file-name"OIFS="$IFS"
IFS=$'\n'
for f in `ls *.html`; do
echo "$f"
done
IFS="$OIFS"uuidgentar xjvf <file>new_id=$(uuidgen) && jq ".request" file.json | jq ".user.ids[0].value = \"${new_id}\"" | pbcopyjq '.selected_diagnostics[] | .date, .name' source.jsonjq '.selected_diagnostics[] | select ( .name | contains("MP")) | .date, .name' source.jsonperl -pi -e 's/\n/\t/ if $.%7' copied-table.txtif ! [ -x "$(command -v git)" ]; then
echo 'Error: git is not installed.' >&2
exit 1
fils -i
find . -inum <inode> -exec rm -i {} \;brew reinstall `brew list`aws s3 cp --sse AES256 <file> s3://destination/path/curl ipinfo.iojava -XX:+UnlockDiagnosticVMOptions -XX:+PrintFlagsFinal -versionawk '! seen[$0]++'grep -F -v -f file1 file2 > remaining^-c v
cat testfile | awk '{ print length, $0 }' | sort -nr | cut -d" " -f2-du -hs */ | sort -hr | headsort -t, -k1,1n -k2,2n file.csvgit log --full-history -- app/assets/images/3.gif
git log -Swhat_i_am_looking_for
for f in $(find lib/finance_api -type f); do
echo $f
git annotate -w -M -C -C --line-porcelain "$f" | grep -I '^author ' | sort -f | uniq -ic | sort -n --reverse
done
git log --date=format:'%Y-%m-%d' --pretty=format:"%ad %s" --after="2024-01-01" --author="yOuRnAmE"
https://github.com/issues?q=is%3Amerged+author%3A%40me
# repo specific
https://github.com/<org>/<repo>/pulls?q=involves%3A%40me
Useful for triggering CI workflows and builds without risk of having to undo anything later.
git commit --allow-empty
# git remote add upstream https://github.com/...
git fetch upstream
get rebase upstream/mastersed -i '' 's/before/after' <file>echo $((0x077C))
# And the other way:
printf '%x\n' 432Copy data to a CSV file.
\copy (SELECT x FROM y WHERE z=1) TO '/tmp/xyz.csv' DELIMITER ',' CSV HEADER;
Turn off Paging
\pset pager off
Get Settings from Query
SHOW ALL;
:w !pbcopy
" or use "+
:map
:nmap " normal mode
:vmap " visual mode
:imap " insert mode
:help index " to see all the build-in commands
:read <file-name>
" Move to next highlight
]s
" Move to previous highlight
[s
" Add current word to dictionary
zg
" Remove current work from dictionary
zw
:redraw!
:right
:center
:left
" May want to add 'Session.vim' to .gitignore
:mksession!
$ vim -S
/[^\x00-\x7F]
g ctrl-a/ctrl-x
d<c-v>2j
d/regex/-1
:bufdo %s|src="/media/|src="/file/|
gx
If that doesn’t work, my .vimrc has a leader key for visual selection, ,o.
vim --startuptime /dev/stdout slow_to_open_file.ex +q | less
/[<=>][<=>][<=>][<=>][<=>][<=>][<=>]
]c jump to next change
do diff obtain (get changes from other window)
dp diff put (put changes to other window)
data = JSON.parse(File.read('/path/to/file-name').gsub('=>', ':'))RAILS_ENV=production bundle exec rails dbconsole -p
awk '/host/ {host=$2}; /password/ {pass=$2}; /database/ {dbname=$2}; /port/ {port=$2}; /username/ {username=$2}; END {printf("\npassword is: %s\n\ndump command is:\n pg_dump --format=c --host=%s --port=%s --dbname=%s --username=%s > /tmp/%s-$(date +%%F).dump\n", pass, host, port, dbname, username, dbname)}' config/local_database.yml
(extend-type js/RegExp
IFn
(-invoke
([this a]
(re-find this a))))getMethods = (obj) => Object.getOwnPropertyNames(obj).filter(item => typeof obj[item] === 'function')const getMethods = (obj) => {
let properties = new Set()
let currentObj = obj
do {
Object.getOwnPropertyNames(currentObj).map(item => properties.add(item))
} while ((currentObj = Object.getPrototypeOf(currentObj)))
return [...properties.keys()].filter(item => typeof obj[item] === 'function')
}npx json-server --watch db.json --port 3001
npm list -g --depth 0 to list all global packages.
npm update to update all packages to the latest (allowed).
npm outdated to identify which libraries have newer versions.
npm install -g npm-check-updates will then allow for ...
ncu -u which will update all versions globally.
Prune old images, networks, containers, and volumes:
docker system prune --volumes