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

June, 2016: Last week when I was having my “allergic angina” fake heart attack followed by a real angiogram, I thought it would be interesting to be one of those people who die, and is then brought back to life.

Of course the problem with that is that you have to die first.

That thought makes me think of the 1980 film Resurrection that stars Ellen Burstyn and Sam Shepard, and that’s where this image comes from.

God is love, and vice versa (versa visa?)

Then there was the time I got stranded in Canada. I had “all season” tires on my car, and the road and weather services in Canada said the roads were clear, but their definition of “clear” was not really clear.

So I got stranded in Dease Lake, a town of 303 people, unable to drive farther north or backtrack to the south. Fortunately a man who would die in a few months from lung cancer had just gotten back into town after his latest round of chemo treatment, and had the little garage shown in this photo. After a five day wait to get the tires delivered, he put them on the car on Day 6. He had no way to balance them, so I had a shaky drive to Whitehorse (in the Yukon Territory), and a tire shop there was able to balance them.

The tires cost $1,200, the motel stay cost $600, and I ate gas station food for five days, so that was an expensive learning experience.

Stranded in Canada

I’m sorry, I don’t remember where I originally found this image, but I love this Ram Dass saying about being the witness:

“Everything changes once we identify with being the witness to the story, instead of the actor in it.”

~ Ram Dass

Identify with the witness to the story, not the actor in it

Sitting down and starting meditation is one of the biggest obstacles there is to meditation. I usually start with different techniques, like focusing on breathing in through one nostril, out the other, and then reversing that.

I also have different sayings that I repeat to get me focused on the here and now. Last night this new one came to me:

My favorite part of meditation lately is when it takes on a life of its own. This is characterized by your awareness moving to whatever you’re focusing on.

For instance, if you focus on the Anapana Spot (ānāpāna, or “AP Spot”, as I call it) just beneath your nose, your awareness will eventually move forward to that spot, and you become aware that your head is behind you.

More dramatically, if you focus on something like a candle a few feet in front of you and your awareness jumps forward to it, now your entire body will be well behind you (“you” being “your awareness”).

Once your awareness jumps forward like this, you are well on your way to your meditation taking on a life of its own, meaning that you don’t have to work hard at it anymore, it’s like your awareness wants to be in this state.

(I think Daniel Ingram has a name for this state, but I don’t remember it at the moment. It may be in his writings about a Fire Kasana.)

~ January 8, 2024

Tonight while meditating I sat in my recliner to meditate as usual. I didn’t know it at the time, but for almost three hours I kept meditating and falling asleep. My head would fall forward, then I’d raise it, then it would fall forward and I’d raise it again, and so on. I’m sure it would have been humorous to watch from the outside.

But after a while, once I got past the initial “tired” stage, my awareness didn’t fall asleep, even though the head would occasionally fall down. I kept focusing on the third eye area and vowed to myself that I wouldn’t stop until I could see. I felt like my neck would break before I’d quit.

I have no idea where tonight’s determination came from, other than I had had an irritating day, so maybe that was a little extra fuel for the meditation fire. (I’ve also been dealing with an upper respiratory infection, and thanks to the antibiotics, today was the first day I haven’t felt sick in several weeks.)

These two paragraphs are some notes from Daniel Ingram in his excellent (and free) book, Mastering the Core Teachings of the Buddha (with some very minor edits from me):

“For those who are practicing meditation (as opposed to experiencing an occurrence in daily life), in the early part of this stage, the meditator’s mind accelerates more and more, and reality begins to be perceived as particles or fine vibrations of mind and matter, each arising and vanishing utterly at tremendous speed. The traditional texts call this stage the beginning of insight practice, as from this point on there is a much more direct and non-conceptual understanding of the three characteristics...

This stage is marked by dramatically increased perceptual abilities when compared with the previous stages. For example, we might be able to hone our awareness to laser-like precision on the tip of our little finger and seemingly be able to perceive the beginning and ending of every single sensation that made up that finger.”

If that makes any sense and you want to know more about it, the printed book version of his book is here on Amazon, and you can also read the free HTML version of this book at this link.

As a brief note today, here is a short list of spiritual teachers I am aware of who have expressed the idea “I am not the body.” Sri Nisargadatta Maharaj made this the most obvious to me by writing a book titled, “I Am Not The Body,” but when you think about it, many spiritual teachers have said the exact same thing in different ways.

macOS FAQ: From the command line, how do I show the largest files under a directory on macOS (and Linux/Unix systems).

Solution: Use the Unix du (disk usage) command, and sort its output.

A du/sort command to show the largest files under a directory on Mac OS X

