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

Was Yoda based on this Buddhist master? A post on Lion’s Roar says he was.

Was Yoda based on this Buddhist master?

In a recent attempt at freeing up some disk space, I wrote this little Unix shell script to go through all of my Scala/SBT project directories, and run the sbt clean command in each directory:

#!/bin/sh

# WARNING: make sure you have backed up your files
# and directories before running this script.
for file in `cat sbt_dirs`
do
    dir=`dirname $file`
    echo "WORKING ON $dir"
    cd $dir
    sbt clean
    cd -
done

This script assumes that you have a list of the desired subdirectories in a file named sbt_dirs.

Sadly, I forgot to check the before and after disk space comparison, so I can only guess that it helped by deleting all the SBT project and target subdirectories it generates.

As a brief note, my Mac/macOS system disk was pretty full, so I started looking at things I could delete easily. One thing I found is that the Scala-CLI/Coursier cache is location in this Mac directory:

/Users/al/Library/Caches/Coursier

I don’t know yet if it’s safe to delete anything in that directory/folder, but it’s using 7.2GB of space, so I’m about to look into it.

UPDATE: Here is information on deleting the scala-cli/Coursier cache.

Note that I deleted everything in that Coursier directory, and after that NONE of my Java and Scala tools worked, and I had to manually run commands like this to get Java working again:

eval "$(cs java --jvm 11 --env)"

and then later I had problems with scala-cli and had to run this command to kill bloop:

scala-cli --power bloop exit

Unix/Linux tip: How to change/edit the content on thousands of files using awk and a Unix shell script.

As a note to self, today I had to delete the same lines (or line patterns) from over 10,000 files on this Unix/Linux server. Basically I was looking in each file for a specific pattern, and if that pattern was found, a ceertain number of lines should be deleted, starting at that point.

I worked with ChatGPT today to solve the following Unix/Linux problem:

If I have a file that has one or more filename paths like this:

If you ever need to determine the length of one or more video files (MP4 files) on a MacOS system, I can confirm that this ffmpeg command works:

“This is what I practice for, to play against the best players in the world. It’s going to be tough. This, I know. I will control the controllable, which is giving 100%, having the right attitude, fighting for every ball. And then we see the outcome, no? More than this we cannot do.”

~ Jannik Sinner, before playing Novak Djokovic in 2024

January 28, 2020: In a dream this morning a bunch of people came into my apartment uninvited. All but one of them were maintenance people, and they started renovating my apartment. I argued with them that a little notice would have been nice.

While that was going on, I saw that the other person was a Tibetan monk. While the maintenance people started drilling and cutting, the monk walked around breaking all of my things. He’d pick up a glass thing and let it drop to the floor and break, and work harder to break other things. I ran over to him and asked, “Why are you breaking all of my things?”

He didn’t reply, but broke some DVDs in his hands. For some reason this made me more lucid in the dream, so I stepped on some of the DVDs he had dropped to the floor so I could crunch them more. “I get it,” I said, “it’s the whole ‘impermanence’ thing, right?” Then I thought of something and said, “Stay right here for a moment. Break something if you need to, but I’ll be right back.”

Then I went over to my DVD collection and grabbed my Dalai Lama video collection. I went back to the monk, handed him the DVDs, and said, “Here, you can break these, too. Or watch them. I don’t care.” Then I remembered that my tv started on fire when the maintenance people did something, but it didn’t matter, he took the DVDs and sat down silently.

Adam Warski shared code similar to this image during his video titled “Why Scala?”:

Adam Warski flatMap example and anonymous function with case statements

(To see his exact code, see that video.)

allStreets, flatMap, case statements, and function literals

Now he walks in quiet solitude
The forest and the streams
Seeking grace
In every step he takes
His sight is turned inside himself
To try and understand

~ John Denver

Snow on the Rocky Mountains (and John Denver lyrics)

I will continue to be.
But you have to be very attentive to see me.
I will be a flower or a leaf.
I will be in those forms and I will say hello to you.
If you are attentive enough, you will recognize me, and you may greet me.
I will be very happy about it.

This article contains a collection of quotes on industrial design from former Apple chief designer Jonathan Ive (or “Jony Ive,” as Steve Jobs called him). As an interesting note, Mr. Ive prefers to refer to himself as a “builder” or “maker” as opposed to a designer.

For those who don’t know of him, Jonathan Ive is credited with designing almost every Apple product from 1997 until roughly 2020. I (re)discovered Apple when I bought an iPod in 2004, and given that very long string of success, I became interested in what Mr. Ive has to say about design, and to that end, here’s a collection of Jonathan Ive design interview quotes I’ve gathered over the last few years.

If you ever wanted to see the Ammonite REPL and ZIO, Option, Try, Either, Future in a Scala for-expression, here you go.

Ammonite REPL and ZIO, Option, Try, Either, Future in a Scala for-expression

As a note to self, while working on my “Generate the Table Of Contents code for this website,” I just needed to do create some “nested DIV” content using Jsoup, Scala 3, and Scala-CLI, and with the help of ChatGPT, I came up with this working code:

As a little note today, if you want to create a little startup file for the Scala Ammonite REPL, the way you do that on Mac and Unix/Linux systems is to create or edit this file:

~/.Ammonite/predef.sc

As I continue to work through photos, this is a photo of a painting of a church, which I believe I saw in the lobby of the La Fonda hotel in Santa Fe, New Mexico.

Painting of a church, La Fonda hotel, Santa Fe, NM

Sunrise at Virginia Beach, April 9, 2017. No filters have been applied, this is what it looked like. :)

Ocean sunrise

Sled dogs, from the start of the 2011 Iditarod, on the lake in Willow, Alaska. (I took this photo that day.)

Sled dogs, from the 2011 Iditarod, Willow, Alaska

Always trust pure functions, they cannot lie. :)

I was going to add this to my free Thinking With Types booklet, but alas, it did not make the cut.

Always trust pure functions, they cannot lie