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

When I first moved to Alaska I took a really nice camera with me, and I took some fun photos I would have never thought to take with a regular camera. In this photo I was more or less laying down in a field of wildflowers (some weeds) at the Talkeetna Airport, bees and everything.

Wildflowers at the Talkeetna, Alaska airport

One thing I learned in Alaska is that when you see green water in it, that means there’s protein in the water, which means there will be fish, and also bears.

Green water in Alaska

Here’s some source code that demonstrates a quiet, concise, and attractive new programming language I’d enjoy using:

Scala 3 (Dotty), September 30, 2019

These are some terrific words from a blog post titled, I’m Not The Radical Left, I’m The Humane Middle:

I believe in full LGBTQ rights.
I believe we should protect the planet.
I believe everyone deserves healthcare.
I believe all religions are equally valid.
I believe the world is bigger than America.
I believe to be “pro-life,” means to treasure all of it.
I believe whiteness isn’t superior and it is not the baseline of humanity.
I believe we are all one interdependent community.
I believe people and places are made better by diversity.
I believe people shouldn’t be forced to abide by anyone else’s religion.
I believe non-American human beings have as much value as American ones.
I believe generosity is greater than greed, compassion better than contempt, and kindness superior to derision.
I believe there is enough in this world for everyone: enough food, enough money, enough room, enough care — if we unleash our creativity and unclench our fists.

I just noticed that some of the MySQL files on this website had grown very large, so I wanted to be able to list all of the files in the MySQL data directory and sort them by filesize, with the largest files shown at the end of the listing. This ls command did the trick, resulting in the output shown in the image:

ls -Slhr

The -S option is the key, telling the ls command to sort the file listing by size. The -h option tells ls to make the output human readable, and -r tells it to reverse the output, so in this case the largest files are shown at the end of the output.

'ls' command output sorted by filesize

When I originally saw the first image, I thought it was a “This would be nice in Scala 3 (Dotty)” idea. But then I found the “No parentheses in control structures” pull request shown in the second image. Here’s a link to that pull request.

Scala 3: No parentheses in control structures

From a friend on Facebook, this is a great way to look at the two possibilities about climate change:

  • If scientists are wrong, hey, we’ll have a cleaner world
  • If they’re right, we’re all dead

Your choice.

If climate change is wrong, at least we’ll have a cleaner world

I’ve been working with Flutter and Dart for several weeks now, and I was surprised to read several times that Dart is single-threaded, knowing that it has a concept of a Future (or futures) and async methods. Last night I read this excellent article about Dart’s event loop, which sums up Dart futures very nicely in that statement:

“the code of these Futures will be run as soon as the Event Loop has some time. This will give the user the feeling that things are being processed in parallel (while we now know it is not the case).”

Earlier in the article the author also states:

“An async method is NOT executed in parallel but following the regular sequence of events, handled by the Event Loop, too.”

So, in summary, Dart has a single-threaded event loop, and futures and async methods aren’t handled by a separate thread; they’re handled by the single-threaded event loop whenever it has nothing else to do.

I just wanted to note this here for myself today, but for many more details, please see that article, which also discusses Dart isolates, which are like a more primitive form of Akka actors.

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: