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

“My current advice to everyone is this: fall in love with your life. Pursue the things that bring you joy. Let go of things that don’t. Know the difference.”

~ Edie Freedman, Creative Director at O’Reilly Media

“I realize that most inventions fail not because the R&D department can’t get them to work, but because the timing is wrong‍ — not all of the enabling factors are at play where they are needed. Inventing is a lot like surfing: you have to anticipate and catch the wave at just the right moment.”

~ Ray Kurzweil

I just saw this “Prayer of Saint Francis” in a collection of photos from a church in Santa Fe, New Mexico, and it reminds me of the creed of a superhero. :)

Prayer of Saint Francis, Santa Fe, New Mexico

Ferguson Jenkins was one of my favorite pitchers to watch when I was very young. Unlike other “throwers,” he was a true “pitcher,” getting by more by his control and changing speeds than having a blazing fastball. I created this “artistic” image of him pitching using Gimp.

Ferguson Jenkins, Chicago Cubs (painting)

It’s worth mentioning that my last post about a glass teapot was inspired by a book titled Emotional Design: Why We Love (or Hate) Everyday Things by Don Norman. In that book he shows this image of three teapots, and the glass one in the middle is known as a “Nanna teapot.” I just saw that one sold on eBay for $275; that’s a little more than I had in mind. :) Mr. Norman earlier published a best-selling book titled The Design of Everyday Things.

Nanna teapot (from Don Norman's Emotional Design)

When I saw this tweet this morning:

[DOG MAGICIAN] think of a color, any color ... is it ... gray?

[OTHER DOG] oh my GOD

I knew that I loved the joke, but I didn’t like the presentation. I wanted to put the joke on Facebook, but I know that people like images more than they like text, so I made a second cup of coffee and began putting the text on an image.

This is a cartoonize’d version of Yoda on Luke Skywalker’s back during Luke’s initial training in the swamp. To create it, I found the original movie image with a Google search, opened the image in Gimp, then worked back and forth with a Cartoonized plugin effect, the Beautify options, and the Artistic/Oilify effect. I can do a lot better than this, but for the purposes of this example, I created this cartoon image in less than five minutes. Given more time, I would clean up Yoda quite a bit before using the Cartoonize effect.

I’ve used Gimp to create almost 2,000 images that I use with the Mac screensaver “rotate images” feature, and this is the latest addition.

(Click the image to see the full-size, 1200x600 pixel image.)

Cartoon of Yoda on Luke Skywalker's back

“The important thing is not to stop questioning. Curiosity has its own reason for existing.”

~ Albert Einstein

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 great thing about the printf formatting syntax is that the format specifiers you can use are very similar — if not identical — between different languages, including C, C++, Java, Perl, PHP, Ruby, Scala, and others. This means that your printf knowledge is reusable, which is a good thing.

After getting an infection in my eyes this week, someone suggested I try echinacea (which is not recommended for people with weakened immune systems). That reminded me of this “euthanasia, echinacea” tweet.

Euthanasia, echinacea, whatever

I just received notice that the Apple Store in Anchorage, Alaska has reopened. Might be time to move back, although I have no idea what “all the new Today” means. :)

The Apple Store in Anchorage, Alaska has reopened

This is an excerpt from the Scala Cookbook (partially modified for the internet). This is Recipe 14.6, “How to disassemble and decompile Scala code.”

Problem: In the process of learning Scala, or trying to understand a particular problem, you want to examine the source code and bytecode the Scala compiler generates from your original source code.

Solution: You can use several different approaches to see how your Scala source code is translated:

As a quick note, I just got a little bit better about logging stack traces when writing Java or Scala code. In Scala I used to get the text from a stack trace and then log it like this:

// this works, but it's not too useful/readable
logger.error(exception.getStackTrace.mkString("\n"))

In that code, getStackTrace returns a sequence, which I convert to a String before printing it.

I didn’t think about snakes at all when I lived in Alaska, but here in Colorado they cross my mind from time to time. Following up on my previous article, Can snakes see?, here’s some information on what snakes do in the winter, from snakeprotection.com:

“Snakes do not actually hibernate, rather they become less active during cold weather. It is called ‘brumation.’ Brumation is an extreme slowing down of their metabolism. Snakes are awake, but just very lethargic so you don’t see them moving around. In the fall, snakes move back to the previous year’s den. If a sudden cold snap catches them before they get there, they may die if not fortunate enough to find a suitable secondary den. A number of species may share the same den. For example, black rat snakes, timber rattlesnakes, and copperheads commonly den together. Sometimes there will be as many as 100 snakes in one cave. A group site is called a hibernaculum.”

Linux grep FAQ: How can I perform a recursive search with the grep command in Linux?

Solution: find + grep

For years I always used variations of the following Linux find and grep commands to recursively search subdirectories for files that match a grep pattern:

find . -type f -exec grep -l 'alvin' {} \;

This command can be read as, “Search all files in all subdirectories of the current directory for the string ‘alvin’, and print the filenames that contain this pattern.” It’s an extremely powerful approach for recursively searching files in all subdirectories that match the pattern I specify.

This is my interpretation of the meaning of the Alanis Morissette song, Thank You (also known as Thank U). I don’t claim any special knowledge about the song; this interpretation of the lyrics is just based on my understanding of Zen and Buddhism, and also my practicing of yoga, specifically Iyengar yoga. If you’ve read some of the personal entries on this website, you know a lot of what I know.

I haven’t been back to Alaska in a while now, but this is what the movie theater in Homer, Alaska looked like the last time I was there.

The movie theater in Homer, Alaska

When training an adult polar bear, it’s important to let their cub eat on your leg. #protip

(I don’t remember the original source of this photo.)

Training polar bears

“People inspire you, or drain you. Pick them wisely.”

~ Hans F. Hansen (image from positivelifetips.com)

People inspire you, or drain you. Pick them wisely.