Wednesday, December 23, 2009

On Font Rendering

If you have ever wondered (as I have years ago) why the text rendering on Linux usually looks inferior to both Mac OS X and Windows text, no matter how much you try and tweak the settings, there is a great and very in-depth article at http://www.antigrain.com/research/font_rasterization/index.html. It is quite long, but it contains excellent background information, theoretical and practical discussions of the concepts behind text rendering in general, what Windows and Mac OS do right/wrong and how to improve the situation in general.

This is a must read for anyone remotely interested in font rendering.

Saturday, December 19, 2009

Star Wars Review – Hilarious

I just came about this Star Wars – The Phantom Menace Review on Daring Fireball. Yes, the movie has been out for years, so why a review? Well, go see for yourself (it is 7x10 minutes long!). Be aware that if you loved it (who would?) you might be offended by the heresy against George Lucas’ creation, but I for one mostly agree with it.

You might have to get used to the guy’s voice, but the contents and the insight are definitely worth hanging on.

Technorati Tags: ,,

Thursday, December 17, 2009

51 Weeks since my book writing adventure began

In one week, on December 24th, it will be exactly one year since I was first contacted by Packt Publishing. After reading several posts from this blog they asked me if I’d be interested in writing a MySQL administration cookbook with hands-on recipes for those among us who have to make sure the MySQL servers are kept running and in good shape.

Funny thing, I almost deleted their email, because initially I thought GMail’s spam filter had not caught some sort of bulk or phishing email, because I had never heard of Packt Publishing before and at first only saw an unfamiliar sounding sender’s name. As I was one of very few people in the office on that day I decided to read it anyways. Turned out to be not so spammy after all…

What followed were several weeks of sending mails back and forth, convincing a colleague to co-author and together set up a chapter outline. Finally, around February we started writing actual contents. Boy did I underestimate the amount of work this was. This being my first book I was completely unable to make any educated guessing as to what was lying before me. The initial estimate from the publisher was an hour a day – I strongly doubt than anyone would be able to sit down for an hour every day and get anything done. Often just setting up some test scenario takes longer…

Even things I knew inside out turned out to be really time consuming in writing them down in a structured manner. Add to that preparing screenshots and diagrams, discovering bugs and unexpected behavior in the tools, fighting the word processor and you are in for many late nights in front of the computer, sometimes wondering if I’d ever be finished.

Nevertheless yesterday I submitted the edited – hopefully final – drafts of the last two chapters. If everything goes according to plan most of what’s left is for the publisher to do. Alas, now that I have said this, there will almost certainly be some more fine tuning for me to do as well…

Strangely enough – even though I had somehow almost expected this – editing and going through the stuff you wrote sometimes weeks ago is a real eye-opener. It is as if you were reading someone else’s material; things you thought were perfectly clear when you wrote them sometimes sound strange, sometimes are not clear to understand and sometimes even plain wrong. The feedback from the publisher and the reviewers was extremely helpful to get a different point of view and become aware of ambiguities and flaws you otherwise would probably not have seen at all.

If you are a regular reader you might have wondered why my blogging frequency somewhat stagnated over the past year – now you know what was eating up my time.

So if you like, you are welcome to pre-order the book right now. It is planned to be released in March of 2010 and I expect it to show up on Amazon and other online stores soon. Nevertheless, you can already read more about it on Packt’s website: MySQL Admin Cookbook.

When everything is really finished and I hold the first copy in my hands I plan to write some more on the process of planning, writing and editing. Until then, it might remain somewhat quiet around here for a little longer.

Wednesday, October 28, 2009

Google Navigation

You just gotta love this tech world...

Tuesday, October 20, 2009

Fluid app for TWiT.tv

For the last couple of weeks I have found myself regularly having a Safari or Firefox window open, showing the Bitgravity stream from http://live.twit.tv, Leo Laporte’s netcast site. Time and again however, I accidentally closed the video when I routinely quit the browser when I had finished using it for other web related stuff.

Today I got sufficiently annoyed by myself to resolve this situation once and for all. So I created a Fluid app, took a TWiT logo from their homepage and now have a standalone TWiT.tv application on my dock.

This is the setup in Fluid:

Fluid Settings

On first start I had to add live.twit.tv to the ClickToFlash white list again – the App in Dockwhite   list from the regular Safari settings was not taken into account by this standalone browser – and then resize the Window to precisely match the video size. This is remembered for any subsequent launches. I went for the popped out player available from the regular page (see the URL in the Fluid setup screenshot above), because I usually do not need the surrounding extra information like the production calendar or the web-based IRC chat room.

This is what it looks like now, when I have started it. I will not go so far and set it up to auto start on login, but keep it in the dock for quick access.

App Running

Technorati Tags: ,,,

Wednesday, October 07, 2009

Setting up iPod Touch for Google Sync

Google offers an Exchange/ActiveSync based option to keep your mails, contacts and calendars lined up nicely on your iPhone and iPod Touch. I succeeded in setting this up on my iPod Touch 2G as per their instructions, but when I tried to configure which of my calendars were to be synced by going to http://m.google.com/sync with the Mobile Safari browser, it told me that “Google Sync is not supported on your device” (well, actually in German, but never mind).
I suspect there is some user-agent filtering going on and that for some reason – even though from what I understand the iPod should be fine – it likes an iPhone better.
Mac OS X 10.6 Automator to the rescue:
Automator Setup for configuring Google Sync
Both options are from the Internet section of the Library on the left (not shown). Save this as an Application or just run it from Automator and you will get this:
Automator Webpage Popup in iPhone mode
This allowed me to set up the calendar on the iPod to sync more than just one Google calendar.
EDIT: Much simpler, it just did not like the German language. Switching to English on the iPod works, too.

Tuesday, October 06, 2009

Another note on code readability

Some time back I posted a piece of code I found that was trying hard to obscure its meaning (see this post from September 2008). Today I came across this:

