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

“How to write ‘Hello, world’ in Haskell.” This was even more humorous this morning when I saw it shared on Twitter by someone who is recruiting Haskell developers.

How to write 'Hello, world' in Haskell

A funny thing about life is that the worst video I’ve ever made (about the vi/vim editor) now has over 175,000 views.

Every once in a while I have a dream where someone is speaking in a language I don’t understand. This morning a woman said something that sounded like, “Yada yada yada Thich Nhat Hanh yada yada.”

I replied, “I’m sorry, I don’t know what you’re saying, but I think I heard ‘Thich Nhat Hanh’ in there.”

She got excited and seemed to repeat the same phrase faster, “Yada yada yada Thich Nhat Hanh yada yada!”

Being clever, I decided to speak very slowly: “I .. don’t .. know .. what .. you’re .. saying, but it sounds like it might be in French.”

Her: “Français?! Oui. Yada yada yada Thich Nhat Hanh yada yada!”

Unfortunately I then had the familiar feeling that I was about to be pulled away from the scene. She had been speaking with her hands a lot, so I held her hands with mine and said, “Something is wrong with my body, I have to go now. Come back again and we’ll try to figure this out,” and with a little “whoosh” I woke up in bed.

(A Facebook post from June 13, 2016.)

This is a sample .gitignore file that I use for Scala SBT projects:

architecht.io has this interesting interview with Bradford Cross on AI and startup businesses. I don’t know much about AI, but from my experience with it, I’m sure that you want to “own” the data.

Bradford Cross on AI and startups

“A little progress every day can add up to big results.”

(Think of the proverbial snowball rolling down a mountain.)

If you add ScalaCheck to an SBT project like this:

libraryDependencies += "org.scalacheck" %% "scalacheck" % "1.13.4" % "test"

it’s only available in the SBT “test” scope. This means that when you start a Scala REPL session inside of SBT with its console command, the ScalaCheck library won’t be available in that scope.

To use ScalaCheck with the SBT console (REPL), don’t use its console command — use test:console instead. A complete example looks like this:

$ sbt

> test:console

scala> import org.scalacheck.Gen.choose

Note that after you type test:console your project may be compiled, so that step may take a few moments.

In summary, use SBT’s console command to start a “normal” Scala REPL inside SBT, and use test:console to start a REPL that you can run tests inside of. (Note that this same advice also applies to using ScalaTest or specs2.)

“Even when I was just three years old, I could recall many previous lives. But to many people this sort of thinking isn’t acceptable, so now when I’m asked what I can remember, I just say ‘I remember when I was three years old.’”

~ a monk

When I meet people who seem stressed out (stress/anxiety/worrying), I try to encourage them to practice mindfulness meditation or yoga. I find both of those practices to be a wonderful way to quiet the thoughts in the mind. It may help to know that the basic practices are 100% non-religious, and both help to teach you how to breathe properly. (I recently learned that people who are anxious typically breathe in their chest, which is the wrong way to breathe. You want to learn to breathe in your lower abdomen.)

Personally, I enjoy living in the present moment, without thoughts about the past or future. I used to be an angry young man, and using these practices to calm my mind has made my life happier and more productive. A couple of times a year I still lose it, but these practices always help to re-quiet my mind.

(I think the image shown was created by Gemma Correll.)

Practicing mindfulness meditation and yoga to calm the mind

“I suffered, I learned, I changed.” I found this image on this Pinterest page, and it reminds me of the learning process in general, but mostly of learning about our own minds, feelings, and emotions.

I suffered, I learned, I changed

To me, a lot of Buddhist teachings are based on logic. Today I particularly like this quote from this LionsRoar.com article titled, Silencing the Inner Critic: “The judging mind is optional; it can be understood and released.”

It always amazes me how the brain works. I got to hear these lyrics from the Alanis Morissette song, Thank U, in a dream last night:

How bout no longer being masochistic
How bout remembering your divinity

“President’s spokesman can’t speak for the President.” *sigh*

President’s spokesman can’t speak for the President

If you happen to be looking for the free, HTML version of my book on Scala and functional programming, I’m currently in the process of moving it to this website. That way you (and I) can search it more easily, along with several hundred other pages I’ve written about programming in Scala. The first page of the content is available here: Learning Functional Programming in Scala.

On the same day the president of the United States decided to ignore that whole science thing and opt out of the Paris Agreement, a gigantic iceberg the size of Delaware is about to break off from one of the largest ice shelves in Antartica.

I was having a metaphor in a dream this morning and I had to stop it and say, “Really? Aren’t we past this point by now? Pfft.”

(A note from June 1, 2014)

Here’s a link to a page by James Earl Douglas that I don’t quite understand yet, but also don’t want to forget. Here’s his intro to the problem, and then the image shows his solution.

Problem: You have a mutable variable (a var in Scala) that is both read from and written to outside of a tightly-scoped block.

Solution: Remodel the block as functions that take an initial value of the variable, and return both the final value of the variable and the original return value of the expression.

Joining multiple StateRefs together in a 'for' expression

This article titled, Little things I like to do with git, has a fun series of git commands.

Fun git commands

Here’s a cool tip: if you want to search for a text string in all fields of all tables of a MySQL database, you can use phpMyAdmin to do this very easily. Here are the steps to search every MySQL/MariaDB database table.

1) Select the desired database

The first step is to select the database you want to search. Don’t select a table — just select the database you want to search. (If you select a table you’ll get a different search form in Step 2.)