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

In a brief personal note, here’s a story about how “Pain is the Doorway.”

Pain is the Doorway

In my post on Ram Dass’s best books — and in other articles on this website — 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, as well as the speeches, books, and other writings of Ram Dass, I have put together the following “Ram Dass glossary of terms.”

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, such as:

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

And also:

Java date/time 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:

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.

Mac OS X launchd FAQ: Can you share some Mac launchd examples (also written as launchd plist examples, or launchctl examples)?

In an earlier tutorial (Mac OS X startup jobs with crontab, launchctl, and launchd) I demonstrated how to use the Mac OS X launchd facility instead of cron to run what would normally be a cron (crontab) job. As I started working with launchd and launchctl, I realized it would probably be helpful to see several different launchd examples, specifically launchd plist file examples.

MacOS screen zooming FAQ: Is there a way I can zoom in and zoom out my Mac screen (iMac, MacBook, MacBook Pro, Mac Mini)?

Yes, you can zoom in and zoom out your Mac/MacOS screen. The solutions are shown in the sections that follow. Note that this solution has been tested on macOS — formerly Mac OS X — systems from OS X 10.6 through macOS 10.14.

Mac desktop zoom in/out commands

If you’re using a Mac desktop system (iMac or Mac Pro) with a keyboard and a mouse with a mousewheel (or any sort of mouse-based scrolling system, like a Magic Mouse), just press and hold the [control] key, then scroll the mousewheel up and down, and you’ll see what I mean. The entire Mac screen zooms in and out, just like the “software zoom” on a digital camera.

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 the same thing 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.

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.”

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