long now = CalendarUtil.theCalendarUtil().getCalendar(new Date()).getTimeInMillis(); 
long milis = now - creationDate; 
milis = (milis < 0 ? milis * (-1) : milis); 
return (milis > 2 * 60 * 1000);

Now, do you immediately see what’s going on here?

Right – of course, you do. The method is called isInstanceTooOld(), the idea being that it should return true, if the current object was created less than two minutes ago. The constructor records the creationDate field to track that.

This nicely shows that convoluted code – even intended to provide a simple function like this one – is prone to errors: This one returns true, too, if the current object is two minutes newer than the current time. The correct function looks like this:

static final long MAX_AGE_THRESHOLD_MILLIS = 2L * 60 * 1000;
long now = System.currentTimeMillis(); 
long age = now - creationDate; 
return age > MAX_AGE_THRESHOLD_MILLIS;

Always a pleasure to see the face of people when they recognize what strange things they did only weeks ago, probably late at night :)

Technorati Tags: ,,,

Thursday, October 01, 2009

John Lloyd on Invisibility

The following video I came across by chance – listening to some podcast I was reminded about  TED, browsed through the site and found this. I really find it a great little talk (10min), so here it is:

The original can be found on the TED Site (direct link).

Technorati Tags: ,,,

Tuesday, September 29, 2009

iMac hangs at gray boot screen – solution

Today my Intel iMac (mid-2008) suffered a heavy software crash, effectively leaving me no choice but to turn it off, as the shutdown process would hang forever. I held down the power button several seconds, until it went off.

Unfortunately getting it back up was not that easy. I would hear the startup chime, but after that the screen would just hang, completely gray. I could hear the CD in the drive spin up and down again after a few moments. Keeping the mouse button pressed, the option key down etc. – all sorts of tips you get on the Internet – did not work.

First I suspected the stuck CD was the problem. The Intel iMacs do not have an emergency eject hole for the slot in drive, though. Looking for a solution to my problem, I searched for all sorts of keywords I could come up with related to an emergency eject, but to no avail. All the tips and hints you get – including those on Apple’s site – relate to older models that still had such a hole for a paper clip.

After a while I remembered a similar situation a few months ago, albeit without the stuck DVD part, when I was ready to take the whole thing to an Apple partner for checkup. In preparation for that I unplugged it from power, but did not take it off the desk immediately. For some reason I later decided to give it another shot and plugged it back in, just to see it boot up normally. I did this again today and after 20 seconds without power (actually I just switched of the power strip), it would boot just fine.

Only after that did I find this Apple support document which actually does not really help unless you search for SMC or PRAM reset on Google and dig for a while. So hopefully I saved you some time, if you read this.

Monday, August 31, 2009

Reducing Mac screen brightness even further

While I generally love my iMac, one thing I always hated from the first day was the insufficient range within which you can regulate the screen brightness.

Especially at night when the surroundings are dark, even the lowest setting is still too bright and both illuminates the whole room and also hurts the eyes after a while.

Today I found a simple tool with the even simpler name Brightness Control that allows you to tune down the screen backlight brightness in a much wider range than the built-in Mac OS brightness control. Unfortunately you cannot have it disappear completely - its icon will stay in the dock while running - but this a small price for the added comfort.

Monday, August 24, 2009

Eclipse: ClassFile cannot be cast to ICompilationUnit

Today, checking out from the repository, I got this error message from Eclipse:

org.eclipse.jdt.internal.core.ClassFile cannot be cast to org.eclipse.jdt.core.ICompilationUnit

To save anybody getting the same message from wondering and poking around what it means, here is the simple reason. A colleague had accidentally checked in a .class file in a source folder, causing my Eclipse to try and process (compile) this presumed Java source file.

Deleting it from disk made the problem go away. Thinking about installing a pre-commit hook on the repository server to prevent this from happening again.

Monday, August 17, 2009

myTexts with Keymote – a nice combo

Some time ago I wrote about Using Pages ‘09 in “WriteRoom” Mode, but since then I found myTexts from MOApp Software and bought it. I like the idea of having a document storage inside the application without having to worry about file handling – which is one of those things I do not want to think about while writing.

However, the (intentionally) spartan design of pure writing applications like this has a slight drawback: In order to activate certain functions you either have to take your hands away from the keyboard to grab a mouse, or learn the keyboard shortcuts. Usually I am a very keyboard centric person, but just yesterday I found Keymote, a universal Mac remote for the iPhone/iPod Touch from icedcocoa which made my life even easier.

My writing deskIt has got its fair share of (most favorable) coverage already, but I think this little program is still worth another positive mention. For me, this is what an iPhone application should be like. It offers clearly defined and useful functionality while at the same time being both beautiful to look at and self-explanatory to use. Even though the homepage contains some tutorial screencasts, I did not have any problems  getting everything to do what I wanted.

The big picture show my writing desk with my iPod Touch placed behind my keyboard for easy access. The closeup below has the layout I created for the shortcuts most commonly used when writing in myTexts.

myTexts keyset closeupThis is the first application I have seen (personally) that makes use of the new iPhone OS 3.0 in-app store functionality, and it was a pleasurable experience. They allow people to share their keysets – currently they are all free – and there already is one for many popular applications already. I just created and shared a keyset for myTexts and uploaded it. This worked pretty much instantaneously, and while version 1.0.0 still has a little localization problem (which is already being worked on according to the support forum) I think this tool is worth every cent of its €2,99 price!

I definitely recommend you go to their website and have a look at the tutorial and the promotion videos – you’ll probably be excited as well.

Sunday, August 02, 2009

Bud Spencer Gedächtnislache

Just stumbled across an old Bud Spender movie snippet and got here per related links:

This is the German dubbing voice of Bud Spencer (and a few others as well: John Rhys-Davies, Charles Bronson, Oliver Reed, etc.) and I just *love* the laughing right at the beginning...

Just GREAT!

Thursday, July 16, 2009

iPod Touch 2G requires charger adapter

I know this has been blogged before, but I feel so strongly about it, I need to post my own rant as well.

Apple for some obscure reason decided to change the layout of the dock connectors charging pins between the iPod Touch and its 2G successor. The same fate also hits iPhone 3G and 3GS. The older models used the FireWire portion of the dock connector to charge the devices battery. Many accessories, including Apple’s own hifi adapter kit and most car-connectors are now useless in terms of battery recharge, because the new models only access “USB electrons”. I guess we can call us fortunate that we don’t need a Linux kernel module in our cars to keep charging while driving. 

This is really annoying, because before the new device I would just plug the iPod in when I got into the car, listened to podcasts while commuting and could leave with a fully recharged device when I arrived. Now they seriously ask me to pay €25 ($35) for an adapter that will a) provide a cross-over of the power pins and b) prevent me from putting the iPod where it belongs in the car: that special slot in the console where the connector of the car kit emerges!

I am somewhat p*ssed right now!

Technorati Tags: ,,

Thursday, July 09, 2009

Modularizing Software with Ant/Ivy and Eclipse

This is one of the rare times when you get the chance to some technical cleanup and rewrite time from management, so we are trying to get some new things going that were pushed time and again in the past. In the architecture meetings we have been telling ourselves that we’d have to modularize better, so more unit tests could be written and overall quality be improved. Instead for lack of time we had to add new features to an already overloaded codebase and cross our fingers that nothing would go truly wrong in production. So far we have been very lucky.

Having some time now for cleanup and refactoring we quickly came to think about the build process – currently a large pile of Ant scripts, resembling a full blown software project in its own right regarding the complexity. I asked around on StackOverflow for experiences and best practices. I got some interesting answers, including recommendations for using OSGi and maven. I have some experience with OSGi from a previous project, and I think we will go for at least maintaining the relevant metadata in the MANIFEST.MF files we are creating. However as this is a chance for cleanup, not rewrite, getting everything in shape and run inside an OSGi container would both be too time consuming and hard to sell internally.

Currently the product is “organized” in about 45 Eclipse projects, totaling about 3 million lines of code, including a very small fraction generated classes. The real problem here is not really size, but complete and utter chaos concerning dependencies. When the project started out we were under severe time constraints and people took all sorts of shortcuts, not documenting which depends on what and why. Add duplication of functionality (“copy-paste-coding”) to the mix and there you go with a fine spaghetti dish…

But back to building the thing… The build process relies on a specific build order, but everything that gets compiled can “see” everything that came before it. This includes external libraries of course. A full build – and that’s the only thing possible – takes about an hour, excluding findbugs, checkstyle, tagging the repository etc. All in all about 3.5 hours from start to end.  And of course whenever something changes we have to compile the whole thing from start again – reason explained already.

We decided to go for some technical underpinnings to try and separate from each other for starters, as we can do this without needing to exchange and interact with business people. Once we gain some experience and have learned some lessons about what works and what does not we will try and go for the more juicy stuff. When looking at maven we quickly decided that we could not restructure our code in a way that would make it compliant with maven’s project layout. This and the fact that we would not realistically be able to follow the one-project-one-artifact rule maven forces on you (I hope this is still like that, did not check again). Ivy does not impose anything like that, a module (configuration) can consist of as many jar files, zips etc. as you like.

Moreover we also realized that in the beginning we will not be able to get completely rid of some custom logic that would be hard to implement within maven anyway. However we came across Ivy again – which a) we had looked at maybe two years ago but lost sight of again and b) has become an “official” Apache project – and decided to give it another try.

I have to say this was the most pleasing experience with an open source product I have had in a long time – maybe ever. The documentation is really extensive and very well written, despite the author’s self-criticism in terms of his English-skills:

An important thing to be able to use a tool is its amount of documentation. With Ivy, even if they are written in broken english (would you have preferred well written french :-)), the reference documentation is extensive and covers all the features including many examples. We also provide some official tutorials which are maintained with the new versions of Ivy. And since we consider documentation so important, we also provide online versions of documentation per Ivy version since Ivy 2.0.0-alpha2.

It is very readable and from my (German) point of view it sports a better writing style than many other manuals – if you get documentation at all. In fact trying out Ivy was a profoundly enlightening experience. Without much exaggeration, time and again when we came across a new aspect of the old system which we would have to find some way to redesign and re-implement in a new build, Ivy already presented a viable solution. This combined with an apparently very real-world approach to some problems (e.g. recommending not using a public repository for corporate products, something I always disliked anyway when reading about maven) really impressed us. (You can however use maven2 repositories if you really want to).

The concept of configurations is very useful: You can define a module and give it a name and define its version and then have several views of this module, called configurations. One configuration might be for production use, another one for testing. For both configurations you can define individual dependencies on other modules and their configurations. This combined with the very comprehensive Ant integration library the build.xml scripts of most reworked components simply consist of jar-ing and zip-ing compiled classes and source files together. Once done, we just call an ivy task inherited from a common build script that publishes the new module version first to a local repository for testing and optionally to a shared company repository. For simplicity we currently use a simple fileserver share, but there are other options available as well. All the rest is taken care of by Ivy: just pointing it to the repository it manages to fetch the required module artifacts from there to a local cache to build against. Conflict resolution is very configurable with the built in options already, and for the unlikely event that there is no suitable option available, you could just write a plugin yourself.

Maybe the best part however is the availability of a really useful and thought-through Eclipse plugin called IvyDE. As mentioned earlier our product is modeled and coded in Eclipse. In the past it had always been a chore to keep the poorly defined dependencies somewhat in sync between Ant scripts and Eclipse project definitions. The Ivy plugin solves this very elegantly: You configure the location of your repositories and common settings file (used by Ant and standalone Ivy tools) once and then just add an automatically maintained user-library to your project. If you later edit your ivy.xml file(s) – which include the dependencies and module properties for Ant anyway – upon save the user library gets updated automatically, including source and java doc attachments to allow for step-by-step debugging, source lookup etc. Without this it would have been really difficult to get acceptance with the other developers – they do not really care about too much of the “meta-stuff”. But I also personally have to admit, it makes things much easier to use, you just don’t have to give up any of the comfort you have gotten used to.

