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

Today I learned that for several reasons, Flutter Debug mode may be significantly slower than Production mode. As just one reason, Debug mode is compiled using JIT while Production mode uses AOT. You can read more about the reasons on the Flutter UI Performance page.

A very important note on that page is that if you’re using a real hardware device (as opposed to an emulator), you can run your code in Profile mode like this:

When using Flutter (and Dart), if you need to compare two TimeOfDay values, I can confirm that it helps to first convert the TimeOfDay to a double using this function:

/// note: 'hour' is in 24-hour format
double _timeOfDayToDouble(TimeOfDay tod) => tod.hour + tod.minute/60.0;

If you ever need to run multiple Dart futures in parallel (simultaneously), I can confirm that this approach works:

So I pour some root beer in a Ball jar glass I use to drink from. I put some ice in it, then set it on the counter because I realize I left my glasses in the bedroom. In the bedroom I hear a cracking noise from the kitchen, but when I come back I can’t figure out what it was, so I assume it was the ice cracking in the root beer.

I pick up the Ball glass, take it to the computer area, then realize I now left my glasses in the kitchen. So I start walking to the kitchen, and the bottom of one of my feet feels a little wet. I can’t make sense of that, unless the Ball glass already started perspiring and dripped.

I come back to the computer area and find a little puddle of root beer under my glass. “Oh,” I think, “the root beer must have overflowed after I put the ice in. Strange I didn’t feel it on my hands.”

So I pick up the Ball glass and think, “Huh, that’s a lot of root beer under there,” so I take it back to the kitchen to rinse the glass under the sink. When I put the glass under the sink the bottom explodes and falls out.

Ball jar glass cracks, explodes

Flowers at an intersection in downtown Colorado. :)

Flowers at an intersection in downtown Colorado

In the “lucid dream holodeck” this morning, I was hanging out with a group of peeps when a tornado suddenly appeared. Everyone started running for cover, and I grabbed a dog and started running for a basement when I looked back at it and thought, “This isn’t a tornado, it’s just an insane amount of energy.”

Holding the dog under my right arm, I stood my ground. When I did this, the energy stopped moving like a tornado, and — skipping over the whole “Transformers” thing — it eventually took on a female human form.

Further skipping past our introductions ... I eventually suggested that she talk to some other people in the dreamspace, but she said no, I had less “hate-y bits” than the other people. (Language differences often make for interesting translations.)

Over the last two days I started to get my Just Be notifications working on Android. I’m rewriting the app using Flutter, and this is what a notification currently looks like if you do a long-press on the app icon after receiving a notification.

Getting Flutter notifications working on Android

Notes from September 24, 2016:

Doctor: I’d like to collect a bone marrow sample ...

*Al runs out of the hospital in a hospital gown, screaming like a little girl*

(later, after they caught me)

Doctor: The next time you break out in a rash, hives, or blisters, I want you to have those biopsied.

Me: Is there going to be any part of our relationship that doesn’t involve a lot of pain on my part?

Doc: Yes, pee in this cup, and we’ll look at it under a fluorescent light to see if you have the same disease that King George III had.

Me: The crazy one?

Doc: Yes.

Me: Cool.

I recently created a command I named ffx that lets you search your filesystem for files that contain multiple strings or regular expressions. This post describes and demonstrates its capabilities. (There’s a little video down below if you want to see how it works before reading about it.)

If you need to get a random element from a list in Dart, I can confirm this this getRandomListElement method works:

When I woke up this morning I was very refreshed and my brain was quiet, so I decided to meditate. Shortly after that the room got a little busy, and then a terrific Michael Jackson song started playing. As I watched what was going on in the room and listened to the musicians and the lyrics, I realized it was a song that doesn't exist here in awakeland. Stuff like that will make you wonder about the nature of reality.

As a quick note, here are a couple of examples of how to simulate a slow-responding Flutter method:

As a quick note, the Dart ternary operator syntax is the same as the Java ternary operator syntax. The general syntax is:

result = testCondition ? trueValue : falseValue

A few examples helps to demonstrate Dart’s ternary syntax:

“All things that appear in this world are illusion. If you view all appearance as nonappearance, you will see your true nature.”

“There he goes. One of God's own prototypes. A high-powered mutant of some kind never even considered for mass production. Too weird to live, and too rare to die.”

~ Hunter S. Thompson, Fear and Loathing in Las Vegas

Here’s a little example of how to pass a Dart function into another function or method. The solution is basically a three-step process.

Step 1: Define a method that takes a function parameter

First, define a method that takes a function as a parameter, such as this exec method:

As a brief note, if you ever need to use the Flutter CupertinoDatePicker — a spinning wheel chooser — in “time-picker/time-chooser” mode, I can confirm that this example works:

I initially thought you couldn’t pass functions around in Dart (you can!), so I had to remember what we used to have to do with interfaces and inheritance. (See the image.)

Put another way, when you have the ability to pass functions into functions, it eliminates this kind of code interface/inheritance code.

What your source code looks like when you can’t pass functions around

At one point when I was recovering from a surgery I wasn’t feeling very well, so I ended up watching a lot of movies, including 13 Going on 30. I was struck not only by the humor of this particular scene in the movie, but also the empathy. When I worked as a manager, I always appreciated it when employees could see my situation from time to time. It shows a certain maturity that is rare to find in employees.

An example of empathy (from “13 Going on 30”)

When I first studied Zen, I had a very hard time with this concept. I tried to focus very hard on the present moment, and also on being kind, and as a result, I didn’t always do what was really best for the situation. Over time, you figure out how to respond properly.

Zen - Accepting the “just this” of a situation