Posts in category “Tech”

Eponymous Laws

We stand on the shoulders of giants. Or at least, those who suffered that we might not, and so we should respect our elders. I do, and this is a list of places I'd prefer to lean on experience than relearn the hard way:

  • Cunningham's Law: The best way to get the right answer on the Internet is to post the wrong answer and wait for people to correct you.
  • LeBlanc's Law: Later == Never
  • Brooke's Law: Adding developers to a late software project makes it later.
  • Hyrum's Law: All observable behaviors of your system are depended on by someone.
  • Parkinson's Law: Work expands to fill the time available for it's completion.
  • Pareto Principle: For any phenomonon, 80% of the consequences stem from 20% of the causes.
  • Hofstatter's Law: Everything takes longer than you think it will, even when accounting for Hofstatter's Law.
  • Conway's Law: Any software reflects the organization that built it.
  • Linus's Law: Given enough eyeballs, all bugs are shallow.
  • Wirth's Law: Software gets slower faster than hardware gets faster.
  • Zawinksi's Law: Every program expands until it can read email. Those which can't are replaced by those that can.
  • Sturgeon's Revelation: 90% of everything is crud.
  • Stein's Law: If it can't go on forever, it'll stop.
  • Goodhart's Law: When a measure becomes a target, it ceases to be a good measure.
  • Wiio's Law: Communication fails except by accident.
  • Macnamara Fallacy: Making decisions based on both measurable data and ignoring unmeasurable data is suicidal.
  • Trust but verify: (Russian: доверяй, но проверяй, tr. doveryay, no proveryay, IPA: dəvʲɪˈrʲæj no prəvʲɪˈrʲæj) is a Russian proverb, which is rhyming in Russian. The phrase became internationally known in English after Suzanne Massie, a scholar of Russian history, taught it to Ronald Reagan, then president of the United States, the latter of whom used it on several occasions in the context of nuclear disarmament discussions with the Soviet Union.
  • Wright's Law: The more times a task has been performed, the less time is required on each subsequent iteration.
  • Hyrum's Law: all observable behaviors of your system will be depended on by somebody.
  • Layne’s Law – “A) Every debate is over the definition of a word, B) every debate eventually degenerates into debating the definition of a word, or C) once a debate degenerates into debating the definition of a word, the debate is debatably over.”
  • Lamport's Law - If you’re thinking without writing, you only think you’re thinking.
  • Mellon's Law - Everyone wants to make an API, but nobody wants to use one.

While it's not a law, it should be. Cunningham said: "If software is not periodically rewritten to communicate what we've learned, then the software will lack any sense at all eventually."

Counting with Different Script Languages

Every day at work, I make sure to learn at least one more Powershell function, and I'm bridging my bash knowledge over. Net goal; I can do everything on a Windows server that I can do on a Linux server, if not more.

I do a huge amount of log file review, and one common thing I'll do is to take data like this:

2023-09-06 12:22:47.008 [Pickle Thread] Reticulating Splines 2023-09-06 12:22:47.019 [Apple Thread] Forecasting future misinformation 2023-09-06 12:22:48.100 [Pickle Thread] Neglecting the step children 2023-09-06 12:22:48.219 [Apple Thread] Registering pain points 2023-09-06 12:22:49.062 [Banana Thread] Organizing a Raffle

.. let's say this goes on indefinitely. I want to know how many times in my log each of my fruity threads appears. In Bash, that looks like this:

cat sample.log | sed 's/.*\[//;s/\].*//' | sort | uniq -c 2 Apple Thread 1 Banana Thread 2 Pickle Thread

In powershell, that looks like this

gc .\sample.log | Group-Object { $_ -match "\[(.*?)\]" | Out-Null; $Matches[1] }
Count Name Group
----- ---- -----
2 Pickle Thread {Pickle Thread, Pickle Thread}
2 Apple Thread {Apple Thread, Apple Thread}
1 Banana Thread {Banana Thread}

Lunchtime RTLSDR

I want to use my iPad to listen to 101.5 FM. Before you mention that I could find the online stream, and yeah, I know that's a thing, that's too easy.

This is the Raspberry Pi 4 running headless, displaying it's IP and wifi SSID, and connected to a Software Defined Radio (the silver USB dongle) which is in turn connected to the antenna hanging in the tree. It's taking its audio from the FM channel and streaming it over the USB-C connection to the iPad over VLC.

The script looks like this:

#!/bin/bash

rtl_fm -g50 -f 101.5M -M wfm -s 180k -E deemp |\ sox -traw -r180k -es -b16 -c1 -V1 - -t flac - |\ cvlc - --sout '#standard{access=http,mux=ogg,dst=10.55.0.1:8080/audio.ogg}'

I would love to claim that I knew all of this, but I picked it up from a random google result that has since escaped my history, else I'd credit the writer. Whoops.

RTL_FM is telling the radio how to hit my station. Sox is taking the raw output of that and encoding it, and cvlc is my transmitter. On the iPad, I've asked VLC to play the stream from http://10.55.0.1:8080/audio.ogg and I get to hear my station.

It has some occasional issues where the audio drops, and I'm working through that. My intention is to also pipe my Pi's pulseaudio output to the same method so that I can hear what it's doing; that's my last impediment to running DOSBox with audio and without shenanigans using iPad Dev Mode and signing packages every seven days. Need to remember this link.

Impressions of AI and Scripting

The AI instances I've worked with to help me build code are suffering terribly from Dunning-Kruger; it has no idea how bad the code it generates actually is.

What makes that particularly damning is how subtle some of the problems that it introduces are. An example was a recent request for devising a Powershell script to check the contents of Zip files for Authenticode signatures. Now, I know how to build a temp space and decompress files and scan them; I was hoping for a better method. In Linux, there are thanks to Fuse filesystems, but let's not get bogged down.

The method Copilot provided looked good, and even scanned my test file successfully. However, when it finished on my production file set, my list of files within files came back utterly broken. This is because Copilot's approach was based on some assumptions about zip file structure that just aren't always true. Net result, I ended up going back to the old reliable.

.. later..

Another example. I need to break up a string of semantic version numbers to compare by the third integer. In most SQL's, that's trivial, but not if you happen to be locked into an SQLite that's compiled without support for four arguments to instr(). I tried Copilot and ChatGPT; both of these seemed to understand this limitation, and offered me code to work around this, but both of them kept offering code that continued to include that fourth argument. I ended up solving it by moving left and breaking the value into columns when populating the table, however the arguments that I had with both system showed me the current limitations of AI in fairly short order.

I think there are cases for using AI to help you code, but I don't see AI replacing programmers any time soon.

Considering how often my prognostications prove to be wrong, though, you might want to learn another skill set.

Wiring an e-ink Display to the iPad RPi4

Documentation for the unit's here

I'm using this unit.

The PI's GPIO pins numerate left to right, top to bottom with the microSD on top.

ModuleColorNamePi Pin
VCCGray3.3V17
GNDBrownGND20
DINBlueMOSI19
CLKYellowSCLK23
CSOrangeCE024
DCGreenGPIO 2522
RSTWhiteGPIO 1711
BUSYPurpleGPIO 2418

The Waveshare Gitlab Library works well. I wrote a shell script to check my wifi and SSID and update the display if it changes. The script also use BASH's "trap" to clear the display when the box shuts down.

Next up is getting kismet scanning. I see the purchase of a wifi dongle in my future.