How to Start Godoc on Mac

Fish: godoc -http=:6060 &; disown (pidof godoc) Bash: godoc -http=:6060 &; disown `pidof godoc` And pidof can be installed with Homebrew.

May 5, 2018

How to Measure Response Time with Curl

curl [args] --write-out "%{time_total}s" --output /dev/null --silent [URL]

June 20, 2017

A Single Command to Download a Website

wget --recursive --level=2 --no-parent --no-clobber --convert-links --continue [URL]

April 9, 2017

One-liner to check MongoDB Connections

mongo --eval "JSON.stringify(db.currentOp(true))" | \ tail -n +3 | \ jq -r .inprog[].client | \ sed 's/\(.*\):.*/\1/' \ | sort | uniq -c | sort -nr dump connection information in standard JSON format remove MongoDB header extract IP:port as a list trim port sort IPs by freqencies

September 2, 2016

Counting Word Frequencies in One Line

cat book.txt | \ tr '!()[]{};:",<.>?“”‘’*/\r' ' ' | \ tr ' ' '\n' | \ grep -a -P "^[\p{L}\p{N}\-']+\$" | \ grep -a -P -v "^[\p{N}\-']+\$" | \ sed "s/'s\$//" | \ sed "s/^'//" | sed "s/'\$//" > words.txt cat words.txt | \ sort | uniq -c | \ sort -nr | \ cut -c9- > words_desc.txt replace punctuations with space; remove \r from `\r\n' one word per line keep only words composed of unicode letters, numbers, hyphen and apostrophe remove pure numbers remove ’s remove starting and ending apostrophe output words.txt sort and count unique words ...

August 9, 2016

How to Remove All Exited Containers & Dangling Images for Docker?

Updates at 2020-07-08: docker system prune Old tricks: docker ps --quiet --filter=status=exited | xargs docker rm docker images --no-trunc=true --filter="dangling=true" --quiet=true | xargs docker rmi

August 3, 2015

Tips on SSH

Generate SSH keys ssh-keygen -C [email protected] Authorize public key at remote server ssh-copy-id user@host On Mac OSX, ssh-copy-id should be installed first. brew install ssh-copy-id Generate PEM ssh-keygen -f ~/.ssh/id_rsa -e -m pem > ~/.ssh/id_rsa.pem Copy file by base64 On remote session, run base64 < myfile and copy the output. On local terminal, run base64 -d > myfile, paste the content and press ctrl+D.

April 28, 2015

How to Disable the Touchpad in Linux?

Have you ever been annoyed by accidentally touching the touchpad on your laptop when you are typing? I am using a Linux laptop with both trackpoint and touchpad so the touchpad is just an annoying redundant thing. Here is the one-liner to disable it: xinput list | grep TouchPad | grep -Po 'id=\K([0-9]+)' | xargs xinput disable

June 10, 2014