The plugin is still a beta release, but more in the Google sense of beta. There are some problems – error messages could sometimes be a little better and from time to time when you have syntax errors in our ivy.xml files the user library is not displayed in the Project Explorer view – but this stuff is really usable already!

We still have ways to go before we can really call our efforts even remotely complete, but I am very sure without Ivy it would be hell of lot more painful! Thank you Ivy!

Monday, July 06, 2009

Domain Hassles - Part 2

I am almost done with the domain changes to this blog. It is currently reachable via www.danielschneller.com which is what you should already be seeing in the address bar right now.

The danielschneller.de domain is working partially, I guess some DNS updates have not propagated to everywhere yet. It should redirect to the .com immediately, however currently it still seems to have the CNAME to Blogger in place. This should only be a matter of hours now.

Mail is configured for both domains and seems to work just fine.

During the whole change process I had to contact DomainFactory's support for some tips on which contract types would give me the features I wanted at the minimum possible cost, and even though it was on Sunday I got a (sensible human-written) response within 5 hours. Pretty impressive.

Their web interface is clean and understandable, very nice as well. And the pricing is really affordable: I now have 2 domains in the MyMail package which is 6.60€/year per domain + the domain costs of 1x .de (6.60€/year) and 1x .com (12.60€/year), totalling 32.40€ per year. This is way less expensive than the 1&1 rate (47.88€/year for just the .de domain and no chance of configuring CNAMEs).

The only thing left now is to cancel that 1&1 account.

Using Pages ‘09 in “WriteRoom” Mode

As I am currently in the process of writing a book, I am always on the look for a better way to write stuff down. While the publisher wants to have OpenOffice or Microsoft Word files, I am not perfectly happy with writing in either OpenOffice or NeoOffice. They both seem to bloated and full of stuff, all the time taking my attention away from just pure writing.

When looking for a simple note taking tool for OS X I came across a recommendation for WriteRoom, even though it is not a note taking tool per se. Turns out this is the most useful – and also simple – piece of software I have seen in a long time when it comes to getting the one task it was designed for done right: Write and don’t let anything distract you. This is how it’s done in WriteRoom; a fixed font display in a retro-looking green on an all-black background in fullscreen mode:
Write Room

While at first I was a little skeptical I have come to love it. My iMac screen is not set to a very high brightness by default - but even when I dim it down to a minimum, it still somewhat hurts my eyes to look at the white page background when the room around me is dark (which it usually is at the time I tend to write the most). With DarkRoom this is not a problem anymore, and if you like other colors better than green on black, you can of course customize that as well.

However I am not sure I want to pay $30 for what is basically a standard text control wrapped in a full screen mode. Today I remembered I had never actually used Pages ‘09 from the iLife suite I bought when it came out for iPhoto’s Faces and Places features. But I knew that it sports a full screen mode as well. Unfortunately you cannot configure the display settings to use a different color than white for the “paper”.

So I just went ahead and created an empty document, placed a rectangular shape on it, filled with a black to dark gray gradient and put that into the background. Then I sent it to the page master and adjusted the default font color to white. Voila: A WriteRoom-esque full screen editor:

Pages 09 in Full Screen Mode

This works just as well – and the best is that I have already paid for it.

Saturday, July 04, 2009

DomainFactory

I just whipped through the ordering process for danielschneller.com with DomainFactory. From ordering to having the domain online and reachable (at least for me) it took less than 30 minutes, including automated SMS message for activation, setting up mailboxes and configuring the CNAME to point to the blog.

I am impressed. Now I will try and test this a little more, before maybe migrating the rest of my domains to them as well…

1&1 Domain Hassles

Earlier this week I (again) thought about changing my Blogger settings to use my own domain - in the end what is it good for to pay every year for my custom danielschneller.de domain only to have it forwarded to the one-of-many .blogspot.com subdomains.

So - having pushed this for in fact several months now - I finally went to the Dashboard and looked up the instructions on how to configure my own domain name - turns out you need to set up a CNAME and point it to a Blogger subdomain.

Unfortunately my (then) current 1&1 contract did not allow DNS customization - I could just set up an HTTP redirect which I had been using all along. This is when the fun began...

First I tried to find a way to somehow upgrade my contract from within their "control-center" to no avail. I did find - via their homepage - the homepage hosting offerings, however there did not seem to be a way of telling them I already had the domain in a running contract.

So I contacted their support team and was told I needed to sign up for a new webhosting package and transfer my domain in the process - somewhat over-engineered and rather un-intuitive if you ask me. Nevertheless I did as I was told and signed up for a 3,99€/month minimum hosting account and checked all the marks needed to transfer my domain.

After what felt like 35 emails and web forms later the control-center showed me that the domain was being deleted from the old contract and added to the new one. Fortunately the supporter had told me to externally write down my email settings, because in the process of moving from one contract to the next within the same company(!) all configured email addresses and all content in the current webspace would be deleted! Luckily I only use mail-forwardings to GMail, otherwise I would have had to change all IMAP mail clients as well...

In the middle of the whole thing my website suddenly disappeared - accessing danielschneller.de brought a 404 error. I could not do anything about that for about 4 hours. Great stuff...

When finally everything seemed to have completed - it was possible to set up the mail addresses in the new contract in the meantime - I went to the DNS settings, just to find out that I can only change A and MX records!

I was however sure I had seen some screenshots on the web before, showing a 1and1.com admin site snippet with a CNAME setting, otherwise I would not have started the whole thing in the first place. Turns out that there seems to be either a difference in the German and US/UK configuration options. Of course when I searched for this very problem Google dug up several forums and blogs of other German customers, all telling about the same experience.

