Posts

Showing posts from 2007

OS X / iPod Touch DHCP timeout problem

It has been some time since I last posted, but I spent the time well, especially on a vacation in Malta. Very nice place, even in late November. Apart from one rainy day we had great weather and temperatures around 20°C. Very comfortable. Another nice aspect was the display of prices in both Maltesian Lira (Lm) and Euros, because as of January 1st, 2008 Malta will change their currency and introduce the Euro as well. Very convenient for travelers :)Back to business: Of course I did not want to be cut off from the net completely, so apart from my girlfriend's notebook I took my iPod Touch with me. The hotel advertised free WiFi access in the lobby. The first day I went down there and connected to the network without any problems using the iPod. They provided a freely accessible, unencrypted access point.Two days later I could not get a working link. The iPod detected the wireless network and was able to join it, however I never got an IP address from the DHCP server but ended up wi…

New GMail rather slow

I noticed the new GMail (the one where an "Older Version" link appears in the top right part of the window) seems to be way slower than that "older version". Whenever I use the mouse to scroll through my inbox I can see the browser slowly redraw the screen from top top bottom.Is this normal on a 3GHz HT machine? I surely hope this is still pre-release code :)

iTunes depending on Internet Explorer cache?

Today I noticed that although in Firefox I could see the latest episode (#150) of The JavaPosse iTunes did not notice it, even when I called the "Update Podcast" menu. It still insisted on episode 149 to be the most recent one.I reloaded the Feedburner feed with F5 and Strg-F5 to no avail. I suspected our company proxy to somehow misbehave and launched Internet Explorer to check what I would get there. Usually I do not use IE, so I could be quite sure to have it request the feed through the proxy and not serve it from its own cache.To my surprise I immediately got the right, current feed displayed, including Episode #150.Once I had seen this in Internet Explorer I tried "Update Podcast" in iTunes again and this time it started to download the episode it had not seen before.I have not bothered to look through the iTunes documentation, so maybe I am writing about something completely normal here, however for me it is definitely counter-intuitive and took me 10 minute…

Upgrading Windows XP Home to Professional

Some time ago a friend of mine upgraded his little office network with a Windows 2000 server. Since then he had been using Windows XP Home edition - mainly to just access SMB shares on the server. There were however some pain points with that setup. Profiles were not stored on the server, so the backup to tape drives on the server could not include them. Moreover we had to manually take care of having identical user accounts on all machines to share data among them and grant access to each others printers.So we decided to upgrade to Windows XP Pro, set up Active Directory and use roaming profiles. However because there were several products installed on the different workstations that take a long to time to configure properly we did not want to start from scratch.Unfortunately with XP you cannot just change the product key and all of a sudden Home becomes Professional. For one the keys just do not match - there are even different keys for the retail XP Pro version and the corporate vo…

Leverage Eclipse perspectives for different screen layouts

At work I use a three monitor setup for Java development. The machine is based on Windows XP and Eclipse 3.3. The individual views are spread out across the middle and right screens, the left one is mostly used for browser and email windows. Because I usually use a rather large font for code editing the center screen is entirely dedicated to the code editor.  The right screen contains outline, call hierarchy, source history, a console view, the package explorer and the task/warnings lists. All in all each and every pixel of this 2560x1024 area is used effectively for Java development.However in the evenings I sometimes like to complete some unfinished task at home. Thanks to a VPN connection I have full access to the CVS server and everything else I need. However I do not want to have to synchronize and download all changes to the laptop before I start. Usually I leave open Eclipse on my office PC all the time. To save time I just connect to it via RDP. The problem with that is howeve…

How to charge the iPod Touch's battery on Linux

I have never been very much into iPods before. Although people were all excited about the click-wheel and the great user experience I tried some of them and never shared the whole fuzz.However when I first heard about the iPod Touch I was really fascinated. I watched the iPod Keynote from September 2007 and immediately like the iPod Touch. Usually I am not a person who buys products immediately after their release, but I figured they had had some time to get the worst bugs out of the iPhone; and as the iPod is undoubtedly nothing more than the "phone without the phone" I decided to give it a go and ordered it from the Apple Online Store on September 9th. Delivery was scheduled for the week starting Oct 1st and it promptly arrived on Thursday. As I had it delivered to the office address I suddenly noticed a lot of people coming to my desk...I connected it to the office desktop (XP) where I had been using iTunes for quite some time already to manage the music I usually listen …

Can't start server: Bind on TCP/IP port: No such file or directory

(Also see the follow-up post about some progress)Today I was (again) facing a log file from a machine that had for some reason not been able to start a temporary MySQL daemon during the night to prepare for a streaming MySQL slave installation. The necessary 2nd daemon had created its new ibdata files, however just after that aborted the startup process with the following message:Can't start server: Bind on TCP/IP port: No such file or directory 071001 23:09:55 [ERROR] Do you already have another mysqld server running on port: 3310 ? 071001 23:09:55 [ERROR] Aborting 071001 23:09:55 [Note] mysql\bin\mysqld.exe: Shutdown completeAs you can see, the port is a different one from the default MySQL port, so I can be sure there was no conflict with the primary instance. Even more curiously the same process has been working on that and other machines flawlessly for some time. However I remember having seen this message once before, but back then I did not have the time to look into it any…

The value of a CVS commit database

Due to some discrepancies between the Eclipse 3.2.2 compiler and Sun's javac we needed to upgrade our development environments to Eclipse 3.3. Otherwise we could not tell for sure that something that looked ok in Eclipse would compile in the daily build process. Even though I had used 3.3 privately for some time now, there is always some tension when switching a whole bunch of developers in a really large project.
At first everything seemed fine, apart from some minor issues that could be easily worked around.However I ran into a nasty little bug regarding the CVS integration when I had to switch a workspace that had been checked out on HEAD to another branch. That branch had been created to keep the Helpers- and Utilities-Refactoring I wrote about before separate from the HEAD until it is complete.Within Eclipse you can just select "Switch to another branch or version" from the context menu on any project (or file for that matter) and select the branch you would like. I …

Helpless Helpers and Useless Utilities

With any code base of a reasonable size there are lots of issues you would normally take care of immediately when you come across them, however often there is just no time for it. In the end you will have to live with the knowledge that you had to leave some ugly hacks in it just to meet the deadline.Because we have recently finished development of the next major release of our software product, there is some time now to do code cleanup and get some more automated tests on the way. Because one of the bugs that almost prevented us from holding our schedule was a particularly nasty - but well hidden one - there has (again) been some discussion about coding guidelines and quality.People always seem to agree that you need to talk to each other, think in larger terms than just your specific problem at the time and strive for code readability and re-usability. For starters I personally would sometimes even do away with just a little more of the former one...The bug I mentioned above was …

Hard disks are too big

I remember when I got my first hard drive. It was part of the first PC machine I ever had, a 386DX40. Before that I owned an Atari 800XL and an Amiga 500. While there were hard drives for the Amiga I couldn't afford one at the time. The 386 came with a 52MB Quantum. Back then I had to decide whether I wanted to have Windows 3.0 on the disk orWing Commander 2. While I'm not really too eager to go back to those times I recently noticed (again) that the vast amounts of disk space we have today are not always a good thing in a manner of speaking.Over the years I owned several computers, with each new one came a new, bigger hard drive. As I usually sold the old machine - and the smaller hard drive with it - I just copied (almost) everything into some sort of "old_disk" folder on the new machine. When the next upgrade came, I had (of course) not reviewed everything in that folder and so, just to be on the safe side, just put it into the next "layer of archive" di…

ERROR 1033 (HY000) on InnoDB configuration error

One of the key features MySQL often uses to advertise for their database is the modular architecture that allows them to have different storage engines below the same SQL layer. In practice the application and/or database designer can choose from a variety of low level data storage implementations that each offer different characteristics and may be chosen on a per table basis. (Even though I personally believe most designs will use one type of table for all tables of a particular schema).The idea behind this is that for example people who do not need transactions should not have to worry about them at all – maybe there is a performance impact involved which they cannot afford to take. Moreover some specialized types of index or column might not be available on all engines. Basically the concept is very interesting and can be really useful for developers.However there is a weakness that in my opinion needs some severe work to be done: The interface between the common SQL layer and the…

Comfortable XPath accessor

Three weeks ago I blogged about a "Groovy way" to create XML documents in Java. This article now is about a convenient way to access XML without requiring more than a single class (downloadable here) on top of the JRE's own XML library functions.In fact I wrote this class before I even looked for an easy way to create XML myself, because at the time I just had to parse some XML and extract the values in an easy to use fashion.I believe it is easiest to show an example of how to use the class. Consider the following very simple Java class: import java.math.BigDecimal;

/**
 * Simple value object for a contact.
*/
public class Contact {
public String firstname;
public String lastname;
public boolean withAccount;
public Integer numberOfCalls;
public BigDecimal amountDue;
} Usually the fields would not be public of course, but for the sake of the example, just imagine the getters and setters being there ;-)Now consider getting an XML string back from an external sy…

How the Vulcan greeting came about

Ever gave a thought on how the Vulcan greeting (you know, the V shaped hand gesture) came about in Star Trek? Turns out this is really a fun and interesting story, not just some script writer conceiving it out of thin air. Have a look at this very funny video in which Leonard Nimoy, Mr. Spock, explains how it entered the show.

Windows Date Created Timestamp strangeness

I have been using Windows since version 3.0 and thought  I had seen most of its subtleties. However today I found a new "gem" I had not encountered before.We use two Perl scripts to do some FTP transfers regularly, scheduled by the Windows "Scheduled Tasks" to run several times a day. The scripts both use a common function to append to their respective daily log file. In case a file is older than 5 days, judging by its age in days based on the "Date Created" timestamp, it will be deleted and a new one created under the same name. This is intended to not have the files grow indefinitely.
While one of the jobs worked just fine, appending to its log files and rotating after 5 days, the other seemed to overwrite its log file on each run. Strangely enough  - as said before - they both used the same log function, just with different file names.After some poking around in the scripts source we decided to make a more low level test to see whether this had anything…

Gnome Nautilus SSH fails when hostkey changed

Today I tried to upload some files to my server via Nautilus. Months ago I created an SSH connection to my home folder via the "Places - Connect to Server" option on the main menu. It allows you transparently use SSH via the graphical user interface.However for some reason trying to double click the desktop connection just did not do anything at all. Selecting the entry in an open file manager windows led to a confusing error message: Nautilus cannot display "ssh://shipdown.de".
Please select another viewer and try again.Another connection, set up via WebDAV worked without problems. It occurred to me that this might have something to do with the recent crash of the server which made it necessary to set it up freshly. This of course included the generation of a new SSH host key. Trying to connect via the command line confirmed this:ds@yavin:~$ ssh ds@shipdown.de
@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@
WARNING: REMOTE HOST IDENTIFICATION HAS C…

GMail advanced search operators

Several rules in my GMail account apply various labels to mails and mostly archive them right away. This is handy for newsletters, mailing lists and the like. However over time - if you do not read them all - there are unread mails, scattered around several labels which are too old to show on the first 50 items.Up to now I sometimes went through the following pages, using the "Select unread" and "Mark as read" functions. Today I stumbled across a page that mentions a search term to show only unread mails. I had suspected something like this must exist, but there is no GUI feature I know of to use it.So in addition to any other search criteria you might have (e. g. "label:newsletter") you can just add "is:unread" and only get those mails that you haven't looked at before. Other things I just tried out and found to work:is:starred - applies to messages with stars.is:unread - applies to unread messagesis:read - applies to read messagesOnly afte…

Building XML the Groovy way in Java

When working with XML - i. e. creating XML documents - the Java DOM API is a little cumbersome. You have to ask all sorts of factories for instances of themselves, those instances for documents, elements and so forth. It is usually a lot code to write, even if all you want is a little XML fragment with only a few elements, e. g. to be sent over the network to some server. One way to make your life easier is to resign to StringBuilder/StringBuffer and building the XML "by hand". However this is error-prone and not always easy to read.Recently I had to implement a service that responded with XML over the net, building the document by collecting data from several sources and combining them together. The first version I wrote used the DOM API and once finished was hard to read even for me. I would have liked to use Groovy's MarkupBuilder for this, however company policy does not allow this (yet).So I looked around for a similarly easy to read solution in plain Java. I found

MySQL Index Analyzer updated

After several months I have again spent a little work in the MySQL Index Analyzer I first published back in August of 2006.I added a feature that will find duplicate columns inside an index, caused by the internal appending of the InnoDb primary key columns to each secondary index.To get the code and read more about the new feature, including an example, go to the MySQL Index Analyzer Blog.

Back online