The Unix/Linux command that worked for me on my MacOS system is this:

$ du -a * | sort -r -n | head -10

du is the disk usage command, and the -a flag says, “Display an entry for each file in a file hierarchy.” Then I use the sort command to sort the du output numerically and in reverse. After that, head -10 shows only the first ten lines of output. In the Music folder on my Mac the command and output look like this:

Tho’ much is taken, much abides; and tho’
We are not now that strength which in old days
Moved earth and heaven, that which we are, we are;
One equal temper of heroic hearts,
Made weak by time and fate, but strong in will
To strive, to seek, to find, and not to yield.

~ Part of the poem Ulysses, by Lord Alfred Tennyson

(In the process of writing Functional Programming, Simplified, I had to make thirteen trips to the emergency departments of three different hospitals.)

If you’d like to buy a signed copy of the Scala Cookbook, here’s a link to one I have on sale at ebay.

As I note on ebay, I only have seven copies of the Cookbook, and this is Book #4 out of 7.

Buy a Scala Cookbook, signed by Alvin Alexander

As a quick note today, here’s a list of my currently-free books and online video courses about the Scala programming language and functional programming (as of October, 2024):

These books and courses are free thanks to the generosity of Ziverge. If you ever want to pay them back, check out their “on-demand team extension services.”

Free books and online video courses from Alvin Alexander

December 11, 2023: The following quote is from a book I’m currently reading named Demystifying Awakening. I wish everyone had the chance to experience Nirvana at least once in their physical lifetime. I think Earth would be a much better place.

Here’s the quote:

I just had a situation where I wanted to convert this Scala Map:

val userPrefs = Map(
    "theme" -> "dark",
    "lang" -> "en"
)

into a formatted String that looks like a collection of key/value pairs, like this:

"theme=dark;lang=en"

In short, I found this to be a good solution:

Server-side HTTP FAQ: When you're writing a server-side application, are cookies considered to be part of the header information?

Answer

Yes, cookies are part of the HTTP headers. Specifically:

Here’s a photo I took on the drive back from Golden today of some cattle on the right and wrong side of the fence, a big field, and some mountains. (Click the small image to see the full size image.)

Cattle, field, and mountains near Golden, Colorado

December 10, 2021:

I was sitting there meditating in the pitch dark this morning, enjoying a peaceful, easy feeling, when I heard a woman say, “Alvin.” It wasn’t like “Alvin, are you there?”, but more like, “Alvin, pay attention, I’m about to say something to you.”

But for some reason that was as disconcerting as any experience I’ve ever had, and I popped out of the meditative state and opened my eyes.

I only learned about Sri Nisargadatta Maharaj in 2024, but his teaching have made a huge impression on me. To that end, here are some of my favorite quotes related to his famous saying, “I am not the body,” from the book, Consciousness and the Absolute: The Final Talks of Sri Nisargadatta Maharaj:

  • The very idea that you are the body is ridiculous. Consciousness is experiencing its manifestation.
  • Just as I see you, I look at this body, but I am apart from it. I am not identified with the body.
  • (A jnani) watches the play as a witness.
  • ... this consciousness functions through millions of forms.
  • A jnani’s state remains the same with or without the body.
  • Disassociate from the body.
  • There is no otherness; you are everything.

There are many more great quotes in that book, but these are the ones that really strike me today (December, 2024).

I was sleeping on the couch this morning when X (a black and white husky) jumped up on me. I was laying on my right side, facing the back of the couch, so my back was to her. When she jumped up, her front legs were on my left hip, so I assumed she was standing on her back legs.

This woke me up and without moving much, I said, “Do you have to go out? That’s a good girl for letting me know.”

So I moved around and got up, but there was no dog there. X was asleep on her bed in the hallway.

(This was the third time a dog has gotten in bed with me while I was laying down, only to not be there after I moved around.)

~ December 7, 2022

[From time to time I write little stories that have nothing to do with programming or technology; this is one of those stories. So, if you’re only here for the technology stuff, you’ll want to skip this one.]

I’m standing in the kitchen of a friend’s house at a Christmas party, making myself a drink while talking to a friend named Angie. This was nothing unusual; she and I were always talking about something. We became friends during our last year in high school, and we’ve been talking ever since.

In retrospect, it’s obvious that I have feelings for her, but I guess you could say that I didn’t appreciate her back then. After high school, my ambition took me away to college, and then to a series of jobs in different states. By the time I decided to move back home, she was married and had two young children.

While we talked all the time, this kitchen conversation was unusual. I don’t remember how it started, but Angie did ask me about something I rarely talk about: my parents getting divorced in high school.