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

“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

If you ever need to include multiple Play Framework 2.6 validators for a template form field, the uri field below shows the syntax that worked for me:

“You are neither right nor wrong because the crowd disagrees with you. You are right because the data and reasoning are right.”

~ Benjamin Graham

“Deliver to the world what you would buy if you were on the other end.”

~ Charlie Munger

Table of Contents1 - Define the routes2 - Create a controller3 - Create the template/form4 - What the form looks like5 - Play form input helpers6 - Form resources

If you’d like an example of how to create a data entry form using the Play Framework v2.6, here’s a complete example.

“Warren Buffett has become one hell of a lot better investor since the day I met him, and so have I. If we had been frozen at any given stage with the knowledge we had, the record would have been much worse than it is today. So the game is to keep learning, and I don’t think people are going to keep learning who don’t like the learning process. You need to like the learning process.”

This is another quote by Charlie Munger. It reminds me both of working on good programming teams, but also of learning from people that I haven’t enjoyed working with, but learned things from.

A Scala substring example: I ran into a situation today where I wanted to get a string after the Nth occurrence of another string, in this case after the 6th occurrence of a “:” character. There are probably many ways to determine the Nth occurrence of a string in another string, but as a quick example, this is what I did.

First, I started with this string:

“Terribly smart people make totally bonkers mistakes.”

~ from the book, Charlie Munger, The Complete Investor

“In engineering, people have a big margin of safety. But in the financial (investing) world, people don’t give a damn about safety.”

~ from the book, Charlie Munger, The Complete Investor

As I wrote last week, I got tired of dealing with Drupal 6 (D6) security update issues — especially since D6 is no longer officially supported and the last unofficial D6 security update made my websites unusable — so I wrote a Play Framework (Scala) application to display my D6 database tables data.

It’s still a work in progress, but as you can see from this page on my One Man’s Alaska website, it’s coming along. As far as visitors of the website are concerned, mostly only thing the website needs is some CSS styling and maybe a search field. (I could also add support for comments and a contact page, but my D6 websites are old, and I don’t need/want those things. I probably also won’t put any effort into supporting 10-20 custom “category” URIs I used back in the day.)

As for the specific page I linked to on the One Man’s Alaska website, that’s a favorite memory of getting ready to winterize the car in October, 2010, when I lived in the Wasilla/Palmer area.

I’m reminded of this story today:

Back in 2005 I used to walk over to a bar that was across the street from my apartment. One night I was talking to a waitress and wondered out loud whether I’d be happier working a job that I enjoyed that might only pay $30K to $40K per year — as opposed to my current job, which paid a lot more but wasn’t making me happy.

She said, “Don’t look at me honey, I don’t make that kind of money,” then turned and walked away.

The image shows a couple of good quotes from Niels Bohr about quantum mechanics. I like this one as well:

An expert is a person who has made all the mistakes that can be made in a very narrow field.

Niels Bohr on quantum mechanics

I also ran across an old business card this morning. I didn’t remember that our address was, “1 NASA Drive”, that’s cool. The blurry stuff in the upper-left says, “Gencorp Aerojet”.

“I believe the key to self-sufficiency is breaking free of the mindset that someone, somewhere, owes you something and will come to your rescue.”

“Self-sufficiency,” wrote Epicurus, “is the greatest of all wealth.” Epictetus added that “wealth consists not in having great possessions, but in having few wants.”

~ two quotes from this Farnam Street blog post

“If somebody is a problem for you, it’s not that they should change, it’s that you need to change. If they’re a problem for themselves that’s their karma; if they’re causing you trouble that’s your problem with yourself.”

and also this:

“If I’m not appreciated, that’s your problem that you don’t appreciate me. Unless I need your love, then it’s my problem. So my needs are what is giving you the power over me.”

~ from Ram Dass post, A Heavy Curriculum

In my own experience I can say that when you’re with your soul this is true; and when you’re with your ego you can’t understand this.