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

I woke up a few nights ago dressed in a wedding gown. I didn’t know that at first; all I knew was that some lights outside were waking me up. So I got up, looked out a large glass window, and saw a large city at night outside the window. Then I realized I was dressed as a bride in a wedding, and the room had rose petals scattered all over the bed and floor.

Of course I was asleep and this was some sort of very realistic dream, and with that thought I woke up in bed as usual, gasping for air.

An important life lesson I learned somewhere along the line is that other people don’t think the way I do (and what a boring world it would be if they did).

As one example, when I started my business, I thought everyone else would want to be a co-owner, so I wanted to create it as an ESOP. But then I learned that a lot of good, talented co-workers didn’t want to be a co-owner, they just wanted to do their work and go home. (They had what you might call “a life outside of work.” 😁 )

I’m reminded of this because a friend keeps encountering a problem related to this: because they expect others to think and act the way they do, they inflict a lot of stress onto themself.

I just wrote some Scala code to create an ASCII chart/plot that looks like this:

+-------------------------|-------------------------+
                 ^

In this chart, the left side of the chart represents a low value, the right side represents a high value, so the overall line represents that range, and then the ^ on the second line indicates the current value. This can be used to show the 52-week low and high values for a stock, along with its current range. It could also be used to show someone’s current batting average in a season, compared to their low and high values, and any other value that can be expressed as low, high, and current values.

I initially thought the correct name for this was a Sparkline chart, but it’s really something like a “current value in range” chart. I haven’t been able to find the exact correct name, but that’s close enough for now.

Today I learned that on macOS systems you can send text messages from the command line and shell scripts. You can send text messages to phone numbers and email addresses, and the only restriction I’m aware of is that the contact has to be a known Messages/iMessage contact.

A Mac shell script to send a text message to a phone number

Here’s a shell script to send a text message to a known phone number:

ZIO 2 FAQ: How do I work with the ZIO.attempt function?

Solution

When you’re working with existing (legacy) Scala code that:

  • is synchronous, and
  • can throw an exception

wrap that code with ZIO.attempt. As you’re about to see, this creates a ZIO effect from that legacy code.

Not only does this create a ZIO effect, it also puts the exception in the ZIO “error channel,” i.e., the E parameter in the ZIO[R, E, A] type signature.

As a brief note today, here’s a little ZIO 2 example that shows how to print a series of values with a random delay in between each value that’s printed.

Also note that in the code below there are different ways to implement randomWaitTimeInSeconds ... for instance, it could return a Duration, but I just have it return an Int.

I also use ZIO.foreach to generate the values in a range, and that could be handled differently.

Another thing I do is use an exception inside ZIO.fail, and I do that because I want that error to be a Throwable on the ZIO “error channel” (i.e., the E parameter in ZIO[R, E, A].)

I don’t remember where the video was, but I saw a video with Shinzen Young where he mentioned that as we meditate, things come up from our subconscious, and even when we get old, we’ll eventually be able to remember things from when we were like ten years old. My specific note from the video is that “there is stuff propelling us from when we were ten years old.”

Scala FAQ: When you write a Scala for expression or for loop, when do you use an = symbol and when do you use the <- symbol in the for block area?

As a brief note today, here’s an example of making an HTTP GET request using ZIO 2 and the Scala sttp library. I also let the user specify a “timeout” value, so the request will timeout, rather than hanging.

As a very important note, this is a blocking approach, not a non-blocking approach.

ZIO 2 HTTP GET request with a timeout example

Here’s the source code and Scala 3 + ZIO 2 + sttp function:

Ram Dass FAQ: What is the best Ram Dass book about the Maharaji, aka, Neem Karoli Baba?

The best Ram Dass book about Maharaj-ji (Neem Karoli Baba)

I believe the best Ram Dass book about Maharaj-ji (Neem Karoli Baba) is the 1979 Ram Dass book Miracle of Love. It’s over 400 pages in length, with story after story about the “miracles” Maharaj-ji performed. Some of the stories are told by Ram Dass, but most of them are told by other people. Almost all of the stories are less than one page in length, so it’s easy to read a few stories every night, if you like.

If you’re interested in what the Maharaji was described as being able to do, along with his quotes about Maya/illusion/delusion, service, loving everyone, etc., this is a great book.

A second great book ...

Another great Ram Dass book about Neem Karoli Baba is Polishing The Mirror.

A great thing about this book is that I think it’s the best summary of all his work. It’s a relatively short book, and summarizes much of what you’ll read in his other books. I really like to underline and highlight words, and I found that I could highlight most of this book. :)

As you can see from the tabs I attached my book, the book covers love, karma, the ego, Bhakti yoga, service, Maya/illusion, The Witness, Hanuman, and much more:

I started reading the book Walking Each Other Home by Ram Dass and Mirabai Bush a few nights ago, and if you like Ram Dass, you’ll like this book. This is an image from early in the book about a “pretty fierce journey.”

Ram Dass - Pretty fierce journey

I was just looking around for a Ram Dass quote about Maya and couldn’t find anything great, but then I found this YouTube video where he talks about Maya and illusion:

“There’s a philosophy in India where the outside world — the world of things — all is illusion. And that’s a way to deal with the sense world ... to get free of it, and go inward, and go into the Atman, the God within.”

In this Entering the Stream article, Ram Dass also states the following:

“Beings who have understood how it all is, who have realized their identity with the ātman, are stream enterers; they have tasted the flow of the nectar of liberation. They are a breed apart from other people in the world. They know something others do not know. Every part of their life is colored by that merging.

A free being no longer identifies with the body or personality, with a personal past or future. The body, the packaging, still has its karma running off and the skandhas, the mental aggregates, continue, but with nobody in them.”

(For more on Ram Dass, see my article on The Best Books of Ram Dass (My Recommendations).)

I keep thinking about this lately, so I thought I’d post a list of my favorite tv series that lasted only one season. In no particular order they are:

As a business analyst — or any person interested in writing software requirements and quality — there is one thing you should always ask yourself whenever you write a business requirement:

Is this software requirement testable?

I’ve seen some business analysts write some crazy things and call them requirements, but IMHO, if you can’t test it, it’s not a requirement.

“He who lives to see two or three generations is like a man who sits some time in the conjurer’s booth at a fair, and witnesses the performance twice or thrice in succession. The tricks were meant to be seen only once, and when they are no longer a novelty and cease to deceive, their effect is gone.”

~ A quote from Arthur Schopenhauer,
read by Steve Jobs,
as found in the book, How Google Works

Welcome! This page contains direct links to all of the videos in my 100% Free Scala and Functional Programming (FP) Video Training Courses. When I say “100% Free”, I mean that there are no ads and no paywalls — all of the videos below are completely free to watch.

June 9, 2024: I’m pleased to announce the release of my new, free video course:

This video course picks up where my free “Introduction to Functional Programming” video course left off, and gives you all the background you need to get even further into ZIO 2 functional programming!

Functional Programming in Depth -- free video course

NOV., 2022: My new book, Learn Functional Programming The Fast Way, is currently an Amazon Java and functional programming #1 new release. The book is now available in three formats:

PDF Format
FREE on Gumroad.com

Learn Functional Programming The Fast Way! (PDF Version)

Paperback
$30 on Amazon

Learn Functional Programming The Fast Way (Paperback)

Kindle
$10 on Amazon

Learn Functional Programming The Fast Way! (Kindle Edition)

In terms of heat and humidity, Kentucky has all the benefits of living at the ocean. :)

A little meditation:

In all the history of the world,
And all its future,
The only thing that matters,
The only thing that’s real,
Is now.