Scala, Java, Unix, MacOS tutorials (page 287)

The MySQL “Sakila” sample database can be helpful when you want to test a new application framework, or write a blog post, or book.

(This article is an excerpt from the 1st Edition of the Scala Cookbook.)

To put what you’ve learned in this chapter to use, let’s create two examples:

  1. First, you’ll create a timer method that looks like a Scala control structure, and works like the Unix time command.
  2. Second, you’ll create another control structure that works like the Try/Success/Failure classes that were included with Scala 2.10.

Example 1: Creating a Scala Timer

On Unix systems you can run a time command (timex on some systems) to see how long commands take to execute:

$ time find . -name "*.scala"

After watching a replay of a Chicago Cubs' game recently I noticed the clock over the scoreboard:

After seeing that, I thought, “How cool would it be to have a clock like that at home?” After a quick search I found that someone on Cafepress already had the same idea, but a poor design:

This is a great example of using pattern matching in a Scala for expression. It’s from one of the Typesafe Coursera courses; sorry, I don’t remember which one.

Google software development information, from this Twitter link.

Life of late has me interested in how the human heart works. The two diagrams below help show the process. First, this one from WebMD:

Next, this one from the Mayo Clinic:

I don’t eat meat very often, but when I do, I make my own Buffalo-style chicken, and toss some in a mixed-green salad.

A nice graphic on the use of open source tools on the internet.

If there’s something you like to do, but maybe you’re not good at it right now, keep at it, you’ll get better! This recipe worked well for Bill Nye and many others. Remember the lesson from Blink: When it comes to growing and learning, quantity > quality. (Image from the loop.)

More Pi Day humor. :)

In honor of Pi Day. :)

(This is a story from my book, A Survival Guide For New Consultants.)

Your attitude is such an important topic, I want to end this book by getting you to look at yourself the way other people see you.

The people who run the Free Spirit Siberian Husky Rescue page on Facebook keep hitting home runs with their posts. If you ever had a Siberian Husky, you’ve seen this face before.

Problem: You want to use an enumeration (a set of named values that act as constants) in your Scala application.

Solution

Extend the scala.Enumeration class to create your enumeration:

package com.acme.app {

    object Margin extends Enumeration {
        type Margin = Value
        val TOP, BOTTOM, LEFT, RIGHT = Value
    }

}

Then import the enumeration to use it in your application:

A long time ago -- 1991 to be exact -- a friend of mine named Joe was a contractor for the aerospace company I worked at. Just like a consultant, Joe was paid by the hour.

At some point Joe decided he was going to leave that company to take a permanent job elsewhere, as he had a medical problem and wanted to get better insurance. Upon telling my employer of his plans, the employer came back and said, “What if we make you a full-time employee here?”