Thursday, March 18, 2010

Snorcle day

I have spent this day in the warm embrace of Oracle. Due to their recent acquisition of Sun Microsystems they hosted a fluffy suit event this afternoon and then sponsored the more stuffy Javaforum tonight. Naturally the acquisition is a big event in the computer world affecting everyone writing software in Java and making Oracle into another IBM. Suddenly Oracle not only have the full suit of software needed to run a business - they also have Suns outstanding hardware. This means - as the suits pointed out over and over again - that they can deliver integrated solutions with extreme everything (seems like the pool of superlatives is running out - the word extreme appeared more than once). Still they vow to continue supporting open standards so that the result is not another vendor look in alá Microsoft. In practice though it may effectively leave customers with the choice of buying the full Oracle stack or spending lots of money integrating parts of the stack with products from other vendors. This is probably not a good thing for the diversity of software business. Some other sightings that may or may not scare you:
  • every Oracle presentation starts with a legal disclaimer slide - kind of nicely sums up the corporate culture
  • new elevator message: "Software. Hardware. Complete." - as usual with engineers they forgot about people. I like the dots after each word though.
  • "There will be no forced migrations" of current Sun customers. Great I guess but there will on the other hand be new no development on a wide range of Sun products. Just a bit of support....
  • Martijn Vlek - the middleware suit - said: "We are very proud of sort of 'own' Java now."
This fluffy event was repetitious and not very dense so I slipped away for some Rails coding and a geocaching walk before the stuffy event.

The JavaForum stuff started with Dan Bergh Johnsson talking about future performance problems and how we should solve them with event driven architecture. He probably meant JMS on the server side. I agree that we have a problem with performance when integrating all our systems but I am pretty sure that JMS isn't the way forward. This whole issue may call for another blog post actually. We'll see. Then Adam Messinger who works as Vice President Development Fusion Middleware at Oracle talked vaguely about Oracles strategy for Java. It was pretty much the same message as during the fluffy session. Everything will be supported for a while but in most overlap cases the Oracle solution will be the strategic product of the future. It feels a bit like they want to sound like the good guy now but they might do whatever in the future. The serious part of the evening ended with a panel of mostly oraclers taking questions from the audience. Some really interesting questions were brought forward but the Oracles reps didn't really answer much of them.

My personal feeling about the merger is that I couldn't care less. I don't care much for the Java world anymore. Long gone are the times when I looked forward to new interesting articles in JavaWorld. Java is a nice language but there are far superior languages to use in most cases. Java - or rather the JVM - as a platform for other languages is really cool. The enterprise thingie is just a big mess of stuff without real value to the business. And I don't think Oracle will make it much worse. Java could have gone worse places.

Thursday, March 11, 2010

Notes on my Nexus One

Google gave me a Nexus One when Android Developer Labs visited Google Tech User Group Stockholm. (Thank you Google! Do you own my soul now? And another thank you to Peter Svensson that made GTUG happen in Stockholm.) This is possibly the best phone I have ever owned so here are a couple of notes after using it for about a month. My previous phone was a Nokia N95 which was ok but not outstanding at all.

The screen is awesome. With a great resolution (800x480 compared to 480x320 on the iphone) all applications feels crisp and looks great. It is even possible to watch youtube videos with no apparent loss of video quality.

The virtual keyboard is a bit hard to get used to but I think it will prove useful in the end. I probably type faster on it then on a standard phone keyboard. While typing english it is also great with suggestions. Typing in swedish is not so good.....

It is possible to run things concurrently. I can listen to Spotify while browsing the Internet or running sports tracker Endomondo. The possibility to run things in the background and switch seamlessly between applications makes the device more powerful.

I got a 4GB SD card with the phone. This means that I can have a spotify list of 500 songs stored on the device. This is really needed since Spotify does not run well in online 3G mode. 3G probably isn't fast enough yet. Spotify manages online/offline without me having to do anyting more than (un)checking boxes.

There is a GPS in the phone that works really nice. It finds my location really fast. With my Nokia I had to stand still for a minute while the GPS searched for satellites - not good..... This means that Endomondo, Google Maps, Google Earth, foursquare, gowalla, twidroid et al knows my position fairly well most of the time. While being outside..... And this is of course a prerequisite for augmented reality apps - more on that later.

The browser is really good. It has multi touch support so it is easy to navigate pages. I was satisfied with the built-in browser in my N95 but this one is so much better. One reason is the great Google Reader mobile implementation that makes it easy to keep up with feeds when on the move (or in meetings). The possibility of changing the phones orientation to landscape mode makes most web pages readable even when the text is a bit wide.

