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

New book/story idea: Life is a bit of a game, and as a result you’re put in the vicinity of your soulmate. Not right next door per se, but somewhere within your range of life such that you will encounter this person, such as the friend of a friend, someone you work with, a person you run into at a store, etc. So the game is, out of all the people you meet as your life unfolds, can you identify your soulmate? And maybe as a secondary plot, how do you handle it if you get get close but make a mistake ... say you marry a person which creates circumstances that put you in the vicinity of your soulmate, and you later realize your mistake?

This is a favorite quote from the book, Zen Training. Anyone who has ever meditated deeply at home, in the mountains, or on retreat has probably had these feelings.

A favorite quote from the book, Zen Training

Scala community build is an interesting project, which is described like this:

“This repository contains configuration files that enable us to build and test a corpus of Scala open source projects together using Lightbend's `dbuild`. How big is it? It’s 3.2 million lines of Scala code, total, from 185 projects (as of January, 2019), and takes about 15 hours to run.”

“Why do this? The main goal is to guard against regressions in new versions of Scala (language, standard library, and modules). It’s also a service to the open source community, providing early notice of issues and incompatibilities.”

As a note to self, I added SSL/TLS certificates to a couple of websites using LetEncrypt. Here are a couple of notes about the process:

I just ran across this photo of my old apartment. I liked using a shoji screen to add a temporary “wall” in different spaces, and I used to keep Christmas lights going for most of the winter evenings, as shown.

Shoji screen in my apartment

Here’s a link to my Scala String utilities, which includes a few hopefully-useful string utility functions, some of which are shown in the image. My “Q” interpolator is also included in that library.

Scala String utilities functions

I ran into a couple of interesting things today when trying to generate random alphanumeric strings in Scala, which can be summarized like this. I won’t get into the “random” stuff I was working on, but here are a couple of examples of how to generate lists of alphanumeric/ASCII characters in Scala:

scala> val chars = ('a' to 'Z').toList
chars: List[Char] = List()

scala> val chars = ('A' to 'z').toList
chars: List[Char] = 
List(A, B, C, D, E, F, G, H, I, J, K, L, 
     M, N, O, P, Q, R, S, T, U, V, W, X, 
     Y, Z, [, \, ], ^, _, `, a, b, c, d, 
     e, f, g, h, i, j, k, l, m, n, o, p, 
     q, r, s, t, u, v, w, x, y, z)

scala> val chars = (' ' to 'z').toList
chars: List[Char] = 
List( , !, ", #, $, %, &, ', (, ), *, +, 
     ,, -, ., /, 0, 1, 2, 3, 4, 5, 6, 7, 
     8, 9, :, ;, <, =, >, ?, @, A, B, C, 
     D, E, F, G, H, I, J, K, L, M, N, O, 
     P, Q, R, S, T, U, V, W, X, Y, Z, [, 
     \, ], ^, _, `, a, b, c, d, e, f, g, 
     h, i, j, k, l, m, n, o, p, q, r, s, 
     t, u, v, w, x, y, z)

When it comes to working as a business analyst, I’ve learned that there are just three things you need to keep in your mind when meeting with your customers (the project sponsor (gold owner) and domain experts (“goal donors”)) to gather requirements. These three thoughts will keep your meeting on track, lead you to the next question, and will help you know when your work is done.

As one last photo of Alaska (for the time being), here’s the Arctic Circle sign that you’ll find on the Dalton Highway north of Fairbanks, on the way up north to places like Deadhorse and Prudhoe Bay.

The Arctic Circle sign in Alaska

Here’s another view of Denali from the rivers in Talkeetna in mid-September. As I always add, Denali is at least 60-70 miles away in this photo.

When I lived in Alaska I was told that you can only see Denali one day out of every eight, so visitors only have ~12.5% chance of seeing it. I was fortunate to live there and see it many times.

A view of Denali from Talkeetna

This is a photo of a day tour boat in Resurrection Bay, Seward, Alaska

Tour boat, Resurrection Bay, Seward, Alaska

A favorite gift from the last twelve years is the purple pencil sharpener shown at the top of this image. It may have only cost a dollar or two, but one of my sisters and her daughters gave it to me when I saw them right before I moved to Alaska, and it’s been with me ever since. I especially like it at times like this, when I’m editing a new book.

A favorite gift from 2007

I found a little ice skating rink in downtown Louisville, Colorado recently. Looks like it would be fun at night. :)

Little ice skating rink in Louisville, Colorado

“When someone shows you who they are, believe them the first time.”

~ Maya Angelou

Table of Contents1 - Scala 2: Create the method in an implicit class2 - Scala 3 (Dotty): Adding methods to closed classes with extension methods

Scala lets you add new methods to existing classes that you don’t have the source code for, i.e., classes like String, Int, etc. For instance, you can add a method named hello to the String class so you can write code like this:

"joe".hello

which yields output like this:

"Hello, Joe"

Admittedly that’s not the most exciting method in the world, but it demonstrates the end result: You can add methods to a closed class like String. Properly (tastefully) used, you can create some really nice APIs.

In this article I’ll show how you can create implicit methods (also known as extension methods) in Scala 2 and Scala 3 (Dotty).

“On one occasion of my own practice, nearing deep samadhi, I happened to notice that the stage of my mind was quietly turning and a new scene was appearing. In this new scene no wandering thought popped up its head; there was absolute stillness and silence, as if one had landed on the Moon.”

~ Zen Training

Table of Contents1 - A shell script solution2 - A JavaFX GUI3 - Summary

I recently started using AsciiDoc to write a new book. A great thing about it is that unlike Markdown, you can use AsciiDoc to write a book and get all of the features you want in a book, including linking between anything, captions for tables and figures, indexes, etc. Because this got me started using AsciiDoc I thought, “Wouldn’t it be nice if I could also use AsciiDoc to write blog posts like this one?”

Sadly, I quickly ran into a problem: I couldn’t find a good way to convert AsciiDoc into HTML, or even Markdown. There are tools to convert AsciiDoc to HTML, but for some reason they take the approach of including a ton of markup in the HTML (divs, spans, and attributes), and as far as I can tell there’s no way to turn off that markup.

Back to top

A shell script solution

“One woman can make you fly like an eagle, another can give you the strength of a lion, but only one in the cycle of life can fill your heart with wonder and the wisdom that you have known a singular joy.”

~ Twin Peaks

From a translation of the Tao Te Ching:

The master, by residing in the Tao (the Way),
sets an example for all beings.

Because he doesn’t display himself,
people can see his light.

Because he has nothing to prove,
people can trust his words.

Because he doesn’t know who he is,
people recognize themselves in him.

(I recommend that third stanza in particular for people who are interested in consulting.)