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

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

Java 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

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

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

“As a general principle, any positive state that you experience within the context of silent sitting practice (when you reach the state of samadhi), you must try to attain in the midst of ordinary life.”

~ Shinzen Young’s teacher

“Have you got any cookies?”

~ Frank Burns, in M*A*S*H

Frank Burns, Mash: Have you got any cookies?

Dear diary,

Annihilation of the ego continues to make progress, at least during sleeping hours. In recent nights I’ve gained awareness during the dream state to find “myself” as animals, women, and other men.

Last night I gained awareness as an older black man, talking to other black men about some of the discrimination and injustices we’ve gone through in our lives. We can laugh a little amongst ourselves about them now, but I could feel that under the laughter there’s also a deep sadness and pain.

Lately each nightly occurrence ends the same way: Eventually there’s a realization that “I” am supposed to be “Al,” and that realization startles me, pulls me from the scene, and wakes me.

Yours truly,
The Hopefully-Disappearing Self

P.S. — I don’t know if it’s more correct to say “black man,” “African-American,” or something else. To be clear, if it wasn’t important to the story I would not mention it at all.

In my experience, some “judgy” people will make up their own opinion about you — about what you should do or shouldn’t do — when they don’t know all the facts. I use the word judgy, because if you’re a Christian, Jesus was very clear on this point:

Judge not, that ye not be judged.

To wit, sometimes you just have to let people be wrong about you. (From this tweet by TinyBuddha.)

Sometimes you just have to let people be wrong about you

Some day I might write a book called, Random Conversations with Strangers While Aimlessly Wandering Around, and it will include stories like this:

Many years ago I walked into a favorite bakery in Alaska. Nobody was there, no customers or employees, so I took a few minutes to look over the cookies and donuts to decide what I wanted.

Finally a young woman came out of the back room. I knew from previous donut/cookie runs that she was born in Ohio, moved here about five years ago, was nineteen years old, and would be twenty in a few months. As she brought out a tray of something new, she said, “Oh, I’m sorry, I didn’t hear you come in.”

I replied it was no problem, it gave me a chance to think about what I wanted. We chatted for another minute or two and then she looked around and said, “Can I be honest with you?”

Ram Dass FAQ: What is the best Ram Dass book to start with?

My answer: The best Ram Dass book to start with is ...

I wrote this in my earlier blog post, What Are The Best Books By Ram Dass, but I believe the best book you can start with is Polishing The Mirror.

I think this book is the best summary of all his work. It’s a relatively short book, it’s clearly written, and summarizes much of what you’ll read in his other books. I started reading this when I was in the hospital, and as bad as I was feeling at the time, it just blew me away. I like to underline and highlight text, and I felt like I could highlight most of the book.

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

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

A funny moment from the tv series Life: “Did he ever have a head injury?”

Life tv show: Did he ever have a head injury?

Every spring I think about moving back to Alaska. This is a photo of the cabin I lived in in Talkeetna, Alaska back in the day.

The cabin in Talkeetna, Alaska

If you’ve never seen the movie Starbuck, it’s very good, and often very funny. This is one scene where a pregnant women is trying to come to grip with various feelings she is dealing with.

The park scene in the movie Starbuck

I just saw this drawing on the Learn You a Haskell website, and I wish I had done something visual like it for the Scala Cookbook. It does a nice job of showing the head, tail, init, and last functions (methods).

Scala sequences: head, tail, init, last (visual, image)

Scala/Java/Kotlin String FAQ: How do I replace left and right brackets — the [ and ] characters — in a String when using methods like replaceFirst and replaceAll?

Solution

If you’re using Scala, Java, Kotlin, or other JVM languages, and need to replace left or right brackets in a String, I found the following solution, which seems to work well with String methods like replaceFirst and replaceAll.

My meditation tip of the day: If you really, really, really can’t take time out to meditate, the best thing you can do is pay ruthless attention to the present moment during your daily activities. And the best way to do that is through mantras or noting practices.

“You can meditate while talking to someone, while washing the dishes, while driving. As your experience grows, you eventually come to a point where you are so present that there is a kind of merging of inside and outside. When that happens, ‘focus’ becomes more than an extremely interesting and pleasant experience; it becomes a transformative experience.”

“Eventually a delicious figure-ground reversal takes place. In the beginning, meditation is something that happens within your day. Eventually, the day becomes something that happens within your meditation.”

~ From “The Science of Enlightenment: How Meditation Works

As a quick note, if you have a problem using Alfred snippets on Mac/macOS, where (a) your snippets are being displayed to you properly, but (b) aren’t pasting properly, see this url on alfredapp.com for the solution.

After trying to manually remove and then re-add permissions — as suggested on the Alfred forum — I found this page and the tccutil command. Following their instructions, I first shut down Alfred and then ran this command at the command line:

> tccutil reset All com.runningwithcrayons.Alfred
Successfully reset All approval status for com.runningwithcrayons.Alfred

I then restarted Alfred, and all of the “snippets” functionality began working again, including showing my snippets when I press my shortcut key combination, and then expanding and pasting in my snippets.