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

Git FAQ: How do I compare two different versions of a file with git?

This solution depends on what exactly you need to do.

1) You have not run `git add`

If you just modified a file but haven’t run git add on it yet, use this:

$ git diff introduction.md

2) You have run `git add`

To see changes to a file you have run git add on, but have not committed, use this:

$ git diff --cached introduction.md

A git file diff example

In my case, I updated this introduction.md file, and then added it with git add, so I used that second command:

> git diff --cached introduction.md 
diff --git a/_overviews/overview/introduction.md b/_overviews/overview/introduction.md
index eecc4e86..2773a705 100644
--- a/_overviews/overview/introduction.md
+++ b/_overviews/overview/introduction.md
@@ -1,6 +1,9 @@
 ---
 title: Introduction
 description: This page begins the overview documentation of the Scala 3 language.
+num: 1
+previous-page: 
+next-page: scala-features
 ---

The + changes in the last three lines showed the changes I made, so this gave me confirmation that I did what I wanted.

Comparing two file versions in your Git repository

If you’re using Git and need to compare two recent versions of the same file, I can confirm that this git diff command works:

git diff HEAD^ HEAD nodeBlog.scala.html

That command compares the second-most recent version of the file (given by HEAD^) to the most recent version of the file (HEAD). In this example I want to see the detailed differences of these versions of the file named nodeBlog.scala.html. In my case, the result of this command is shown in the image.

Per the excellent book Pro Git, “HEAD^” means, “The parent of HEAD.”

As shown on this SO page, there are other ways to issue this Git command, and similar commands.

Git: How to compare two different versions of a file

“That was a lot of kidney stones.”

~ the surgeon, October, 2020

This is a field of prairie dogs in the foreground and mountain ranges in the background, near my new home in Longmont, Colorado.

Prairie dogs and mountain ranges, Longmont, Colorado

As a brief note today, here are a couple of comparisons of Java’s Optional and Scala’s Option.

First, here’s a Scala makeInt method written with Option in Scala 3:

def makeInt(s: String): Option[Int] = 
    try
        Some(s.toInt)
    catch
        case e: NumberFormatException => None

and here’s the same method written with Optional in Java:

Last night we had all sorts of beautiful whispy clouds, throughout the Louisville/Lafayette/Erie Colorado area. For those who can see my Facebook stuff, you can see several more photos at this link.

Whispy clouds, Louisville, Colorado

A crazy thing about mast cell disease is that you can be doing perfectly fine, all systems normal, and then you eat something wrong and two hours later you wish you were dead, or at least not conscious.

Every day I take a little blue pill.

Two of them, actually.

And they’re extremely helpful.

Later this week I’ll be giving birth to septuplets. Kidney stones, that is. Seven of them.

They’re going to be surgically removed, and whatever chemicals are in these little blue pills they gave me helps to reduce the spasms caused by the stones being stuck in places where they shouldn’t be.

Rafael Nadal, October 9, 2020: “It’s important to go through all the process. You have to suffer. You can’t pretend to be in a final of Roland Garros without suffering. That’s what happened there. But I found a way, no?”

This is part of the mountain view from the Foothills hospital in Boulder, Colorado.

The mountain view from the Boulder, CO Foothills hospital

Very soon I’ll be under anesthesia for the 19th time in my life. Hopefully when you get to 20 you get a prize. :)

I was listening to a book by Lisa Scottoline named Killer Smile, and a woman in her seventies told a woman in her late 20s or early 30s to be brave.

“I don’t know if I can be brave,” the younger woman replied.

“Don’t worry about that,” the older woman said. “If you can’t be brave, just be determined. And you’ll end up in the same place.”

That struck me as smart. I’ve often thought that I don’t know what brave is, but we all know what it is to be determined.

Ninety-nine dreams I have had
In every one a red balloon
It’s all over and I’m standing pretty
In this dust that was a city
If I could find a souvenir
Just to prove the world was here
And here is a red balloon
I think of you, and let it go

~ from the song, 99 Red Balloons

“Humans without romance become curmudgeons and predictable with misery.”

~ Carlos Santana

In his book, The Universal Tone: Bringing My Story to Light, Carlos Santana writes about hearing other guitar players, and wondering with an intense curiosity how those other people got their guitars to make the sounds they made. As I thought about this I thought it was a good attitude to have in programming. For instance, if I look at an application where someone has done something really cool I try to understand, “How did they do that?”

Listened to a Buddhist teaching on impermanence while watching a brand new crack in my windshield grow to 20" today. Now in Fort Collins, Colorado.

~ a Facebook post from September 29, 2011

Apparently my lasting memory of moving out of my apartment in Broomfield, Colorado in September, 2020, is going to be getting stung by a bee when I walked into the local Walmart for the last time. Both a guy pushing carts and I saw something fly directly into my chest, but neither of us could figure out what it was. About thirty seconds later the bee stung me at this point in my arm.

Getting stung by a bee can be kind of a big deal to someone with mast cell disease (MCAS), so I walked over to the pharmacy and got a bottle of liquid Benadryl and some Zyrtec, and swallowed the pills with the Benadryl. A helpful pharmacist also had an EpiPen on standby for me if I needed it.

I don’t know how “normal” people react to bee stings, but this photo was taken almost five days after the sting.

Five days after a bee sting

While I’m sharing photos of Siberian Huskies I’ve known and loved, here’s one of Rocky working on a bone. My wife originally found him stuck in a cinder block in Virginia when he was 12-18” long, and he became the first husky we’d know. He became famous for destroying furniture, howling, and running around saying words like “Oprah” and “Geraldo.”

Rocky and a bone

This short video on Twitter shows the depth of the “front range” of the Rocky Mountains here around Denver and Boulder, Colorado. When you look at them from the ground you can’t get that depth perspective, so this is really a great view.

Depth of the Rocky Mountains front range

Remember when we was on ice skates,
And I thought you was supposed to be great,
So I kept giving you lip,
And you kept trying to slip,
So I could catch you.

That was our first date,
And after that,
Every day was great.

So now I want you to know,
That wherever you go,
Atlantic City or in the snow,
Don’t worry about a thing,
’cause as long as I got this ring,
I’ll always be there to catch you.

~ Rocky’s poem to Adrian in Rocky II

September 18, 2020: Apparently my lasting memory of the Walmart near Apartment #1 is going to be getting stung by a bee.