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"
uuidgen
new_id=$(uuidgen) && jq ".request" file.json | jq ".user.ids[0].value = \"${new_id}\"" | pbcopy
jq '.selected_diagnostics[] | .date, .name' source.json
jq '.selected_diagnostics[] | select ( .name | contains("MP")) | .date, .name' source.json
perl -pi -e 's/\n/\t/ if $.%7' copied-table.txt
if ! [ -x "$(command -v git)" ]; then
echo 'Error: git is not installed.' >&2
exit 1
fi
ls -i
find . -inum <inode> -exec rm -i {} \;
brew reinstall `brew list`
aws s3 cp --sse AES256 <file> s3://destination/path/
curl ipinfo.io
java -XX:+UnlockDiagnosticVMOptions -XX:+PrintFlagsFinal -version
awk '! 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 | head
git 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
sed -i '' 's/before/after' <file>
echo $((0x077C))
# And the other way:
printf '%x\n' 432
Copy 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
vim --startuptime /dev/stdout slow_to_open_file.ex +q | less
/[<=>][<=>][<=>][<=>][<=>][<=>][<=>]
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.