Great... Now I have a 6 months contract, payable in advance for nothing! Looking for a different domain provider now...

Geeez... And all I wanted was a nicer looking address bar...

Monday, June 29, 2009

Added Twitter Widget because of Windows 7

I just added a slightly customized Twitter widget to the blog. The title might be a little misleading, as of course Windows 7 does not have anything to do with this directly. Actually I am waiting for the release candidate to finish downloading, so in the meantime I am browsing the web for some stuff - partly in research for the book, but partly for fun as well.

This is when I came across the blogger widget and found the default one a little to ... well ... default.

The Windows download did not work in Safari 4.0.1 - I had to switch to Firefox as there is no IE available on the Mac. Somehow Safari would not go past the Live login and show a green progress indicator. Firefox 3.5 is now happily downloading the image using a download manager Java applet. Somewhat strange considering it's from Microsoft.

Once the download is complete I will try and set up a virtual machine with Windows 7 (is this going to be the final product name? I certainly like it more than "Vista"). Hopefully the reports are true and it is faster than its immediate predecessor.

Thursday, June 25, 2009

Twittering @dschneller

For quite some time I have successfully ignored Twitter and regarded it as just another form of celebrities promoting themselves (probably through the same PR companies also writing their blogs for them) and random people yelling the state of their digestion into the world.

However when I heard the good folks of the BitsUndSo podcast talk about it all the time, I decided to get an account (@dschneller) and have a closer look - and I have to say, I was wrong!

Of course, there are the types I mentioned above, but I quickly learned there are lots of interesting bits of information flying around. I just started by following the JavaPosse, the BitsUndSo members, Scott Hanselman and a few others and very soon got interesting (and of course irrelevant as well) tweets to read.

Since then I tried out several Twitter clients, but so far I stuck with TweetDeck, because I like the display very much - this and the fact that there is an iPhone version as well. Yes, sometimes that latter one still crashes, but overall I find it quite usable, especially with the recently added "sync-my-searches" option that helps keep iPod, private Mac and work Windows PC up to date configuration-wise.

Feel free to follow me, I try to keep the signal to noise ratio attractive.

iPod with OS 3.0

Being a good Apple customer I of course updated my 1st generation iPod Touch to the latest version of the OS (3.0) made available a few days ago. So far I like the changes very much and will not go into detail about what changed - there are lots of other sites covering things like that.

Nevertheless I wanted to comment on two things in particular, both part of the music player component.

The first one is the multi-speed scrubber. The iPod was my first Apple product and I was eager to find out if the often praised UI designers were really as good as people claimed. I almost immediately got very disappointed with the support for long contents like audiobooks or even some podcasts, because the scrubber control to skip ahead or go back to a specific point in time in the program was unusable for anything longer then maybe 5 minutes. In an audiobook the precision would sometimes only be enough to jump in 30 minute hops - unusable.

When I got a feedback form some time later I complained about that in great detail, even suggesting a virtual click-wheel for more precision. Now, finally, they solved the problem in a different, but cool way. Where in earlier versions you could just move the scrubber left to right with constant speed, they now introduced sort of a "gear shift" (they call it precision scrubbing and highspeed scrubbing). When you move your finger up and down you modify the "seconds per pixel" ratio of the horizontal direction. I personally absolutely love this stuff.

The second thing which caught me a little off guard and which I even suspected to be a bug was that I suddenly had no volume slider anymore. As I had docked and undocked the iPod several times before in a very short period of time I thought it might have somehow gotten confused and now did not render correctly. However when the problem persisted even after a full switch off and back on cycle I was a little worried.

Only then I "found out" I had just not put the headphone jack back in after undocking the iPod. As soon as I plugged it back in, the volume slider would appear - and vanish when pulling it out. A nice idea in general, but definitely the kind of thing that might confuse you, as it definitely wasn't like that in 2.2.

-- posted with Ecto (which is definitely not as eye-pleasing as Windows Live Writer)

Wednesday, June 24, 2009

Trying a new Blog Editor - Ecto

I am fairly busy at the moment, apart from my day job I have taken on writing a book in February; this is why it's gotten somewhat silent here lately.

Nevertheless I just stumbled across "Ecto", a blog editor for Mac OS X that people claim has the potential of replacing Windows Live Writer which have up to now used with VMware Fusion as the tool of choice.

Booting up the virtual Vista however is something I'd like to avoid, so from time to time I have a look around what's new. MarsEdit did not work for me and the Blogger web-based editor is for emergencies only.

I just downloaded the Ecto 21 day trial and will attempt to blog some things in this time to make up my mind. I have not even looked at the price yet to keep this from influencing my decision.

Friday, June 19, 2009

User Interface (Fun)

Just found this. This is absolutely hilarious (and so true...):

Even without knowing a single word of Japanese you can tell the annoyance :)

Saturday, April 25, 2009

CVS Performance: I/O Bottleneck because of locks

Today we found the reason for our sometimes abysmal CVS performance, even though the repository is located on a fast SAN: Locks were written to the local disks rather than the SAN.

For years we have been using CVS as our internal version control system. The repository has grown to about 20GB and covers 6 years of code and resources in several hundred thousand files and their history revisions.

Some time ago we migrated the repository data from an internal disk subsystem to a SAN based on 15k hard drives. The server is a Dual Xeon HP box with 4GB of RAM serving about 50 users.

Even though we thought we had a decently fast setup here, sometimes – especially when more than 10 or 15 people started to checkout or synchronize their Eclipse workspaces – performance would start to really degrade. In some cases working on branches only was possible after increasing the client timeouts to 3 minutes!

Our datacenter administrators provided us with I/O statistics in which we recently realized (don’t ask why they did not tell us about this earlier when we complained about bad I/O rates) that while the SAN interface was never really getting busy, local disks where 100% busy most of the time, especially during times when we had the most complaints from users.

