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

I was having a metaphor in a dream this morning and I had to stop it and say, “Really? Aren’t we past this point by now? Pfft.”

(A note from June 1, 2014)

A wee bit of cause and effect:

I may never have lived in Alaska
if I didn't first go there on vacation.

I may have never gone to Alaska on vacation
if Colorado wasn't on fire in 2002.

I may not have thought to go to Alaska in 2002
if I hadn't discovered Northern Exposure ~1996.

I may never have discovered Northern Exposure
if I didn't quit a job I didn't like in 1995.

I may never have discovered Northern Exposure if a tv channel
that doesn't exist today hadn't aired it back then.

This keeps going back in time until I was born (or before then),
but that's the basic idea.

Here’s a link to a page by James Earl Douglas that I don’t quite understand yet, but also don’t want to forget. Here’s his intro to the problem, and then the image shows his solution.

Problem: You have a mutable variable (a var in Scala) that is both read from and written to outside of a tightly-scoped block.

Solution: Remodel the block as functions that take an initial value of the variable, and return both the final value of the variable and the original return value of the expression.

Joining multiple StateRefs together in a 'for' expression

This article titled, Little things I like to do with git, has a fun series of git commands.

Fun git commands

Here’s a cool tip: if you want to search for a text string in all fields of all tables of a MySQL database, you can use phpMyAdmin to do this very easily. Here are the steps to search every MySQL database table.

1) Select the desired database

The first step is to select the database you want to search. Don’t select a table — just select the database you want to search. (If you select a table you’ll get a different search form in Step 2.)

This made me wonder how a Zen student is supposed to drive a car when mountains aren’t mountains and rivers aren’t rivers (and presumably, roads aren’t roads).

Before you study Zen, mountains are mountains

If you like “works in progress,” I’m currently in the process of moving the HTML version of my new book to this website ( You can find the first page here at Learning Functional Programming in Scala.

(The motivation for moving it here is that I want to a) make my life easier, and b) make it so I can find my own content by just searching this website.)

“True self appears when we actively practice in the present moment, not waiting for enlightenment to appear in some special way.”

~ Les Kaye, Zen at Work

Every once in a while when something hits you, you really remember it; it stands out in your mind as an “Aha” moment. One of those moments for me was when I saw a particular “Model/View/Controller” (MVC) diagram, and the light bulb went on. This diagram made the MVC pattern very simple, and I’ve never forgotten it.

If you’re interested in “meta” programming in Scala, check out the Scalameta project. It’s described on its website like this:

“Scalameta is a clean-room implementation of a metaprogramming toolkit for Scala, designed to be simple, robust and portable. We are striving for scalameta to become a successor of scala.reflect, the current de facto standard in the Scala ecosystem.”

“Scalameta provides functionality that's unprecedented in the Scala ecosystem. Our killer feature is abstract syntax trees that capture the code exactly as it is written — with all the original formatting and attention to minor syntactic details.”

I don’t send cards at Christmas, but if I did, I might send this “Fox looking at Santa and the Moon” Christmas card that I saw in Santa Fe, New Mexico this week.

'Fox looking at the Moon' Christmas card from Santa Fe

On May 24, 2013, I finished with the last hardcopy chapters of the Scala Cookbook. I put all of the chapters next to the paper shredder as a way to show what I had just done. The final edits would be finished with a copywriter over the next several weeks, and I signed off on the final edition while I was at Virginia Beach.

Last draft of the Scala Cookbook

Somewhere around the year 2006, my writing style was influenced by the CIO of a company I was working with. When trying to get a new project started, a project manager gave me a very vague description of what he wanted, and as a result, the cost estimate and Statement of Work I wrote (so I would get paid) was vague as well.

The CIO called me to her office, and then told me that I didn’t have to write anything fancy, I just had to “say what I mean.” Since then, that simple approach has been a key to my writing style.

Summary: This page is a printf formatting cheat sheet. I originally created this cheat sheet for my own purposes, and then thought I would share it here.

A cool thing about the printf formatting syntax is that the specifiers you can use are very similar, if not identical, between several different languages, including C, C++, Java, Perl, Ruby, and others, so your knowledge is reusable, which is a good thing.

I love these quotes:

- My happiness depends on me.
- Do not give anyone else responsibility for how you feel.

Unfortunately, many people blame other people for their problems. I hear people say, “If only so-and-so would do xyz, I’d be happy.” Guess what? No you won’t! Nobody else is ever going to give you lasting happiness. If your friend/sibling/whatever is a slacker, they’re a slacker! (And guess what else? You’re judging them, and that makes you judgmental!) Get over it, move on! Tend to your own garden. You make yourself miserable, and you can also make yourself happy. It’s your choice. Stop blaming others.

My happiness depends on me

For people who have life partners (spouses, etc.), I think it’s important to ask, “Is there joy in my partner’s life?”

Sometimes we get so caught up in our own lives, we forget to check in with our partners and ask how they’re doing, if they’re happy. (And if they’re not, what we can help do about that.)

Being a “life partner” is a commitment to the other person, and to their well-being.

If you’re interested in a simple introduction to mindfulness meditation, search the Internet for a free, 25-page PDF booklet named, “Buddha in Blue Jeans,” by Tai Sheridan. Despite that name, the booklet has good, non-denominational tips about meditating and mindfulness (and only mentions the name “Buddha” twice in the main text).

Here’s a favorite quote: “Be like a cat purring. Follow your breath like ocean waves coming in and out.”

“I thought once everybody could speak freely and exchange information and ideas, the world is automatically going to be a better place,” Mr. Williams says. “I was wrong about that.”

~ Evan Williams, in a N.Y. Times article, The Internet is broken.

A farmer plowing a field in Palmer, Alaska on May 20, 2015.

At 10:30 pm.

A farmer plowing a field