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

“The dark night of the soul is when you have lost the flavor of life but have not yet gained the fullness of divinity. So it is that we must weather that dark time.”

After moving back to Kentucky, I remember that the reason I moved away from here is that there isn’t anything here I want to do on my days off, in part because it’s so hot and humid, it sucks the joy out of everything. (And heat makes the MCAS worse.) That being said, I also know that some of the angst of that last sentence comes from the whole dark night of the soul thing, which is driving me insane.

(FWIW, in Alaska and Colorado, my favorite off-day activities were bike-riding and going up into the mountains for hikes.)

This image shows the symptoms of mast cell disease, such as mast cell activation syndrome. I’ve had every one of those (except for that gynecological ones). For years I just assumed that everyone went through this, and it got worse as we got older. (Turns out that’s not the case.) The image comes from The Mastocytosis Society website.

Update: I noticed that they missed a few things, including unusual/allergic reactions to medications and insect bites.

Symptoms of mast cell disease (image)

One of the stranger things about mast cell disease is that unless I wrote this here, most people would never know that July 6, 2024 was one of the most difficult days of my life to get through, one of those days where if you pass out for the final time, it would not have surprised me at all. (And then somehow you get through that and the next day you’re fortunate if you feel a little better.)

Two of the more unusual things that can happen during lucid dreams are (a) to see a bunch of friends and relatives gathering at some future party, and knowing that you are dead, and (b) seeing yourself in a dream, as if you were someone else watching you.

I have had both of those happen to me, and both are a little mind-blowing.

One of the more interesting things about the teachings of Sri Nisargadatta Maharaj is that he says we should focus on “I am,” but from what I have read so far, he does not specifically describe what he means by this.

Therefore, I have taken to researching this myself through his own quotes, internet searches, and the use of A.I. tools. This is what I have found so far.

“It would be so fine to see your face at my door.”

This being human is a guest house.
Every morning a new arrival.

A joy, a depression, a meanness,
some momentary awareness comes
as an unexpected visitor.

Welcome and entertain them all!
Even if they're a crowd of sorrows
who violently sweep your house
empty of its furniture,
still treat each guest honorably.
He may be clearing you out
for some new delight.

The dark thought,
the shame,
the malice,
meet them at the door laughing,
and invite them in.

Be grateful for whoever comes,
because each has been sent
as a guide from beyond.

~ The Guest House, by Rumi

the small man
builds cages for everyone
he
knows,
while the sage,
who has to duck his head
when the moon is low,
keeps dropping keys all night long
for
the
beautiful
rowdy
prisoners.

~ an old Persian named Hafez

As a personal “note to self,” here are a few thoughts I’ve had lately, both when I was awake and also while I was asleep (which happens quite often to me in lucid dreams):

FIRST:  While meditating on the sounds of birds chirping outside this morning, I was in a terrific state, and then each time I heard a bird chirp, my body shook or jerked in response to the sound. That was new, but I think it’s a good thing. (Shaking, jerking, or other involuntary movements during meditation are referred to as kriyas or energetic releases, and are believed to be due to energy release, a relaxation response, emotional release, and/or nervous system adjustments. Sometimes I also come out of deep meditation sessions to find my teeth chattering.)

Mac/macOS FAQ: How do I print an image to a specific size in inches or centimeters using macOS?

Solution

When you want to print an image on a macOS system to a specific size in inches or centimeters, you’ll quickly find that the Mac Preview application is not helpful. As you can see in this image, Preview only lets you control the image scale by using a percentage value:

Mac Preview application does not let you print in inches or centimeters

Scala FAQ: Using Scala, how do I generate random numbers without duplicate values, i.e., how do I generate a sequence of random, unique values?

Solution

To show the solution, here’s a Scala 3 function that generates a random sequence of unique integer values:

As a little note today, here’s an example ZIO 2 application where I do the following:

  • Pass a value to the ZIO application (named app) from run using a ZLayer
  • Use that ZLayer value in the application
  • Pass a result value from the application back to the run value
  • Use that value in run
  • Handle any possible errors in run with foldZIO
  • Show other ways to write the run value/function

ZIO/ZLayer example

Given that introduction, here’s the ZIO source code:

On multiple occasions I have had a lucid dream where someone or something is pulling me by my feet, and they proceed to pull my feet up and into the air. On one occasion they had me hanging upside down like that, but on other occasions they have stopped, got stuck, or I have woken up.

The last time this happened was last week — mid-June, 2024 — and I think I now know what is happening. But I don’t want to share that until this happens again and I can confirm what I’m thinking.

(And if you’re interested in lucid dreams, another common one is where light switches don’t work in lucid dreams.)

ZIO FAQ: How do I create a very simple ZLayer in a ZIO 2 application?

Solution

As a wee bit of background, the ZIO Zlayer approach provides several important purposes, including:

  • Dependency injection
  • Modularity and composability
  • Resource management
  • Testability
  • Separation of concerns
  • Type safety

ZIO/ZLayer FAQ: How do I use a Typesafe Config HOCON properties file with ZIO?

Solution

For this ZIO ZLayer solution, you can use the zio-config library for things like this, but at the moment my preferred approach is to hand-code this solution. That’s probably because I’ve written code before to read a HOCON file, so it’s more straightforward atm.

ZIO/ZLayer FAQ: How do I use a Java Properties file with ZIO 2 and Scala?

Solution

You can use the zio-config library for things like this, but at the moment my preferred approach is to hand-code this ZLayer solution. Maybe that’s because I know how to work with a Java Properties file — i.e., how to read and load it — so I like to see those details.

Therefore, given this Java properties file named application.properties:

A friend of mine who was been battling addiction told me that the most important thing for them once they were “triggered” was to get away from the trigger and also ask someone for help.

Additionally, they said that when they couldn’t do those things for one reason or another, they had certain phrases that they would repeat to themself. They even kept cards with them that they’d carry around.

One of the phrases went like this: “You CAN keep doing the same thing today, tomorrow, and every day until you die, or, you CAN choose to make a change right now.”

As a little Scala example, here’s a little Scala “string utilities” object that right- and left-justifies strings to a certain string width. Another way to say that is that the strings are left- and right-padded.

Also, the first function adds an ASCII underline to the string it’s given, so it expects a one-line string as input and returns a two-line string as output.

Here’s the source code for these Scala string utilities:

As a little Scala example, here’s a function that converts a given Double value into a new Double value that has only two decimal places: