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

Every once in a while when your brain runs into a new concept, you really remember it: it stands out in your mind as an “Aha” moment. One of those moments for me was when I saw a particular “Model/View/Controller” (MVC) diagram, and the light bulb went on. This diagram made the MVC pattern very simple, and I’ve never forgotten it.

The Model / View / Controller diagram

The MVC diagram I’m talking about comes in two parts. The first MVC diagram shows the symbols the authors use for Model, View, and Controller objects. Here’s that diagram:

Model View Controller - symbols for MVC objects

Note: I originally wrote this article in the summer of 2010. I survived on this diet for a long time, but eventually gave up my gallbladder to a surgeon.

My gallstones diet advice: Ugh, my health has destroyed my productivity lately. Due to a mysterious stomach ailment, I’ve had a lot of “stomach” pain, visited the ER several times, met a lot of doctors, had many tests, and lost thirty pounds in less than seven weeks.

Scala FAQ: How do I sort a sequential collection in Scala? (Or, how do I implement the Ordered trait in a custom class so I can use the sorted method (or operators like <, <=, >, and >=) to compare instances of my class?

Git user FAQ: How do I show or change my Git username or email address?

How to show your Git username

There are at least three ways to show your Git username:

  1. The git config command
  2. The git config --list command
  3. Looking in your Git configuration file

The following sections describe each solution.

MySQL "show status" FAQ: Can you demonstrate how to use the MySQL show status command to show MySQL variables and status information, such as the number of open MySQL connections?

I don't have a whole lot of time today to give this a detailed discussion, but here is a quick look at some MySQL work that I did recently to show MySQL open database connections.

[toc hidden:1]

In a personal note, I found out the hard way that the Sage Hotel in Santa Fe, New Mexico had bed bugs when I stayed there in late 2023. The photos below show the bed bugs that I discovered on the bed at 1:15 a.m. one morning, along with the resulting invoice/receipt from the Sage Hotel (formerly named Sage Inn Hotel).

2024 Update #1: I wrote the Sage Hotel in 2024 about my experience, and how disappointed I was — both with the hotel having bed bugs and with their service — and never received any sort of reply.

2024 Update #2: I talked to a person when I later stayed at another hotel, and they said (a) their hotel never had bed bugs, and (b) if they ever did, they would give customers a full refund. (The Sage Hotel would not give me a full refund.)

Sage Hotel bed bug images

This first photo is from the bed bug I killed. I woke up, saw something moving in the bed, pressed it with my finger, it popped, and left this blood stain:

If you’re looking for a great Christmas/holiday gift for your favorite geek or programmer, I’ve reduced the price of my book, Learn Functional Programming The Fast Way! to just $20 for the holidays. It’s usually price at $29 or higher.

For a while there, the book was Amazon’s best-selling book in both their Java and functional programming categories, so although I’m biased, I think it’s a pretty good book.

The book is intentionally written for Java, Kotlin, and object-oriented programming (OOP) developers, and I also made the book much less expensive than other FP books to make Scala 3 and functional programming as accessible as possible to everyone. As a result, I hope it makes for a terrific 2023 Christmas/holiday gift for the Java/Kotlin/OOP computer programmer in your life!

Great 2023 holiday geek/programmer gift book

If you’re interested in baseball — especially pitching — this is a terrific discussion between “Pitching Ninja” Rob Friedman and Hall of Fame pitcher Greg Maddux.

In a personal note, back in the day I had an opportunity that would have allowed me to pitch with Greg’s brother Mike Maddux, but my shoulder wouldn’t hold up.

To my surprise, I saw that this favorite old Zen book was sponsored by the late Prince Philip.

Similarly, many people have thanked me for creating my free Scala and Functional Programming training videos, but the thanks go to Ziverge. These videos will take months to create, and I could not do this without them.

Zen, the arts, patronage, Scala, and Functional Programming

As a brief note, here are my favorite songs of late:

Dateline May 30, 2023: Today I just released a new version of my book, Functional Programming, Simplified. This is Version 0.08, and it adds “App 4”, where we get into traits, inheritance, generics, variance, bounds, modules, Nothing, and more.

May 30, 2023: New release of Functional Programming, Simplified

The realized yogi continues to function and act in the world, but in a way that is free. She is free from the desires of motivation and free from the desires of the rewards of action.

The yogi is utterly disinterested but paradoxically full of the engagement of compassion. She is in the world but not of it. The yogi is beyond cause and effect, action and reaction.

Later we shall see the role that Time plays in this — how there is freedom because the Illusion of Time no longer exists to bind us to the past and future.

~ from Light on Life, by B.K.S. Iyengar

“The most beautiful people we have known are those who have known defeat, known suffering, known struggle, known loss, and have found their way out of the depths. These persons have an appreciation, a sensitivity, and an understanding of life that fills them with compassion, gentleness, and a deep loving concern. Beautiful people do not just happen.”

~  Elisabeth Kubler-Ross

This is a recipe from the Scala Cookbook (2nd Edition). This recipe is titled, Working with Parameterized Traits in Scala.

Problem

As you become more advanced in working with Scala types, you want to write a trait whose methods can be applied to generic types, or limited to other specific types.

Solution

Depending on your needs you can use type parameters or type members with traits. This example shows what a generic trait type parameter looks like:

If only ... I had a little bit more time
If only ... I had a little bit more time with you

I fell down, down, down
Into this dark and lonely hole
There was no one there to care about me anymore
And I needed a way to climb and grab a hold of the edge
You were sitting there holding a rope

...

And maybe someday I’ll see you again
We’ll float up in the clouds and we’ll never see the end

~ from Clouds (Up Up Up) by Zach Sobiech

A poem from the tv series Monk:

“Hold me, Adrian,
my darling husband.

True love’s touch is so rare a gift.
How much more precious is your caress
who loves so deeply,
yet fears the warmth,
of hand on hand.

Still your love is given free,
only to me,
only to me.”

~ Trudy Monk

Possibly my favorite part of the movie Spanglish is when Cloris Leachman’s character says, “I love you. I love everyone. That’s what’s killing me.”

From a Zen/Buddhist perspective, that’s the emotion of a Bodhisattva (an enlightened being who chooses to stay here out of compassion, to save all beings). You love everyone, and there are consequences of that.

I started watching Dawson’s Creek recently because I was curious what Joshua Jackson was like before Fringe, and I have to say — I know their conversations are intentionally verbose — but even in the short talks between Dawson and his parents, my relationship with my parents was nothing like that. We never talked about things because my mom was very sick and my dad was very domineering and abusive. So I watch this show and wonder, is that what parental relationships are really like in a healthy household?

I think I managed to alienate all of my “Facebook friends” by writing about things like Zen, meditation, mindfulness, yoga, and all the experiences that come from studying and practicing these things. And I also understand that alienation, because there are many “spiritual” things I’m not interested in from certain other spiritual/religious perspectives. (I’m more open than that sounds, but I have a hard time when people don’t practice what they preach, or cherry-pick a few things Jesus taught while ignoring the teachings they don‘t like.)

That being said, the things that Shinzen Young — a modern day meditation master in the U.S. — speaks about here and in this two-minute video echo everything I’ve discovered on my own and wrote about. So while, yes, I feel bad about oversharing about this sort of thing with people who don’t have similar interests on my now-defunct Facebook account, well, at least I was right. :)