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

JMH is an SBT plugin for running OpenJDK JMH benchmarks. Per its docs, “JMH is a Java harness for building, running, and analysing nano/micro/milli/macro benchmarks written in Java and other languages targeting the JVM.”

They also recommend reading an article titled Nanotrusting the Nanotime if you’re interested in writing your own benchmark tests.

I just saw that this is a way you can easily determine the blocksize of a filesystem, at least a Mac/Unix/Linux filesystem:

$ echo foo > foo

$ du -h foo
4.0K    foo

I tried to do the same thing with touch foo, but that didn’t work. Without digging into it more, the key seems to be in having very little text in the file, at which point the du command shows the minimum block size for the file.

I drove back from Kentucky to Colorado today following the death of my brother-in-law, and got to enjoy a beautiful view of a full moon for much of the day, including a stop at a rest area in Indiana this morning.

Full moon over an Indiana rest area

Since my brother-in-law passed away on Monday I haven’t felt like working — and I haven’t had any time to work — but on the rare occasions I’ve thought about work, I’ve thought that Scala is a beautiful programming language, and I’m fortunate to be able to work with it.

After a long illness, my brother-in-law passed away this morning, August 20, 2018. Godspeed, Kenny.

If you’re interested in a simple, pretty, instrumental song, Rain, by Simply Three might fit the bill. I especially like the little bicycle rider guy in the taxi cabi window.

This page contains a large collection of examples of how to use the Scala ArrayBuffer class.

Use the ArrayBuffer class when you want to use a general-purpose, mutable indexed sequence in your Scala applications:

I thought about writing a “functional programming in Kotlin” book, but I think that Kotlin and Scala are similar enough that Functional Programming, Simplified will be good for Kotlin programmers as well as Scala programmers.

August 15, 2011, Palmer, Alaska: I just got a flush letter from a local hospital. I guess I shouldn’t have put “You have my gallbladder” and “Your nurses seem really nice” as my top reasons for wanting to work there.

When using Scala, if you ever need to list the subdirectories in a directory, or the files under a directory, I hope this example is helpful:

import java.io.File

object FileTests extends App {

    // list only the folders directly under this directory (does not recurse)
    val folders: Array[File] = (new File("/Users/al"))
        .listFiles
        .filter(_.isDirectory)  //isFile to find files
    folders.foreach(println)

}

If it helps to see it, a longer version of that solution looks like this:

I just learned that Warren Buffett’s shareholder letters can be found here in PDF format.

The first time I started to go back to work after moving to Colorado, I ended up with thyroid cancer. Then I went unconscious seven times, had two fake heart attacks, and eventually learned I have a rare blood disease that caused those problems and more. Then I had diverticulitis twice, possibly epiploic appendagitis several times more, and ended up having to have part of my colon removed. Come September I’m not going to look for work, I’m just going to be like Kramer and show up at someone’s office.

As a quick note, here’s an example of how to use the Kotlin sortedWith syntax with an anonymous function (lambda). Given this list of integers:

val list = listOf(7,3,5,9,1,3)

Here’s an example of how to use sortedWith using a Comparator and lambda:

“And when things got hard, you started looking for something to blame, like a big shadow. Let me tell you something you already know. The world ain’t all sunshine and rainbows. It’s a very mean and nasty place and I don’t care how tough you are, it will beat you to your knees and keep you there permanently if you let it. You, me, or nobody is gonna hit as hard as life. But it ain’t about how hard you hit. It’s about how hard you can get hit and keep moving forward. How much you can take and keep moving forward. That’s how winning is done.”

I enjoyed this quote from Rocky Balboa the first time I saw the movie, and I appreciate it even more now after getting my a** kicked by this f-ing blood disease, but still grinding along every day.

It's about how hard you can get hit and keep moving forward

Tomorrow (August 15th) is the last day in 2018 that the Sun will set after 10pm in Talkeetna, Alaska.

The last day the Sun sets after 10pm

Here’s a quick example of how to use the Kotlin groupBy syntax on a list, with the result of each example shown in the comments:

val names = listOf("kim", "julia", "jim", "hala")

names.groupBy { it -> it.length }  //LinkedHashMap: {3=[kim, jim], 5=[julia], 4=[hala]}
names.groupBy({it}, {it.length})   //LinkedHashMap: {kim=[3], julia=[5], jim=[3], hala=[4]}

Two good quotes about work this morning:

“The harder you work the less competition you’ll find.”
~ Shane Parrish

“There are no traffic jams along the extra mile.”
~ Roger Staubach.

Here's a brief message for married people stuck in lousy marriages. One thing I learned about marriage is that it’s about teamwork, and if one partner isn’t part of that team — or doesn’t appreciate the other person — it’s no marriage at all, it’s just two people sharing bank accounts and living quarters. I strongly believe that a marriage partner should be someone who builds you up, not one who tears you down.

(I was reminded of that when I saw this image on Facebook today.)

Better off being single

Motley Fool has an excellent collection of Jeff Bezos quotes going back to the 1990s.

If you open your mind for me
You won’t rely on open eyes to see
The walls you built within
Come tumbling down, and a new world will begin
Living twice at once you learn

You’re safe from pain in the dream domain
A soul set free to fly
A round trip journey in your head
Master of illusion, can you realize
Your dream’s alive, you can be the guide but

I will be watching over you
I am gonna help you see it through
I will protect you in the night
I am smiling next to you
(in Silent Lucidity)

(I’ve been having a crazy amount of lucid dreams lately, and as a result I can’t listen to this song loud enough.)