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

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.

[toc]

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 his best book. I had a young friend in Colorado who was struggling with 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.

IMHO, I think the following books are his best, where I believe best will depend on a person’s experience with his writings and teachings, and also their own progress on the spiritual path.

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.

Java FAQ: How do I format Java double and float output to two decimal places, such as when I want to format its output?

Solution

There are at least two ways to round a double or float value to two decimal places in Java:

[toc]

I just took a little time to update some old notes from my meditation practice about “The purpose of mindfulness.” Or, stated another way, instead of asking about the purposes of being mindful you might ask, “Why bother being mindful?”, or “What is the motivation for practicing mindfulness and meditation?”

The purposes of mindfulness

In the following sections I outline the reasons/motivations for practicing both mindfulness and meditation.

I don’t know how many people know Ram Dass or have read his writings, but I updated the first motivation here based on his work, because if you really get into mindfulness and meditation, what he states is the end goal.

After reading pretty much every book by Ram Dass, and other books related to the man he called Maharaj-ji (aka, Maharaji, Neem Karoli Baba, Neeb Karori Baba), I decided to put together the following “glossary of terms” related to Ram Dass’s work and writings. This includes work related to Ram Dass, yoga, Hinduism, Maharaj-ji, Buddhism, meditation, mindfulness, mantras, and more.

Glossary

Here’s the glossary of terms:

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

Solution

Yes, 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.

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, Nothing 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:

March 27, 2024: I just received my first payment from Ezoic ads, so that’s cool.

March 16, 2024: As a brief note today, I recently started using Ezoic for the ads on this website, and so far my revenue is much greater than it was with Google AdSense. My ad revenue has increased 100%, maybe more.

Switching from AdSense to Ezoic

For a long time I was afraid to switch to another company besides AdSense because I had not heard of Ezoic and others, but after several weeks on their platform, all is well.

I should also say that I was very busy, and I thought that “making the switch” might take a while, but if you have existing AdSense and Analytics accounts, it doesn’t seem to take too long. The actual time I spent on a computer to make the changes was probably about 4-8 hours overall, but in calendar time it took a few days because of the AdSense and Analytics integration (waiting), and a few other configuration things I had to wait for. (So, several days in calendar time, but 4-8 hours in actual time.)

It’s also important to note that Ezoic is an AdSense partner, which I discuss more below.

A few days ago I found this black paint that “turns any surface into a chalkboard.” I’ve been painting the backs of some cheap cabinets, whose backs are now exposed after I moved some furniture around. If you know me, you know I like to have surfaces I can write on. :)

Black paint that "turns any surface into a chalkboard"

As the caption says, Margaret Hamilton, Apollo flight software designer, stands next to a tall stack of software code that was printed out, circa 1969. Image from this Twitter page.

Update: There’s more about Margaret Hamilton on this vox.com page.

Margaret Hamilton, Apollo software designer, next to her code

Per the BoulderCast website, these are the largest snowstorms in the history of Boulder, Colorado.

Boulder, Colorado: Largest snowstorms in history

[toc]

Scala math FAQ: How do I square a number in Scala, such as squaring an Int, Double, Long, or Float?

Solution

You can square a number in Scala in at least two different ways:

  1. Multiply the number by itself
  2. Call the Java Math.pow function or the scala.math.pow function

This is a photo of the Shiloh Missionary Baptist Church, in Palmer, Alaska. It used to be on my bike-riding path when I lived in Palmer.

Shiloh Missionary Baptist Church, Palmer, Alaska

This is part of a little log cabin church that used to be on my walking/biking path in Palmer, Alaska.

Little log cabin church in Palmer, Alaska