Saturday, October 15, 2011

Microsoft Word: Disabling spellcheck for a block of text

Often times, when I'm putting together a piece of documentation for work, it helps to include code samples and console commands in the document. I like to use Word to write documentation because it allows you to stylize the text (such as increasing the font size of headers, making things bold, etc) which I think makes it easier to read (when used in moderation). It's also nice for code samples because when you copy and paste code from Eclipse, it includes the syntax-highlighting of the code. Creating plain text files is simpler, but you loose that readability aspect I think is important.

Anyway, one annoying thing is that Word spell checks and grammar checks these code samples and console commands, so you get all these red and green squiggly lines under the text.

However, it is possible to disable spell and grammar check for selected blocks of text! First, select the text that you want to exclude from being checked. Then, select the "Review" tab from the ribbon at the top of the screen and click on "Set Language".

In the dialog window that appears, click the "Do not check spelling and grammar" checkbox and click "OK". If your document happens to have multiple written languages in it, you can also use this dialog to tell Word which blocks of text are written in which language.

Now, those squiggly lines should disappear!

Saturday, October 8, 2011

Book Review: Play Framework Cookbook

Play Framework Cookbook is divided into seven chapters, each of which contains a dozen or so recipes. The recipes range in skill level from beginner to advanced and are pretty much organized in this order, with the more basic recipes at the start of the book and the more advanced ones at the end. Some examples of the more basic recipes include "Defining your own controllers" and "Basics of caching". Advanced topics include "Understanding bytecode enhancement" and "Implementing your own persistence layer". Nearly all of the recipes are self-contained so you don't have to read the book from start to finish--you can jump around at your leasure and read whatever looks interesting to you.

Each recipe is usually divided into four sections. "Getting Ready" describes how to prepare your development environment for the recipe. "How to do it..." covers the steps you have to take to complete the recipe, like what code you have to write. A detailed explaination of those steps can be found in the next section, "How it works...". The last section, "There's more..." (what's with all the ellipses?), contains supplemental information on how to improve upon the recipe and broaden its scope. I like the way the author divided each recipe this way because it makes it easier to find what you're looking for. For example, if I'm in the midst of coding something and need to refresh my memory about a particular method call or class name, I can jump right to the "How to do it..." section and not have to wade through a lot of text to find what I'm looking for.

I would say that the only prerequisite of the book is that you know how to program in Java, though having basic knowledge of Play beforehand will help. The Forward contains an informative overview that describes where Play fits into wider the Java web application world and how it differentiates itself from other web frameworks. And the recipes in the first chapter contain a lot of the basics of the framework, like how to define routes and create controllers.

But all the information in the first chapter can be found in the official Play documentation online. Where the book really shines is in the subsequent chapters. They describe how to perform specific tasks such as creating an RSS feed, creating PDFs, and generating JSON data. They also describe how to integrate Play with a variety of systems like Apache, MongoDB, Spring, Google Charts, and Jenkins. Getting an application to "play nice" with the other parts of a system, no matter what technology you are using, can be a hairy ordeal, so I think these recipes are especially helpful.

All of the code samples can be downloaded from the book's website. Each sample corresponds to a single recipe and is a complete Play application, which is great because it means the samples are self-contained and can be run right off the bat. However, I had a little trouble getting some of them to run. I had to manually enable the in-memory database (the "db=mem" config property) because I was getting JPA errors on application startup. But otherwise, the samples seemed to work fine.

All in all, I would recommend this book to anyone interested in learning more about Play. It covers a wide variety of topics, so you're bound to find something useful no matter what kind of Play application you're developing (or want to develop) or what your skill level is.