Archive for Mac

08.01.07

Sail on silvergirl, sail on by

Posted in General Ramblings, Mac at 8:33 pm by kkj

Vacation time and the weather still sucks … DMI and Accuweather both agree on this and almost with identical forecasts :-) . At the same time I’ve been struck by a frenzy, a crazed state of widget-mania ignited by my recent success in the field *coughs*. Talk about being stuck between a rock and a hard place …

I often travel from Ã…rhus to Copenhagen by car and whenever I remember to check the itinerary the day before and actually get up in time I choose the short cut by ferry to Zealand. This gives me an hour to doze or read while digesting the possibly most expensive breakfast in Denmark. That is, when I remember to check the schedule.

The ferry I take is operated by Molslinjen who offer up-to-date travel information in HTML and WML. I’ve bookmarked the WAP link in my cell, but thought it would be nice to have a widget that displayed the same information as well. As an added bonus that would mean having a fairly decent project on which to experiment with AJAX. Enter: The Molslinjen Widget:

The widget uses the Javascript XMLHttpRequest object to retrieve the current itinerary in WML format asynchronously whenever the Dashboard is displayed. You can switch between the different routes by clicking on the headline, and get to the not-so-informative back page by clicking on the info icon, which appears when the mouse rests over the widget.

For some reason, the WML offered by Molslinjen is not well-formed. My cell phone doesn’t seem to mind, but the XMLHttpRequest object choked on the XML and I had to perform a bit of string replacement to work around the problem. If Molslinjen ever decides to remedy this shortcoming, my widget will break.

Oh and I should mention: Molslinjen is not involved in this project. You can use the widget at your own peril as long as you leave me out of it, should you miss the ferry anyway.

Sail on by!

07.24.07

Apologies!

Posted in General Ramblings, Mac at 8:33 pm by kkj

Okay, so given that we have a Paris in Denmark as well, I guess I should have expected there to be a Copenhagen in the USA also. Turns out my AccuWeather widget defaults “Copenhagen” to “Copenhagen, USA” … obviously. When you enter “Copenhagen, Denmark” you get a more accurate picture of the weather situation:

Sorry about the noise AccuWeather - maybe you should consider adding a country code to the city name as well to avoid similar situations in the future?

07.22.07

Prediction is difficult …

Posted in General Ramblings, Mac at 8:24 pm by kkj

… especially of the future! This fact of life has to be a daily nuisance to meteorologists all over the planet as they struggle to interpret satellite images of the Earth’s atmosphere painted in all colors of the spectrum. Meteorology is a science of probabilities, a trade whose precision diminishes rapidly the farther into the future predictions are made. Tomorrow’s weather can almost always be predicted with certainty, but what about today’s?

InAccuWeather

The OS X Dashboard sports an “Accuweather Widget”, which, although extremely slick in its look and feel, fails miserably at displaying even the current weather situation. At least in Denmark. Today on July 22nd 2007 AD the Danish Meteorological Institute (DMI) informs anyone who shows an interest that it is raining. In fact it will rain so much here that the institute has issued a warning for “extreme weather conditions” with 17°C and yet AccuWeather thinks that we have a cloudless sunshine here and 27°C!!

Did anyone say “useless”??

What to do? I decided to ditch AccuWeather and write a widget that grabs the current 5 day forecast image from DMI. The result can be seen in the picture below with AccuWeather gleaming sunshine on a rainy Sunday:

The image caching nightmare

Writing a widget is not rocket science, and requires little more than HTML and Javascript skills in its most basic form. The Dashboard is basically a specialized web browser. Brilliant! Unfortunately this also means that widgets inherit any problems that browser applications suffer. One of these problems relate to the caching of images. In this case, the forecast, which DMI has decided to publish on the same image URL. The current 5 day forecast for Eastern Jutland, for instance, is always published on http://www.dmi.dk/dmi/200611090030_cms6dognostjylland.jpg”. Once the Dashboard has downloaded this image, it will be cached for the lifetime of the widget i.e. until it is eventually removed, and so the forecast slowly but surely becomes irrelevant.

