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

As a quick note, here’s an example of how to use the Kotlin sortedWith syntax with an anonymous function (lambda). Given this list of integers:

val list = listOf(7,3,5,9,1,3)

Here’s an example of how to use sortedWith using a Comparator and lambda:

“And when things got hard, you started looking for something to blame, like a big shadow. Let me tell you something you already know. The world ain’t all sunshine and rainbows. It’s a very mean and nasty place and I don’t care how tough you are, it will beat you to your knees and keep you there permanently if you let it. You, me, or nobody is gonna hit as hard as life. But it ain’t about how hard you hit. It’s about how hard you can get hit and keep moving forward. How much you can take and keep moving forward. That’s how winning is done.”

I enjoyed this quote from Rocky Balboa the first time I saw the movie, and I appreciate it even more now after getting my a** kicked by this f-ing blood disease, but still grinding along every day.

It's about how hard you can get hit and keep moving forward
Table of Contents1 - GET, POST, DELETE, and PUT examples2 - More POST examples3 - Headers returned by the server4 - Discussion5 - Summary

There may be better ways to do this, but as I’m writing a mobile app with the client written in Sencha Touch, and the server written with the Play Framework, I’ve written some curl scripts to simulate GET, POST, DELETE, and PUT request (method) calls to my Play Framework “RESTful” services.

Tomorrow (August 15th) is the last day in 2018 that the Sun will set after 10pm in Talkeetna, Alaska.

The last day the Sun sets after 10pm

Here’s a quick example of how to use the Kotlin groupBy syntax on a list, with the result of each example shown in the comments:

val names = listOf("kim", "julia", "jim", "hala")

names.groupBy { it -> it.length }  //LinkedHashMap: {3=[kim, jim], 5=[julia], 4=[hala]}
names.groupBy({it}, {it.length})   //LinkedHashMap: {kim=[3], julia=[5], jim=[3], hala=[4]}

Carlos Castaneda meets Denali: “Does this path have a heart?”

For me, the path that led me to Alaska had a heart. For others, that path may have no heart, but another path does.

Carlos Castaneda meets Denali: 'Does this path have a heart?'

Two good quotes about work this morning:

“The harder you work the less competition you’ll find.”
~ Shane Parrish

“There are no traffic jams along the extra mile.”
~ Roger Staubach.

Here's a brief message for married people stuck in lousy marriages. One thing I learned about marriage is that it’s about teamwork, and if one partner isn’t part of that team — or doesn’t appreciate the other person — it’s no marriage at all, it’s just two people sharing bank accounts and living quarters. I strongly believe that a marriage partner should be someone who builds you up, not one who tears you down.

(I was reminded of that when I saw this image on Facebook today.)

Better off being single

Motley Fool has an excellent collection of Jeff Bezos quotes going back to the 1990s.

If you open your mind for me
You won’t rely on open eyes to see
The walls you built within
Come tumbling down, and a new world will begin
Living twice at once you learn

You’re safe from pain in the dream domain
A soul set free to fly
A round trip journey in your head
Master of illusion, can you realize
Your dream’s alive, you can be the guide but

I will be watching over you
I am gonna help you see it through
I will protect you in the night
I am smiling next to you
(in Silent Lucidity)

(I’ve been having a crazy amount of lucid dreams lately, and as a result I can’t listen to this song loud enough.)

This page contains a large collection of examples of how to use the Scala Map class, including most of the methods that are available on a Vector. (Currently well over 100 examples.)

With the fireweed blooming in Alaska, summer will soon be yielding to fall and winter.

Fireweed blooming in Alaska (and winter coming)

Enjoyed Cowboys & Aliens at Wasilla’s fancy new stadium seating movie theater. How strange to walk out of a theater and into a valley of fireweed surrounded by misty mountains.

(A Facebook post from Wasilla, Alaska, August 9, 2011.)

Maybe the sun’s light will be dim
And it won’t matter anyhow
If morning’s echo says we’ve sinned
It was what I wanted now
And if we’re victims of the night
I won’t be blinded by the light.

~ Judy Kay “Juice” Newton, “Angel of the Morning

I’m a fan of Domata Peko of the Denver Broncos. This video helps to show why I like him, he seems like a bundle of happy energy, a real positive force. (There’s also that whole war battle thing, too.)

If you happen to walk down the right side street in Santa Fe, New Mexico, you’ll come across this Burro Alley painting on a wall.

Burro Alley painting (Santa Fe, New Mexico)

“And that’s one reason we like to believe in genius. It gives us an excuse for being lazy.”

~ Paul Graham, What You Wish You’d Known

Linux/Unix FAQ: Can you share some Linux find command examples?

Sure. The Unix/Linux find command is very powerful. It can search the entire filesystem to find files and directories according to the search criteria you specify. Besides using the find command to locate files, you can also execute other Linux commands (grep, mv, rm, etc.) on the files and directories you find, which makes find extremely powerful. 

Six weeks after colectomy surgery I’m able to eat some solid foods for the first time since October, 2017. I also hope to start practicing yoga again in a few weeks.

Table of Contents1 - macOS: crontab, launchd, and launchctl2 - Running a simple command every minute with Mac launchd3 - 1) Move to the $HOME/Library/LaunchAgents directory4 - 2) Create a Mac plist file to describe your job5 - 3) Tell MacOS about your Mac plist launchd file6 - 4) How Mac launchd works with system reboots7 - An important note about root and sudo access8 - MacOS launchd, launchctl, and plist resources9 - MacOS startup jobs: cron and crontab, launchd and launchctl

MacOS crontab FAQ: How do I run a Unix job (or shell script) through the MacOS crontab facility? I keep trying to edit my Mac crontab file, but my Mac won't save my crontab changes, or run my program.

Back to top

macOS: crontab, launchd, and launchctl

Way back when (~2012-2014), I found that the Mac crontab command was deprecated on MacOS, and the Apple documentation encouraged you to use their launchd facility. Here’s a blurb from Apple's crontab man page:

“Darwin note: Although cron(8) and crontab(5) are officially supported under Darwin, their functionality has been absorbed into launchd(8), which provides a more flexible way of automatically executing commands. See launchctl(1) for more information.”