Alvin Alexander | Java, Scala, Unix, Perl, Mac OS X

[This is a chapter from a currently-unpublished book I’m writing on meditation and mindfulness.]

As a spiritual being, one possible way to think of life here on Earth is as a “game” that serves as a training ground for the soul. It’s a game like other games, so it has many levels, and they get harder and harder as you progress. So in this case, the better you become at the game of spirituality — the Soul Game — the harder the levels become.

To help set some rules for the game, let’s say that it has fifty levels. The first time you play the game you’re born here on Earth in Level 1. Hopefully you score some points and move up, so maybe by the time it’s “game over” for your first lifetime, you’ve passed Level 9 and you’re playing on Level 10. Maybe you get a brief break in between lifetimes, but the next time you’re born you start right where you left off, at Level 10.

This brings me to a very important rule: Once you start playing the Soul Game, you’re strapped in for eternity. (That was clearly mentioned on page 52 of the End User License Agreement.) Once you’re in the game there are only two ways out:

A cool thing about the Unix/Linux grep command is that you can show lines before and after a pattern match with the -B and -A options. As an example, I just used this combination of find and grep to search for all Scala files under the current directory that contain the string null. This command prints five lines before and after each null line in each file:

$ find . -type f -name "*.scala" -exec grep -B5 -A5 null {} \;

That’s good stuff, but it prints a really long list of lines, and I can’t tell the output of one file from another. To fix this, I put the following code in a file named helper.sh, and made it executable:

As seen in Santa Fe, New Mexico, in 2017.

My Indian name is 'Runs With Beer'

I woke up at 4:30am on Friday with the idea for a story that I’ve currently titled, The Soul Game, which I hope to release next week. Lucid dreams being what they are, I came up with the first draft while I was sleeping, and then put it down on paper after I woke up. Working on that story leads me to write the following today:

Sometimes in life you meet another person, and as you get to know them you find that they’re incredibly awesome, but ... they’re also married. This has happened a couple of times in my life, to differing degrees. I always find that I don’t want to do anything to interfere with that person’s marriage, but part of me wants to say, “In case you didn’t know it, I think you’re pretty awesome, one of a kind.”

As a practical matter saying things like that tends to create problems, so I haven’t said it to anyone in a long time. (The last time I said it to anyone we ended up making out in a parking lot.) Instead, I hope that other people know that I think they’re awesome because I choose to spend my time with them. In this way the sad part is that things go unsaid, but I hope the other person knows what I think because I laugh and enjoy myself when I’m with them, and we have great conversations.

All of which today makes me think of the Gloria Estefan song, Words Get In The Way, and the Olivia Newton-John song, I Honestly Love You.

The Human Route, by Zen Master Seung Sahn, on a card from the people at DharmaCrafts.com.

The Human Route

“I just want something beautiful, Mo.”

“We all want something beautiful, Willie.”

[Dateline: The evening of May 5, 2007, On The Border restaurant, Louisville, Kentucky, after several pitchers of margaritas and beer, and three days before I would leave for Alaska.]

Brother-in-Law: Seriously man, I want to thank you.

Me: For what?

Brother-in-Law: You inspired me to start my business.

Me: That’s great, how did I do that? (Now I’m all geared up to hear a motivational story of how I inspired him.)

Brother-in-Law: I figured if you can start a business, anyone can.

In one of the stranger things to happen in dreamland, I’ve had several dreams with my brother-in-law in them in the last few weeks. He passed away last summer, and each time he appears, he’s a translucent white color, and as I observe him, he keeps helping people within the dreams. Last night a man passed away in a bed, and then my brother-in-law appeared and picked the man up and carried him away.

Though I have lucid dreams all the time, these are particularly unusual because I haven’t had a translucent person in a dream since I was less than eight years old. Back then we lived in Chicago and right after I’d go to bed, a translucent man would come out of the closet and try to play with my toys, in particular a large model Boeing 727 aircraft. (Which is probably more than you want to know about my dreams, lol.)

This land today, shall draw its last breath
And take into its ancient depths
This frail reminder of its giant, dreaming self
While I, with human-hindered eyes
Unequal to the sweeping curve of life
Stand on this single print of time.

This land, today, my tears shall taste
And take into its dark embrace
This love, who in my beating heart endures
Assured, by every sun that burns
The dust to which this flesh shall return
It is the ancient, dreaming dust of God.

When working from home, my preferred writing environment is to use a huge fixed-width font on a large monitor with a matte finish, and nothing else on the screen. I write my text using either Markdown or LaTeX, depending on what the output format is going to be. And Yoda and Meditating Guy make me feel a little less crazy when I’m talking to myself. ;)

My preferred writing environment

And in the category of “Strangest Things I Never Knew About Java,” I give you ... CAFEBABE.

CAFEBABE and Java class files

If you want to create a shell script so you can change between MacOS dark mode and light mode from the Terminal (Unix) command line, put this source code in a file and name it something like dark:

osascript -e \
'tell application "System Events" to tell appearance preferences to set dark mode to not dark mode'

Then make that file executable, and make sure it’s on your PATH. Now you can type dark to toggle back and forth between dark mode and the regular light mode:

Table of Contents1 - Example2 - A more complex example3 - Note4 - Summary

If you’re ever working on a really small Scala project — something that contains only a few source code files — and don’t want to use SBT to create a JAR file, you can do it yourself manually. Let’s look at a quick example. Note that the commands below work on Mac and Linux systems, and should work on Windows with minor changes.

If you run into a problem where a Scala shell script won’t run on MacOS — it hangs indefinitely without doing anything — hopefully this bug report will help. The solution is to change this line at the beginning of the Scala shell script:

exec scala -savecompiled "$0" "$@"

to this:

exec scala -nocompdaemon -savecompiled "$0" "$@"

I just had this problem with Scala 2.12.x and Java 8 running on MacOS 10.14.4, and I can confirm that adding -nocompdaemon solved the problem for me.

Table of Contents1 - def field in trait2 - val field in trait (abstract)3 - val field in trait (concrete)4 - var field in trait (abstract)5 - var field in trait (concrete)6 - An abstract class in the middle7 - A trait in the middle8 - Summary

I generally have a pretty good feel for how Scala traits work, and how they can be used for different needs. As one example, a few years ago I learned that it’s best to define abstract fields in traits using def. But there are still a few things I wonder about.

Today I had a few free moments and I decided to look at what happens under the covers when you use def, val, and var fields in traits, and then mix-in or extend those traits with classes. So I created some examples, compiled them with scalac -Xprint:all, and then decompiled them with JAD to see what everything looks like under the covers.

I was initially going to write a summary here, but if you want to know how things work under the hood, I think it helps to work through the examples, so for today I’ll leave that as an exercise for the reader.

Sometimes people write to tell me that they like my writing style, that I’m good at explaining things. Other people write and say that if they wrote a book, they would have written it just like mine.

The truth is, when I first started working with Scala I fell in love with the language, so wanting to write about it was easy. After that, I’m not that smart, so I have to break complex things down so I can understand them myself. So I think that by breaking things down and looking for meaningful examples, people seem to appreciate what I’ve written (or I hope they do).

After I wrote the Scala Cookbook and people sent me notes like that, I struggled with writing for a little while. Then I decided to just try to write for a younger version of myself and ignore what other people were saying. I just ask myself, “Would this have helped Al 2+ years ago?” Since then I’ve been fine.

Don’t objectify me

“What is it about elevators?”

~ Christian Grey