Regexp fun
November 25, 2009 on 11:57 pm | In IT, fun | No CommentsReading the post about useful regular expressions, remembered what my favourite solution is to one of the questions of the test we give to junior Java developers.
The task is to write a method that takes a string as a parameter and returns the acronym of the string in uppercase made up of the first letters of the words in the string. The acronym must ignore the words “the”, “of” and “and”.
The usual solutions are either to sequentially step through the string (Yuck!) or split it up or use a StringTokenizer class. The people usually overlook the fact, that the input strings can be padded with whitespace, or contain multiple spaces, and they usually ignore, that the keywords that are to be omitted might be found on the begining of a valid word. Thus my test ” United States of Andorra” string breaks most of the methods. The ones who have time to write the answer down, usually forget to return the value from the method, or to change it to uppercase and sometimes even ignore that it should be a method to start with! This is my favourite question, as it can really show how the applicant can handle stressful situations.
I was tired after several interviews one day and tried to come up with the shortest possible solution. Naturally it contains regular expressions.
My solution looked something like this (OK I just reproduced it for the sake of the article, using nano and javac, so it might have overlooked flaws in it):
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 | public class Acronym { private static String toAcronym(String str) { return str.toUpperCase(). replaceAll("(THE|OF|AND)(\\W+|$)",""). replaceAll("(\\w)\\w*\\W*","$1"); } public static void main (String args[]) { if(args.length>0) { System.out.println(toAcronym(args[0])); } } } |
New trends in Linux desktop UIs
November 24, 2009 on 11:14 pm | In IT | No Comments
As I see there is a solid movement to reform the user interfaces that are in use in our computers. After all the menu bars with a start menu are on the mainstream desktops since the win95/OS2 era. And the programs can be started using icons on the desktop and the start menu. For the ones who know what they are looking for there is also a command line. And there is a task bar to switch your running applications. But things ought to change with time, shouldn’t they?
Continue reading New trends in Linux desktop UIs…
Brief – a feed reading extension for Firefox
September 2, 2009 on 4:50 pm | In IT | No Comments
I read several feeds daily, like The Daily WTF or friend’s blogs. Since I always have both Thunderbird and Firefox running on my computer, I don’t want a standalone RSS reader application, like Liferea hog my memory. I don’t want to keep a Google page always open to use the Reader either. I took some time to research an RSS reader, which fits these criteria.
Continue reading Brief – a feed reading extension for Firefox…
Maker’s Schedule, Manager’s Schedule
September 1, 2009 on 1:00 pm | In IT | No CommentsInsightful post about issues in scheduling.
Maker’s Schedule, Manager’s Schedule.
Wicket in action and confusion
August 29, 2009 on 12:53 am | In IT, annoyance | No CommentsFor a recent project lead, we decided to create a mock-up of the application, so the prospective Customer would be able to see that we understand their needs.
As I’m not very good at interactive HTML mock-ups I decided to go with Wicket, which seemed to be useful and easy when a friend showed me. The mock-up progressed well, but upon deployment all Hell broke loose.
Continue reading Wicket in action and confusion…
Creating for a bot for MafiaWars
August 12, 2009 on 11:54 pm | In IT | No CommentsI started playing MafiaWars on my last job, where I had time to spare. As it has happened in the past with me playing on a mud, when the game got repetitive I start writing tools to speed things up.When I was on the mud I used macro-enabled clients, like tintin++ to perform simple tasks for me. Since MafiaWars is a Web 2.0 application, one must emulate a web client, so things are a bit trickier than what one can achieve using a simple wget or shell-script based bot.
Continue reading Creating for a bot for MafiaWars…
Starting VirtualBox on boot
August 6, 2009 on 4:13 pm | In IT | No CommentsAfter setting up VirtalBox based virtualization on our server, I needed a way to have it automatically started and stopped whenever the host is restarted.
Also it would be for the better if the system was not simply started and stopped, but rather saved and restored when possible. I love scripting, but prefer the easy way, and since it’s a problem many have probably already tackled I sniffed around for a while.
There it was, new and shiny tool to make my day!
Starting DB2 instances on boot
August 6, 2009 on 10:32 am | In IT | No CommentsAfter migrating our hosted application to a virtual server I realized, that as usual the system is a “maintenance free” Linux, meaning we set it up as it were and left it running for ages without touching it. On the occasion of power failure the applications were started manually.
As I don’t want to restart everything by hand, whenever our system is restarted I decided to iron these glitches out. OK, the system is only restarted about twice a year, but I tend to forget to restart things manually, so that’s the real reason.
Continue reading Starting DB2 instances on boot…
Migrating from physical to virtual server with pain and tears
August 5, 2009 on 3:45 pm | In IT, annoyance | No CommentsWe host the server for a legacy application in our office. Since it’s more like a favor than a real assignment we don’t care much about the server. However we had a few network issues lately, so we decided to migrate it to a virtual server running on our hosted server. Also the machine produces lot’s of heat and noise, so we’d better had it switched off.
This seemed like such an easy task to do, what could be hard in creating a disk image with CloneZilla, copy it to a server, set up a virtual machine there with kvm, restore the image and redirect all traffic to this computer instead of the one in our office. We estimated it could be done in two to three hours tops, and we get home around 7PM.
Continue reading Migrating from physical to virtual server with pain and tears…
Using JAX-WS without code generation
August 5, 2008 on 11:58 pm | In IT | No CommentsSomething gave me the weird idea to try the new features of JAX-WS on a current project. The main idea was, to get rid of the code generators that must be ran whenever some minor change is done in the web service.
So instead of designing the WSDL along with the matching schema definition for the connector classes, I decided to start of by designing the interfaces and the connector classes, then just create the implementation with the corresponding annotations on the server side, that will be deployed automatically. The WSDL is generated from the annotations and the connector classes, there is no need to write them manually.
Continue reading Using JAX-WS without code generation…
