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

The most interesting story for me yesterday was that a mile-wide meteor hit Greenland, possibly as recent as 12,000 years ago, and created an impact crater 19.3 miles wide. The impact would have released 47,000 times the amount of energy that was released by the Little Boy nuclear bomb that was dropped on Hiroshima in 1945. The impact crater was hidden by a half-mile thick sheet of ice until recently. (The image shown comes from the article I linked to.)

A mile-wide meteor hit Greenland and was hidden by an ice sheet

I just saw that the first person to take a chance on me out of college — and a person who would become a mentor to me — passed away last November. Frank Jordan, thank you for everything you did for me. You are missed, and I’m sorry we didn’t stay in touch.

“Since I had started to break down all my writing and get rid of all facility and try to make instead of describe, writing had been wonderful to do.”

I’ve been working on a Kotlin book on and off for the past few months, and this morning I pulled a Steve Jobs on myself and canceled the project, even though it’s about 75% complete (by chapter count).

The problem with the book is that at this point it doesn’t contain anything unique, although arguably my way of explaining things might be better than other approaches. Unlike the Scala Cookbook, which provides solutions to common Scala problems, and Functional Programming, Simplified, which provides a unique approach to explaining functional programming in Scala, I don’t feel like there’s anything new here.

So, in short, without getting into the details of what’s next, the “vision guy” part of me decided that there are better things to do with my time. (And if you’ve ever been on a project that was canceled and you thought it was hard to take, imagine canceling your own project.)

“You’ve got to start with the customer experience and work backwards to the technology.”

~ Steve Jobs, as heard in this 1997 video

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.”

“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

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

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. Based on its name 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

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.)

From this LionsRoar.com article on how to have lucid dreams: “Studies have shown that meditators have more lucid dreams, and for a true meditation master, all their dreams are lucid. We’re non-lucid to the contents of our mind at night to the extent we’re non-lucid to the contents of our mind during the day. Become lucid to your thoughts during the day by practicing mindfulness meditation and you’ll naturally become lucid to your dreams at night.”