There are some augmented reality apps for the phone. I have tried Google Goggles and Layar and there probably are a couple more that I don't know of. Goggles is a kind of search through the camera. You point and something and click and in some cases you get a decent search result or a similar picture out of it. It is supposed to work great with landmarks but I don't think any building out in Sollentuna qualifies as such... It also scans text and sometimes finds appropriate search results. I tried it with a wine bottle and it correctly found the site of the wine maker. Other trademarks doesn't work so well. A Cola label didn't work at all. It looks like they are crowd sourcing the results so maybe it is improving organically somehow.... It is a cool app anyway! Layar is a framework for viewing "points of interest" through the devices camera. Layar provide the engine and third parties provide with list of points. Anyone can setup a back end layer that serves points to layar. Examples of layers to use in layar are nearby tweets, geolocated wikipedia entries and max burger joints. Augmented reality are certainly a technology of the future and once screen technologies move away from the handheld to retinal projection or useful head-mounted displays this will really take off. (2020?) An interesting development to follow. [interesting about augmented reality user manuals]

A local app that has been really useful is Johan Nilssons local commute planning tool. It is a front for the journey planner at www.sl.se. It works really great with the GPS and you can save commonly used locations. It is one case when the phone seriously beats your desktop computer.

Another thing that may seem trivial but that REALLY WORKS is the calculator. On a "normal" phone calculating stuff involves lots of button pressing. With the touch screen it is just as easy as a special purpose calculator.

And of course - being a "professional" Java developer - I can code my own apps. Haven't really done much yet but after the current side project there may be some more android coding. And despite being Java it is a really cool platform to work with. There are also lots of initiatives that will bring dynamic languages to the platform. Check - for example - out Mikael Kindborgs effort on bringing Javascript to the platform. He calls it droidscript and blogs about it. I really wish I had more time to try these cool things out.

The least useful but possibly coolest feature is live wallpapers. They are downloadable from the store like any normal app and there really aren't anything more to say about them.... I can have digital rain on my phone and that makes me a bit more happy....

A downside in sweden is that the market for apps is only serving free apps at the moment. There are probably a whole bunch of great apps to pay for that I can't download yet.

Monday, March 08, 2010

How to process files with spaces using bash

The other day I wanted to rename a whole bunch of images with spaces and brackets in them. I had files of the form filename1 (1).JPG, filename1 (2).JPG, ..., filename2 (1).JPG, ...
In case you are wondering, these file came from a windows box where copies of files get saved in the format filename().xyz. I know that from a OS point of view spaces in file names are no problem, but hell are spaces a pita if you have to process the files in a script. So what I wanted to do was to remove the space with a '_', replace the brackets and while on it lowercase the filenames (I really just don't like JPG, I want jpg). For these kind of problems I would normally try a for loop. Here is my first attempt:

for i in `ls -1 *.JPG`; do j=`echo $i | tr -d "[:blank:]" | tr "[:upper:]" "[:lower:]" | tr "(" "_" | tr -d ")"`; mv "$i" "$j"; done

The idea is to process each file name in a loop, transform the filename with a a set of tr calls and then do a final rename of the files using mv. tr takes its input from standard in and writes to standard out, hence the trick of first echoing the current value of the iteration, passing it through several tr calls and then assigning it to a temporary variable. Note the use of the character classes for the transformation via tr.

This one liner works fine for file names without spaces, but as soon as there are spaces in the file names you are getting into trouble. The default field separator of a for loop is the space character which means file names with spaces are causing two iterations of the loop. One solution to the problem is to set the $IFS variable prior to executing the for loop. The value of this variable determines the field separator. However, in this case you also have to remember to reset the variable afterward.

Another approach is to  use a completely different construct which you don't see so often. Let's use find together with a while loop.

find . -name "*.JPG" -print0 | while read -d $'\0' file; do j=`echo $file | tr -d "[:blank:]" | tr "[:upper:]" "[:lower:]" | tr "(" "_" | tr -d ")"`; mv "$file" $j; done


We use find together with the -print0 option to print all file names into one line separated by a ASCII NUL character. In the loop we use read together with the -d option which determines the delimiter for read. The rest is the same as in the for loop solution.

Hope this helps some people, but maybe its just me who gets frustrated with spaces in file names ;-)

Enjoy,
Hardy

Thursday, March 04, 2010

Support at its best

Fredrik and I are working on a little Rails app at the moment (more to this in a later post) and decided to host it on Site 5. The features of the hosting package are what you can expect from any decent hosting company our-days and would not be worth writing about, but there is one thing which really makes Site 5 stand out from the crowd - their support. This guys have excellent support and the best is the support chat functionality. You have a problem? Just click on the Chat Now button, type your question and within seconds you are chatting with someone who tries to help you. Many problems can be resolved on the spot and for others support tickets will be created. After the chat you just provide your email address in the chat window and you get a transcript of the chat sent to you. No waiting in a phone queue for hours the phone pressed to your ear in fear you might miss the moment where it is finally your turn, no unqualified people who don't have a glue what you are saying, no useless problem categorization games before you can talk to someone. No just a simple line of communication to someone who knows what he is talking about.
So listen up you Dells, Telias, Comhems, ... of this world - what works for them can work for you! And for heavens sake, get rid of this ridiculous voice recognition driven help systems. They are just a pita.

Enjoy,
Hardy