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

As a quick note, if you need some examples of the syntax of how to write a Java method that returns a generic type, I hope these are helpful:

As a quick note, here’s a Java method that will round a float to the nearest half value, such as 1.0, 1.5, 2.0, 2.5, etc.:

 * converts as follows:
 * 1.1  -> 1.0
 * 1.3  -> 1.5
 * 2.1  -> 2.0
 * 2.25 -> 2.5
public static float roundToHalf(float f) {
    return Math.round(f * 2) / 2.0f;

The comments show how this function converts the example float values to their nearest half value, so I won’t add any more comments here.

As a quick note, here’s the source code for a Java “approximately equal” function that I use in an Android application:

I went of my diet a little last night by eating some mozzarella cheese and half a beer, and this morning I woke up extremely itchy with several bumps. That’s how I roll with my version of MCAS.

“As your practice proceeds you’ll be able to remain conscious as you transition from your normal waking state into the states of sleep ... once you can remain conscious like this, you’ll no longer sleep but merely pass through the night by going into deeper states of meditation.”

To those who know me that sounds like something I might write, but those words were published by Ram Dass in 1971.

This image shows a little more of his text. I deleted a few sentences that were repetitive or used obscure words.

Ram Dass on sleep and dreaming

From a article titled The thermodynamics of learning:

“The greatest significance of our work is that we bring the second law of thermodynamics to the analysis of neural networks,” Sebastian Goldt at the University of Stuttgart, Germany, told “The second law is a very powerful statement about which transformations are possible — and learning is just a transformation of a neural network at the expense of energy. This makes our results quite general and takes us one step towards understanding the ultimate limits of the efficiency of neural networks.”

The thermodynamics of learning

Last week I was wondering how mechanical watches work, and this morning Erik Bruchez shared this ‘animated infographic’ article on how they work.

How a mechanical watch works

From a Reuters article titled, Apple seeks design perfection at new “spaceship” campus:

“But de la Torre ultimately saw that Apple executives were not trying to evoke the iPhone per se, but rather following something akin to the Platonic ideal of form and dimension. ‘They have arrived at design principles somehow through many years of experimentation, and they are faithful to those principles,’ de la Torre said. Fanatical attention to detail is a key tenet.”

HP offers 157 “business” laptops. (I have no idea how many “personal” laptops they offer, I didn’t look.)

When I searched Dell for 15” laptops, their search results showed 167 models.

Apple has one. Maybe as many as four, depending on how you count.

To create this graphic, someone Google’d all the queries for “Why is [state] so” (like, “Why is Illinois so”), and mapped the first Google auto-complete result onto each state. Makes me want to spend some time in the “haunted” states.

(They actually Google’d these queries in 2014. Makes me wonder what the current results look like.)

Why is state so (Google search results)

In dreams at night I jump off of buildings and balconies because it’s the fastest way to get to my next destination. I have to remember not to do the same thing during the day.

As a note to my future self: Take time to think!


Even at my advanced age, if I don’t think through an algorithm I can still waste an awful lot of time.

As an example I just started working on a complex algorithm for my Android football game based on the initial thoughts in my brain, and came to regret it. After recovering from that faux-pas I decided to write just a few simple notes like this to clarify my thoughts:

“It just tells you how tough this team is. Down 25 points, we just keep grinding and we finish on top again.”

~ Julian Edelman, New England Patriots

This is a photo of the RV campground in Seward, Alaska. Several people had small fires burning, and it was great to talk with the people there.

The RV campground in Seward, Alaska

If you need to iterate over the elements in a Map in Java 8, this source code shows how to do it:

Map<String, String> map = new HashMap<String, String>();
map.put("first_name", "Alvin");
map.put("last_name",  "Alexander");

// java 8
map.forEach((k,v)->System.out.println("key: " + k + ", value: " + v));

I spent some time last night reading the book, Practical Common Lisp. In all Lisp books you’ll read about S-expressions, but very few authors explain what they are. This image comes from this Wikipedia page, which states, “In computing, s-expressions (for “symbolic expression”) are a notation for nested list (tree-structured) data, invented for and popularized by the programming language Lisp, which uses them for source code as well as data. In the usual parenthesized syntax of Lisp, an s-expression is classically defined as a) an atom, or b) an expression of the form (x . y) where x and y are s-expressions.” See that link for more information about Lisp and S-expressions.

Lisp: What is an S-expression?

“I love you so much that I want you to be happy, even if that happiness no longer includes me.”

A quote from the movie, The Longest Ride (which, thanks to my illness, I have no memory of watching)

The Milky Way is moving at over half a million miles per hour. (In the time it took me to type that, we sailed about 1,500 miles through the Universe.)

Inside the Milky Way, the Earth revolves around the Sun at 66,600 mph.

The Earth rotates around its axis at about 1,040 mph (depending on your latitude).

And yet, somehow I feel like I’m sitting perfectly still in this chair.

That’s quite an illusion.

“I can’t stand when someone treats you like crap and then they act like the victim. Noooo ... get the heck out of here with that B.S.”

A friend just shared a slightly more profane version of that on Facebook, and (sadly) I know exactly what she means.