Tales from the jar side: Magic man almost gets arrested, Connecting Java to DALL-E, Other AI projects, and the usual silly toots and skeets
My doctor told me I was colorblind. Wow, that came completely out of the green! (rimshot)
Welcome, fellow jarheads, to Tales from the jar side, the Kousen IT newsletter, for the week of August 27 - September 3, 2023. This week I held a YouTube Live Stream and released a video containing an excerpt from it.
Regular readers of (and listeners to, and now video viewers of) this newsletter are affectionately known as jarheads, and are far more intelligent, sophisticated, and attractive than the average newsletter reader (or listener, or viewer). If you wish to become a jarhead, please subscribe using this button:
As a reminder, when this message is truncated in email, click on the title to open it in a browser tab formatted properly for both the web and mobile.
Live Stream with Magic Man Michael Carducci
On Wednesday, I held a Tales from the jar side Live Stream with magician / software developer Michael Carducci.
That was a lot of fun, but if you don’t have time to watch or listen to the whole thing, I’d like to recommend this awesome excerpt:
That’s my favorite story from Michael. It’s a riot. I can honestly say I had no idea where the story was headed until nearly the end, and the payoff is well worth the journey.
For those who might be interested, I imported the full Live Stream video into Descript and then processed it. That meant removing all the so-called “filler” words (which Descript does for you automatically), adding studio sound, breaking the story into individual scenes so I could add lots of short images or videos, adding the dynamic captions, and so on. Descript is very good at those tasks, but I don’t have a lot of experience with it. Creating this video therefore counts as part of my learning curve, so any feedback you might have is welcome. The bottom line, however, is that Michael tells a great story.
Descript has several built-in AI tools. I mentioned the studio sound tool and the filler word removal tool, but there’s also a way to shorten all word breaks (which I didn’t use) and a text-to-image generator. Descript includes a library of images and video, but it doesn’t take long to ask for something that doesn’t exist. Even something as simple as an English street sign partially hidden by a hedge was too much for it, so I asked it to generate one for me.
Not bad, as long as you don’t want to actually read that sign. I don’t know what image generation tool Descript is using under the hood, but it’s probably DALL-E from OpenAI. My own experiments suggest that both Stable Diffusion (especially SDXL) and Midjourney are far better, but this was good enough for the moment.
Java to DALL-E
Speaking of DALL-E, I’ve been working on a set of videos for integrating AI tools into Java systems. That involves treating AI tools like the simple RESTful web services they are, which means I access them via an HTTP client and transform the inputs and outputs between JSON data and Java records. My previous videos involved Listing the Models supported by OpenAI and Talking to ChatGPT. OpenAI also supports access to the DALL-E image generator, which turns out is much simpler than I expected.
From the documentation, here’s the form of a request using curl
:
All you need is a text prompt, the number of images you want, and one of the valid sizes (256x256, 512x512, and 1024x1024). Here’s the sample response, which is also very simple:
In other words, you get a JSON structure with a created
timestamp and an array of URLs called data
. That’s it. I therefore created three records:
To access the API, I created an ImagePrompt
, sent it to a method that does the networking to send it as a POST request, and get back an ImageResponse
, which contains an array of Image
instances. I wrote all the networking code by hand, which got annoying pretty quickly, but then it was time to consider switching to Spring, especially with its new Http Exchange Interfaces from Spring Boot 3.0.
So here was the result, more or less. My interface includes a method to make the POST request:
and all I needed to do was configure the WebClient
as an @Bean
method in a configuration file:
Most of that is pure boilerplate, except for one line that cost me hours of effort.
To explain that, let me start by saying I kept trying to run this test case, which failed over and over again:
I kept getting a timeout exception and a cancelled request. I couldn’t figure out what the heck I was doing wrong, and since I didn’t have direct access to the WebClient
(the code for using it is generated for me), I couldn’t figure out a way to log what was going wrong.
As it turns out (grr), there was nothing going wrong. In the bean where I configured the WebClient
builder, I just needed to increase the timeout period. I finally figured out how to do that and bumped it up from the default 5 seconds (which is way too short for an image generator) up to 30 seconds or more, and suddenly it worked. That’s what the line that says
.blockTimeout(Duration.of(2, ChronoUnit.MINUTES))
in the above code is all about. Here’s one of the results:
I did get some better results, but unfortunately I didn’t save them. Also, since generating images is way more expensive (nearly 2 cents / image) than exchanging text prompts, I chewed up a whopping 45 cents figuring that out.
Still, it works, and now I just have to record the companion video. Look for that this week.
Trinity Course Starts This Week
I spent a lot of time thinking about the course I’m teaching this Fall at Trinity College in Hartford, CT. Most of that was spent on the syllabus and thinking about interesting ways to handle the subject (Software Design, primarily using Java), but I did manage to get over the university to pick up my ID:
Hey, I’m official now. I guess that also means I’m committed, or should be. Feel free to speculate on how long it will be before the I say in an upcoming newsletter, “I’m too old for this nonsense.” Maybe a month? Two months? The first day? Not at all? I guess we’ll have to wait and see.
Getting an ID reminds me of the time I had to teach a training course at a financial institution that shall go unnamed, but they’re all equally insane. As you might expect, the security process at those sites is really complicated and annoying. When, at long last, they approved me (not even to get into the main building — just the training room), I immediately called a friend and said, loudly, “You know how 80% of all security violations at companies are done by insiders? Well, guess what? Now I have a badge.”
I got some pretty stern looks that day.
Question Bank Finally Finished
I’ll have more to say about this in future newsletters, but one of the projects I’ve been working on recently has been preparing a question bank of multiple-choice questions for my upcoming revised version of my Spring and Spring Boot video course. The videos were finished weeks ago, but I really didn’t want to do the question bank at all. Therefore, I decided to try to get ChatGPT to generate it for me.
Let me simply say that I learned a lot, but I was effectively hoist by my own Picard.
(Yeah, I know, it should be petard. But you laughed, right? And see how much better Midjourney is than DALL-E on practically anything?)
The questions generated by any of the current family of AI tools (ChatGPT, GPT-4, Bard, Claude, etc) ranged from mediocre to horrible. I was hoping to save myself tons of time, and while I probably did save at least some, it was way less than I expected.
Honestly, I should show those people worried about AGI (artificial general intelligence) taking over the world some of those generated questions. Staggering levels of cluelessness, not to mention the hallucinations. Ugh. Anyway, that project is done, more or less. Thank goodness.
Toots and Skeets
An elegant solution
Yeah, that ought to do it.
Can I have some money?
I wasn’t going to say anything about Twitter this week, but then I saw that article that said that when Musk’s daughter came out as trans, he decided to buy Twitter and destroy the “woke mind virus” infecting it. She filed papers to disown him four days later.
Ugh. At least this cartoon was clever.
Integer underflow FTW
An integer underflow occurs when “storing a value lesser than the minimum supported value. For example, when we try to store -129 to signed char data type, it gets stored as 127 due to the underflow.” Not sure how the result in the figure would happen, but I’d be willing to try.
The caption makes the joke
The caption on the toot I saw was the Colonel’s wife saying, “Would it kill you to mow the lawn?”
As it turns out, yes.
Hideous, you say?
In case you don’t get the joke, that’s a graph of the trigonometric tangent function, abbreviated tan
. Yeah, seriously old geek joke, but I’m a seriously old geek.
Speaking of old jokes
I can’t believe I hadn’t seen this before, but now I’ll think of it every time I hear that song.
I hope this email finds you well
Seems extreme, but there are days.
Sure, why not?
Finally, there’s this clever idea:
Looks like a harder game than the version we play, and the lack of opposable thumbs complicates things. A great gag, nevertheless.
Have a great week, everybody!
The video version of this newsletter will be on the Tales from the jar side YouTube channel tomorrow.
Last week:
Live Stream with Michael Carducci.
Published an excerpt as an individual video.
This week:
Week 1 of my Spring in 3 Weeks course, on the O’Reilly Learning Platform
Getting Started with Spring and Spring Boot, ditto.
First day of my Software Design course at Trinity College, Hartford.
Too old to teach...