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

Makezine.com has a little article on Google’s AIY kits (DIY machine learning kits), including their Voice and Vision AI kits being for sale at Target. Google also has a terrific page that shows how to put the Voice kit together.

If you’re into Star Wars, ThinkGeek has a big “May The Fourth” sale going on.

May the Fourth sale

Here’s a great 1999 interview with Jeff Bezos on YouTube. And here’s a transcript of an interview with James Comey, where he says, “so much of what I’ve tried to do as a leader is guardrail around what I think my weaknesses are. Really important to me that I avoid the danger — which I think all humans have, but I know I have — of falling in love with my own view of things, my own righteousness.”

“The new basic principle is that in order to learn to avoid making mistakes, we must learn from our mistakes. To cover up mistakes is, therefore, the greatest intellectual sin.”

~ Karl Popper (a quote from Farnam Street Blog)

If you happen to need Scala method to perform an MD5 hash on a string, here you go:

def md5HashString(s: String): String = {
    import java.security.MessageDigest
    import java.math.BigInteger
    val md = MessageDigest.getInstance("MD5")
    val digest = md.digest(s.getBytes)
    val bigInt = new BigInteger(1,digest)
    val hashedString = bigInt.toString(16)
    hashedString
}

In case you’re worried about artificial intelligence (AI), there’s this:

Me: Alexa, cancel the current timer.

Alexa: I don’t have a timer called “current,” but there is one called “Fifteen minute timer.”

Me: *sigh*

If you need to handle a unique constraint in a database table field when writing an add or edit process in a Play Framework application, I hope this example will be helpful. In the end I’ll show:

I don’t take too many photos of traffic intersections, but this is a favorite view of Boulder, Colorado and the Rocky Mountains. In this image I am on South Boulder Road, with the city of Boulder directly ahead.

A favorite view of Boulder, Colorado and the Rocky Mountains
Table of Contents1 - Solution2 - Example data3 - Append a single item4 - Append multiple elements5 - Prepend a single item6 - Prepend multiple elements7 - Seq works just like Vector8 - How to remember the method names9 - A possible problem

Scala FAQ: How do I append or prepend one or more elements to a Vector or Seq class?

Back to top

Solution

To append or prepend one or more elements to a Vector or Seq, use these methods:

Dear Amazon: You’re taking quite a chance raising the rate for an Amazon Prime membership again. I don’t like the Echo Dot, I really don’t like the Amazon Fire TV stick, and I can easily do without your video and music services. I’m just in it for the “free” shipping, and at $119/year that’s not much savings, if any.

Wow, in the last 48 hours Twitter, GoDaddy, Etsy, and other websites/businesses have sent me emails saying that their privacy policies have changed. The stuff Facebook has gone through (or created, depending on your perspective) seem to be having a rapid ripple effect on the industry.

On April 22, 2018, the Mosaic web browser — the internet’s first major web browser — turned 25 years old. And I’m old enough to remember using it. (Image from this tweet.)

The Mosaic web browser turned 25

As a quick note, here’s a Java method that will round a float to the nearest half value, such as 1.0, 1.5, 2.0, 2.5, etc.:

/**
 * converts as follows:
 * 1.1  -> 1.0
 * 1.3  -> 1.5
 * 2.1  -> 2.0
 * 2.25 -> 2.5
 */
public static float roundToHalf(float f) {
    return Math.round(f * 2) / 2.0f;
}

The comments show how this function converts the example float values to their nearest half value, so I won’t add any more details here. I don’t remember the origin of this algorithm — I just found it in some old code, thought it was clever, and thought I’d share it here.

From a recent email:

Paraprosdokians are figures of speech in which the latter part of a sentence or phrase is surprising or unexpected; frequently humorous. Winston Churchill loved them.
 
1. Where there's a will, I want to be in it.
2. The last thing I want to do is hurt you. But it's still on my list.
3. Since light travels faster than sound, some people appear bright until you hear them speak.
more ...

“Complaining is not a strategy. You have to work with the world as you find it, not as you would have it be.”

~ Jeff Bezos

If you struggle to learn new things, check out this podcast interview with Barbara Oakley. A few years ago I read her book, A Mind for Numbers: How to Excel at Math and Science (Even If You Flunked Algebra), and it was helpful to me, and even influenced my book, Functional Programming, Simplified.

As I noted five days ago, Mollom went out of business so I had to switch this Drupal 8 website to use a different module to control comment spam. I ended up adding two modules that work together, but the side effect of using their best features is that they end up disabling Drupal 8 page caching. This image clearly shows the result that disabling page caching has on CPU use.

Disabling Drupal 8 page caching significantly increases CPU use

“People have a voracious appetite for a better way, and yesterday’s ‘wow’ quickly becomes today’s ‘ordinary.’”

~ Jeff Bezos, Amazon, in his 2017 (2018?) letter to shareholders

In a slightly related note I find that work is easier when you have the attitude that what you’re working on is constantly changing, constantly evolving. If one day you think, “There it is, Product 1.0, I’m done,” you’ll find it mentally hard to come into the office tomorrow to work on the same product. The only constant is change, and if you accept that your job is to be in that process of change, life and work are easier.

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