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

As a quick note today, if you ever need some examples of how the Kotlin collections methods work, I hope these examples are helpful.

Sample data

First, here’s some sample data:

val a = listOf(10, 20, 30, 40, 10)
val names = listOf("joel", "ed", "chris", "maurice")

“Why, darling, I don’t live at all when I’m not with you.”

“I didn’t want to kiss you goodbye — that was the trouble — I wanted to kiss you good night — and there’s a lot of difference.”

“Fear is the cheapest room in the house. I would like to see you living in better conditions.”

~ Hafiz (here’s a link to the full poem)

My MacBook recently told me I was running out of disk space. I knew that the way I was backing up my iPhone was resulting in me having multiple copies of photos and videos, so I finally decided to fix that problem by getting rid of all of the duplicate copies of those files.

So I wrote a little Scala program to find all the duplicates and move them to another location, where I could check them before deleting them. The short story is that I started with over 28,000 photos and videos, and the code shown below helped me find nearly 5,000 duplicate photos and videos under my ~/Pictures directory that were taking up over 18GB of storage space. (Put another way, deleting those files saved me 18GB of storage.)

A brief conversation about the symbolism of flowers, from the movie, Midnight in The Garden of Good and Evil:

MANDY: You want to send some flowers?

JOHN: I think so. I don’t know, though. It’s kind of complicated.

MANDY: For whom? What’s she like?

JOHN: I don’t know her that well.

MANDY: Roses are a favorite ... a bit presumptuous. How about poinsettias?

JOHN: Perennials might give the wrong impression.

MANDY: Too long-term?

JOHN: Yeah, it’s hard to say.

MANDY: This is complicated. How about petunias? They’re pretty without being presumptuous, smell nice, and in 3 days you throw them out. Sound like what you’re looking for? (pause) Sorry, we’re all out of petunias.

“The reason we struggle with insecurity is because we compare our behind-the-scenes with everyone else’s highlight reel.”

Three moose running across my neighbors yard, Wasilla, Alaska, November 12, 2010. I still remember being surprised at how much noise they made, it was like a rolling thunder sound and the little apartment I was in was shaking pretty good.

Three moose running across my neighbor’s yard, Wasilla, Alaska

One tin soldier. :)

One Tin Soldier

I don’t look at website stats very often, but with a little free time tonight I was just curious how many people in Alaska visit this website. I was glad to see people have visited it from Utqiagvik, Kotzebue, Nome, Fairbanks, North Pole, Unalaska, Bethel, Kodiak Island, Ketchikan, and many other locations. Alaska holds a special place in my heart, and I hope the pages on this site have been useful to the people there.

Happy to serve people in Alaska

As I continue to work through photos, this is a photo of a painting of a church, which I believe I saw in the lobby of the La Fonda hotel in Santa Fe, New Mexico.

Painting of a church, La Fonda hotel, Santa Fe, NM

A friend bought me some of these USB-powered Christmas lights, and I like using them in the winter months, especially on days when it’s snowing, like today. They’d also be a nice “under $20” gift for one of those White Elephant Christmas gift exchange parties.

USB-powered Christmas lights

I was writing some Scala code like this today:

val sb = new StringBuilder
for (b: Byte <- mdOut.digest) {
    val hexString: String = String.format("%02x", b)
    sb.append(hexString)
}
sb.toString

and encountered this error message:

While reading the excellent book, Programming Collective Intelligence recently, I decided to code up the first algorithm in the book using Scala instead of Python (which the book uses). This is a Euclidean distance algorithm, and it provides one way to compare two sets of data to each other, and attempts to score the similarity between the data sets.

Without any further introduction (and assuming you have the Collective Intelligence book), here's the Scala source code for the Euclidean distance algorithm as described in the book:

I was going through some photos recently and came across this one of The Feed Store Church, which is between Alamosa and Monte Vista, a rural area in southern Colorado. I pass it when I drive back home after visiting Taos, Los Alamos, and Santa Fe, New Mexico. I thought it was some sort of a combination of a feed store and a church, but it turns out that it’s a church.

The Feed Store Church

Sometimes during meditation strange things happen. As just one example, this morning I was enjoying a deep meditation, just focusing on the breath ... focusing on the breath ... and suddenly I was standing on a street corner. I looked around briefly, then thought, “What the heck just happened,” and with that thought I returned to my meditation.

While driving back from Golden, Colorado on November 10, 2016, I happened to be listening to Lady Cab Driver by the artist formerly known as Prince, and wondered if these days he would have called it Lady Uber Driver. I thought it was interesting how society in the current moment has an effect on music and writing.

And here’s a gratuitous photo of some cattle on the right and wrong side of the fence near Golden, a big field, and some mountains.

Drive back from Golden, Colorado (and Lady Cab Driver)

If you like cold weather, this photo was taken at the airport I used to live next to in Talkeetna, Alaska.

Five weeks ago.

Talkeetna airport snow, November, 2015

Thanks to some ongoing abdominal pain from my colectomy surgery back in June, I’ve learned what a Trocar device is. Per Wikipedia (and also my surgeon), “Trocars are placed through the abdomen during laparoscopic surgery. The trocar functions as a portal for the subsequent placement of other instruments, such as graspers, scissors, staplers, etc.”

I have pain in the spot where a trocar device was placed, and the theory is that’s because of a combination of scar tissue and a nerve in that area. A backup possibility is that I may have a hernia in that spot, though the surgeon thinks that’s unlikely. I’ll be having a CT scan soon to see if that shows what’s going on.

Speaking as a guy, a nice thing about the local JC Penney is that nobody seems to want to help you. I went in there to look at suits, and nobody bothered me the whole time, which was nice. I’ll ask for help if I need it.

Conversely, I went to the local Dillards to look at suits, and right away someone was all over me trying to make suggestions. Personally I don’t like that. I don’t mind if someone introduces themselves, but then (IMHO) they should leave you alone. Personally I’m much more likely to buy something if you give me time to compare things and make up my own mind instead of trying to sell me on something. As I wrote in A Survival Guide for New Consultants, a good salesperson is really a buyer’s assistant, and sometimes that means giving the buyer space and time to think.

(I left the Dillards pretty quick when it became apparent they weren’t going to leave me alone.)