Tales from the jar side: Cat Pictures in Groovy and Java, NFTs are evil, Big Questions, and Wholesome Memes
Dad joke: I wonder what my parents did to fight boredom before the internet? I asked my 18 brothers and sisters and they don't know either
Welcome, fellow jarheads, to Tales from the jar side, the Kousen IT newsletter, for the week of January 16 - 23, 2020. This week I taught an Introduction to Gradle course for Gradle, Inc., and my Kotlin Fundamentals course on the O’Reilly Learning Platform. I also gave a presentation at the online Java Champions conference.
Java Champions and Cat Pictures FTW
I keep forgetting to do this early enough, but just before my talk at the Java Champions conference I finally remembered to tweet this:
And cat pictures there were. I’ll get to that in a moment, but if you want to see my presentation, it’s on YouTube like all the others:
That overall link takes you to the JChampions Conf YouTube channel, which contains all the talks (so far) from this year and all the ones from last year. If you’re interested, the conference continues Monday and Tuesday of this coming week, and you can register for free here.
In my talk, I used examples from Java, Groovy, and Kotlin. My last demo is the one that shows cat pictures, and I thought I’d break that one down here. The idea is to download the latest six photos tagged with the word “kitties” at Flickr.
Remember Flickr? It’s an image and video hosting service, and was a big thing long before Instagram. The Wikipedia page has a good summary of its history. Yahoo! bought it (and the parent company) in 2005, which, like most Yahoo! acquisitions, was the kiss of death. By 2007 all users were required to get Yahoo ids, which I’m pretty sure is one of Dante’s Circles of Hell. By 2009 the founders left and by 2010 many of the employees were laid off. Then in 2017 Verizon bought Yahoo (I totally forgot about that) along with AOL (which apparently still exists) and there were more “reorganizations”. Finally, in 2018, SmugMug (who?) acquired Flickr and cut back on the free tier.
So be it. For me what matters is they provide a restful web service that allows developers to download images for free. To access it I had to create a Yahoo API (ouch), but then I could download “public” photos without authentication. That’s good enough for a demo anyway.
(To do a similar search on Instagram apparently requires undergoing the App Review process on Facebook, and as awful as Yahoo is, that’s way too high a bar.)
Here’s the link to the Flickr photos search documentation. If you are a true advocate of the REST (representational state transfer) architecture, you are already appalled, because Flickr puts the name of the service directly into the URL. Yikes.
Aside: you know what those true REST advocates are called? RESTafarians. Seriously. I’m impressed, actually, because that shows way more of a sense of humor than those people normally demonstrate. The old joke back in the late 2000s was that some people actually preferred the SOAP (Simple Object Access Protocol) approach over REST, because nobody ever argued whether a service was truly SOAPful or not. It was a different world.
The photo search API documentation shows a sample response:
The fact that the sample shown uses XML gives you an idea how old this is. The idea is that you make one call to get the list of photo elements, and then you use the attributes in each photo element to create another URL that downloads the individual pictures. With that in mind, here’s the beginning of my Groovy script, cat_pictures.groovy. Note that you can find this script, along with all the rest of the code, in the Java_Groovy_Kotlin GitHub repository. Here is the direct link to that script.
I start by building up the URL for the download of six images in JSON format, because if I used XML, I suspect my audience would laugh me out of the building (and since this was a remote talk done over Zoom, that could get awkward). Then the Groovy JDK adds a toURL() method to String, and by accessing its text property (which calls the getText() method), it downloads the results.
I write the data to a file, but I’ll skip that here. Next I form the URL for the individual images and download them, in parallel (!), using Java streams:
That code also converts the downloaded bytes into BufferedImage instances using the ImageIO.read method from Java.
The last part is to use the SwingBuilder class in the Groovy library class to render the images:
That’s it. Of course, as I warn the attendees, when I run this I never know exactly what I’m going to get. I used to search on the tag “cat,” but then I often got tractors (Caterpillar, get it?), but in case you think it was predictable I often got dogs or even monkeys (?). Sometimes I would get images that were, shall we say, not appropriate for a public forum, despite Flickr’s reputation for censorship. Over the years I’ve found that “kitties” is the most reliable tag that results in actual cats.
I just ran the script again now, and here’s what I got:
Each of those contains something at least vaguely resembling a cat, so I’m calling it a win. I could do a lot to clean up the formatting, but like most developers my UI skills leave a lot to be desired, so I just went with simplicity.
Incidentally, in addition to saving the JSON data, I also print to the console which thread is downloading each picture:
main: Kitty Mug
ForkJoinPool.commonPool-worker-4: Max's story
ForkJoinPool.commonPool-worker-5: Catnap Serigraph
ForkJoinPool.commonPool-worker-2: Mannequins with 4 paws @ Gacha Loft
ForkJoinPool.commonPool-worker-3: Introducing JIAN Pets Wardrobe! - The Saturday Sale 1/22/22
ForkJoinPool.commonPool-worker-1: Max's story
That’s my evidence that I’m actually doing the downloads in parallel.
Desktop Kotlin
None of that uses Kotlin. I spent a few hours playing with Kotlin, using the Retrofit 2 library for the downloads (maybe I should have gone with Picasso?), but that’s not finished. It then occurred to me that this was a perfect opportunity to learn Jetpack Compose for Desktop. Of course all of their samples are much more complicated than what I’m doing, but I need to learn Jetpack Compose anyway for my Android stuff, and my simple app might be doable there, and that would give me something cross-platform and everything.
I’m scheduled to give this same talk at the NY Java SIG in March (more about that as it gets closer), so I have a vague deadline. If I can’t figure it out I’ll stick with what I have, but if I can get it to work, it would be a nice compatible demo, and it would also fit in nicely with my Kotlin presentations.
One thing I know for sure is that it will require much more code and complexity than the Groovy solution, but I’m used to that.
NFTs are Evil, The Definitive Guide
I frequently quote tweets here about how misleading non-functional tokens (NFTs) are, and how they’re mostly just a scam to get people to convert dollars into some form of cryptocurrencies like Bitcoin or Ethereum. A few issues immediately come to mind:
An NFT does not include the image or other resource you are supposedly “buying.” At best, it contains a link to that image. If the owner of the site changes the location of the image, or if the site is hacked to do the same, you’re out of luck.
Owning an NFT does not confer any addition rights to the underlying property. Did you see that wild tweet by some crypto bros who bought an NFT of a Dune art book and thought they owned everything? This article at Esquire gives the details:
If fear is the mindkiller, then stupidity must be the pocketbook-killer. Just ask the crypto bros who made a three million dollar mistake by failing to read the fine print.
An anonymous NFT group called Spice DAO (decentralized anonymous organization) made waves this week when they triumphantly tweeted about their recent acquisition of a rare art book: Jodorowsky’s Dune, the guidebook to an ambitious but ill-fated film adaptation of Frank Herbert’s Dune. These spiceheads had big plans to convert the book into NFTs, burn the physical copy, and adapt the story into an animated series. There’s just one problem: little did they know, they don’t actually own the copyright to Dune. All they own is one very, very expensive book.
In order to buy an NFT, you need to buy the associated cryptocoins first. The problem is, cryptocurrency isn’t currency at all, it’s just another asset. In order to get your money out of crypto and back into dollars, you need to sell your coins, which means there needs to be a demand for them. It’s like any other product that you’re trying to sell on the secondary market — if there are no buyers, or if the buyers don’t want to pay full value for what you’re selling, you’re out of luck. In fact, the only way crypto holders can make money is if new buyers keep entering the system. This is known as the Greater Fool scam, and it’s also why any discussion of crypto anything completely suppresses dissent. If anybody complains, or even asks the same questions you would ask when buying any other asset, the whole structure collapses.
All of this and much, much more, is laid out in detail in a monumental YouTube video called The Problem with NFTs by Dan Olsen, known as @foldablehuman on Twitter.
This video is truly epic in scope. I planned to watch it in multiple short sittings, but wound up engrossed and devoured the whole thing. I highly recommend it, though I understand if you want to break it into smaller chunks as well. It should, however, be required watching for anyone who decides to buy into that foul ecosystem.
I should also mention that recently a developer by the name of Moxie Morningspike (seriously), whose biggest claim to fame is that he was the creator of the Signal secure messaging app and the company CEO until recently, wrote a blog post called My first impressions of web3. That’s also worth a read, and it shows what kind of world some of these giant technology companies (Facebook, i.e., Meta) want to create. Depressing and ugly.
For yet another perspective, consider this tweet:
Says it all, doesn’t it?
Other Happenings
Unless you are a Green Bay Packers fan, you’re probably enjoying the fact that idiot, lying anti-vaxxer Aaron Rodgers lost on a last second field goal on Saturday to the San Francisco 49ers. My favorite tweets that resulted were:
and this one:
He’s probably going to win his second consecutive MVP award this year, but he’s out of the playoffs. The 49ers will very likely get destroyed next week in the NFC Championship game, but hey, on back-to-back weeks they defeated the Dallas Cowboys (owned by one of the worst humans in the world, Jerry Jones), and the Green Bay Packers (quarterbacked by awful human Aaron Rodgers), so I’m rooting for them anyway. Can you imagine the press if next week they wind up facing Tom Brady and defeat him too? Stay tuned.
Speaking of anti-vaxxers, Meat Loaf passed away this week at age 74, from COVID. I don’t want to celebrate anybody’s death, but he was a key, early Trump supporter and did enormous harm to society. See this article for details. I was 15 when the Bat Out Of Hell album was released and I practically wore it out at the time, but yikes, some Boomers have really not aged well.
On the lighter side
At least one person is struggling with one of the big questions of our time:
After all, androids dream of electric sheep, right?
Here is another person wrestling with Big Issues:
My assumption is both, but I’m not an insurance person. I just have a lot of contempt for insurance companies, and am sure they wouldn’t miss an opportunity like that.
Here’s one about the Supreme Court:
Even people who agree with him must admit this rings true. The follow up might be even better:
Finally, in case you need it, there’s an entire twitter feed called WholesomeMemes:
A few years ago, I was sitting on the (Pretend To Be An) Expert Panel at one of the No Fluff, Just Stuff conferences, when one of my statements was being heavily criticized by another speaker (who I won’t name). My friend and fellow speaker Stu Halloway was sitting next to me and noticed that I was staring at my phone while this was happening, so he glanced over my shoulder to see what I was looking at. He burst out laughing when he saw I was browsing a twitter feed called Emergency Kittens, and felt compelled to tell the audience that’s what I was doing. Guilty as charged, your honor.
(I’d link to that feed, but there are about a dozen of them now with the same name and I don’t know which one I followed at the time. Go with Wholesome Memes if it helps.)
As a reminder, you can see all my upcoming training courses on the O’Reilly Learning Platform here and all the upcoming NFJS Virtual Workshops here.
Last week:
Introduction to the Gradle Build Tool, online for Gradle, Inc.
Kotlin Fundamentals, on the O’Reilly Learning Platform
This week:
Deep Dive Into Spring, an NFJS Virtual Workshop
Spring MVC, an NFJS Virtual Workshop