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

When using Unix or Linux, if you ever need to find all files that contain multiple strings/patterns, — such as finding all Scala files that contain 'try', 'catch', and 'finally' — this find/awk command seems to do the trick:

find . -type f -name *scala -exec awk 'BEGIN {RS=""; FS="\n"} /try/ && /catch/ && /finally/ {print FILENAME}' {} \;

As shown in the image, all of the matching filenames are printed out. As Monk says, you’ll thank me later. :)

(I should mention that I got part of the solution from this page.)

Unix/Linux: Find all files that contain multiple strings/patterns

Here’s a photo of the view in Los Alamos, New Mexico.

Los Alamos, New Mexico

“The activity of consciousness, contrary to expectation, conceals the real nature of existence and represents it in a distorted way.”

~ Zen Training

This is a painting of a Native American Indian that I saw in Santa Fe, New Mexico. (Sorry, I don’t know the artists name.)

Native American Indian painting (red stripe over left eye)

I post this image from this tweet in memory of Kendrick Castillo.

When will the violence against our school children stop?

In memory of Kendrick Castillo

Here’s part of the road (I-25) from Colorado to Santa Fe, New Mexico.

The road from Colorado to Santa Fe, New Mexico

One thing I never thought about, but as an author you can end up with a lot of copies of your own books laying around.

Your own books laying around

“Zen is above all a matter of personal experience. The student is asked to accept nothing the truth of which he cannot demonstrate for himself, with his own mind and body.”

~ Zen Training

Old woman, trying to make a man feel guilty: “What would your mother say?”

Man: “She’d say, ‘I’ve been dead for ten years, leave me alone.’”

~ an episode of Midsomer Murders

I had never heard of the term “Yoda Conditions” until now, but I have seen them in some Java code where programmers put the constant first in an effort to avoid null pointer exceptions.

Yoda Conditions in programming

I don’t remember where I saw this code, but I took a photo of it a while back, and it shows a for loop as a Scala method body. I don’t think I’ve ever written anything like that before, so it impressed me enough that I took a picture of it.

A Scala `for` loop as a method body

With Scala it’s common to embed variables in strings like this with the s string interpolator:

val name = "Fred"
println(s"My name is $name.")

That’s cool, but when you need to format your string, Scala gives you an even more powerful tool: the f string interpolator. Here’s an example of how I just did this in my LittleLogger logging library:

My mother is the nicest person in the world, and has dementia. She was also in a coma for ~10 days after falling down a flight of stairs in 2015, which eventually resulted in both of us being patients in the same hospital at the same time.

During a lucid moment last week one of my sisters asked her why she didn’t do something, and mom replied, “I have trouble remembering things.” :)

May the Fourth Be With You.

May the Fourth be with you

I noticed on the drive to the hospital today that there’s still plenty of snow up in the Rocky Mountains.

Still plenty of snow up in the Rocky Mountains - May 3, 2019

Watchin’ the clock
It’s four o’clock
It’s got to stop

Tell him
Take no more
She practices her speech

As he opens the door
She rolls over
Pretends to sleep
As he looks her over

She lies and says
She’s in love with him
Can’t find a better man

She dreams in color
She dreams in red
Can’t find a better man

To herself
There’s no one else
Who needs to know
She tells herself

~ Better Man, by Pearl Jam (a favorite song of the last week)

Back in 2011 I was meditating in the mountains of Hatcher Pass, Alaska — a place where you generally don’t have to worry about bears, unless you’re picking berries down in the valley — and I heard some yelling. Then I got up, came around the side of where I was, and saw the paragliders at this YouTube video.

I never thought of myself as an orphan, but this image makes me think that maybe I was adopted by a squirrel when I lived in Talkeetna, Alaska.

Was I adopted by a squirrel?

“Writing a book is an adventure. To begin with it is a toy and an amusement. Then it becomes a mistress, then it becomes a master, then it becomes a tyrant. The last phase is that just as you are about to be reconciled to your servitude, you kill the monster and fling him to the public.”

~ Winston Churchill

Writing a book is an adventure

“If you’re going through hell, keep going.”

~ Winston Churchill