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

“If you are neutral in situations of injustice, you have chosen the side of the oppressor.”

~ Desmond Tutu

The New York Times has this article on how Silicon Valley’s attitude towards Donald Trump changed in less than 36 hours. The photo shows Sergey Brin, Google co-founder and refugee, joining a protest at the airport in San Francisco.

Sergey Brin, Google co-founder and refugee

Tony Fadell, Chris Sacca, and other people are matching donations to the ACLU today. Learn more at this Twitter link.

I spent some time last week working on an Android application, and with my newfound knowledge of functional programming (FP), I was trying to apply FP principles to my Android Activities and Fragments.

Android isn’t really meant for FP, but one thing I found that I could do is to move a lot of my business logic out of the Activities and Fragments and into separate classes, where I could often implement methods as static functions. The advantage of this is that it forces you to consciously pass variables in and out of those static functions, rather than mutating them as instance variables (think “global” variables) in your Activities and Fragments (which is a common way to handle them).

I don’t have a specific example I can share today, but when I can I’ll update this post to show specifically what I mean. In the meantime, if you try to move some of your logic out of your Activities and Fragments, I think you’ll see what I mean.

In his book, The Universal Tone: Bringing My Story to Light, Carlos Santana writes about hearing other guitar players, and wondering with an intense curiosity how those other people got their guitars to make the sounds they made. As I thought about this I thought it was a good attitude to have in programming. For instance, if I look at an application where someone has done something really cool I try to understand, “How did they do that?”

“Look, I have no illusions, okay? I know that the life I live ... I know how it's gonna end for me. Whatever. I'm okay with that. But I wanted you to know ... that when I do picture myself happy ... it's with you.”

~ Dean, Supernatural

This image shows a very early (ugly) prototype of the next version of my Android football game. The orange boxes on the bottom-left let you choose the formation, then the “run,” “pass,” and “other” icons stand for tabs that let you choose different plays. I may put the formations inside a tab as well ... that would be more consistent, and it will be something I’ll need to do as the game grows.

A major new feature in the game is that you can can create your own custom teams, with each player on the team having a collection of ratings. For instance, a running back will have rating categories of a) running, b) blocking, and c) pass-catching abilities. Therefore, the running plays will let you choose to run left or right, and passing plays will let you choose the intended receiver.

I’ll write more as time goes on, but this ugly little prototype is one of the first steps in the redesign/upgrade.

Prototype of the next version of my Android football game

For everyone who is upset by the actions of the current president and other political leaders, I urge you to take action. By “action” I don’t mean posting things on social networks. I mean writing your senators and congressmen. I mean peacefully marching and demonstrating. I mean supporting others who are marching and demonstrating. Every time you think about sharing a post, send a check to the ACLU and other organizations that are fighting against hate, oppression, destruction of the environment, etc. Otherwise, it’s just a lot of people preaching to the choir.

#imho

Katniss three-finger salute

One good thing about mast cell disease: because I’ve had to follow a strict low-histamine diet I’ve lost almost twenty pounds in the last eighteen months, with most of that coming in the last six months. I’ll soon weigh what I weighed in high school (albeit it without the same muscle mass). This is a photo of my during my first year in college, where I was at roughly the same weight.

If you’re interested in a similar story, you can find before and after photos of the “Low Histamine Chef” (Yasmina Ykelenstam) at this link. For me the important thing is not getting down to a low weight, but a healthy, sustainable weight where I feel good.

Alvin Alexander in college (in Kentucky)

“No dreams come without a bill. The reality of making something happen is just a ton of hard work.”

~ Peter Gabriel

I’ve written about this before, but I was just reminded in this article about Steve Jobs advice to Nike: Get rid of the crap.

Steve Jobs advice to Nike

Per their website: “MyShake is a free app for Android phones that has the ability to recognize earthquake shaking using the sensors in every smartphone. The app runs ‘silently’ in the background on your phone using very little power – just like the step-tracking fitness apps. When the shaking fits the vibrational profile of an earthquake, the app sends the anonymous information to our central system that confirms the location and magnitude of the quake.”

“Our goal is to build a worldwide seismic network and use the data to reduce the effects of earthquakes on us as individuals, and our society as a whole. MyShake also provides users with information about recent earthquakes around the world and significant global historical earthquakes.”

MyShake: A free app that has the ability to recognize earthquake shaking

“It was unbelievable,” a drained Moya told a handful of reporters after the match. “He’s such a fighter, a warrior. I have no words to describe for what I saw today.”

Four years ago, at the 2013 French Open, Nadal explained how he had learned to enjoy suffering in big matches, finding the joy of winning so much better as a result. The indomitable spirit -- no matter what travails Nadal has endured -- has not waned.

On Friday, we saw the grimaces on his face, the clenched fists, screams of vamos. The emotion was raw, especially when he lost the fourth-set tiebreaker. Moya could barely watch.

2016: The National Park Service is nice, I like the Redwoods and Volcanoes.

2017: I will follow the National Park Service into battle.

Hi, my name’s Ray. I’ll be drawing your blood today as soon as I finish this Capri Sun.

*misses hole 4 times then punches straw through bag*

(Reminds me of a few people who have drawn my blood.)

Scotch neat, please.

Umm ... this is a Starbucks.

*sigh*

Okay ... a scotch “grande.”

Without much discussion, here’s an Android ListView/ListFragment with its Back/Up/Home button enabled:

An Android ListFragment/ListView with Back/Up button enabled

(That button used to be a Home button, but now it’s used for the Back/Up action.)

And here’s the source code for that ListView/ListFragment:

space.com has this article about scientists going rogue as “a response to the Trump administration's order for at least four government agencies to stop all communications with the public.”

Going rogue (NASA, NOAA, and more)

I don’t know what happened to Freedom of Speech in the U.S., but I like this.

Freedom of speech?

After working with Scala for a long time, I had to come back to Java for a while to work on an Android app. Right away I missed a lot of things from the Scala world, including all of the built-in Scala collection methods, and other things as simple as the Scala Tuple classes.

If you haven’t used them before, a Scala Tuple class lets you write code like this:

Tuple<String, Integer> t = new Tuple<>("age", 41);

If you’re comfortable with generics, the Java implementation of a Tuple class like this is simple: