Monday, July 19, 2010

Java Object Initialization Order - Know your JLS!

Recently I came across an interesting problem whose solution eluded me at first glance. Consider these three classes:
package com.ds.test;

public class Upper {
 String upperString;

 public Upper() {
  Initializer.initialize(this);
 }
}
package com.ds.test;

public class Lower extends Upper {

 String lowerString = null;

 public Lower() {
  super();
  System.out.println("Upper:  " + upperString);
  System.out.println("Lower:  " + lowerString);
 }

 public static void main(final String[] args) {
  new Lower();
 }
}
package com.ds.test;
public class Initializer {
 static void initialize(final Upper anUpper) {
  if (anUpper instanceof Lower) {
   Lower lower = (Lower) anUpper;
   lower.lowerString = "lowerInited";
  }
  anUpper.upperString = "upperInited";
 }
}
What output is to be expected from running the Lower class?

Wednesday, June 02, 2010

Set Scaled OS X Desktop Wallpaper via Automator

I regularly enjoy the pictures Romain Guy posts on his blog. Often they make for great desktop backgrounds, but at a whopping 20 megapixels they are just a little too big for my iMac's 1920x1200 screen.
When today I came across his most recent picture called False Kiva I went through my usual list of steps:
  1. Go to the "original size" version of the picture on Flickr
  2. Drag it to the desktop
  3. Open the file with a double click
  4. Scale it to 1920x1200 in Preview.app
  5. Save it to the Pictures folder
  6. Set it as the wallpaper
It occurred to me, that apart from liking and downloading a picture, all the remaining steps could be automated with a little Automator service. So I recorded this sequence of steps and saved it as a service.

Sunday, May 16, 2010

On Writing a Book, Pt. 4 – The Tools (II)

This is part four of an ongoing series about my experiences while writing the MySQL Admin Cookbook for Packt Publishing. All previous parts can be found under the mysql-admin-cookbook label.

This part will be about more software used in the process of writing the book. The last episode covered writing tools, file/version management and backups. What's up now is graphics programs, virtualization and PDF handling.

Sunday, May 09, 2010

On Writing a Book, Pt. 3 – The Tools (I)

This is part three of an ongoing series about my experiences while writing the MySQL Admin Cookbook for Packt Publishing. All previous parts can be found under the mysql-admin-cookbook label.

Even though I said I would be presenting things in mostly chronological order, I think after the previous - rather dry - part, a little more technical and fun information would be nice for a change: The tools used to create the MySQL Admin Cookbook (well, at least those used by Udo and me). To give a detailed account of what software products we used during the whole experience I will split this topic up into multiple posts. Otherwise it would just become either way too long or I would have to leave out too much stuff than I am willing to.

Friday, April 30, 2010

On Writing a Book, Pt. 2 – Outline and Schedule

This is part two of an ongoing series about my experiences while writing the MySQL Admin Cookbook for Packt Publishing. All previous parts can be found under the mysql-admin-cookbook label.

While last time I focused on the initial contact with the publishing company (just referred to as "Packt" from now on), this issue is about the process of putting together an outline proposal and coming up with things to write about in the first place. As from this point on in the process Udo was involved with everything, I will be referring to "us" and write "we" most of the time from now on.

The Publisher's Expectations

The only thing we knew about the books would-be content was a chapter template for Packt's cookbook series as well as the general description provided by Sarah earlier:

As I'm sure everyone is aware, MySQL is a relational database management system. Administrators of MySQL will be tasked with things such as maintaining the database, tuning the server, managing users etc etc.
This cookbook will have all the MySQL recipes an administrator could dream of, spanning from creating tables to managing views, from improving performance to securing the database, from using monitoring tools to using storage engines. DBAs of all levels will be catered for with recipes of varying difficulty, allowing the reader to administer MySQL to their hearts' content.

Before actually beginning the outlining process there were a few more emails sent back and forth, mostly questions on our part, for example whether we should include programming related materials or tool descriptions in addition to more "real" database themes, what spectrum of experience to expect from potential readers and so on.

Friday, April 23, 2010

On Writing a Book (Pt. 1)

This is the first part of an ongoing series about my experiences while writing the MySQL Admin Cookbook for Packt Publishing. All parts can be found under the mysql-admin-cookbook label.

In a few past posts I wrote about different aspects of my book writing project already. However those posts were not very contiguous, and I was asked a few times what my general experiences were and what caveats to look out for when taking on such a project for the first time. It might be of interest to some if I write down my experiences in a little more structured form.

This will be a series of several posts, because for one I do not think it would be feasible to have a single very long one, and also because this allows me to span writing it over a longer time. I will try to keep everything roughly chronological, but will deviate when I think it makes things clearer or better to understand.

Please be aware that I do not have extensive experience with multiple publishers, their processes and so on. This is solely about my personal experiences while writing a single book, with a single publisher, over a time of roughly 15 months. So please do not take anything for granted – should you go on that route and write something yourself, you might find yourself in completely different circumstances and witness the whole matter completely differently.

As for getting in contact with the publishing company, I already wrote down my experiences with that here: http://www.danielschneller.com/2009/12/51-weeks-since-my-book-writing.html

However I will go into a little more "historical detail" for starters.

Friday, April 09, 2010

Amazon + DHL delivery speed - just great!

Instead of all the bashing that's usually to be found in blogs, I think one should give credit where credit is due.

Yesterday in the late afternoon I ordered some hardware from amazon.de with standard delivery options.

This is what my email inbox looked like today:


The oldest mail (the last one in the screen shot) is Amazon's confirmation of my order. Unfortunately this cannot be seen directly, but the mail arrived - seconds after I placed the order - at 17:50h (5:50pm).

The next mail - today at 09:53 (am) - informed me about the package leaving Amazon.

Only about 5 hours later I was informed that it had been delivered at my chosen destination!

With this kind of speed, I do not think I will be buying an Amazon Prime membership anytime soon, otherwise they would probably deliver the stuff, even before I ordered it ;-)