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

A Machine Learning Bestseller
Hands-On
Machine Learning
with Scikit-Learn

If you’d ever like to pay it forward — or in this case, backwards — all of my free Scala and functional programming video training courses are sponsored by Ziverge, and if you ever need to supplement your development team, please see their On-Demand Team Extension Service. They have qualified developers that work with Scala, Rust, artificial intelligence, and many other technologies.

Scala FAQ: How can I use the startsWith method on a Scala String to match multiple possible patterns in a match expression?

Solution

As shown in the following example, you can use the startsWith method on a String to match multiple possible patterns in a match expression. startsWith checks to see if a String starts with the prefix (or substring) you specify, so although in these examples I use complete strings, you can also use regular expression patterns.

Example: startsWith + match expression

Scala FAQ: How do I perform pattern matching on a regular expression string in a match expression?

Using Scala 3, I was just trying to perform some pattern matching on a regular expression (regex) string in a match expression, and while working with ChatGPT, I came up with this solution, which you can easily verify in the Scala REPL:

A few days ago I found this black paint that “turns any surface into a chalkboard.” I’ve been painting the backs of some cheap cabinets, whose backs are now exposed after I moved some furniture around. If you know me, you know I like to have surfaces I can write on. :)

Black paint that "turns any surface into a chalkboard"

As the caption says, Margaret Hamilton, Apollo flight software designer, stands next to a tall stack of software code that was printed out, circa 1969. Image from this Twitter page.

Update: There’s more about Margaret Hamilton on this vox.com page.

Margaret Hamilton, Apollo software designer, next to her code

Per the BoulderCast website, these are the largest snowstorms in the history of Boulder, Colorado.

Boulder, Colorado: Largest snowstorms in history

This is a photo of the Shiloh Missionary Baptist Church, in Palmer, Alaska. It used to be on my bike-riding path when I lived in Palmer.

Shiloh Missionary Baptist Church, Palmer, Alaska

This is part of a little log cabin church that used to be on my walking/biking path in Palmer, Alaska.

Little log cabin church in Palmer, Alaska

Dateline, 2015: I really like this quote about “paying attention as if your life depends on it.”

One night last spring I laid in bed, unable to move because of severe pain in my chest. Any time I tried to move the pain got worse, so I laid as still as possible. I was laying on my right side, looking at a bedside table, and all I could do was breathe and look at that table, what was on the table, and see the light coming in from outside and shining on the table.

Pay attention as if your life depends on it

I didn’t get to spend much time with her, but I met Kate Johnson at the 2013 Buddhist Geeks Conference and she seemed like a very nice person. I love this quote: “Activism is the rent I pay for living on the planet,” which originally comes from Alice Walker. There’s a little story about Kate Johnson here on LionsRoar.com.

Activism is the rent I pay for living on this planet

I don’t mean to brag, but if you have the mug ...

Alaska stud muffin (coffee mug)

I saw Ender’s Game at the movie theater and thought it was a good movie, but given its dark nature I never expected to watch it again. But after buying a new television — my previous tv was smaller than my iMac, and so old that it didn’t have any HDMI or USB connections — I saw the movie marked down to $5, and it now has the distinction of being the first movie I watched on the new tv. Kudos to Asa Butterfield (probably 15 years of age at the time the movie was made), he pretty much carries the entire movie, with a little help from Harrison Ford and a few others.

Ender’s Game

This is a favorite “gratitude” quote that I keep in my Just Be “mindfulness reminder” app.

A favorite 'mindfulness reminder' quote

How big is your data? This slide comes from this Twitter page.

How big is your data?

“There is nothing intrinsically problematic about this ordinary perspective. The problem comes when it is the only perspective available to a person, which unfortunately is the usual case.

Enlightenment, or freedom, comes when we also have a complementary perspective that we can access at any time. To have this complementary perspective, we must come into direct contact with the third level of consciousness, the Source.

When we are in direct contact with the Source, self is not perceived as a separate particle, objects are not perceived as solid, and space becomes elastic and can collapse to a dimensionless point, taking everything with it to the Unborn. And time is cyclic — self and scene arise from and return to that unborn Source over and over.

“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

When I first learned about Scala I lived in Talkeetna, Alaska, population ~876 (in the summer). Talkeetna is mostly known as a base for expeditions to Denali, and for possibly inspiring the excellent tv series, Northern Exposure. Some of my first Scala blog posts were written while sitting in this cafe. :)

The image shown comes from this Flying Squirrel Bakery Cafe Facebook page.

The Flying Squirrel Bakery Cafe, and Bernie

Can you grow the size of your brain through meditation? This image comes from a story titled, “Mind of the Meditator,” in the latest issue of Scientific American.

Can you grow more brain?

If you’re looking for the Fringe episode with the song, “I’ve Seen All Good People”, by Yes, it’s the Season 2, Episode 4 episode named, “Momentum Deferred.” It’s just before the 20-minute mark of that episode. It’s the one where Walter starts playing the song, hits the table, and Peter starts putting the wires on Rebecca Kibner (Theresa Russell). “I’ve Seen All Good People” is one of my favorite songs, so it’s great to see it and other Yes songs featured on Fringe.

As a brief note, at the time of this writing, SQLite doesn’t have date/time (datetime) fields, so when you want to use a datetime field with Flutter and Dart, you have to do something else.

Solution: My choice was to store my date/time data as a SQLite INTEGER field. I did this so I can query and sort that field easily myself. The benefit of storing a datetime field as a TEXT field is that you can read it easier, but I think an INTEGER field is a little easier to work with, though YMMV.

A Machine Learning Bestseller
Hands-On
Machine Learning
with Scikit-Learn