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

As a brief “note to self,” this is the Bourne shell script I use to copy images from my Drupal 8 sites directory to the same directory on my new “Static Drupal” website:

tarFile=newImagesFromDrupalSitesDir.tar
drupalHtmlDir=/drupal8/html
staticHtmlDir=/staticDrupal/html

cd $drupalHtmlDir
rm $tarFile 2> /dev/null

# create a tar file containing all new images
find sites -type f \( -name "*.jpg" -o -name "*.jpeg"  -o -name "*.png" -o -name "*.gif"  \) -mtime -2 -print0 | xargs -0 tar rvf $tarFile

# TODO make sure the tar file exists
if [ -e $tarFile ]
then
    echo "tar file exists, moving it to $staticHtmlDir"
    mv $tarFile $staticHtmlDir
    cd $staticHtmlDir
    tar xvf $tarFile
    rm $tarFile
else
    echo "POSSIBLE ERROR: the tar file DOES NOT exist"
fi

I changed the three initial variable names, but the rest of the script shows one possible way to copy all of the images in the original sites directory into the new Static Drupal directory. If you wanted to see things such as how to use multiple filenames with the Linux find command, or how to use the find command to create a tar file, I hope this example is helpful.

All those places on Amazon Prime Video where there should be an image, but there isn’t, reminds me of WeakHashMap.

Amazon Prime Video reminds me of WeakHashMap

After switching from Drupal 8 to my Static Drupal app — which generates static HTML pages from a Drupal 8 database — the CPU use on this website has dropped from an average of 22% CPU use down to 9.2%. The max CPU use has also dropped from a whopping 59% down to 22.5%.

My Static Drupal app: CPU usage drops by more than 50%

The CliffsNotes of my favorite meditation instruction for beginners is:

Sit as usual, and then approximately every 4 seconds say either “hear” or “calm,” depending on whether you hear thoughts in your mind, or not. Just keep doing this for as long as you meditate, whether that’s one minute, two minutes, five minutes, etc.

IMHO, it’s a terrific technique for people who are just getting started with meditation. I still use it a few times a year if I can’t calm down or something like that.

That comes from Core 1, Lesson 8 of the Brightmind app.

As one note and example of how to avoid using var fields in Scala, I initially wrote this code:

var numDaysToProcess = 0

if (args.length != 0) {
    numDaysToProcess = args(0).toInt
}

After I looked at that code for a moment I realized that I could write it without a var like this instead:

val numDaysToProcess =
    if (args.length == 0) {
        0
    } else {
        args(0).toInt
    }

That’s a simple example of one situation where you can easily avoid using a var field in Scala. I’ll share more examples as they come up.

“The world is won by those who let it go.”

Lao Tzu: The world is won by those who let it go

After ten years of this site running on Drupal, it is now delivering static web pages to you. More news after I get some sleep. :)

While looking for something else I just ran across this image that shows an example of outlined text created in Gimp. I had forgotten all about it, but I created it when I wrote my How to create outlined text using Gimp tutorial.

Outlined text in Gimp

This image makes me think of the angst of many American voters in this election. They’re angry at “politics as usual,” so they think, “I’m angry, let’s just blow it up.” But it also makes me think of the young people, and the future.

The angst of American voters

We don’t usually get a lot of snow in the Boulder/Louisville/Broomfield area, but up in the mountains near Vail and Aspen, Colorado, they usually get plenty. This was taken at a rest area near Vail.

~ March 21, 2013, on the drive back from Las Vegas

Snow in the mountains near Vail, Colorado

The postal code in Stewart, British Columbia, is “VOT 1WO,” which the locals tell me stands for Very Old Town, One Way Out.

Very Old Town, One Way Out

On the afternoon of March 11, 2020, the number of COVID-19 cases in Colorado increased to 33, from 11 cases two days earlier. A week later, on March 18th, Colorado now has 216 cases.

Also, we were at 160 cases two days ago, so we increased by 56 cases in the last two days.

One of my favorite tips to get on a roll at work is to save some easy tasks for the next day. I could have finished the last three tasks on this list in a couple of minutes last night, but I’d rather spend ten minutes on them this morning to warm up my brain with something easy.

Programming tip: Start with something easy in the morning

These days whenever my face itches when I’m out in public and I can no longer scratch it, it reminds me of the early days of trying to meditate at a Zen center. You’re sitting there with a group of people and it’s absolutely quiet, and you’re trying to meditate, with your legs crossed and your hands in the “cosmic mudra” in your lap, and then something somewhere on your body starts to itch. But you’re not allowed to scratch it, you’re not even supposed to move.

If the itch is on your face you might kinda look around a little bit to see if anyone is looking at you — especially the Zen master with the wooden board. If nobody is looking, you can try to contort your facial muscles in different ways to relieve the itch. One time I tried to curl my lips in a weird way to blow some air up onto my itchy cheek, but in a large, quiet room with a wooden floor, that was surprisingly loud.

So in general, you’re pretty hosed, you just have to sit there and suffer, hoping it will go away, just like when you get an itch on your face when you’re shopping now.

As the Coronavirus gets worse across the United States, remember that Mitch McConnell thought it was more important to have a long, relaxing weekend to attend a party rather than help the Coronavirus fight.

Mitch McConnell chose a party over fighting the Coronavirus

“Are you familiar with Sun Tzu?”

Are you familiar with Sun-Tzu

“We do not see things as they are, we see things as we are.”

We don’t see things like a computer sensor sees them. We see everything through our own rose-colored glasses.

We do not see things as they are

A side effect of the coronavirus seems to be that the local pharmacy can’t get medication in stock. “Sorry we don’t have that prescription that you ordered four days ago and need to stay alive, but hopefully it will be in tomorrow.”

(If you need a prescription refilled, order it as early as you can.)

After it was pointed out to me several times this past week that I live in a nice area, I was reminded of searching for donuts a few weeks ago. I found a Dunkin’ Donuts about twenty minutes from here that is on a direct path to Denver. Nothing about the area was nice, and the store itself looked old and dirty, and one of the front doors is closed with a chair in front of it and a sign telling you not to use that door.

I mention that because despite of how unattractive the area was, I still saw people with their laptops sitting in some booths there. It reminded me of myself about 15-25 years ago. I occasionally worked in some areas that weren’t pleasant, and I’d take my laptop and/or paperwork and sit in places like that and do my work.

Hopefully one of the morals of this story is that if you work hard, you can get out of situations like that and eventually move to nicer areas. I’m sure there are other morals to be had, but that’s what I have in mind by sharing this story.

In a couple of weeks the architecture behind this blog will change significantly. I just started working on the new approach today, and this is what the “front page” of this website currently looks like in my development environment. It needs a little work, lol.

New alvinalexander.com front page (coming soon)