Two weeks after we moved to our new appartement we got DSL back. I have to admit I was sceptical at first, because ususally I tend to not trust phone and internet providers too far when it comes to make changes to an existing setup. However apparently everything worked well. The ISDN line was switched over on the day we moved, keeping the same number without a glitch. The only thing that got lost on the way was the outgoing caller id. However after two calls to the hotline (hey, this is still well within acceptable limits, isn't it?) they assured me it was to be reactivated by tomorrow.The DSL provider promised to get the line back up two weeks after the ISDN line had been established and they kept their promise. Today I plugged the Fritz!Box in and everything worked immediately. It is a real relief. I did not remember how slow ISDN was, even with two channels bundled to 128kbit/s. My girlfriend is relieved, too, not having to use my computer all the time, because she did not like…

Thoughts on (Un)checked Exceptions

Brian Goetz shares his thoughts on the (recurring) idea of removing checked exceptions from the Java language in a future version, because they tend to make code too ugly to read or are just considered a "failed experiment".I personally count myself to the faction of people in favor of checked exceptions, because I believe they can certainly make people think more about error handling than they usually tend to. It may be harsh to say that, but in my opinion people - developers maybe even more - somethimes need to be forced to do unpleasant things. Of course checked exceptions can be a pain in the neck when you need to create e. g. Runnables, however in those cases you can still resort to throw an unchecked one . While this is a somewhat ugly technique you nevertheless are forced to think about error handling.I suggest reading his proposals on what could be done to ease the symptoms. I mostly agree with the 2nd group of people and like the idea of having closures to better en…

Download Youtube Videos (and Google video)

Maybe this is obvious, but it was new to me. :)Today I skimmed through the jroller.com homepage and found an article on Valerio Schiavoni's blog about revision control systems. He embedded a link to a video on YouTube showing Linus Torvalds giving a speech at Google about git and why he thinks it's better than other revision/software control systems.When I started to watch I realized I would not have time to watch it to the end. So I wanted to save it locally and watch it later, without having to be online again. So I googled for "download youtube videos" and the first three matches all pointed to one sort or other of special download tools.Turns out you do not really need anything like that. By chance I found the completely downloaded video file in the /tmp directory named something like FlashRItWZO. I tried some video on Google video, too, works fine as well. The files all start with "Flash" and are then followed by some random part.You just have to wait …

MySQL server_errno=1236 when disk full

Yesterday I was asked for help concerning a replication problem with one of our test systems. My colleague had already installed a fresh dump he had created with mysqldump ... --master-data. The dump looked ok and contained a master configuration statement: ... CHANGE MASTER TO MASTER_LOG_FILE='master-bin.000127',MASTER_LOG_POS=4462223; ... The slave was provided with the correct user, password and host name for this master. Nevertheless issuing a START SLAVE did not work. In the slave .err file we found this: ... 050327 20:54:51 [ERROR] Error reading packet from server: Client requested master to start replication from impossible position (server_errno=1236) 050327 20:54:51 [ERROR] Got fatal error 1236: 'Client requested master to start replication from impossible position' from master when reading data from binary log ... After some fiddling around and searching the net for solutions we had a look at the server as well. SHOW MASTER STATUS revealed seemingly correct …

Visualize hard disk temperature with gnuplot

Image
When the kernel issue I blogged about hit me I first suspected a(nother) defective hard disk. I opened the case to find my 250GB Samsung Spinpoint SP2504C so hot that I could barely touch it without burning my fingers. Mentally preparing to reinstall Ubuntu on a disk yet to be bought I remembered that this disk was not needed to boot at all, because it just contains data files. (Anyone else losing track of what is stored where with the disk sizes these days?)So I decided to just let everything cool down and then start again - in the meantime I had noticed that the latest kernel update had caused the effect and that starting with 2.6.20-15-386 would work. Once I was back to my desktop I installed some packages for hardware monitoring: ds@yavin:~$ sudo apt-get install hddtemp sensors-applet lmsensors Once they (and their dependencies) had all been installed I first started toying with hddtemp: ds@yavin:~$ sudo hddtemp /dev/sd[abc] /dev/sda: IC35L080AVVA07-0 : 46°C…

Beware of Ubuntu Kernel 2.6.20-16!

Anyone using Ubuntu Feisty Fawn should not install the kernel update to 2.6.20-16! It comes as a security update, but it includes some nasty trickery with the ATA/SATA drivers. After I installed it I could not boot anymore, because for some reason the drive names had changed!All the SATA drives that had /dev/sdXX names before were now called /dev/hdXX. Even though my /etc/fstab only contains "by-uuid" entries, all but the PATA boot drive could not be accessed.I already suspected a hardware defect, because booting without the splash screen showed "lost interrupt" errors. I only got skeptical when I read it was on drive /dev/sdg which I just plain do not have!Unplugging both SATA drives at least let me boot into the system again. From what I read in Launchpad Bug #116996 booting with the previous version 2.6.20-15 should work in the meantime.I have to admit I am pretty pissed off by Ubuntu at the moment. I really love the work they do, however sometimes they seem to …