I spent the better part of an afternoon scouring the web for solutions to this annoying problem and ran in to numerous frustrated Javascript developers. After pondering the problem some more I came up with the following possible solutions:

  1. Delete the widget cache. The Dashboard cache lives under ~/Library/Caches/DashboardClient and can be removed by a user with root privileges without problems. In theory this solves the problem, but alas the Dashboard will have to be restarted for the cache to be reread. No go.
  2. Write an applet that gets the image. I was hoping a Java or a Flash Applet could do the trick, but these are limited to their sandboxes and can generally not access the HTML DOM of their enclosing document.
  3. Make a server side PHP image proxy. This site, Vaportrail, has PHP support and I wrote a simple script to proxy the image from DMI. While this solution works, it means lots of irrelevant traffic on my site and hence load. Not the best solution.
  4. Leverage the fact that widgets have extensions for calling shell scripts. A bash script could use CURL to get the image, write it to /tmp/ with a name made unique by the current date, and the widget could load it from the local folder. Eureka!

Caveat: While my solution works, it will fill /tmp/ with images: one per day per region you choose to display. I could have implemented a cleanup facility in the shell script as well, but I am not a big fan of scripts that perform “rm” on my local folders. I leave that as an exercise for those with strong stomachs.

The widget can be downloaded from this link. Quote Apple: “Mac OS X v.10.4 Tiger is required. If you’re using Safari, click the download link. When the widget download is complete, the widget installer appears. Click Install if you want the widget installed on your Mac. If you’re using a browser other than Safari, click the download link. When the widget download is complete, unarchive and open it to show the widget installer.”

Enjoy! And have a sunny summer …

04.30.06

Taming the Tiger

Posted in General Ramblings, Mac at 8:44 pm by kkj

I am typing up this post on silver keys, a soft backdrop of pale moonlight glowing through each letter and symbol, screen dimmed to spare my eyes. In the wake of Commodore’s demise, for a decade I’ve been slugging along with Windows on bulky PCs with no elegance or style, just muscle. But no more, ’cause finally supreme and superior design go hand in hand with high-end gear: I’ve bought an Intel based MacBook Pro.

Apart from its sleek looks and raw power in the shape of a 2.2 Ghz dual core Intel chip beefed up with 2GB of memory, my MacBook sports stereo speakers, a magnetic tripsafe power cord, wide screen, light sensors, and a builtin motion sensor designed for harddrive protection, and put to more cool uses by community geeks: how about a car-like alarm, which can be armed and disarmed by the Mac’s remote control, and which will trigger if someone so much as tries to lift the machine?

And don’t get me started on the virtues of Mac OS X (”Tiger”), which is by far the most elegant version of Unix I ever worked with and years ahead of what the Redmond Empire has ever produced. I’ve spent the better part of a month now taming this truly amazing beast and while the task has been daunting at times, it has been worth the effort.



Mac os X with Windows: I named him Garfield - my pet XP

  • Office Software. I use Microsoft Office and Visio - and yes, I have tried OpenOffice too, but it just can’t measure up. Now this is a problem on a Mac, for it’s Microsoft Office versions are slugging behind and the 30 days trial of Office 2004 (!) has too many issues . My company already has a Microsoft Powerpack deal going on, which gives us heavy rebates, and the Mac versions are not included. I solved the problem by installing a VM called Parallels, a truly amazing product which is very fast, and although still in beta, works well. My OS X and my VM with Windows XP now share the same files and the clipboard. I used to use Powerpoint for presentations, but after trying out iWork Keynote I switched instantly.
  • Development tools. Well OS X is Unix so no need to install Cygwin or the like to get a decent set of shell commands. Intelli/J is already ported to OS X, and I used the opportunity to upgrade my license to 5.1. Works like a charm. Instead of XML Spy I got me Oxygen, which is really cool too. Most of the other tools I use are built with Java and do seem to live up to the “run anywhere” sales pitch.
  • IM. I mostly use MSN Messenger these days, and like Office, the Mac version is generations behind the Windows version. Parallels to the rescue again! Yahoo messenger is up to speed though like Skype.
  • Planning.My contacts are now imported into the OS X native Address Book app, and my schedule is in the native Calendar app. I synch my archaic Nokia 6230 over bluetooth with both applications using the native iSynch program. For email I setup both the native Mail application and Mozilla Thunderbird which I used on Windows too. The native Mail uses the built-in address book, and Thunderbird does not. We’ll see.

I still haven’t figured out a way to print to my wireless D-Link printserver from OS X and the manufacturer states rather explicitly that they will never support anything but Windows. Fortunately I AM running Windows (in a window) … and I CAN print from my XP VM so going via the native PDF facilities of Mac OS X, anything can still be printed.

In conclusion it is involved to make the switch from XP to OS X, but it is one well worth the effort!