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

From John Ousterhout, creator of the Tcl language
A Philosophy
of
Software
Design

While many people know the famous Ram Dass book, Be Here Now — which is currently the #1 All-Time Best-Selling book in Spiritualism on Amazon — I’d argue that it’s not necessarily his best book.

For example, I have met a few people in my travels who were struggling to read and understand it it because of all the art and 1960s “hippie style” stuff — which I personally like — and it was at that time I realized that while Be Here Now is his most famous book, it may not be his best book. (The problem with the “hippie stuff” is that it’s also distracting.)

Ram Dass’s best books

IMHO, I think the following books are his best, where I believe best will also depend on (a) a person’s experience with his writings and teachings, and also (b) their own progress on the spiritual path. And in this case, I think it’s also about book’s that are more straight to the point.

When I first started meditating in the 1990s, I often had a hard time getting into the proper meditative state when I sat down on the meditation cushion. My “monkey mind” would be jumping all over the place, and it would take me a long time to get it to settle down. Many times I couldn’t even get it to settle down before my 30-minute timer went off.

Because of that, and because I really wanted to become better at meditating, I began experimenting with different ways to get into the meditative state faster.

As a result, this page is a summary of the best ways I know to help you get into a good meditation state when you take time to sit on the meditation cushion (or wherever else you sit). If you’re interested in getting into a deep state fast, these are the “best practices” I know, especially when you’re short on time.

As a brief note today, I’ve been reading the Bhagavad Gita (translated by Jack Hawley) lately, and he shares this good line that relates to desire, attachment, and even addiction:

“Realizing the truth of your True Self
is your principal weapon for eradicating desire.”

My short interpretation of that is that our True Self is not our physical body, but something else that you might call awareness, consciousness, the subtle body, the soul, or the Atma — depending on your background — AND, it is possible through yoga, mindfulness, and meditation practice to get in touch with (feel/experience) your True Self. And then, once you realize who “you” really are, your attachments to the physical world will go away.

I used to have a friend who was an addict, and I know she was always looking for anything that would help, so I hope this quote can be helpful for others.

UPDATE 1: As a followup to my original post, in the book, I Am That, Nisargadatta Maharaj basically says the same thing (many times) as the quote I shared above.

UPDATE 2: 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.”

In 2024 I watched the very emotional Elton John “Tiny Dancer” music video, and afterwards I wanted to do some research on how the music video was created, the story behind it, and what its meaning is. To that end, here’s a summary of what I found out about the “Tiny Dancer” music video.

The story and meaning of the Tiny Dancer song

The short story behind the Tiny Dancer song goes like this:

The song, “Empty Garden (Hey Hey Johnny),” by Elton John and Bernie Taupin is one of my favorite “sad” songs, and a great tribute to John Lennon, who was one of my “peaceful” inspirations when I was growing up. In the song, I think there are at least two interpretations of the lyrics, “It's funny how one insect can damage so much grain,” and I’d like to share those here.

“It was the 3rd of September...”

When I think of the song Papa Was A Rolling Stone, I think of the line, “And when he died, all he left us was a loan...”

(I never knew if the lyrics were supposed to be “alone” or “a loan,” but “a loan” is more accurate in the case of my father and family.)

“I would like my life to be a statement of love and compassion.”

Many websites seem to have the wrong lyrics for the Dave Matthews song, Grey Street, so to help correct that problem, here are the correct lyrics for the long version of Grey Street that Dave Matthews played with Tim Reynolds at “Live at Farm Aid 2021”:

Daniel Ingram was the first meditation teacher I ever heard who said that we should make meditation fun. He said something to the effect that when we sit down to meditate, we should try to sense vibrations as fast as possible — like playing a video game — and said, “Let’s bust some vibrations!”

Famous meditation teachers on staying mindful 24x7

As I think about trying to make meditation fun — and the use of mantras — I recall meditation teachers who have talked about the importance of staying mindful all day — 24x7 — to achieve enlightenment. For instance, here are just a few quotes:

As a quick note to self, I wrote this Scala code as a way to (a) find the first element in a sequence, and then (b) return that element without traversing the rest of the sequence.

I initially thought about writing this code with a while loop, for loop, or for expression — because I knew I needed a loop and a way to break out of a loop — but then I realized that an iterator would help me out here.

Also, please note that there is a potentially-better solution after this — the one that uses the “view.”

A first solution

So without any further ado, here’s this solution:

Here’s another A.I. faux painting. This one is based on the Matsuo Basho quote, “Do not seek to follow in the footsteps of the wise. Seek what they sought.”

(I find it hard to get this one right because it’s hard to differentiate what someone is seeking.)

Do not seek to follow in the footsteps of the wise. Seek what they sought.

This is an excerpt from the Scala Cookbook (partially modified for the internet). This is Recipe 20.3, “Scala best practice: Think "Expression-Oriented Programming".”

Problem

You’re used to writing statements in another programming language, and want to learn how to write expressions in Scala, and the benefits of the Expression-Oriented Programming (EOP) philosophy.

[toc hidden:1]

Because functional programming is like algebra, there are no null values or exceptions in FP code. But of course you can still have exceptions when you try to access servers that are down or files that are missing, so what can you do? This lesson demonstrates the techniques of functional error handling in Scala.

NOTE: This is a chapter from my book, Learn Scala 3 The Fast Way. Due to a mistake, this lesson was not included in the book.

When you write functions, things can go wrong. In other languages you might throw exceptions or return null values, but in Scala you don’t do those things. (Technically you can, but other people won’t be happy with your code.)

Instead what we do is work with error-handling data types. To demonstrate this I’ll create a function to convert a String to an Int.

If you like Scala 3 opaque types, check out Kit Langton’s Neotype project as a BIG improvement to opaque types. Neotype gets rid of the opaque types verbose boilerplate code, and offers many more improvements that you’ll like as you use this feature more often.

(Or, for more information about them, see my free “Opaque Types in Scala 3” training video.)

As a little note here today, here’s an example of how to use a Scala Either inside a for-expression when using ZIO 2. In the code you’ll see that I convert each Either into a ZIO in each line of the for-expression.

This is an excerpt from the Scala Cookbook, 2nd Edition. This is Recipe 23.9, Simulating Dynamic Typing with Union Types.

Problem

When using Scala 3, you have a situation where it would be helpful if a value could represent one of several different types, without requiring those types to be part of a class hierarchy. Because the types aren’t part of a class hierarchy, you’re essentially declaring them in a dynamic way, even though Scala is a statically-typed language.

As a “note to self” about using ZIO 2, here are a few ZIO examples that show the ZIO.fail, ZIO.succeed, ZIO.attempt, orElseFail, and orDie methods and functions.

Before looking at the following code, it’s important to know that it uses the following Scala 3 enum:

Regarding Jesus Christ, Maharaji began to cry and said, “He lost himself in the ocean of love.”

~ Maharaji (Neem Karoli Baba).
quoted in Miracle Of Love

I just came across this article where the author suggests that because of Elon Musk’s right-wing political actions, people boycott Tesla, advertisers should boycott Twitter/X, the FTC should sue him, and more.

From John Ousterhout, creator of the Tcl language
A Philosophy
of
Software
Design