MySQL Optimizer Bug 28554

When we tried to clean up a rather large (4.500.000 rows, 20GB) InnoDB table some days ago, we were astonished by the time MySQL took to complete the task. We had already LIMITed the transaction size, but every single chunk still took minutes to execute. The table itself contains some number columns, including a numeric primary key, and a blob. The delete condition was mainly based on the primary key (being smaller than a predefined value) and status field. After some mails between the support crew and us an optimizer bug was identified: MySQL Bug #28554.The problem is that in some cases the optimizer makes a bad choice concerning which index to use. It will pick a secondary index that can be used to cover a WHERE indexed_column=<constant> condition, even though it will cause way more data to be scanned than necessary. The primary key for the second condition pk_column<=<constant> would be a far better choice, visiting only a much smaller number of rows.The bug has been…

USB scanner not working on VMwared XP

I recently changed my health-insurance company. Today I got a letter asking me to return my insurance card or notify them in case I destroyed it myself. So I thought I might just fax them an image of the destroyed card. Because Fritz!Fax works beautifully in my virtual XP box, I wanted to get my Canon LiDE Scan 70 installed in the VM (no Linux support...). I downloaded the most recent driver from Canon's website and installed it.Unfortunately I only get blue screens as soon as I "connect" the scanner to the virtual machine using the VMware server console. Being somewhat disappointed I will now have to boot up the RealThing(TM) Windows partition again...

Linux EventQueue Problem

As a part of an ongoing project I had to write a little on-screen keyboard. It is a very simple thing: Just a panel consisting of a series of JButtons that - when clicked - insert KeyEvents into the EventQueue to enable any Swing text component to be used. I do not have the original code at hand right now, but I reconstructed it at home: import java.awt.*; import java.awt.event.ActionEvent; import java.awt.event.ActionListener; import java.awt.event.KeyEvent; import javax.swing.*; public class TestTool extends JFrame { private JTextArea textArea; private JButton btnA; private JButton btnB; private KeyEvent createEvent(Component aSrc, char aChar) { return new KeyEvent(aSrc, KeyEvent.KEY_TYPED, System .currentTimeMillis(), 0, 0, aChar); } ActionListener btnLstn = new ActionListener() { public void actionPerformed(ActionEvent e) { EventQueue q = Toolkit.getDefaultToolkit().getSystemEventQueue(); if (e.…

MySQL: Add primary key to table with duplicates

Maybe this is obvious, but I post it anyway, just to remind myself should I need it again.Recently I had to change a table that I had not completely thought through when I first created it. The structure was so simple, I did not think I could do anything wrong with it: CREATE TABLE `parent` ( `par_id` bigint(20) NOT NULL, `somevalue` varchar(20) default NULL, PRIMARY KEY (`par_id`) ) ENGINE=InnoDB DEFAULT CHARSET=latin1; CREATE TABLE `child` ( `x_parid` bigint(20) default NULL, `value` bigint(10) default NULL, KEY `fk_parid` (`x_parid`), CONSTRAINT `child_ibfk_1` FOREIGN KEY (`x_parid`) REFERENCES `parent` (`par_id`) ) ENGINE=InnoDB DEFAULT CHARSET=latin1; There is a 1:0..* relationship between parent and child. Some sample data: mysql> select * from parent; +--------+--------------+ | par_id | somevalue | +--------+--------------+ | 1 | Parent No. 1 | | 2 | Parent No. 2 | | 3 | Parent No. 3 | +--------+--------------+ 3 rows in set (0.00 sec) …

FindBugs - Writing custom detectors (Part 2)

This is the second part of the "Howto write a FindBugs Bug Detector" (see the first part here). To understand why one would write the kind of detector mentioned here, you should read the first part if you do not already know it.Last time I presented a detector that is able to detect static fields of the types java.util.Calendar and java.text.DateFormat. While declaring fields like this may be suspicious, there is not necessarily something wrong with the code. The real danger comes from calling methods on suchlike fields, especially if they are not synchronized to protect them against concurrent access. So in this article we will extend and improve the existing detector to cope with this problem.Something to chew onThis a simple class that uses a static Calendar instance. It does not really do much, but the shorter the program, the easier to understand its bytecode (this is what we need to do this time). import java.util.Calendar; public class StaticCalendarSample3 { pub…