Tuesday, February 13, 2024

A Bit of Burlington

[Composed 10/5/2023. High: 82°F(!)]

Leaf looking.
Snake spotting.
Sunset savoring.
Beach browsing.
Cemetery strolling.
Treehouse Treasuring.
Very Vermont.
Beautiful Burlington.

My brief business trip to Burlington, Vermont was delightful. Meetings kept me busy, but as the photos suggest, Shira and I still found some time for exploration. I especially appreciated the tree house, which is a first of its kind and claims to be universally accessible.

In general, the scenery was gorgeous and the vibe was chill. I'd go back in tourist mode in a hot minute.

Monday, February 12, 2024

Review: Cryptonomicon

Finishing Neal Stephenson's Cryptonomicon feels like a literary accomplishment nearly 25 years in the making. For as long as I can remember, Cryptonomicon has been recommended as sort of the ultimate Unix geek novel. Finishing it feels like earning a critical nerd merit badge.

The audio version, weighing in at nearly 43 hours, is twice as long as Moby Dick and over three times the length of the last audiobook I listened to. In fairness, it's still shorter than War and Peace, which comes in at a whopping 59 hours.

So, what do you get for all this text? Well, quite a bit. Some of it exceedingly enjoyable, other parts less so. Below, I'll ramble on about what struck me most. But first, a warning.

Cryptonomicon started off strong for me, and for the first half of the text, I found myself thoroughly enjoying it. In many respects, I felt like the novel was written just for me. The text contains both a modern storyline, as well as one that takes place in World War II. The modern storyline includes Randy, a socially awkward nerd who morphs into a Linux guru and becomes involved in various Internet startups. In 1999, when the book was published, this was--in a much, much tamer version--my story. So yeah, I had no problem relating to Randy and his character's growth.

The World War II storyline, because of its focus on obscure topics, is exactly the kind of historical fiction I relish. For example, being a book with a heavy emphasis on cryptography, one might expect it to focus primarily on, say, cracking Enigma. Instead, it focuses on Detachment 2702, an effort to allow the allies to act on intelligence while keeping the enemy oblivious to the fact that their codes have been broken. I haven't yet researched what parts of Cryptonomicon are truth and what parts are fiction, so I'm not entirely sure if there even was a Detachment 2702 in real life. But there must have been efforts like it, and learning about them is a treat.

It was halfway to two-thirds through the Cryptonomicon when I started to get impatient. I was fine with the long story arc, and I was all for the teachable moments throughout the text. But the incredibly detailed yet seemingly tangents to nowhere started to weigh on me.

The chapter titled Phreaking was a quintessential example of this. First, out of the blue, we meet a new character: Pekka. We naturally get Pekka's backstory. I mean, we'll never hear from Pekka again, but sure, why not? And then we get a detailed description of Van Eck phreaking. This is a bit clumsy because it's all seemingly for no reason, but OK, I can live with that. My guess is that Van Eck phreaking will play an important role in the future of the text, so we need to be educated about it (spoiler alert: it does). Then we get a lengthy, completely unrelated education on the topic of hive minds. Unlike Van Eck hacking, what we learn about hive minds doesn't appear to contribute to the story.

Ultimately, the chapter closes out with the setup that Van Eck phreaking is a sort of x-ray vision that allows Randy, Pekka, and Cantrell to see Tom's screen. By the rules of any teen comedy, Tom has to be doing something embarrassing while Randy and his cohorts are watching his screen. Most authors would have gone with porn as that awkward subject, and everyone would have had a good giggle. But Stephenson isn't most authors. He opts to have Randy, Pekka, and Cantrell observe Tom writing about his most secret sexual musings. Fair enough. But this goes on for what seems like 30 minutes of the audiobook. Looking at the ebook version, Stephenson devotes 10 pages to Tom's writing. The writing seems earnest and strives to be as thoughtful as a text on sexual fetishes can be. But why bother? Why subject your readers to this?

So as the second half of the book slowly unwound itself, I found myself trying to crack this puzzle of Stephenson's verbosity.