Turns out that in the early days when we set up the repository configuration and obviously did not know enough about it, we configured the CVS LockDir variable in CVSROOT/config to /var/lock/cvs. This had never been changed, not even when we moved machines and put the data to the SAN. In effect each and every read or write operation on the repository caused locks to be created and deleted on the local hard drive of the server – completely breaking down the supposedly superb I/O performance.

As this is Friday afternoon we changed the configuration to place the locks on the SAN as well but could not really see the effect, because most people had already left for the weekend. We will certainly have a close look at the system on Monday to see if performance gets better. Probably we’ll set up a tmpfs ram disk to hold the locks if we see any improvements.

Up to this point I never even knew for sure how and when CVS put locks. I was under the impression that they were only required for commit or tagging operations. Because of that (false) assumption I would never have thought we could get a problem with local I/O, but as we have very complex directory structures lots and lots of per-directory read locks could of course pose a problem for a rather slow local disk.

For more information on CVS locks (not related to RCS locks) see the CVS manual.

Technorati Tags: ,,

Tuesday, April 14, 2009

Folder Action: Strip Subversion .svn metadata

I regularly need to send a zipped copy of a folder that is a local Subversion working copy. Every time I create the archive I end up with a file that’s larger than needed, because it contains the hidden Subversion metadata “.svn” subfolders.

Here is quickly hacked together AppleScript than delegates the actual work to the Unix “find” command, but can be attached as a Folder Action. I now have folder on my Desktop called “Strip SVN Metadata” and I just Option-Drag anything from a Subversion working copy there (making a copy, not moving) and a few seconds later I can just zip it from there without the .svn folders.

on adding folder items to this_folder after receiving added_items
    tell application "Finder"
        set fold_name to the name of this_folder
        try
            repeat with i from 1 to number of items in added_items
                set new_item to item i of added_items
                set the item_path to the quoted form of the POSIX path of new_item
                do shell script ("/usr/bin/find " & item_path & " -name '.svn' -type d -exec rm -rf {}")
            end repeat
        end try
    end tell
end adding folder items to

Sunday, April 12, 2009

Solved problem: Access Mac OS X SMB Shares from Vista – no more System Error 1326

Today I tried to map a network drive to a folder shared via SMB from Mac OS X. I enabled sharing in System Preferences and set up the user account appropriately. But whenever trying to connect from Vista, I ended up with “Systemfehler 1326” (“System error 1326 has occurred. Logon failure: unknown user name or bad password”) complaining about invalid username or password.

First I suspected a problem with my longish password that contains special characters, but that was not it. Turns out it is a compatibility problem/feature between the Samba configuration in OS X (the component responsible for sharing folders via the SMB protocol) and Vista’s default security settings.

First a solution for the impatient:

On Vista launch regedit.exe and navigate to “HKLM/SYSTEM/CurrentControlSet/Control/Lsa”. Check the value of “LmCompatibilityLevel” and set it to 1 – it defaults to 3.

For a list of settings for this key, see Microsoft Knowledge Base Entry 239869

On my system I did not have to reboot, I could connect to the Mac share immediately.

LM Compatibility Level 3 means the client will only try NTLMv2 authentication. This will not work against OS X in the default configuration, which only offer NTLMv1. By setting this to 1 you tell Vista to use v2 if the server supports it, but fall back to v1 if not.

While this is a quick and rather simple fix, it degrades security. By default Vista only connects to SMB servers that support the NTLMv2 authentication mechanism, because it is superior to the older variant from a cryptographic point of view. See http://davenport.sourceforge.net/ntlm.html and the Wikipedia entry on NTLM for more details.

In general you should prefer increasing security instead of loosening restrictions. To do so, you should configure XP and Windows 2000 to the same level 3 setting as Vista (the registry key is the same) and also set up Mac OS X to support NTLMv2.

Edit /var/db/smb.conf (using sudo vim) and make sure, the following two lines are present:

ntlm auth = no
lanman auth = no

If not, add or edit them to appear like this. Do not change anything else in that file!

When you are done, relaunch the Samba daemons:

sudo launchctl stop org.samba.smbd
sudo launchctl stop org.samba.nmbd
sudo launchctl start org.samba.nmbd
sudo launchctl start org.samba.smbd

From now on, Mac OS will only accept NTLMv2 connections, matching the higher security standards and refuse v1 clients – so make sure, you configure all your XPs accordingly.

Thursday, February 26, 2009

Funny error with Java’s extended for-loop

Java 5 introduced the enhanced for-loop – or for-each loop – which simplifies iterating over many types of collections. Have a look at this simple piece of code and tell me what’s wrong:

package de.danielschneller.blog.iterator;

import java.util.HashSet;
import java.util.Set;

public class Demo {
	public static void main(String[] args) {
		Set set = new HashSet();
		set.add("Value 1");
		set.add("Value 2");
		set.add("Value 3");
		set.add("Value 4");
		set.add("Value 5");
		
		synchronized (set) {
			for (String tEntry : set) {
				if (tEntry.endsWith("3")) {
					System.out.println("3 has to go");
					set.remove(tEntry);
				} else {
					System.out.println(tEntry + " may stay");
				}
			}	
		}
	}
}

