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

When using ScalaTest, Scala, and SBT, and you want to print output in a ScalaTest unit test that you can see, such as printing to STDOUT with println, I just found out that I can do it using its info function, like this:

If you’re interested in meditation and enlightenment/awakening, the book, I Am That, by Nisargadatta Maharaj, has this terrific conversation, which I have shortened slightly:

M: The Guru is concerned little with the person. His attention is on the inner watcher. It is the task of the watcher to understand and thereby eliminate the person.

Q: But the person does not want to be eliminated.

M: The person is merely the result of a misunderstanding. In reality, there is no such thing.

(later)

Q: When will this happen for me?

M: When you remove the obstacles.

Q: Which obstacles?

M: Desire for the false and fear of the true. You, the person, imagine that the Guru is interested in you as a person. Not at all. (He then clarifies what this means.)

I know that the idea of a “dream vacation” for most people is time at the beach or a beautiful place like Alaska, but once you get to a certain point in meditation, there’s nothing a person would rather do than meditate. So the dream vacation for a meditator is a peaceful, quiet place — both quiet surroundings, and not having to talk to anyone else — where they can meditate, practice yoga, make simple non-meat meals, and go for quiet walks.

Because I have lived in some sketchy places, and other places where people are constantly cutting the grass and running farm machinery, I’ll add that the location should be secure, and again quiet (or at least a place where you know that loud grass-cutting and outdoor activities happen at a certain time). At some point you need to learn to meditate with those issues, but on vacation, no thanks.

As a brief ZIO 2 example, the end of this Scala/ZIO source code shows how to print information to the console in a ZIO application, both in the success case (STDOUT) and also in the failure case (STDERR):

My 100% FREE “Introduction to Functional Programming” online video training course is now finished! To make things a little easier, here are links to all of the free videos in the training course:

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

Welcome! This page contains direct links to all of the videos in my 100% Free Scala and 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.

My first three courses are listed here, and when I add more free video courses I’ll update this page.

As always I want to thank Ziverge for making this possible! This videos take a long time to create, and I wouldn’t have the time to create these without Ziverge being a sponsor. If you ever want to thank the people at Ziverge, be sure to give them a call when your programming team needs assistance on programming projects. They work with Scala, Rust, A.I., Python, and much more.

April, 2024: As a brief note today, the PDF version of my book, Learn Functional Programming The Fast Way!, is now FREE. I wrote this functional programming book for Scala, Java, and Kotlin developers, and you can now download it for free here:

If you’re interested in functional programming, or just want to learn more about data types, generics, pure functions, expression-oriented programming, and functional error handling, I hope this book is helpful.

Free functional programming book (for Scala, Java, Kotlin, etc.)

As a brief example here today, the following Scala/ZIO source code shows one way to read a file using ZIO 2 and then print its output to the console:

Here are two good quotes from this article, Why companies are leaving the Cloud:

“Another significant driver was the failure to meet internal expectations, at 24%.‘Unmet expectations’ describes most technology trends I’ve been involved with, including client/server, enterprise application integration, service-oriented architecture. and now cloud.

Those surveyed also cited unexpected costs, performance issues, compatibility problems, and service downtime. The most common motivator for repatriation I’ve been seeing is cost. In the survey, more than 43% of IT leaders found that moving applications and data from on-premises to the cloud was more expensive than expected.”

As a brief note today, I have 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, 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.

A few years ago I had a lucid dream that had a beautiful song in it. Unfortunately I didn’t wake myself up right away, and by the time I did wake up, I couldn’t remember all the lyrics. But my favorite lyrics, which set the tone for the song, are:

What do you think about
When you think about me?

So over time I’ve been coming up with other lyrics as I think of them, like this:

Tonight at the table,
Looking out at the sky,
My thoughts were so far away,
I wish I could tell you why.

And then maybe:

IntelliJ IDEA MacOS FAQ: What are the keystrokes to switch to the previous editor tab and next editor tab when using IntelliJ IDEA on a Mac/MacOS system?

Solution

To move to the next editor tab and previous editor tab when using IntelliJ IDEA on macOS, these keystrokes work for me:

  • [Command][Shift][LeftBracket] moves to the previous editor tab
  • [Command][Shift][RightBracket] moves to the next editor tab

Also note that when I write:

  • [LeftBracket] I mean the [ character
  • [LeftBracket] I mean the ] character

Java double FAQ: How do I format Java double and float output to two decimal places, such as when I want to format its output for printing or to display in a user interface?

Solution: Java double formatting

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

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.

Ram Dass’s best books

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

In my post on Ram Dass’s best books and other places, I use terms related to the work of Ram Dass, including terms on yoga, Hinduism, Maharaj-ji, Buddhism, meditation, mindfulness, mantras, and the different names of the man he called Maharaj-ji (aka, Maharaji, Neem Karoli Baba, Neeb Karori Baba).

Sources of the terms and definitions

To help understand that article, and the speeches, books, and other writings of Ram Dass, I have put together the following “Ram Dass glossary of terms.” Note that the definitions below come from internet research and the following books:

Sanskrit terms

In The Bhagavad Gita, by Eknath Easwaran, he states in his glossary that these are Sanskrit terms. Wikipedia describes Sanskrit as, “a classical language belonging to the Indo-Aryan branch of the Indo-European languages.”

Glossary

Here’s the glossary of terms:

Scala dates FAQ: How do I calculate the difference between two dates? That is, while using Scala — Scala 2 or 3 — you need to determine the difference between two dates.

Solution: Calculating the difference between two dates (in Scala and Java)

If you need to determine the number of days between two dates in Scala (or Java or Kotlin), the DAYS enum constant of the java.time.temporal.ChronoUnit class provides the easiest solution:

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 fast as possible.

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.

One note

I start off with several tips that I have labeled “All Day.” The intent of those tips is that you can use them all day to keep your mind in a great state all day. If you follow these tips, you’ll be in a great state even before you start with your formal meditation session.

After those initial tips, I get into other techniques that you can use just as you sit down on your cushion (or however else you meditate).

Yesterday 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: