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

When you want to create Play Framework template comments, use the @* ... *@ syntax.

Single line Play Framework comment

Here's a one-line Play Framework comment:

@* COMMENT *@

Multi-line Play comment

Here's a multi-line Play comment:

@*
 * Four score
 * and seven year ago
 * our fathers ...
 *@

MySQL/MariaDB FAQ: What is the MySQL create table syntax?

MySQL “create table” syntax/example

Here’s a quick example of the MySQL create table syntax on a database table named users:

drop table if exists users;

create table users (
    id int auto_increment not null,
    username varchar(32) not null,
    password varchar(16) not null,
    primary key (id),
    constraint unique index idx_users_unique (username)
) ENGINE = InnoDB;

If you need more examples of the MySQL create table syntax, or examples of the MySQL unique constraint syntax, check out my MySQL Nagios database design. It includes many database tables, and as a result, it covers examples of many MySQL/MariaDB features.

A scene from a blizzard in Alaska. This was at the fairgrounds in Palmer, Alaska, October 8, 2012. (I lived about a mile from this location in 2011.)

Just a quick note today that now that this website has my name on it (no longer devdaily.com), I'm adding a photo gallery to the site. You can either click on that link to see the gallery, or click the photo below:

Welcome to Talkeetna sign

Enjoy!

In his book, Beginning Scala, David Pollak provides a series of statements that can be considered as a recipe for avoiding the use of null values in your Scala code. I've organized his statements here in the following three sections.

1) General rules about null and Option

We begin with the following general rules regarding the use of null values in Scala code:

A week ago or so, a friend of mine told me about a game called Mindflex where you can use your brain waves to control a styrofoam ball. Ever since then, I've been wondering if you could do something like this with an Arduino.

This video shows an attempt at doing that:

Here's a link to that video:

Way back in late 1998 (think "before Google"), I started devdaily.com in the hope that it would one day grow into a website where authors would offer tips and tutorials for Java, Perl, C, C++, Linux, and any other open source programming language and technology that came along. Then in 1999 I started a company named Mission Data, and I put the dream of devdaily aside.

If you ever want to have a little fun with Scala, try experimenting with the Scala parallel collections. The following example gives you a little idea of what can happen in the most simple case of creating and using a parallel collection:

Summary: This post is a discussion of the “Option/Some/None Pattern” in Scala, specifically how to use the Either/Left/Right data types instead of Option when you need to know the reason some code failed. As you may know, the None data type does not return failure/exception information, but if you use the Either/Left/Right types, you can access that failure information through the Left type.

The post is sponsored by my book, the 2nd Edition of the Scala Cookbook.

I found a little bit of good news in the mailbox this morning, a little royalty check from the Amazon Kindle eBook publishing program:

The check wasn't for much, but hey, it's a start. If you're new to my website, the check is for my two Kindle eBooks, shown below:

I can never remember the name "unfiltered", so yesterday I kept trying to google for "web service framework", and to my surprise, Google wasn't showing unfiltered. In fact, it didn't show other tools like Scalatra, though it did show Play in the top ten.

So today's post is an effort to help Google out a little bit here. If you're looking for good Scala web service frameworks, check out these tools:

Summary: A look at iPad base stands.

For a while now I've been interested in finding an iPad stand that I can use in my kitchen. The idea is simple: If you're cooking something healthy, it takes a little time, so I'd like to be able to put my iPad in a stand and listen to Pandora or a show on Netflix while I'm cooking, or cleaning the dishes.

Scala SBT FAQ: How do I put SBT into offline mode so I can use it while working on an airplane, or any other location where I don't have a WiFi connection?

Use an SBT command like this to compile and run a project from your operating system command line:

$ sbt "set offline := true" run

I used this command a lot recently when I didn't have internet access, and I had to keep SBT from trying to reach out to the internet all the time.

I'm not going to take any time to describe the following Scala XML/XPath example, other than to say that when it's run, it produces the following output, which is a simulated receipt for an order at a pizza store:

I was doing a little Scala programming this morning, and because I hadn't written any code in a while, I managed to forget how isInstanceOf works with inheritance in Scala.

To refresh my memory, I wrote the following example code:

(The following content is from an email I sent to a relative about the Arduino. They have a college-age student who we might be interested in this.)

The programmable electronics kit I showed you is named "Arduino". Here's the main URL: arduino.cc

Here are links to some fun Arduino projects:

If you ever need to write some Scala (or Java) code where you add a JSON string to the body of an HTTP POST request, here's a quick example of how to do it using the Apache HttpClient library methods:

My original "Day 1 with Play web services" code is shown a few paragraphs below, but on Day 2, the following code looks like an easier solution to the problem, courtesy of this web page:

I just started using tmux last week, and created a cheat sheet to help me remember the basic tmux commands, and I thought I'd share that here.

The cheat sheet has a few things that are specific to my configuration file, so to begin with, here is my ~/.tmux.conf file:

As a note to self, I'm just recovering from a nasty case of food poisoning.

It all started with some gurgling in my stomach on August 12, 2012, so I tried to eat light that day, though I did exercise pretty hard.

On Monday morning I knew something was very wrong, and by that afternoon I was full blown sick. I quit eating that day, and didn't eat again until I had three saltine crackers on Thursday.