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

In a Buddha there has never been
Anything that could be said to be there.
Just as a magician
Does not get caught up in his illusions
And therefore by his knowledge
Is not attached to magic forms,
So also the wise in Perfect Enlightenment
Know the three worlds to be like a magic show.
Liberation is merely the end of error.

~ Gampopa

(I saw this quote in the book Be Love Now by Ram Dass.)

Back in the day I drove up to Fairbanks, Alaska, and then from there I drove up to Prudhoe Bay, which is as far north as you can drive in Alaska. I put some gas cans on the car because I didn’t know if there were really going to be any gas stations on the 494 mile drive, but a little “town” of Coldfoot had a couple of gas pumps.

I stopped here, filled up the gas tank, had a burger, and then finished the trek on the Dalton Highway to Deadhorse and Prudhoe Bay, where I stayed at this little, ahem, motel.

Getting gas on the Dalton Highway

Here’s another photo from my drive from Fairbanks, Alaska to Deadhorse and Prudhoe Bay.

The drive from Fairbanks, Alaska to Deadhorse and Prudhoe Bay (photo #1)

Today people on Twitter are noting the farthest north they’ve ever been. The farthest north I’ve ever been is Prudhoe Bay, Alaska. I drove there when I lived in Talkeetna.

Prudhoe Bay, Alaska - the farthest north I've been

This is one of my favorite traffic signs in all of the world. You can find it if you drive north from Anchorage, Alaska towards Wasilla and Palmer.

When I lived in Alaska in 2010-2011, I would take the exit to the right to go to Palmer. If you keep going straight you’ll go to Wasilla, followed by Willow, Talkeetna, and eventually Denali and then Fairbanks. (If you’re really gung-ho, as I was, you can also keep driving to Prudhoe Bay, if you don’t mind 400 miles of dirt roads in the Arctic Circle.)

And as you can tell from the highway numbers 1 & 3, there aren’t many main roads in Alaska. :)

Highway traffic sign to Wasilla and Palmer, Alaska

This is THE speed limit sign on the Dalton Highway in Alaska. If I remember right, this is the only speed limit sign you’ll see when headed north from Fairbanks heading towards Prudhoe Bay.

I started off driving about 50 mph, but then after realizing I was the only person on the road — an almost-entirely entirely dirt road — and how late it was going to be when I got to Prudhoe Bay, I drove as fast as conditions allowed.

The speed limit sign on the Dalton Highway, Alaska

Scala performance FAQ: Is there a reliable way to determine the number of processors (CPUs) or cores when writing Scala code?

Solution

As I was reading this article on ZIO performance tuning, I decided to look into whether there is a reliable way to determine the number of CPUs or cores on a computer using Scala (and therefore Java, Kotlin, and other JVM languages).

The solution is that there seems to be a reliable way to determine the number of CPUs or cores in Scala. In short, use the Java Runtime class to get the information. This Scala example shows how to do it:

If you struggle with any form of addiction AND are also interested in mindfulness and meditation — to the point of being interested in enlightenment/awakening — this quote from Daniel Ingram may be a helpful motivator:

“Stagnation is guaranteed if you cling to pleasant sensations.”

In other words, you won’t make any progress on the enlightenment path until you get past the clinging to pleasant sensations — i.e., the pleasant sensations that you are addicted to.

Ram Dass offered a quote that’s in the same ballpark: “One way to get free of attachment is to cultivate the witness consciousness, to become a neutral observer of your own life.”

(A friend of mine dealt with addiction for as long as I knew her, and I know she was also looking for any motivation to quit, so I try to share anything I learn that might be helpful.)

In this ZIO performance tuning article by Pierre Ricadat, there’s this nice tip about using ZIO.foreachDiscard instead of ZIO.foreach:

“One of ZIO's common operators is ZIO.foreach, which allows you to run an effect for each item in a collection. There's also ZIO.foreachDiscard that is faster if you don't need to collect results (e.g., if your effect returns Unit).”

For more details, see that article.

ZIO performance tip about foreach, foreachDiscard, foreachPar

Here’s a quick Scala example that shows how to convert multiple spaces in a string to a single space:

scala> val before = "  foo  bar   baz bonk "
before: String = "  foo  bar   baz bonk "

scala> val after = before.trim.replaceAll(" +", " ")
after: String = foo bar baz bonk

As a “note to self” as much as anything, I just updated the following Scala videos and/or video pages:

I had a small issue with these pages, and I think that issue is now corrected.

The best way to keep a prisoner from escaping is to make sure he never knows he’s in prison.

~ Dostoyevsky

Leave your front door and back door open. Let your thoughts come and go. Just don’t serve them tea.

Zen is not some kind of excitement, but concentration on our usual everyday routine.

If you want to know your own mind, there is only one way: to observe and recognize everything about it. This must be done at all times, during your day-to-day life no less than during the hour of meditation.

Seeing into one’s own nature is the goal of Zen.

Treat everyone you meet as if they are God in drag.

All things that appear in this world are illusion. If you view all appearance as nonappearance, then you will see your true nature.

When one realizes their own true nature, they will be free from birth and death.

Zen is keeping the mind which is before thinking.