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

(Note: This is one of over 1,000 lucid dreams that I have had and made notes about. For some reason I have had lucid dreams (and sleep paralysis) quite often, so at some point I started making notes about the dreams.)

I fell asleep very slowly last night, so I was able to stay awake through the whole falling-asleep process, i.e., the usual sleep paralysis part. As I was still awake I started to hear the usual “here/there sucking sounds,” and just told myself that I shouldn’t be afraid, I’ve done this hundreds of times before.

And then the instant I fell asleep here I found myself in a hospital there. A doctor and nurse were looking at a bandage on the lower-right part of my abdomen, above the appendix, and closer to the center of the stomach.

As I looked at “myself,” I noted that the skin color was lighter than mine, and that my arms were smaller and skinnier, and there wasn’t much hair on the abdomen or arms. After the inspection the doctor asked if I had any questions, and I said, “Yes. Who am I? And where am I?”

As a brief note today, this is a very little ZIO HTTP Server application. I’m sharing it here because it’s currently a fairly simple example, and also because I show how to include the necessary ZIO dependencies using Scala-CLI:

Back in the day I was living in Palmer, Alaska, and I just started to look into renting this small brown building to be a home for my software-consulting business during the day and yoga classes during the night, when some family issues came up and I moved back to the Lower-48.

There probably wasn’t enough work in the Palmer/Wasilla area — also known as the Mat-Su Valley — but I loved the area so much I wanted to give it a try.

Little office building in Palmer, Alaska

A big part of meditating for me has been getting to a point of completely dropping the self-conscious B.S., as I call it. (Which is why I may never be a meditation teacher, lol.) You just have to get to a point where there is no you.

The Arctic Circle sign off the Dalton Highway in Alaska. If I remember right, this is less than an hour's drive from Fairbanks.

Arctic Circle sign, Dalton Highway, Alaska

I’ve probably documented over 1,000 lucid dreams in the last 20 years or so, and here’s another one from this morning. To me, the most important part about this one is the hypnopompic hallucination stuff I note at the end.

Had a long dream — approximately 2:30-4am — about “my wife” doing drugs without me knowing it.

I starts with us driving in a seedy part of town. She had mentioned that she knew someone who could get us some drugs if I/we wanted to try them. We ended up getting something that looked like a small rock or stone.

I’m not sure how many people can understand this, but once you’ve been through nine syncope events (unconsciousness), dozens of other pre-syncope events, and four cardiac events (“fake heart attacks”, also known as allergic angina), and a five-month heart infection (pericarditis), you just accept that death is going to happen, and it’s not in your control. So, personally, I just try to be grateful, and hopefully help others along the way, because I know that my time here is limited.

If I have died, please call ...

I’ve been slowly working on a series of new Scala programming books, and today I’m proud to announce the first of these:

Learn Scala 3 The Fast Way! (book cover)

Starting today you can buy the PDF version of Learn Scala 3 The Fast Way! for just ten dollars — $10 (USD) — at this Gumroad.com URL.

MARCH, 2023: This book was previously named Learn Functional Programming Without Fear, but I have renamed it to Learn Functional Programming The Fast Way. I think this name is more reflective of the ZIO and Cats Effect libraries being easier to learn than ever before (without having to know category theory), and the name is also consistent with my other book, Learn Scala 3 The Fast Way.

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

PDF Format
$10 (USD) 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)

Here’s a photo of a snow white tree in Louisville, Colorado, one day in March, 2018. I was headed to a doctor’s appointment in Louisville, so this was probably somewhere between 7-8:30am. The full size image (not shown here) may be the prettiest photo I’ve ever taken in Colorado.

A snow white tree, Louisville, Colorado

This is a photo of some snowy trees in Louisville, Colorado, on March 27, 2018. I had to get up early to go to a physical therapy appointment and I was rewarded with this view.

Snowy trees, Louisville, Colorado

One of my favorite songs of late is named Mad As A Hatter, by Larkin Poe. The song is about their grandfather, who has schizophrenia, and their grandmother, who has dementia.

If you’d ever like to pay it forward — or in this case, backwards — all of my free Scala and functional programming video training courses are sponsored by Ziverge, and if you ever need to supplement your development team, please see their On-Demand Team Extension Service. They have qualified developers that work with Scala, Rust, artificial intelligence, and many other technologies.

March 24, 2024: I just released my free “Advanced Scala 3” online video training course. This free video course gets into different Scala programming topics such as functions, types, generics with variance and bounds, multiversal equality, modular programming, extension methods, and much more.

As always I want to thank Ziverge’s software consulting services for sponsoring these videos! These video courses take many weeks and even months to create, and they would not exist without Ziverge.

<<Click here to start my free Advanced Scala 3 video training course.>>

Advanced Scala 3 video training course

March 24, 2024: Here’s a summary of my current free online Scala and functional programming training courses:

If you’re interested in 100% Free online Scala and FP video training courses, I hope these online video courses are helpful.

Scala FAQ: How can I use the startsWith method on a Scala String to match multiple possible patterns in a match expression?

Solution

As shown in the following example, you can use the startsWith method on a String to match multiple possible patterns in a match expression. startsWith checks to see if a String starts with the prefix (or substring) you specify, so although in these examples I use complete strings, you can also use regular expression patterns.

Example: startsWith + match expression

Scala FAQ: How do I perform pattern matching on a regular expression string in a match expression?

Using Scala 3, I was just trying to perform some pattern matching on a regular expression (regex) string in a match expression, and while working with ChatGPT, I came up with this solution, which you can easily verify in the Scala REPL:

Datline March 22, 2014: A little personal enlightenment:

After going unconscious several times during the last few weeks, I've had conversations with doctors, nurses, friends, and even a shaman about life, death, quality of life, goals, and desires.

I had a hard time answering some of their questions, and yesterday I realized why that was:

If you're truly living in the present moment, those questions don’t make any sense! You can't think about life, death, the past, or the future if you’re fully absorbed in the present moment.

When planning for the future, live fully in that moment of planning for the future. When eating, just eat; and when writing text like this, just write. That’s all.

(In computer parlance, become single-threaded, where that one thread is only focused on HereNow.)

Since I’ve written two functional programming (FP) books, I thought it might help to provide a comparison of them.

The short story is that both FP books have “limited technical jargon,” and as shown, The Little FP Book essentially has one purpose, which is to help Java/Kotlin/OOP developers learn functional programming as fast as possible, using a technique that I “discovered” over the last few years. Conversely, The Big FP Book covers many topics in great detail.

If you’re interested in more details, here are links to the two books:

Functional programming books, comparison

Scala FAQ: What is the Nothing type in Scala, and how do I use it?

Solution

In Scala, the Nothing type is called a bottom type, which means it is a sub-type of every other type in the Scala type system. It is also specifically a data type that has no instances.

In practical use, Nothing is used to indicate that a computation or function will never produce a result normally, either because it throws an exception, enters an infinite loop, or encounters some other abnormal termination.

Visually, this is what the Nothing type looks like in the Scala type hierarchy (image courtesy of this scala-lang.org page):

The Scala type hierarchy and the Nothing data type

Scala: Common uses of Nothing

Some common use cases of Nothing in Scala include: