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

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) a person’s experience with his writings and teachings, and also (b) their own progress on the spiritual path.

Here’s another “fake oil painting” I created with Gimp recently. This one is of Thich Nhat Hanh meditating. I don’t remember the original source of this image (before I converted the original photo to an oil painting), but I’m pretty sure I found it on Facebook. On this one I manipulated the colors quite a bit, and also did a Gaussian Blur on the background.

Thich Nhat Hanh fake oil painting with Gimp

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? (Also, how do I do this in Kotlin or Scala?)

Solution

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

If I have my druthers, I’ll finish writing my current book near this wonderful spot, somewhere in Alaska.

A great place to write a book (somewhere in Alaska)

The following are some favorite quotes from Sri Nisargadatta Maharaj and his book, I Am That.

And on a personal note, to think that I have come to understand/know all of these quotes in this lifetime is a little mind-blowing to me.

Here then are the quotes:

If you’re interested in meditation but “don’t have the time for it,” this quote from Daniel Ingram on intensity in meditation/mindfulness practice was helpful to me:

“It is important to know that really getting into a sense of the breath as a continuous entity for ten seconds will do you more good than being with the breath on and off for an hour.”

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.

All my life I have known someone who has schizophrenia, and in the last 20 years I’ve also known quite a few people who had dementia and/or Alzheimers, so it’s a touching song in multiple ways. YouTube has this terrific live performance of “Mad as a Hatter”.

Here are some of the lyrics from Mad As a Hatter:

If you must then just please wait and let me have some time
(Let me have some time)
Please don’t come for me
Mind over matter (it don’t matter) when you’re as mad as a hatter

The song ends with these repeated lyrics:

Off with her head, off with her head...
Paint the roses, paint the roses...

I assume the ending lyrics relate to Lewis Carroll’s Alice’s Adventures in Wonderland.

If you want to open an Apple News URL in Apple News on a Mac, the trick is to first open the URL in the Mac Safari web browser. From there you can then open the story in Apple News. And FWIW, to me this is a significant user interface and user experience problem when using Apple News with an iPhone and then Mac/MacOS systems.

“I’m going to have to resect the colon.”

~ pretty much every surgeon on M*A*S*H at some point

Thanks to diverticula, diverticulosis, and diverticulitis, in 2018 I had to have a colectomy surgery, which is also known as a colon resection. This page is a diary of my colectomy experience.

Background: Diverticulitis

I had two bouts of diverticulitis in the lower-left portion of my abdomen, once in 2015 and again late in 2017. After the second bout in 2017 the pain never went away completely, and would get significantly worse if I tried to eat normal, high-fiber foods like cereal, wheat bread, broccoli, etc.

After my first-ever bought with diverticulitis, I wanted to make notes about what happened over the last five days.

Monday, April 7, 2015

On April 7, 2015, I woke up at 3:30am with pain and discomfort in my lower-left abdomen. I knew something was wrong, but I didn’t know what it was. It felt like a golf ball was lodged in there, and several hours later it was still there.

As a quick note, if you want to embed a Scala source code example in your Scaladoc comments, just put the source code block in between {{{ and }}} characters in your comments, as shown in this example:

How to format source code blocks in Scaladoc comments

I know that it’s fashionable to say that Scala is dead or something similar to that, but I’ve gotten a few royalty checks from O’Reilly this year for the Scala Cookbook that are amazingly good (💰) for a 3-year old programming book.

Shoot, I’d be happy to receive these royalty payments during the initial months after the book’s release.

As Bjarne Stroustrup said, “There are only two kinds of programming languages: the ones people complain about and the ones nobody uses.”

Java date FAQ: How do I get the current date (i.e., now or today) in Java? (Also asked as, how do I get the current time in Java?)

Solution

With Java 8 and newer — i.e., Java 11, 14, 17, etc. — use any of the follow “now” methods on these Java classes to get the current data and time:

Functional Programming, Simplified — currently 5-star rated on Gumroad.com, 4.5-star rated on Amazon, and one of the all-time best-selling books on functional programming — is currently on sale in three formats (prices shown in USD):

PDF Format
$15 on Gumroad.com

PDF version of Functional Programming, Simplified

Paperback Book
Now $29.99 on Amazon

Print version of Functional Programming, Simplified

Kindle eBook
$14.99 on Amazon

Kindle version of Functional Programming, Simplified

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

Scala dates FAQ: How do I calculate the difference between two dates? That is, while using ScalaScala 2 or Scala 3 — you need to determine the difference between two dates. Also, you want to use the newest Java date/time API for this work, such as the date/time API in Java 8, 11, 14, 17, etc.

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:

In my post on Ram Dass’s best books — and in other places — I use words and phrases 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). 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.”

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.

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