| A Cup of Radicchio A personal website of a power looper, a skateboarder, and a coder |
|
| Home Docs Sources Blog GitHub |
200 OKTo Whom It May Concern
This is what Radicchio loves so much:
$ # Git.
$ git status && git fetch -p && git branch -a && git tag -l && git pull && git status
The second one is a combination of find and grep:
$ # Find and print line(s) of text, based on a specified regex pattern.
$ find . -type f -print0 | xargs -0 grep '<regex>'
The third one is a combination of grep and sed (or perl, where applicable):
$ # Find a text, based on a specified regex pattern, then pass corresponding filenames
$ # to Sed (or Perl) for replacing that text with another one.
$ grep -Rl '<regex_to_replace>' | xargs sed -i -e 's/<regex_to_replace>/<regex-replacer>/g'
$ grep -Rl '<regex_to_replace>' | xargs perl -pi -e 's/<regex_to_replace>/<regex-replacer>/g'
The fourth one is a one-time procedure of logging into a VM box or any other remote host, using SSH public key authentication:
$ # Run SSH agent in the background and add a private key.
$ eval `ssh-agent -s` && ssh-add [~/.ssh/id_ed25519]
$ # Log into a running VM box by means of SSH client.
$ ssh -C <username>@<hostname>
The fifth one is a series of requests for getting statuses of power supply sensors on a laptop in any modern Linux distro like Arch Linux or Ubuntu:
$ # Query AC adapter.
$ cat /sys/class/power_supply/AC+(AD|1)/online
$ # Query the battery.
$ cat /sys/class/power_supply/BAT1/+(charge|energy)_full
$ cat /sys/class/power_supply/BAT1/+(charge|energy)_now
$ cat /sys/class/power_supply/BAT1/+(current|power)_now
The sixth one is an infrequent, from time to time procedure of adjusting the Hardware Clock and the System Clock in the same time:
$ # Set the Hardware Clock and the System Clock unconditionally, non-synced.
$ sudo hwclock --set --date="CCYY-MM-DD hh:mm:ss" --localtime && sudo date MMDDhhmmCCYY.ss
$ # || || ^^ ^^
$ # YY - Year || || || ||
$ # MM - Month || |+------------ Day of month ------------+| ||
$ # hh - Hour || +----------------------------------------+ ||
$ # mm - Minute |+---------------------- Century ---------------------+|
$ # ss - Second +------------------------------------------------------+
The seventh one is an attempt to discover open TCP ports at which daemons are actively listening on. This seems useful when developing microservices running servers, e.g.:
$ # Watch the Erlang BEAM node is listening for connections on two TCP IPv4 ports,
$ # one of them (8765) in this particular case is used by the Cowboy web server.
$ lsof -iTCP -sTCP:LISTEN -nP
COMMAND PID USER FD TYPE DEVICE SIZE/OFF NODE NAME
epmd <pid1> <username> 3u IPv4 377060 0t0 TCP *:4369 (LISTEN)
epmd <pid1> <username> 4u IPv6 377061 0t0 TCP *:4369 (LISTEN)
beam.smp <pid2> <username> 17u IPv4 390816 0t0 TCP *:44937 (LISTEN)
beam.smp <pid2> <username> 22u IPv4 390819 0t0 TCP *:8765 (LISTEN)
Drink with pleasure, consume responsibly, at leisure! ![]()