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

Here’s a small example of how to create a Factory Pattern in Scala. In the Scala Cookbook I created what some people might call a simple factory and/or static factory, so the following code is a much better implementation of a true OOP Factory Pattern.

The factory classes

I don’t have too much time to explain the code today, but here are the classes that make up the factory, including a set of “animal” classes along with a DogFactory and CatFactory that extend an AnimalFactory trait:

This 18-second Twitter video shows what you get when you mix a cookie monster with a Siberian Husky.

Canadian street gangs will mess you up.

Canadian street gangs will mess you up

On the ice-blue line of insanity
Is a place most never see
It’s a hard-won place of mystery
Touch it, but can’t hold it

You work all your life for that moment in time
It could come or pass you by
It’s a push-shove world
But there’s always a chance
If the hunger stays the night

It can cut you like a knife
If the gift becomes the fire
On a wire between will and what will be

~ Michael Sembello

“To know love, be like the running brook, which deaf, yet sings its melody for others to hear. Feel the pain of too much tenderness. Wake at dawn with a winged heart and give thanks for yet another day of loving.”

~ Kung Fu

“Having a direct experience of seeing everything one looks at (including one’s own body) as moving subatomic particles alters the perception of ‘me’ and of the substantiality of what we regard as ‘normal’ reality.”

(I can’t remember where I saw this quote, but I think it had to do with some sort of system that you could walk into and see your body as moving subatomic particles.)

One thing that’s overlooked with Trevor Bauer throwing the ball over the center field fence when he was mad is that he threw it over 340 feet — more than the length of a football field.

Trevor Bauer throws a baseball at least 340 feet

“Effort takes no talent.”

~ Orlando Franklin, former Denver Broncos player

Mike (Pastor/Lawyer): Why’d you want to see me?

Sam (Prisoner): Papa told me you were a spiritual man, and that we need to help each other.

Mike: Help each other? Well ... you’re the one in jail.

Sam: [laughs] Well, there’s all kinds of jails. One of the worst is the prison of wrong thoughts. I was locked up there for many years until I found the key and opened the door.

(from the movie Mountain Top)

Remember when we was on ice skates,
And I thought you was supposed to be great,
So I kept giving you lip,
And you kept trying to slip,
So I could catch you.

That was our first date,
And after that,
Every day was great.

So now I want you to know,
That wherever you go,
Atlantic City or in the snow,
Don’t worry about a thing,
’cause as long as I got this ring,
I’ll always be there to catch you.

~ Rocky’s poem to Adrian in Rocky II

I’m working on a small project to parse large Apache access log files, with the file this week weighing in at 9.2 GB and 33,444,922 lines. So I gave myself 90 minutes to try a few different ways to write a simple “line count” program in Scala. (Not my final goal, but something I could use to measure file-reading speed without applying my algorithm.)

July 28, 2010, Wasilla, Alaska: Bundled up in a semi-rainproof jacket and hat, I just returned from a walk in the cold November rain. Most neighbor's fireplaces were in full use, while one man in a jacket and shorts and smoking a cigarette was mowing his weeds with his lawnmower. Hard to believe, Denali National Park closes for the winter in just over six weeks.

A lot of people seem to create/self-inflict a lot of stress in their own lives, and that’s based on how they perceive situations. In that regard I like this quote by Broncos backup quarterback Kevin Hogan:

“Control what I can control and move on from there.”

Dateline: July 27, 2010, Wasilla, Alaska.

“It looks like she passed away around 4:30,” Al said, holding his neighbor’s just-deceased cat, and looking at the clock on the wall.

“No,” Neighbor #1 replies, wiping her eyes with her kleenex. “That clock doesn’t work. It’s almost 8:30.”

“Oh,” says Al, looking out the window of the second-floor apartment and seeing what appears to be afternoon light in the treetops. Funny how the Alaskan summer sun still throws the perception of time out of balance.

“Can you give us a ride to the hospital? My wife just cut her finger open,” yells unemployed car-less Neighbor #2, suddenly appearing at the open front door. His wife screams from somewhere down below. Neighbor #3, a former police deputy, instinctively gets up to help, but Neighbor #4 says, “I’ve got this one,” and hops off the couch and out the door behind #2. He looks comfortable in his shorts and t-shirt in the mid-40s temperature, as Al shivers.

As they run out the door, Neighbor #5, just home from her job at Carr’s, stands in the doorway, looks around, sees three neighbors and a dead cat in the apartment next to hers, and doesn’t seem to know what she should say or do ...

Some time ago I was at a party, and there was a woman there that I didn’t know, but I felt like I knew her. It was a strange feeling, kind of like deja vu, but it had nothing to do with this party, just the feeling that I knew this woman. Maybe I had seen somewhere before, but I couldn’t place it.

When that thought first came to me I was talking to some other people, so I shrugged it off for the time being. It was relatively early and I figured we’d meet soon enough. A little while later a trash can became full, so I took the bag out of the can and walked it to a garbage can outside by the detached garage. After I put the bag in the can outside I turned around, only to be startled to see the woman standing there.

“How do I know you,” she asked.

In case you were worried about Luke falling in The Empire Strikes Back. (From this collection of 66 behind the scenes photos.)

In case you were worried about Luke Skywalker falling

“My current advice to everyone is this: fall in love with your life. Pursue the things that bring you joy. Let go of things that don’t. Know the difference.”

~ Edie Freedman, Creative Director at O’Reilly Media

“I realize that most inventions fail not because the R&D department can’t get them to work, but because the timing is wrong‍ — not all of the enabling factors are at play where they are needed. Inventing is a lot like surfing: you have to anticipate and catch the wave at just the right moment.”

~ Ray Kurzweil