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

Once upon a pre-pandemic day, I was sitting in the waiting area of a doctor’s office, writing notes all over my functional programming book as I edited it. Another patient came over and asked if the book was any good.

I was kind of immersed in what I was doing, so without looking up I said, “I hope so.” Then I looked up and started to add more, but just then he got called in before I could say any more. :)

A story about editing Functional Programming, Simplified

I know your anger
I know your dreams
I’m everything you want to be
Like Mussolini and Kennedy
Like Joseph Stalin and Gandhi

Neon lights, a Nobel Prize
A mirror speaks, the reflection lies
I sell the things you need to be
I’m the smiling face on your t.v.
I tell you one and one makes three
I exploit you, still you love me

You gave me fortune
You gave me fame
You gave me power in your own god’s name
I’m every person you need to be
I’m the cult of personality

~ from The Cult of Personality, by Living Colour, 1988

Here’s a great view of the Rocky Mountains and part of Boulder, Colorado, as seen from my apartment in Broomfield on December 21, 2013.

Snowy Rocky Mountains and Boulder, Colorado, December, 2013

I can’t remember the history of this image, but the metadata tells me that I created it on May 13, 2014. It looks like I took a slightly zoomed-in photo with an iPhone 5s, because that also appears in the metadata. This was the view I had from my second apartment in Broomfield, Colorado.

Snow on the Rocky Mountains, southeast of Boulder

January 5, 2011, Wasilla, Alaska: This is a photo of our parking lot, a half-inch or more of ice, and black gravel they’ll sweep up and re-use come March or April.

A thick layer of ice in the parking lot, Wasilla, Alaska

On this Contributors thread I just saw this comment by Martin Odersky that I didn’t notice before: “For the moment Scala-3’s @main only covers a small subset of what Mainargs can do. But the plan is to extend that.”

This comment came after Li Haoyi shared an example of his MainArgs library, and it seems like the implication is that the @main annotation in Scala 3 may eventually be able to handle command-line arguments.

vi/vim FAQ: How do I show hidden characters in the vi/vim editor?

Solution

I just learned that you can show hidden characters like tabs and end-of-line/newline characters in vi/vim with its set list command. Just go into last-line mode with the : character, then use that command:

:set list

When I do that in my current file, the $ is used to show newline characters, and TAB characters show up as ^I:

#!/bin/sh$
exec scala "$0" "$@"$
!#$
$
println("Hello, world")$
$
^I// tab test$
$
$

If you ever need to show hidden/invisible characters in vi/vim, I hope this is helpful.

I just wrote this awk script to extract all of the Scala source code examples out of a Markdown file. It can easily be converted to extract all of the source code examples out of an Asciidoc file, which is something else I will do with it eventually.

Here’s the awk script:

BEGIN {
    # awk doesn’t have true/false variables, so
    # create our own, and initialize our variable.
    true = 1
    false = 0
    printLine = false
}

{
    # look for ```scala to start a block and ``` to stop a block.
    # `[:space:]*` that is used below means “zero or more spaces”.
    if ($0 ~ /^```scala/) {
        printLine = true
        print ""
    } else if ($0 ~ /^```[:space:]*$/) {
        # if printLine was true, we were in a ```scala block,
        # so print the end matter, then make printLine false
        # so printing will stop
        if (printLine == true) {
            print "```"
        }
        printLine = false
    }
 
    if (printLine) print $0
}

This is a view in Rocky Mountain National Park, on January 3, 2018. Sister #2 and mom was here, and we went into the park.

Rocky Mountain National Park, Jan. 3, 2018

If you know where to look, you too can find this 12,005’ altitude sign in Rocky Mountain National Park (RMNP), in the Estes Park, Colorado area.

12,000 feet up in Rocky Mountain National Park (Estes Park area)

Unfortunately this image (and accompanying video) are blurry — I didn’t want to get too close to them — but here are two moose in Rocky Mountain National Park, July 31, 2019.

Two moose in Rocky Mountain National Park

“Someone is always in the way.”

That was my predominant thought after living in Alaska, and then moving back to the Lower-48.

In Alaska you can go to a lot of places and find solitude, and when you go to the grocery store it isn’t crowded, but as soon as I came back to the Lower-48 I constantly found that someone was always in my way, standing in front of me, at the grocery store, at the post office, in the Rocky Mountain National Park, wherever.

Way back on December 31, 2010 I lived in Wasilla, Alaska, and planned on driving down to Seward to spend a few days around New Year’s there. But a bad ice storm and the inability to find the right size tire chains derailed my plans, and I ended up in Anchorage instead. But because of that, I learned that they have a great fireworks show in Anchorage on New Year’s Eve.

As I mentioned in my second Facebook post on that day, there’s an Alaska saying that goes, “There’s old pilots, and there’s bold pilots, but there ain’t no old and bold pilots.”

December 31, 2010: Aimed for Seward, ended up in Anchorage

I just noticed that if you want to see which developers contributed to a software release when using git, you can use this git command:

git shortlog -sn --no-merges 3.0.0-M1..3.0.0-M3

I just saw that on this Github page. As shown on that page, the resulting output looks like this:

80  Nicolas Stucki
73  Martin Odersky
64  Krzysztof Romanowski

As a brief note today, here are several examples of the Scala 3 while loop syntax.

Scala 3 while/do syntax

First, here are some one-line examples. This is the preferred syntax, using the while/do keywords.

while i >= 0 do i = f(i)

When using Apple’s macOS Terminal application, sometimes you’ll issue the ls -l command and see @ characters in the ls command output, like this:

$ ls -l
total 1280
-rw-r--r--@ 1 al  staff   1695 Dec 24 17:19 ca-context-bounds.md
-rw-r--r--  1 al  staff   4064 Dec 24 14:41 ca-type-classes.md
-rw-r--r--@ 1 al  staff  20580 Dec 24 14:41 collections-classes.md
-rw-r--r--@ 1 al  staff  15960 Dec 24 14:29 control-structures.md

For me, seeing the University of Louisville (UL) and Texas A&M play this afternoon — December 30, 2015 — must be how it feels to see two of your kids fighting. When I went to UL I lived in the basement of the house on the left, and when I went to A&M I lived in that brick and cinder block place on the right.

As George Costanza would say, “An Al divided cannot stand.”

UL vs Texas A&M (Music City Bowl, 2015)

If you ever have 169 comments on a Github pull request, I learned last week that the Atom editor has a nice feature that lets you see which comments are open or resolved. 169 thank you’s to whoever created that.

Atom editor feature lets you see open/resolved Github PR comments

A few weeks ago I started my morning with some hot chocolate. :)

Started the morning with some hot chocolate

December 23, 2019:

Nurse at the hospital, as part of a questionnaire: Do you feel suicidal?

Me: Well, I want to be careful with this because I don’t want you to get the wrong idea ... I don’t mind living ... and I don’t mind dying, but this in-between stuff where you’re constantly sick and can’t work or have any fun ... it is ... very frustrating.

Nurse: So ... [long pause] ... not yet?

Me: Yes, that’s fine.