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

This page titled, “What I wish I knew when learning Haskell” has this interesting section on monads. I agree with his statement that there’s no sense in studying monads; you just need to write a lot of functional programming code, and then you’ll see when you need a monad. That is, studying monads is like studying OOP design patterns when you don’t need them; they’re interesting to learn, but until you need them and use them you won’t really understand them.

Haskell: Monad myths

A “community library” sounds like a great idea. Well, until someone steals it. :( The story is here at ktuu.com, Anchorage, Alaska.

Community library stolen in Anchorage, Alaska

“Do you hear the sound of your heartbeat?”

“No.”

“Do you hear the grasshopper at your feet?”

(Pause)

“Old man, how is it that you hear these things?”

“Young man, how is it that you do not?”

Kung Fu: The Grasshopper scene

“The light that shines upon me shines upon my neighbor as well. In this way everything is connected to everything else.”

~ Detective Charlie Crews, Life

This won’t mean anything to anyone else, but while cleaning stuff off of my phone just now I ran across this photo of a house I once called home.

A house I once called home

“From a Hindu perspective, you are born as what you need to deal with, and if you just try and push it away, whatever it is, it’s got you.”

~ Ram Dass

“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

“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, use the parentheses

These examples demonstrate the preferred procedure style:

val name = person.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?

Solution

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
        htmlPane.htmlTextArea.setText(html)
        GuiUtils.showHtmlDialog("Your HTML", htmlPane)
    }
}
Platform.runLater(runnable)

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