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

“I slept and dreamt that life was joy. I awoke and saw that life was service. I acted and behold, service was joy.”

~ Rabindranath Tagore

My favorite garbage dumpster in Seward, Alaska: “Look for peace, look for love, look for good things, look for moose.”

A garbage dumpster in Seward, Alaska

AppleScript FAQ: Can you share some iTunes/Music AppleScript examples (example scripts)?

As I've been working a lot with macOS speech recognition software lately, AppleScript has once again become important in my life. I've been writing a lot of small AppleScript scripts — including AppleScript iTunes scripts — and I thought I'd share snippets of code from those iTunes scripts here for anyone else they might benefit.

2021 Update: Wherever it says “iTunes” below, substitute the word “Music”, as Apple has renamed the iTunes application to Music.


It was driving me crazy that the quality of the songs I was streaming from a website known as Bandcamp sounded better than the quality of the songs I was playing from my iTunes (now Music) collection. In my case, I recently bought a Marian Call CD named “Something Fierce”, and had imported the songs from that CD into iTunes. But the songs I streamed from Bandcamp sounded better than the songs I imported from the CD; how could this be?

I dug into the problem and found two simple fixes, both in iTunes. In this article I'll show you how to make those fixes to dramatically increase your iTunes sound/music quality.

I recently took an online “assessment” test with a company named SHL. In general it was good and interesting, but after thinking about it, one thing it really lacked was a concept of “context.”

For instance, one question was something like, “Are you comfortable talking to strangers?” Well, that depends on the context of the situation. In the context of being at a grocery store I generally have my earbuds in and leave strangers alone until I talk to the cashier, but in the context of work, I pretty much talk to everyone. Two different contexts, two totally different answers.

So as I’m answering the questions I keep asking myself, “What’s the context?” Unfortunately I didn’t share this at the end of the SHL test when they give you a little room to comment, so I thought I’d share that here in hopes someone there might see this.

As I wrote in Different meditation/mindfulness practices, different cultures, and they all talk about witnessing/noting, mindfulness and meditation masters (teachers) from different cultures, countries, and styles of practice often teach the same thing in different ways: a style of mindfulness meditation known as witnessing or noting.

To me, a simple way to think about this is that as your body goes along with its daily life, all you have to do is simply narrate what your body is doing at all times, in the present moment.

If you like, you can think of yourself as being the witness/soul, watching the body, and noting what it’s doing, like a birdwatcher does when they note what birds are doing in a forest. It’s that simple.

(This is a recounting of a long dream from October 1, 2016.)

We were playing at our camp when my older brother — who was standing on higher ground than I — saw something in the distance. He stood upright, then perfectly still. After a few moments he turned to me in a look of panic I had never seen before, pointed in a direction opposite from where he was looking, and screamed, “Run! Run!” I was startled at his behavior but I knew that something was very wrong, so I ran. And I ran.

I ran as fast as I could, weaving through the brush and constantly changing my course as I was chased by a white man on a dark horse. I thought I might be close to safety when I darted through some bushes, but I ran right into a creek that was too wide to jump across. As I paused for a moment to decide how to continue, the white man shot me in the back.

In intense pain and sudden shock, I stumbled forward into the creek, bent over with one hand in the creek. As I attempted to stand up and regain my balance, I was shot in the back again. This time my body flew forward towards the opposite side of the creek. I tried to control my fall but could not, and my torso slammed against the land. The right side of my face was pressed against the ground, my eyes still open. My right arm was trapped under my body, my left arm was somewhere down my left side. My legs lay in the creek’s water.

If you’re interested in logging in a ZIO application, the following example shows a collection of different ways you can write log messages. I also show how to create your own custom log format, so the output logging from this application looks like this:

I’m starting to publish my next free video course, called ZIO HTTP + Caliban. You can find it at that website, and it’s free, thanks to the people at Ziverge.

Free video training course: ZIO HTTP + Caliban

Here’s a comprehensive guide to implementing retry logic in ZIO 2 applications, using various scheduling strategies.

Please note that I haven’t double-checked that all of these examples compile as-is, but I do demonstrate many of these in my free Scala and ZIO 2 training videos. (I also added a complete working example at the end.)

“Enlightenment always comes after the road of thinking is blocked.”

Lindsey: Don’t tell me you’re seeing inside them again. (long pause) What are people like, on the inside?

Jeremy: Inside most people there’s a feeling of being separate, separated from everything.

Lindsey: And?

Jeremy: And they’re not. They’re part of absolutely everyone, and everything.

Lindsey: Everything? I’m part of this tree? Part of my dog barking over fences? You’re telling me that I’m part of some fisherman in Italy, on some ocean I’ve never even heard of? There’s some guy, sitting on death row, I’m part of him, too?

Jeremy: You don’t believe me.

Lindsey: It’s hard to believe that. All of that.

Jeremy: That’s because you have this spot that you can’t see past. (Putting his finger on her forehead.) My grams and gramps had it, a spot where they were taught they were disconnected from everything.

Lindsey: So that’s what they’d see if they could? That they’re connected?

Jeremy: And how beautiful they really are. And that there’s no need to hide, or lie. And that it’s possible to talk to someone without any lies, with no sarcasms, no deceptions, no exaggerations or any of the things that people use to confuse the truth.

~ a conversation from the movie Powder (#ad)

“He’s more myself than I am. Whatever our souls are made of, his and mine are the same.”

“Goddamnit!”

Every so often a woman in a lucid dream this morning yelled out like that, so after the fourth or fifth time I had to ask her about it. “Why do you keep saying that?,” I asked.

“Gets your attention, doesn’t it?”

“Yeah, I guess so.”

“There you have it.”

“There I have what?”

“Your ego is writing checks your body can’t cash.”

~ from the movie, Top Gun

As a brief note today, here’s some skeleton code for a ZIO (ZIO 2) application that needs to run forever. It (a) does what it needs to do, then (b) sleeps for a minute, and then (c) goes back to Step A, doing whatever it needs to do, forever.

I wanted to share this code because I think it’s probably a very common pattern and need in the ZIO world — writing an application that needs to run forever, on a schedule.

Also note that the code is written using Scala 3, but the syntax can be changed to use Scala 2, if you need to. I also added a layer/ZLayer to the code to make it a little more “real world.”

All that being said, here’s the ZIO “run forever” code:

If you’re ever interested in meditation, I promise that if you work hard enough, you can achieve this kind of intensity, where you feel like Eleven in Stranger Things. I’m fortunate that it happens to me from time to time now.

As Ramana Maharshi said, “Proper meditation is so intense it doesn’t even allow thinking, ‘I am meditating.’”

Meditate like Eleven giving her all

This page contains a list of my favorite mindfulness quotes. Most of these are short, concise quotes that help bring me back to the present moment, and work well with my “Just Be” mobile app.

Update: I have replaced my Just Be application — which was written for Android only — with a new application I call Back To Now, which runs on both Android and iOS.

Background: Just Be

Just Be was a mobile mindfulness app that I created for Android users. This is what the reminders/notifications look like when you receive them on an Android phone or tablet:

Just Be, a mindfulness reminders app

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.