Making your Scala code more concise (and your intent more clear)

I was trying to write some code last night while I was very tired, and while the code itself isn't difficult in any way, the thought process I went through demonstrates how your code can become more concise as your understanding of Scala evolves, so I thought I'd share the experience here.

While working on my Sarah application, I was rewriting the Brain class, and I started off writing a method that looked like this:

How to improve iPad battery life

iPad battery life FAQ: Do you have any tips on how to improve my iPad battery life?

Yes, it turns out you can do a number of things to improve your iPad battery life. Here's a quick list of the best "iPad battery life" tips I know.

1) iPad battery life tip - Drain the battery monthly

I learned this first battery life tip by digging through the Apple website. They specifically mention that you can improve your battery life by draining your iPad battery completely every month. Here's their quote:

Improve your MacBook battery life (2011 edition)

MacBook battery life FAQ: How can I improve my MacBook battery life (or MacBook Pro or MacBook Air battery life)?

I've written about MacBook battery life before (see the links below), but with a new MacBook Air, I've become increasingly interested in MacBook battery life. I just did some more battery life research on the Apple website, and here's what I found.

MacBook battery life claims reduced by Apple

MacBook battery life news (March, 2011): As I was returning from vacation today, I decided to stop at Best Buy to look at Apple's new MacBook Pro models, as well as their MacBook Air. I've been thinking about buying a MacBook Air or Pro for the last few weeks, but what hit me today when looking at these models is that Apple's MacBook battery life claims have suddenly been reduced by 3-5 hours.

How to improve iPhone battery life

iPhone battery life FAQ: Do you have any tips on how to improve my iPhone battery life (or iPod battery life)?

Yes, it turns out you can do a number of things to improve your iPhone battery life, and I thought I'd share what I've learned here.

Ways to improve your brain power

Recently I wrote an article about using meditation to improve your concentration and brain power. Today I'd like to briefly outline a few other ways you can help improve your brainpower.

Use your off hand

You've probably heard about this already, but if you're right-handed, learn to use your left hand. Brush your teeth with your other hand, write with your other hand, basically reverse everything in your life as your hands go. You'll be amazed at the difference.

A MySQL database table index example

MySQL FAQ: How do I create a MySQL database table index?

Here's an example of how to create an index on a MySQL database table. In this particular example my table uses the MySQL InnoDB database engine, but that doesn't matter too much -- it just happens to be a MySQL database engine that supports foreign key relationships.

To get started, here's the SQL definition of a MySQL table I've named ftp_files: