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

“I recommend almost dying to everybody. It’s character building. You get a much clearer perspective of what’s important and what isn’t, the preciousness and beauty of life.”

~ Carl Sagan, Astronomer, Philosopher

“A man dies when ...”

The words shown in this image come from this speech by Martin Luther King Jr.

A man dies when ... a speech by Martin Luther King Jr.

I was a little busy making popcorn and missed most of tonight’s sunset, but I managed to catch this photo right before it disappeared.

Louisville, Colorado sunset, June 1, 2020

My book, Functional Programming, Simplified — 4.5-star rated on Amazon — is currently on sale in three formats:

PDF Format
Just $15 on
(December sale!)

PDF version of Functional Programming, Simplified

Paperback Book
$39.99 on Amazon

Print version of Functional Programming, Simplified

Kindle eBook
$14.99 on Amazon

Kindle version of Functional Programming, Simplified

“I alone cannot change the world, but I can cast a stone across the waters to create many ripples.”

~ Mother Teresa

A post from 2017:

For everyone who is upset by the actions of the current president and other political leaders, I urge you to take action. By “action” I don’t mean posting things on social networks. I mean writing your senators and congressmen. I mean peacefully marching and demonstrating. I mean supporting others who are marching and demonstrating. Every time you think about sharing a post, send a check to the ACLU and other organizations that are fighting against hate, oppression, destruction of the environment, etc. Otherwise, it’s just a lot of people preaching to the choir.

Katniss three-finger salute

If you think programming now is difficult, VisiCalc was written in assembly language for an Apple II. Here are a few words from this web page that describe this code:

“Each line represents no more than one CPU instruction. The poll_keyboard subroutine call was important. As Bob Frankston describes it: ‘There were no interrupts nor a clock [on the Apple II]. If the user typed a character before the keyboard input buffer was emptied it would be lost ... To avoid [losing characters when the user typed fast during a CPU-intensive operation] I polled the keyboard in the middle of potentially long loops — keyboard checks were strewn throughout the code.”

The code was written at night while dialed into a time-sharing system with only a keyboard and printer.

VisiCalc was written in assembly language

Idea of the day: I think it might be nice if, when using an operating system like MacOS, background windows could optionally be displayed with a gaussian blur effect. That way I could focus more on the main window I’m working in.

For instance, right now I’m writing part of the Scala Cookbook, and as I’m writing in a foreground window it would be nice if my IDE and Terminal windows would seem like they were further in the background. The gaussian blur idea is the first thing that came to mind, but any effect that made those windows seem like they were further in the background would be nice, i.e., if there was more of a 3D depth effect.

I recently had a problem with VS Code, Scala Metals, SBT, and Bloop, and VS Code said that I needed to manually run “build import.” Problem is, it didn’t tell me how to run build import.

The short story is that if you need to manually run build import in VS Code, you need to execute the “Import build” command through the VS Code command palette. On a Mac you do this by opening the command palette with the [Cmd][Shift][p] keystroke, and then start typing the word “import”. When you see “Import build” appear in the drop-down list, click it, and it will run the build-import/import-build process.

Back on this day (May 30th) in 2012, I turned myself in to the police in Virginia Beach. What happened was that I accidentally ran a red light the day before — and I mean it was really, really red — the day before. I was trying to figure out how to get to a grocery store and I was looking at everything but the traffic light.

I was about to leave town and didn’t want to deal with this after I left Virginia, so I called the police and told them I ran such and such a light at approximately such and such time, and I’d like to pay my fine before I left town. They had cameras on all four corners so I figured I was screwed. The woman I spoke to worked for a little while, then came back on the phone and said I was fine, they had no record of it.

As a brief note to self, when calling procedures in Scala, the Scala style guide suggests the following:

  1. If the procedure is basically just an accessor, leave the parentheses off
  2. If the procedure has some sort of side-effect, do use the parentheses

Examples of these procedure calls:

val name =   // a procedure that works like an accessor
openTheGarageDoors()     // a procedure that has a side-effect

Back on June 19, 2012, the Sun looked enormous as it set over the Rocky Mountains, just west of Boulder, Colorado.

Huge Boulder, Colorado sunset, June 19, 2012

Scala String FAQ: How can I extract one or more parts of a string that match the regular-expression patterns I specify?


Define the regular-expression patterns you want to extract from your String, placing parentheses around them so you can extract them as “regular-expression groups.” First, define the desired pattern:

val pattern = "([0-9]+) ([A-Za-z]+)".r

Next, extract the regex groups from the target string:

val pattern(count, fruit) = "100 Bananas"

As a brief note to self, this is some code I wrote to update my GUI in a JavaFX application:

val runnable = new Runnable {
    override def run(): Unit = {
        val htmlPane = new HtmlDialogPane
        GuiUtils.showHtmlDialog("Your HTML", htmlPane)

Woke up this morning and my back was a little sore, so before getting out of bed I pulled my legs up over my body in Happy Baby yoga pose — Ananda Balasana, which sounds cool if you say it with an Italian accent. When I did this I looked at my right foot and thought, “That's a handsome foot.”

Of course I wasn’t awake and it wasn’t my foot or my bed or even me, but as feet go, that was a good-looking foot.

~ a facebook post from may 26, 2018

This is a picture of me as a pitcher in high school. I don’t want to say that we were poor growing up, but I wore a large outfielder’s glove while pitching because I was afraid to ask my dad for a new glove, and the shoe on my right foot — the one way up in the air — was cracked in the middle.

(Many thanks to Dwayne Heidtbrink for the photo way back when.)

Alvin Alexander pitching in high school

Last night (May 22, 2014) was one of the “hell nights” I experience once or twice a year. It started with a dream straight out of Carrie or The Exorcist where everything in a room, including me, was being levitated by something, and whatever that thing was, it was not a good thing, it was evil.

After something went flying out the window near the end of that dream, a voice kept saying a two-word phrase over and over again. At 4am this morning I could have told you those words easily, but I can’t remember them now. They were old, Christian/Biblical words, and in short they meant, “Atone for your sins or go to hell.” The two words were something like, “contrition, damnation”, but those aren’t right; I just wanted to be clear that he kept using only two words, over and over again.

For the last several days in dreamland I’ve been working in a large, beautiful log cabin. Along with a group of cohorts — I can’t call them coworkers — we’ve been giving a series of presentations to a group of visitors.

Before my presentation this morning I went out into the audience to talk to a couple of people I had recently met. They were talking about their plans for next weekend, and invited me to join them on Saturday.

Just after this I turned around and saw that one of my cohorts had scribbled a large collection of new notes on my blackboard. Yes, a blackboard with chalk, not a whiteboard with markers. I would later think about this, and wonder if it was influenced by a Columbo episode I watched recently — the one about the architect who likes classical music and kills the millionaire cowboy who likes country-western music. The architect also teaches at a local college, and he and Columbo spent several minutes wiping off chalkboards during one scene.

So I walk up to this cohort who has written notes all over my chalkboards like a mad scientist. I read what he has written, and he asks, “What do you think?”

These days I’m pretty consistent in how I take notes when reading an online article or blog post, so I’m writing a little “CliffsNotes” app to make that process faster. The basic app consists of a browser on the left, and some controls at the bottom of it so I can rapidly put notes in the notepad on the right.

A “CliffsNotes” app

I’ve been stuffing receipts and junk into a compartment in my car for years, and cleaned it out yesterday. This card is by far the best thing I found in there (find Haines, AK on a map, and you might know why). As I’m shredding things, I just saw that on this day two years ago I was in Virginia Beach.

A motel in Haines, Alaska