Did he simply love to write? Where one author would be satisfied by saying Randy was crushing on a girl unlike any he'd ever met, Stephenson gives us an intense 9-page essay on Randy's wisdom teeth. The entire story seems to exist so that Stephenson can write one paragraph about how bad Randy has it for a girl. I can just imagine Stephenson talking to his editor:

Stephenson: I'm thinking about adding

Editor (interrupting): Yes.

For a good chunk of the text, I decided that all this verbosity was a sort of Detachment 2702 style answer to the challenge of keeping the reader informed yet surprised. The approach: bury critical details under a mountain of text. Will Randy's success hinge on Van Eck phreaking, hive minds, Tom's sexual preferences, or the extraction of his wisdom teeth? Through information overload and camouflaging, it's possible to have told the reader the answer and yet still keep the twist a secret.

As the text closed out and gaps in the storyline were filled in, I found myself developing a new theory of Stephenson's insistence on complete detail. As a programmer, I'm vividly aware of the duality of computers. On one hand, they are amazingly powerful, completing complex tasks in milliseconds. On the other hand, without specific instructions—that is, code—they are little more than expensive doorstops. For example, when I type:

 wget -r https://pallas.eruditorium.org/

I'm essentially instructing my computer to download every web page on pallas.eruditorium.org. This task is both tedious (considering there could be thousands of pages to download) and complex (as it involves establishing a secure connection for each page). Nevertheless, the computer handles this task effortlessly. It accomplishes this feat thanks to the thousands, if not millions, of lines of code meticulously crafted to guide it through the process.

In this light, I can see Cryptonomicon as the polar opposite of a short story. With a short story, the author relies on the reader's imagination to fill in gaps in the text. It's a clever bit of mental judo that lets a few fragments of a story be shaped into an entire narrative. Cryptonomicon takes the opposite approach: not only does it describe the characters and circumstances of the text, but it also teaches the reader how all of the technology that these characters and circumstances call for works. In other words, Stephenson has strived to write a fully defined story. You can roll your eyes at the verbosity, but unlike many stories that involve technology, there's no magic being deployed here. Pull on any thread you want; it all holds together (at least the tech side of things does).

With this perspective, I found that I could answer a question that had been baffling me for a good portion of the text: what is Cryptonomicon about? Sure, it involves Detachment 2702, Epiphyte Corp., a data haven, the Battle of Manila, the search for gold, cryptocurrency, and many other topics. But using my computing example, I can see the narrative in a new light. Cryptonomicon is simply all of the supporting material for the final moment of the book: "Randy Waterhouse, sitting on a boulder above a stream flowing with molten gold, is happy." Like the wget command, this statement may look simple, but it calls for 40 hours of audiobook to allow this statement to make sense.

I can also see in Stephenson's verbosity a suggestion for why the book is called Cryptonomicon. The Cryptonomicon that's alluded to in the novel is a collection of resources to help would-be code breakers learn from each other and advance the art of cryptanalysis. Because I haven't researched what parts of the story are true or not, I don't yet know if the Cryptonomicon is a real thing or an idea invented by Stephenson. And while it comes up a few times in the story, it doesn't jump out to me as being pivotal enough to earn its place as the book's title.

However, if I consider Stephenson's side-trips into technology as not just an attempt at being uber-complete or wishing to obscure the plot but instead look at these passages as essential, then a new picture begins to develop. In that case, Cryptonomicon is a sort of Cryptonomicon itself. Instead of being focused solely on cryptography, it takes a wider view. But the result is the same: if you're interested in being a hacker*, then here's your handbook. Sure, it's got a storyline running through it, but don't let that fool you; this is far more guidebook than love story.

Perhaps these theories explain my primary frustration point with the text: the characters never seem to acknowledge how they are connected. For example, how does Goto Dengo never discover or acknowledge that he's connected up with his beloved friend's son and grandson? It's maddening. But, to explain Randy's state of happiness or to create a hacker's bible, this moment of mushiness isn't really needed. So, we don't get it. It kills me, but surely Stephenson had a good reason to not give us this moment of reunion. It certainly wasn't for lack of interest in writing; after all, he's given us vivid descriptions of so much else.

OK, so those are my thoughts and theories. Now it's time to run a few well-placed Google searches and see just how far off the mark they are. This should be fun!

*Hacker in this context refers to a positive definition; not the up-to-no-good definition that you may be thinking of.

Tuesday, February 06, 2024

Tasker: Saving Spouses one Profile at a Time.

(Chat GPT's rendering of Shira calling me on her way home from work, and me ignoring her. Nailed it.)

I've been happy keeping my phone on silent and getting notifications via my watch. This simplifies my life; I don't worry about my device's ringer going off at just the wrong moment, or having to overthink setting up ringtones and notification sounds.

Every once in a while, however, I'll miss an important call from Shira and she'll ask me: why don't you put my number on the DnD exception list? This list is the set of contacts who cause the phone to ring even though the device is in Do Not Disturb mode.

I then have to explain that I'm not using Samsung's built-in Do Not Disturb mode, instead, I'm using a custom Tasker Profile that doesn't know anything about this exception list. She then tells me that I should really fix this, and I promise her one day I will. I then forget about the problem until I miss another important call, and the discussion repeats.

But not anymore! Over this past weekend, I took a few minutes and looked into how I could implement an exception list for my always-on-silent Tasker profile. Turns out, it was easy to implement. The magic lies in Tasker's Call Screened Event. Creating a profile linked to this event allows you to run code as a phone call comes in, but before the phone has started ringing.

Using this event, I'm able to detect if the caller is in a special always-ring contact group. If they are, then I disable Force Silent Mode, crank up the volume, and accept the call. I then wait 1 minute and put the phone back into always-on-silent mode. Admittedly, this approach is clumsy: for 1 minute after Shira calls, anyone who calls will result in the ringer sounding. But for now, the simplicity of this approach outweighs its lack of finesse.

Here are the Tasker profiles, feel free to grab and use them: Force Silent Mode, Bypass Silent Mode.

I'm psyched to have learned about the Call Screened event. It seems like this capability could be put to use in all sorts of interesting ways.

Monday, February 05, 2024

Wanted Lofty AI Automation; Got Epic AI Distraction

Lately, I've been experiencing a case of AI-inspired automation-FOMO. I've got a sense that ChatGPT and other AI tools can help me automate a number of tedious tasks, yet I haven't had a chance to experiment with this. To put my mind at ease, I started digging into OpenAI's ChatGPT API docs. My intent was to find a practical scenario that would benefit from the magic of AI. Of course, I quickly chucked this noble goal, opting instead to focus on one of ChatGPT's sexier features: image generation.

Using the ChatGPT API, you can trivially send a description to the /images/generations endpoint, and in a few seconds, be rewarded by a freshly generated picture that matches the description. Here's an example:

$ curl -s https://api.openai.com/v1/images/generations -H 'Content-Type: application/json' \
       -H 'Authorization: Bearer <API Key>' \
       -d '{ "model": "dall-e-3", "prompt": "Create an image of a mystical machine that you feed in a description of an image and the machine produces that image. The image should be created in the style of a page out of Leonardo Divinci'\''s famous journals.", "n": 1, "size": "1024x1024" } '
{
  "created": 1706768428,
  "data": [
    {
      "revised_prompt": "Imagine an enchanting apparatus with a truly mystical function: input a worded depiction of a scene and behold as it crafts the described image. This uncanny but fascinating contraption appears to be constructed with old, worn-out gears, levers, and dials. It is set within the yellowed pages of an ancient journal. The illustrations surrounding the machine reflect detailed observations, studies, and annotations reminiscent of the kind found in Leonardo da Vinci's legendary chronicles. Note his signature use of mirroring handwriting, intricate sketches, and the feel of the Renaissance era.",
      "url": "https://oaidalleapiprodscus.blob.core.windows.net/private/org-qq9fGeTcJMX10fGOLJwKITpG/user-UPdzD30ImYLuuuc75Gumw2B1/img-D4era9FvLJfMpq0NHYZrVIYA.png?st=2024-02-01T05%3A20%3A28Z&se=2024-02-01T07%3A20%3A28Z&sp=r&sv=2021-08-06&sr=b&rscd=inline&rsct=image/png&skoid=6aaadede-4fb3-4698-a8f6-684d7786b067&sktid=a48cca56-e6da-484e-a814-9c849652bcb3&skt=2024-01-31T21%3A44%3A47Z&ske=2024-02-01T21%3A44%3A47Z&sks=b&skv=2021-08-06&sig=13Ighk1MZnk6i0D9A5AJ2MMGtmZv4D6AZM0w6w6is4g%3D"
    }
  ]
}

Amazing, right? No, this image isn't going to win any awards. And no, this use of ChatGPT isn't going to streamline my business or coding life. But come on, this is simply too cool not to play with.

I've folded this functionality into the chatgptassist shell script for easy execution. Now, image generation is a Linux one-liner:

$ url=$(chatgptassist -a generate-image -p "Generate an image of a machine, that has a slot to feed in sheets of paper and a small window. If you look in the window, you see a haggard individual hunched over a drafting table, hard at work drawing the images that are being fed in from the slot. Show a conveyor belt where the finished images are ejected from the machine. The outside of the machine should look as a futueristic devic as imagined by an individual in the 1950's.")
$ curl -s "$url" > machine2.png

Again, can we take a moment and appreciate how remarkable it is that I could conjure this image using little more than a vague description? I love how the request included the phrase "haggard individual," and sure enough, the subject in the final image has a deeply furrowed brow. That's some impressive attention to detail.

Somewhat surprisingly, I've found that image generation does have some practical uses. For example, I was debugging a checkout page of an eCommerce platform and needed to create a product with multiple variations. I could have solved this a number of ways, but asking ChatGPT for red and blue versions of a ninja, pirate, and astronaut-themed chess set was both easy to do and made for a delightfully realistic test product.

$ for theme in ninja pirate astronaut ; do \
  for color in red blue; do \
     prompt="Generate an image of a chess set that is suitable for use on an \
             ecommerce product page. The chess pieces should have the theme \
             of $theme. One player's chess pieces \
             should be $color and the others be black." ; \
      echo $theme-$color ; \
      url=$(chatgptassist -a generate-image -p "$prompt") ; \
      curl -s "$url" > $theme-$color.png ; \
  done ; \
done
ninja-red
ninja-blue
pirate-red
pirate-blue
astronaut-red
astronaut-blue

While ChatGPT's image generation is amazing, it does appear to have significant limitations. For example, I tried to have it draw a basic LAMP stack network diagram. Compared to a pirate-themed chess set, this task was a piece of cake. I described what I was after:

$ url=$(chatgptassist -a generate-image -p "You are a network engineer with an advanced understanding of Amazon's Web Services. Draw a network diagram of a LAMP stack as implemented by AWS services.")
$ curl -s "$url" > network1.png

The resulting image, while visually interesting, completely missed the mark.

I tried again using a different description:

$ url=$(chatgptassist -a generate-image -p "Draw a network diagram of a typical load balanced web app. Include a load balancer, web servers, a redis caching server and database.")
$ curl -s "$url" > network2.png

Again, Chat GPT proudly presented me with an interesting image—yet it's equally useless.

This suggests to me that Chat GPT's image generation isn't appropriate when details matter. With that said, it's excellent for broad concepts, placeholder images and for sparking ideas.

Now that I've built my first AI based tool you might be wondering how I'm feeling. Here, let me show you:

 chatgptassist -a generate-image -p "A programmer sits at Linux terminal, with a cup of tea nearby. He's got emacs and bash running on screen, as well as an image viewier. Inside the image viewer is an image for rainbows and butterflies coming out of a laptop. The programmer is celebrating his success." | tee ~/dl/url.out | clipit