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

As shown in the image, the project known as Dotty will be Scala 3.0.

Dotty will become Scala 3.0

It’s kind of neat when you get royalty checks in multiple currencies. :)

(But one drawback to receiving physical checks is that most tellers here don’t know what to do with them. Each time I’ve received checks in foreign currencies it’s taken 15-30 minutes to deposit them at the local bank.)

Royalty checks in multiple currencies

This is a good quote from the tv series, Hart of Dixie. I remember when I thought about selling my business I knew I might regret it, but I also knew that I was sick with something and doctors couldn’t figure out what it was. So I decided to sell the business and move to Alaska, and that was one of the best decisions of my life. I got to experience things that won’t even be possible to experience in the future because roads are being paved, civilization keeps encroaching on nature, and global warming is melting the glaciers and polar bears into extinction. In retrospect I’d make that decision 100 times out of 100.

A life without regret ain't worth living

I like both parts of this tweet. I try to help other people where I can, but in the end you can’t take responsibility for what the other person does or doesn’t do.

Peace requires us to surrend our illusions of control

I just bought a bunch of MP3 music files from Amazon, and when I downloaded the zip file they provide onto my Mac, it was a bunch of files in a bunch of subdirectories; not really convenient to work with when you’re trying to import them into iTunes. So I used this Unix find command to move all of the music files from the subdirectories they were scattered in into the root directory that was created when I expanded the zip file:

cd Amazon-Music-Folder
find . -type f -exec mv {} . \;

If you ever need to either copy or move a bunch of files with a single command, I hope this example shows the correct find command syntax for your needs. (If you need to copy the files, use the cp command instead of the mv command.)

Table of Contents1 - Anorm2 - More background ...3 - A note about my coding style4 - SQL SELECT queries5 - A brief intermission6 - SQL INSERT with primary key (auto increment)7 - SQL INSERT with no primary key8 - SQL UPDATE9 - SQL DELETE10 - Complete example methods11 - A complete class12 - More information

In general the online Play Framework documentation is excellent, but one area where I needed more help was in seeing more examples of the Anorm syntax. To that end, here are some Anorm query examples, taken from a Play Framework application I worked on recently. But first, a little background about Anorm.

One thing I never thought about before is that if you need to get multiple, unique, random elements from a list of elements, one solution to the problem is to shuffle the list and then take as many elements as you want/need. For instance, if you want three unique, random elements from a list of integers in Scala, you can do this:

scala> val list = List(1,2,3,4,5,1,2,3,4,5)
list: List[Int] = List(1, 2, 3, 4, 5, 1, 2, 3, 4, 5)

scala> val uniq = list.distinct
uniq: List[Int] = List(1, 2, 3, 4, 5)

scala> val shuffled = scala.util.Random.shuffle(uniq)
shuffled: List[Int] = List(1, 4, 5, 2, 3)

scala> val firstThree = shuffled.take(3)
firstThree: List[Int] = List(1, 4, 5)

As that solution shows, you start with a simple list; get the unique/distinct elements from the list; shuffle those elements to create a new list; then take the first three elements from the shuffled list. That’s probably not a great solution for huge lists, but for many simple lists it’s a way to get multiple random elements from the list.

I’m not sure why, but on April 3, 2018, the people behind the Mollom anti-spam module for Drupal basically went out of business. This meant that I either had to disable comments on this site (which I did for a while), or look at other anti-spam modules, which I did over the weekend.

Drupal 8 - enabling anti-spam modules is bad for performance

While this photo looks like a sunset, it was actually a sunrise. I took it in Virginia Beach on April 17, 2017.

Dark sunrise, Virginia Beach

“Do I look like a guy who needs hookers?” is going right between “We choose to go to the moon...” and “Mr. Gorbachev, tear down this wall” in my list of great presidential quotes.

If you’re interested in learning about “pay for written content” models, Medium has an article titled, The Medium Model
How we are building a system for high-quality publishing at scale

Every year about this time I have to fight the urge to move back to Alaska. If you ever happen to drive up there you might come across this “North to Alaska” sign.

North to Alaska sign

I don’t put too many photos of myself out here, but this is me escaping from the hospital one day.

Alvin Alexander, Colorado

Scala date FAQ: How do I determine the day of the year in Scala?

Solution: Use the Java Calendar class, as shown here:

scala> import java.util.Calendar
import java.util.Calendar

scala> Calendar.getInstance.get(Calendar.DAY_OF_YEAR)
res0: Int = 104

I’m writing this on April 14, 2018, which is the 104th day of the year.

“I’ve failed over and over again in my life, and that is why I succeed.” ~ Michael Jordan

Table of Contents1 - Resources2 - A custom user authentication action3 - Use that action in your controller methods4 - A sample form5 - Setting the user login cookie6 - Discussion

This past week I started working with the Play Framework (version 2.6), and this is a quick look at how to implement user authentication in a Play application. Specifically this blog post focuses on how to create a custom action so you can secure your Play controllers methods, where you’ll implement those methods using this new, custom action.

One summer morning back when I lived in Talkeetna, Alaska, I had to leave my little cabin at 5am to be at the Toyota dealer in Anchorage by 7am so they could try to figure out why my RAV4 kept filling up with water every time it rained. Since it was summer, the sunlight at 5am was pretty much the same as it was at noon, which was always cool.

About twenty seconds after driving down the main road out of town — actually there’s only one road in and out of town, so it’s hardly worth referring to it as the “main road” — I came across a woman in a white dress walking on the lane divider stripes in the middle of the road, in the same direction I was driving.

I was reminded of that morning when I heard the song Chevy Van by Sammy Johns just now.

Mark Zuckerberg is now living out every young person’s worth nightmare: Trying to explain how tech stuff works to the nation’s elderly.

~ someone on twitter yesterday