Drop 2022-05-06: Untitled

Moar CLI Data Wrangling; The Laws of Simplicity; The gif Gallery

Apologies for two missed days. This is my penultimate week at my current employer and Wednesday was the day the establishment announced it, so it was more than a tad stressful. Yesterday was rather selfish, as it was the perfect weather here in southern Maine for a massively long road cycle, which ate up the time usually devoted to these missives. Rest assured there will be five newsletters this week, come hook or crook!

Moar CLI Data Wrangling

A large percentage of my computing life has been and still is at the command line as I’m nigh obsessed with the power contained in that thin (or blocky) blinking cursor. One challenge that still remains is how to turn the output of various commands into something that resembles data. Sure, many new CLI tools have delimited or JSON output as an option, but most of the old, reliable ones still do not, and many of us have spent years accumulating *sh functions/scripts to handle the output. While a previous newsletter edition showed one tool that is frighteningly good at turning CLI output into “data”, one can never have too many tools. With that in mind, today’s CLI installment features jc (“JSON Convert”), a “CLI tool and python library that converts the output of popular command-line tools and file-types to JSON or Dictionaries. This allows piping of output to tools like jq and simplifying automation scripts.”

It, too, has an astonishing number of parsers:

  • --acpiacpi command parser

  • --airportairport -I command parser

  • --airport-sairport -s command parser

  • --arparp command parser

  • --asciitable: ASCII and Unicode table parser

  • --asciitable-m: multi-line ASCII and Unicode table parser

  • --blkidblkid command parser

  • --cksumcksum and sum command parser

  • --crontabcrontab command and file parser

  • --crontab-ucrontab file parser with user support

  • --csv: CSV file parser

  • --csv-s: CSV file streaming parser

  • --datedate command parser

  • --dfdf command parser

  • --digdig command parser

  • --dirdir command parser

  • --dmidecodedmidecode command parser

  • --dpkg-ldpkg -l command parser

  • --dudu command parser

  • --envenv command parser

  • --filefile command parser

  • --fingerfinger command parser

  • --freefree command parser

  • --fstab/etc/fstab file parser

  • --git-loggit log command parser

  • --group/etc/group file parser

  • --gshadow/etc/gshadow file parser

  • --hashhash command parser

  • --hashsum: hashsum command parser (md5sumshasum, etc.)

  • --hciconfighciconfig command parser

  • --historyhistory command parser

  • --hosts/etc/hosts file parser

  • --idid command parser

  • --ifconfigifconfig command parser

  • --ini: INI file parser

  • --iostatiostat command parser

  • --iostat-siostat command streaming parser

  • --iptablesiptables command parser

  • --iw-scaniw dev [device] scan command parser

  • --jar-manifest: MANIFEST.MF file parser

  • --jobsjobs command parser

  • --kv: Key/Value file parser

  • --lastlast and lastb command parser

  • --lsls command parser

  • --ls-sls command streaming parser

  • --lsblklsblk command parser

  • --lsmodlsmod command parser

  • --lsoflsof command parser

  • --lsusblsusb command parser

  • --mountmount command parser

  • --mpstatmpstat command parser

  • --mpstat-smpstat command streaming parser

  • --netstatnetstat command parser

  • --nmclinmcli command parser

  • --ntpqntpq -p command parser

  • --passwd/etc/passwd file parser

  • --pidstatpidstat command parser

  • --pidstat-spidstat command streaming parser

  • --pingping and ping6 command parser

  • --ping-sping and ping6 command streaming parser

  • --pip-listpip list command parser

  • --pip-showpip show command parser

  • --psps command parser

  • --routeroute command parser

  • --rpm-qirpm -qi command parser

  • --rsyncrsync command parser

  • --rsync-srsync command streaming parser

  • --sfdisksfdisk command parser

  • --shadow/etc/shadow file parser

  • --ssss command parser

  • --statstat command parser

  • --stat-sstat command streaming parser

  • --sysctlsysctl command parser

  • --systemctlsystemctl command parser

  • --systemctl-ljsystemctl list-jobs command parser

  • --systemctl-lssystemctl list-sockets command parser

  • --systemctl-lufsystemctl list-unit-files command parser

  • --systeminfosysteminfo command parser

  • --time/usr/bin/time command parser

  • --timedatectltimedatectl status command parser

  • --tracepathtracepath and tracepath6 command parser

  • --traceroutetraceroute and traceroute6 command parser

  • --ufwufw status command parser

  • --ufw-appinfoufw app info [application] command parser

  • --unameuname -a command parser

  • --update-alt-gsupdate-alternatives --get-selections command parser

  • --update-alt-qupdate-alternatives --query command parser

  • --upowerupower command parser

  • --uptimeuptime command parser

  • --vmstatvmstat command parser

  • --vmstat-svmstat command streaming parser

  • --ww command parser

  • --wcwc command parser

  • --whowho command parser

  • --xml: XML file parser

  • --xrandrxrandr command parser

  • --yaml: YAML file parser

  • --zipinfozipinfo command parser

You can install it with a simple pip3 install jc (you can brew install jc on macOS with Homebrew), but if you’re keen to “try it before you buy it”, there’s a web version — which may take a few seconds to warm up, being a Heroku app — where you can paste command output and get your conversion.

One CLI tool I like to use jc with is dig DNS lookup tool. Try running this command to see just how many DNS TXT records Optimizely has:

$ dig optimizely.com TXT | jc --dig | jq -r '.[].answer[].data' # everybody has 'jq' installed, right?

Alternatively, you can just see it in this gist.

Remember that this is a Python module as well, and that means R folks can use it to process CLI output in a more straightforward way, such as:

library(reticulate)

jc <- import("jc")

system("dig optimizely.com TXT", intern = TRUE) |> 
  paste0(collapse = "\n") |> 
  jc$parse("dig", data = _) -> res

sapply(res[[1]]$answer, `[[`, "data") |> 
  writeLines()

which has the same output you’ll find in the linked gist.

The Laws of Simplicity

We delve back into the world of design principles today with a look at The Laws of Simplicity by John Maeda.

The Laws of Simplicity

The book was written at the time of the iPod, but the principles within it hold up to today, and the principles aren’t just about product time. The book’s subtitle is “Design, Technology, Business, Life”, and the the essays withing are, indeed, applicable almost everywhere.

I’ll let John describe how you can use this book:

The ten Laws outlined in the body of this book are generally independent of each other and can be used together or alone. There are three flavors of simplicity discussed here, where the successive set of three Laws (1 to 3, 4 to 6, and 7 to 9) correspond to increasingly complicated conditions of simplicity: basic, intermediate, and deep. Of the three clusters, basic simplicity (1 to 3) is immediately applicable to thinking about the design of a product or the layout of your living room. On the other hand, intermediate simplicity (4 to 6) is more subtle in meaning, and deep simplicity (7 to 9) ventures into thoughts that are still ripening on the vine. If you wish to save time (in accordance with the third Law of time), I suggest you start with basic simplicity (1 to 3) and then skip to the tenth Law of the one which sums up the entire set.

Each section is a collection of micro-essays that cluster around the main topic presented. Rarely do I have answers, but instead I have a lot of questions just like you. Every Law begins with an icon of my design that represents the basic concepts I present. The images are not a literal explanation of the con- tents, but may help you to better appreciate each of the Laws. There is also associated Web content at lawsofsimplicity.com where you can download the artwork as desktop patterns in case that will help to motivate you.

These are the ten “laws”:

  1. reduce: The simplest way to achieve simplicity is through thoughtful reduction. 2 organize Organization makes a system of many appear fewer.

  2. time: Savings in time feel like simplicity.

  3. learn: Knowledge makes everything simpler.

  4. differences: Simplicity and complexity need each other.

  5. context: What lies in the periphery of simplicity is definitely not peripheral.

  6. emotion: More emotions are better than less.

  7. trust: In simplicity we trust.

  8. failure: Some things can never be made simple.

  9. the one: Simplicity is about subtracting the obvious, and adding the meaningful.

I am especially fond of the essays, guidance, and examples in “Law 2” (organize) and check back in with it every so often to remind myself both how to engage in said process and the absolute need to do so if I’m going to remain sane.

It’s a quick read, the website is a great companion, and the resources will, hopefully, be as useful to y’all as they have been for me.

The gif Gallery

i-29114

This is just to give you a Friday distraction that doubles as a reminder of that the bad ol’ days of “Geocities” pages were. You start off in one “room” and scan through the page of gifs to find the next one.

Sound up!; Don’t be afraid to click on things; and, take a digital walk down animated memory lane.

Click the gif to get started!

FIN

Look for another newsletter drop later today! ☮


One response to “Drop 2022-05-06: Untitled”

  1. Drop #583 (2025-01-01): Wrapping Day – hrbrmstr's Daily Drop Avatar

    […] a little help from a utility we covered way back in 2022 (jc) and (ofc) DuckDB, 2024 Drop stats were quick work this time […]

    Like

Leave a comment

This site uses Akismet to reduce spam. Learn how your comment data is processed.