When I wrote this I naively expected something like this to be written out(the order of the iteration is undefined for a HashSet, but bear with me:

Value 5 may stay
Value 2 may stay
3 has to go
Value 4 may stay
Value 1 may stay

Admit it, this is what you would have guessed, too! But instead this code throws an exception! The problem occurs in line 16 and looks like this:

Value 5 may stay
3 has to go
Exception in thread "main" java.util.ConcurrentModificationException
at java.util.HashMap$HashIterator.nextEntry(HashMap.java:841)
at java.util.HashMap$KeyIterator.next(HashMap.java:877)
at de.danielschneller.blog.iterator.Demo.main(Demo.java:16)

Any clearer now? Well, turns out that the hidden magic behind some of the Java 5 features (this time the part that makes the enhanced for-loop possible) promotes  some kinds of problems I – in this case – would most probably have seen and avoided had I used the old-style Iterator approach.

Under the hood there still is an Iterator at work, but the syntactic sugar in the example above hides this detail from you. At compile time the above will be translated into the old-style iteration for you.

Because now there is no obvious Iterator instance, it is easy to forget this important part of the JDK API documentation for “ConcurrentModificationException”:

Note that this exception does not always indicate that an object has been concurrently modified by a different thread. If a single thread issues a sequence of method invocations that violates the contract of an object, the object may throw this exception. For example, if a thread modifies a collection directly while it is iterating over the collection with a fail-fast iterator, the iterator will thow [sic] this exception

This is exactly what happens here. The Iterator is still there, even if it does not appear in the source. It’s hasNext() and next() methods are used to loop through the elements of the collection. Once “Value 3” has been found, the code removes it from the Set directly, bypassing the Iterator. The next time it is used – which is when the next element is prepared to be passed into the loop body – it detects that the underlying collection has been independently changed and obeys its fail-fast policy, producing the exception above.

So in this case, even without the classical problem of multiple threads sharing mutable state, there are two parties modifying the collection. To solve the problem, we have to fall back to the classical looping code:

String tEntry;
for (Iterator iter = set.iterator(); iter.hasNext(); ) {
	tEntry = iter.next();
	if (tEntry.endsWith("3")) {
		System.out.println("3 has to go");
		iter.remove();
	} else {
		System.out.println(tEntry + " may stay");
	}
}

This in fact produces the desired output, however the code looks somewhat more cluttered than before.

Proves (again) that despite lots of eye-candy, syntactic sugar or whatever it is called you still need to understand what is going on under the covers most of the time. A novice programmer might get really confused about this...

Technorati Tags: ,,

Monday, February 02, 2009

Disable drop shadow on OS X screen shots

Recently I found myself doing numerous screenshots on OS X. While the drop-shadow effect that gets included in the resulting PNG files looks nice on screen, it tends to come out rather bad on black and white printouts. As there is no GUI setting for this one has to use the "defaults" command on a terminal:

defaults write com.apple.screencapture disable-shadow -bool true
killall SystemUIServer

Instead of killing the SystemUIServer process you could also log out and back in. To restore the shadow, just delete this property again:

defaults delete com.apple.screencapture disable-shadow
killall SystemUIServer

Oh, and just in case you did not know: These are the keyboard shortcuts to take screen shots in the first place:

  • Fullscreen: Shift-Cmd-3
  • Rahmen: Shift-Cmd-4
  • Fenster: Shift-Cmd-4, Space
Technorati Tags: ,

Wednesday, January 21, 2009

eRCP/eSWT: Windows CE and Win32 (XP): Different Keyboard Event Handling

When developing GUIs with Swing in Java I often swear about event handling, because it sometimes slightly differs from what the underlying platform would do. However when using SWT/eSWT and getting the native behaviors there are also gotchas waiting...

In our Eclipse Embedded Rich Client Platform (eRCP) based mobile application we want to allow keyboard as well as touch-screen access. In order to do so we attach a KeyListener to the buttons that handle the assigned shortcut bindings in addition to a SelectionListener to respond to clicks.

Another feature request called for the possibility to trigger a button by moving the focus to it with the keyboard and then hitting enter.

During development we usually work with the eSWT implementation for Win32. Because by default pressing enter does not do anything on a button, we add another KeyListener to respond to the return key. This usually works flawlessly. However on the mobile device we had trouble with button actions being triggered twice, even though the return key was only pressed once.

It took us some time to realize that the problem only occurs on the Windows CE platform, but never on our XP development machines.

This is were that “closer to the platform” part of SWT comes is: Hitting a button on a CE device seems to be the same as pressing return on it (as well as the space key, however on our hardware there is no way to do so except the onscreen keyboard). As soon as we removed the KeyListener that responded to the CR KeyEvent, the problems vanished on the mobile devices.

In retrospect it is hard to believe that we did not solve this much earlier. Seemingly regardless of whether you use a cross-platform library like Swing or the “closer to the real thing” SWT variant, you always seem to get caught by the same things – the one way round or the other…

Technorati Tags: ,,,,

Tuesday, January 20, 2009

Prefer plain-text message display in Apple Mail

If a received mail contains a plain-text part I prefer Mail to display that instead of the often more “stylish” HTML or Rich-Text parts. While this cannot be configured via the GUI, it can be from the command line.

This is a reminder post for myself and anyone who might be interested.

Turn on:

defaults write com.apple.mail PreferPlainText -bool TRUE

Turn off:

defaults delete com.apple.mail PreferPlainText

Mail.app should be closed while you do this.

Technorati Tags: ,,,,

Friday, January 16, 2009

Windows CE 5 Batch File Caveats

If you find yourself in the unlucky position to have to write some batch files for the Windows CE5 version of cmd.exe (called Pocket CMD v 5.0) you might be interested in these peculiarities I stumbled across today:

  • IF EXIST foldername GOTO label

    This will not tell you for real if a folder called "foldername" exists and jump to "label" if it does. Instead, this will always fail and never jump to the designated target label. You can try this yourself with

    IF NOT EXIST \WINDOWS ECHO "I have no OS"

    If this output were true, I'd wonder where the Pocket CMD that had issued the command came from.

    You need to check for a file contained in that folder with IF EXISTS, which will work fine. If you do not know a file name to check for - for example if you want to check if a removable storage card is inserted, you can check for the "nul" file which will always exist on a FAT formatted drive, according to Microsoft Knowledge Base Entry #65994

  • IF ERRORLEVEL 10 GOTO fatalError

    This will not jump to the "fatalError" label in case the program that last finished with an exit code of 10 or above.

    Instead you will get an error message "Bad errorlevel conditional". In the German localization of CE5 this is even better: "Ungültige Bedingung in Fehlerebene" and proves that the person who translated this had no idea what the message meant. The problem in fact is, that the Pocket CMD only allows single digit error levels!

    If you want (or rather have) to use errorlevels in your batch script, you better hope (or can control) the exit codes of the applications you'd like to query.

If I come across more things like this, I will update this post.

Tuesday, January 06, 2009

Launch Mac application / AppleScript by keyboard

In the comments to my recent post about full keyboard access to Mac OS X GUI controls “christian” asks about a way to open a new Finder window regardless of the front application. I understand his need, on Windows you just hit Windows+E anywhere and get a new Explorer window.

So far I have worked around this when I needed a Finder window by first hitting F19 which I bound to Exposé’s Show Desktop option and then clicking on the desktop. This enabled the finder and allows the Cmd-N hotkey to work.

However being able to just bring up a new Finder window from anywhere would of course be preferable. I first tried through the keyboard system preferences, however even though you can bind new keyboard shortcuts to any menu item by name. Because the application you target usually needs to focused this would not be of much help. There is a “Any application” setting, but this seems to work for a few people if any. I have not managed to get it right.

In Apple’s AppleScript documentation there is an example of how to bring up a Finder window with specific settings (like Column, List or Icon View, the initially displayed folder etc.) that goes like this:

tell the application "Finder"
	set w to make Finder window to home
	set current view of w to column view
	set toolbar visible of w to true
	set sidebar width of w to 0
end tell

On the net I found a nice little application called “Spark”. It provides a working way to define system wide keyboard shortcuts. Among other things like simply launching an app you can also execute AppleScripts. So I just defined Cmd-Shift-E – similar to Windows-E – to run the aforementioned script.

Picture 6

When you first start Spark it allows you to enable it on logon, so it is immediately available even after a reboot. I have not yet tried what happens if an application defines a shortcut for itself, so maybe there will need to be some tweaking.

Sunday, January 04, 2009

Migrate VM from VirtualBox to VMware Fusion

For some time I have been using VirtualBox to run the few Windows applications I still need. While being generally very usable there were still some issues with networking, sharing folders and sometimes the VM would crash when shutting down the guest OS.

Yesterday I decided to give VMware Fusion a chance. I downloaded and installed the trial version. Because I did not want to reinstall Vista and go through the whole update story again I looked for a way to reuse the existing VirtualBox VM. Unfortunately VMware cannot open the VDI files directly.

There are some How-To’s on the web which usually include some trickery with Linux or at least involve several steps, but all those seemed a little too much hassle for me and I kept looking for an easier way.

Turns out, VMware themselves offer the solution for free: Fusion’s main menu bar includes a “Migrate your PC…” option that will just open browser and take you to http://www.vmware.com/download/fusion/windows_to_mac.html.

VMware Converter Web Site

There you can first have a look at a video which shows the process of downloading and installing the VMware Converter started edition. This tool is designed to create a new Virtual Machine from a running physical PC.

I imagined that this tool would not really mind whether I was running Vista on a physical piece of equipment or inside a different virtualization product, so I downloaded it into the Virtual Box Vista VM and installed it.

From there everything was really simple. I just had to click through the conversion wizard and point to a directory (I used an external USB drive) where the new VM was to be created and stored.

Conversion of the Vista installation with approx. 18GB of used space on a 20GB virtual hard disk took about some hours – I let it run over night. In the morning I could simply open the newly created machine with Fusion. Booting took some time and once I had logged in Vista detected tons of new hardware and installed the necessary drivers. One time I saw a wizard come up and ask for drivers for a “Base system device”. As I could not do anything about it I just ignored it. Later I installed VMware tools manually again which seems to have fixed whatever was missing.

Through the Control Panel I uninstalled the VirtualBox Guest additions and VMware Converter which of course migrated itself over.

Live Writer in Unity mode So far I have not seen any problems – the integration experience is really good. I just set up some shared folders with no problems at all. Right now I am writing this post in Windows Live Writer in Unity mode, creating screenshots in Mac OS and simply importing them through the shared folders. Something that seems to be a problem of Live Writer was an exception message when I tried to insert a PNG by going through the UNC Path to the host which starts with \\.host\… This brought up an error where the stack trace said something about problems parsing the host name. I just mapped a drive letter to get around that.

From what I have seen so far I think I will just buy a license after the end of the trial.

Saturday, January 03, 2009

Mac OS X – Full Keyboard Control

As a long time Windows user I still have some trouble finding my way around Mac OS X Leopard without resorting to the mouse all the time. I am a “keyboard person” and like to keep my hands right before me instead of constantly reaching for the mouse.

When I started to use Mac OS I believed it would simply be a matter of practice and learning some new key combinations until I could work as mouselessly as before.

Since August I have gotten much more fluent with the keyboard alone, but something that bothered me ever since was that not every button, tab, slider etc. could be focused with the TAB key or activated using some mnemonic – as is normal in virtually every Windows application, especially Microsoft’s own ones.

On the Mac the focus would only jump between various text controls and not to buttons and the like. I started to believe that the Apple idea of “keep things simple and define a default that’s good for 90% of the people” without a chance for the remaining 10% to have things their way was going a little too far here.

Only recently when I started using XCode to get my feet wet with Cocoa and Objective-C I looked for a way to quickly switch between my default German keyboard layout – which is sensible for writing Mails, letters etc. – and a UK/US English one – much easier to program with as all the square and curly brackets are located in a much easier way. On Windows I just hit the left Alt and Shift keys to toggle thru the list of active keyboard mappings.

Though the Mac’s System Preferences “International” applet I activated the “U.S. Extended” keyboard layout and defined Ctrl-Option-Space as the toggle. Only by change I clicked on the “Keyboard Shortcuts…” button:

Picture 1

This opens the “Keyboard and Mouse” preferences:

Picture 2

There – one the rightmost tab – sits the option I have been looking for: “Full keyboard access”. Switch to “All controls” and now I can readily reach all controls without having to get my fingers off the mouse. Guess it will still be some time until I am “as at home” in Mac OS as I was in Windows.