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

In case you ever need to manually a certificate to your ${JAVA_HOME}/jre/lib/security/cacerts file, it turns out the password for that file when using the Java keytool command is changeit.

To add a certificate to that file, you’ll want to use a command like this:

keytool \
    -import \
    -alias "" \
    -keystore ${JAVA_HOME}/jre/lib/security/cacerts \

I had to do this today for a Java/Scala script that accesses an HTTPS URL, and the site I’m accessing uses a “Let’s Encrypt” certificate.

If you ever need to parse JSON stock data from using Scala, here’s a test class I just wrote that uses Lift-JSON.

The JSON data format

First, here’s the JSON I get back from them:

It’s almost comical how many people tell me they feel stressed, but they won’t even try yoga or meditation.

(They tell me they’re stressed/anxious/worry-a-lot, I seem relaxed, and ask how I do it. I tell them “yoga and meditation,” but apparently they don’t like that answer.)

If you ever wondered what Digital and Print book sales look like for a technical book (a computer programming book, in this case), here you go. This is a slightly cleaned up chart that O’Reilly provides to me for sales of the Scala Cookbook over time, showing eBook sales vs the printed book sales.

What Digital and Print sales look like for a computer programming book

I wrote a little “Notes” application using Scala and JavaFX to go along with my “Hello, Scala” tutorial. If you’d like to see how it works, here’s a two-minute video:

The source code for the project is at this Github URL:

Last night I was reading the classic old book, The Pragmatic Programmer, and came across this definition of DRY, an acronym that stands for Don’t Repeat Yourself:

“Every piece of knowledge must have a single, unambiguous, authoritative representation within a system.”

That’s well stated, especially after a recent experience in which I found some code where I created an “Add Widget” dialog in a different way than I created its related “Edit Widget” dialog. I created the main pane of the dialog the same way, but I managed the details of the two dialogs that contained that pane differently, and I realized what I had done when I decided to make the dialog resizable. When I discovered what I had done, I refactored the code so both the Add and Edit dialogs were created by a single method.

“Every action in our lives touches on some cord that will vibrate in eternity.”

~ Edwin Hubbel Chapin

As a short note, here’s some Scala source code that shows how to write a foldLeft function using recursion:

After yesterday’s Scala nested Option + flatMap/for example, here’s another example of plowing through nested Options with flatMap. First, start with some nested options:

val o1 = Option(1)
val oo1 = Option(o1)
val ooo1 = Option(oo1)

Here are those same three lines, with the data type for each instance shown in the comments:

Here’s a little fun with Scala functions, including the use of andThen and compose:

scala> val add1 = (i: Int) => i + 1
add1: Int => Int = <function1>

scala> val double = (i: Int) => i * 2
double: Int => Int = <function1>

scala> val addThenDouble = add1 andThen double
addThenDouble: Int => Int = <function1>

scala> addThenDouble(1)
res0: Int = 4

scala> val doubleThenAdd = add1 compose double
doubleThenAdd: Int => Int = <function1>

scala> doubleThenAdd(1)
res1: Int = 3

(Inspired by the book, Functional and Reactive Domain Modeling, and my own book, Learning Functional Programming in Scala.)

If you come here for the Scala, I’m sorry that I haven’t posted much here lately. I have my next medical procedure coming up on January 29th, and then my body decided to have a cold and then the flu.

“Developing the habit of mastering the multiple models which underlie reality is the best thing you can do.”

~ Charlie Munger

If you own a copy of Functional Programming, Simplified, and would like to report any bugs, I started this Github repo so you can do that. Just report your bug under the Issues tab.

Legend has it that Bodhidharma sat facing a wall for nine years. I’m going to sit facing my faux fireplace on my new cushion (known as a zabuton, which was a Christmas gift this year).

New meditation cushion (zabuton)

Today’s word of the day is reticent. Per Google, it means, “Not revealing one’s thoughts or feelings readily. ‘She was extremely reticent about her personal affairs.’”

“If you try to drive through Canada in the winter with those tires you’re going to end up as a statistic.”

~ A RCMP person, after looking at my car, March, 2011. They were very close to being right, as I got stranded for five days.

As a note to self, I used code like this in a Scala + JavaFX application to add a ContextMenu to a TableView:

LinkedIn’s engineering blog post has this article about how they use the Play Framework and Akka show online “presence indicators.”

I keep running into Maslow’s Hierarchy of Needs lately, so I thought I’d share that Wikipedia link, and this image, which was created user FireflySixtySeven.

Maslow's Hierarchy of Needs