Scala, Java, Unix, MacOS tutorials (page 1)

Dateline Broomfield, Colorado, November 30, 2011: This was a Rocky Mountain sunset on that evening.

Broomfield, Colorado: Rocky Mountain sunset

“Keep inventing, and don’t despair when at first the idea looks crazy. Remember to wander. Let curiosity be your compass. It remains Day 1.”

~ Jeff Bezos, in this sec.gov message to employees and shareholders

As a brief note to self, this is a SQL query I use in the Scala Cookbook to get a distinct list of all movie titles in the MovieLens dataset that are five-star rated in the Comedy/Romance genre:

val q = """
    select distinct(m.title), r.rating, m.genres
    from movies m, ratings r
    where m.movieId == r.movieId 
    and m.genres like '%Comedy%Romance%'
    and r.rating == 5.0
    order by m.title"""

spark.sql(q).show

As kind of a crazy thing, I haven’t given a live presentation in fifteen years. But last week I was asked to give a two-hour talk about writing and editing, and after that I decided to create this video presentation on YouTube, titled, Almost Everything I Know About Writing. It’s a 33-minute long presentation that’s based on the introduction to the original presentation, and if you’re interested in technical writing, I hope it’s helpful.

Almost Everything I Know About Writing (webinar)

In case this might help anyone else, I thought I’d share this information. I was having a weird problem where some mornings when I woke up my blood pressure would be really high, so long story short, I did an at-home sleep study a few weeks ago, and went over the results with a doctor this morning. I’ll include the doctor’s notes with each image.

Image 1: The “A+H” metric

In the first image, “A+H” is the main metric they use. It measures the average number of apnea events that occur per hour while you’re sleeping.

In my case, a 19.4 overall average means, “Yes, you have apnea.” The 36.8 value means, “you have really bad apnea on your back, don't sleep there.” Interestingly, 0.7 means “you have no apnea when sleeping on your left side, so sleep there as much as possible.” I’ve known for years that I sleep better on the left side, so the doctor encouraged me to sleep on that side as much as possible.

“I can’t judge. There are two kinds of people in Alaska: those who were born here, and those who come here to escape something. I wasn’t born here.”

~ Rachel Clement, Insomnia

“Do that thing that will charm you, that will make you say, ‘Yes, it’s the real me.’ Do that, and you’re alive.”

As a quick note, I wrote this little Unix/Linux shell script that I named sbtnew to run the sbt new command (with the template shown), and then delete the project and target directories that sbt new creates in my current directory:

#!/bin/sh

# sbtnew:  a script to run 'sbt new' and then clean up the project and target directories
# version: 0.1
# license: GNU GENERAL PUBLIC LICENSE, see https://choosealicense.com/licenses/gpl-3.0/#

# [1] create a new Scala 3 project
sbt new scala/scala3.g8

# [2] clean up the 'project' and 'target' directories
if [ -e project ]
then
    echo "i see project"
    rm -rf project
fi

if [ -e target ]
then
    echo "i see target"
    rm -rf target
fi

Please note that this project/target directory situation seems to be getting better with new versions of sbt, so this sbtnew shell script may not be needed in the future, but I still like it because it’s easier to remember than the full sbt new... command. One day I’ll also add the ability to rename the directory to what I entered, because for some reason sbt new changes the name to lowercase.

Every once in a while when something hits you, you really remember it; it stands out in your mind as an “Aha” moment. One of those moments for me was when I saw a particular “Model/View/Controller” (MVC) diagram, and the light bulb went on. This diagram made the MVC pattern very simple, and I’ve never forgotten it.

The Model / View / Controller diagram

The diagram I’m talking about comes in two parts. The first MVC diagram shows the symbols the authors use for Model, View, and Controller objects. Here’s that diagram:

Model View Controller - symbols for MVC objects

My 700+ page book, Functional Programming, Simplified — 4.5-star rated on Amazon, their 6th-best selling book on functional programming, and 5-star rated on Gumroad.com — is currently on sale in three formats (prices shown in USD):

PDF Format
$15 (sale!) on Gumroad.com

PDF version of Functional Programming, Simplified

Paperback Book
Now $34.99 on Amazon

Print version of Functional Programming, Simplified

Kindle eBook
$14.99 on Amazon

Kindle version of Functional Programming, Simplified

While driving back from Golden, Colorado on November 10, 2016, I happened to be listening to Lady Cab Driver by the artist formerly known as Prince, and wondered if these days he would have called it Lady Uber Driver. I thought it was interesting how society in the present moment has an effect on music and writing.

And here’s a gratuitous photo of some cattle on the right and wrong side of the fence near Golden, a big field, and some mountains.

Drive back from Golden, Colorado (and Lady Cab Driver)

My (former) cattle neighbors in Broomfield, Colorado, who I discovered on the afternoon of December 4, 2011.

My cattle neighbors in Broomfield, Colorado

As I noted here on the Valley Programming website, I just released Version 0.1 of my Automated GUI Testing (AGT) software. It still needs a lot of work, but a key is that I added in some basic image-recognition capability. This means that as a GUI tester, you don’t have to rely on pixel coordinates; you can instead write, “Find this icon on the screen, and when it’s visible, click it.” Similarly, you can also write, “When this given icon goes away, do (whatever you need to do).”

I’ll write more about AGT over time, but for today, I’m happy to get to Version 0.1.

This is a photo from the drive from Santa Fe, New Mexico north to Colorado, taking the back roads (Route 285) rather than the expressway. I took this photo in March, 2015.

Road from Santa Fe, New Mexico north to Colorado

Here’s part of the road (I-25) from Colorado to Santa Fe, New Mexico. It looks like a painting, but it’s not.

The road from Colorado to Santa Fe, New Mexico

“Remember, remember, the fifth of November.”

~ from the movie, V for Vendetta

 November 5th and V for Vendetta

Peter Gabriel, discussing a moment of “enlightenment” that reminds me of the movie V for Vendetta:

I was doing some gigs in Germany with Frank Zappa ... we were supporting Frank Zappa. And his audience in Berlin were very much old hardcore hippies, and they thought I was just cheap shit, and the boos was just ... this rain of stuff being thrown on the stage. It was very humbling.

Next night we’re in another German city and I thought, “Oh shit, here we go”, and we go out there again, and a similar sort of reaction, they hate it. But it wasn’t just the music, it was me, personally, you know, they meant it.

And suddenly I had one of those moments and I thought, “That’s it, I’m no longer afraid.

You know the thing you’re most scared of when you get on stage is being rejected and booed off, and I suddenly realized I’d been booed off and I was still out there. They didn’t like it any more, but I was still doing it, and they couldn’t stop me.

And I just started giggling. And Tony Levin looked over like I’d gone crazy. But it was a fantastic moment of enlightenment.

This is a photo of Denali from about 70-90 miles south on Highway 3. I think I was just before or after the gas station in Willow when I pulled over and took this photo.

Denali, from ~70-90 miles south

This is all still very much a work in progress, but here’s an example Automated GUI Testing (AGT) script that I developed yesterday.

An Automated GUI Testing example (Nov. 2, 2021)

Coach Billy Donovan called Dosunmu “fearless’’ once again.

“My motto is just fear God, so I don’t fear anything but God,’’ Dosunmu said. “When I go out there and compete, I trust in what I can do.”