Top posts

Posts in Development


Erasing partition stupidity

Posted by Jongerius under Development, General Rant
1 Star2 Stars3 Stars4 Stars5 Stars6 Stars (No Ratings Yet)
Loading ... Loading ...

Sometimes I just have the worst luck possible. Yesterday was one of those days. I recently had some issues with my HHD in my work laptop. So I thought why not install Ubuntu on a spare partition I never use.

So far for the good idea, but when Ubuntu asked me what partition to delete I wasn’t sure which was the spare one and which one contained all the source code of all applications and websites I developed. And you probably guessed it, I erased the wrong one.

Gone is a couple of days of work. Serves me right for not checking it in every day :-(


IE framesets and printing

Posted by Jongerius under Development, Webdevelopment
1 Star2 Stars3 Stars4 Stars5 Stars6 Stars (No Ratings Yet)
Loading ... Loading ...

So I recently encountered a weird problem with printing in Internet Explorer. To ease the usability of a website we opened a new window that had a frame-set in it with 2 frames. The first frame contained a button to close the pop up and the second frame a clone of the page to be printed. This was done to apply a slightly different lay-out to the print version.

For some reason some of our customers reported that the print-out font size was bigger then it was supposed to be. And in some cases the tables didn’t even fit the page anymore. Surprisingly everything worked normally in Firefox, and only the customers using IE7 and above reported the issue.

After a couple of hours debugging it turned out that IE jumped into some weird rendering mode that caused the content not to fit a normal A4 page anymore. Appearantly adding the DOCTYPE definition to set it to compatability mode helped solving the problem. So I included the below to fix the issue:
<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.0 Transitional//EN" "http://www.w3.org/TR/html4/loose.dtd">


Advanced enum’s in Java

Posted by Jongerius under Development
1 Star2 Stars3 Stars4 Stars5 Stars6 Stars (1 votes, average: 5.00 out of 6)
Loading ... Loading ...

Ever since Java 1.4 the usage of the enum type is supported. For those who don’t know an enum is a more elegant way to store constant options. Below is a simple example of how it enhances your code:

public static final int ANIMAL_DOG    = 1;
public static final int ANIMAL_FISH   = 2;
public static final int ANIMAL_CAT    = 3;

Into something a bit more object oriented:

public enum Animal {
  Dog,
  Fish,
  Cat
}

But when you have the need to serialize the enum values then you may have to use a bit complicator code. It is supported just not out of the box. So lets say I want to predefine the ordinal number and add a name for each animal in my enum. Then I would have to add something similar to this:

public enum Animal {
  Dog(10, 'Swoop doggie'),
  Fish(20, 'Blub'),
  Cat(30, 'Garfunkel');

  int iOrdinal;
  String iName;

  private Animal(int aOrdinal, String aName) {
    iOrdinal = aOrdinal;
    iName = aName;
  }
}

Now each one of the enums values consists out of a name and a custom ordinal which can be used to save the value in a database or represent it in a form. Off course you would have to add methods to obtain the name and ordinal like:

public String getName()    { return iName; }
public int    getOrdinal() { return iOrdinal; }

That introduces a second problem, if you represent the enum Animal by its ordinal on for example a webpage you will need to be able to regenerate the correct enum value by its ordinal representation. To do this you could add a method to lookup the correct Animal for any ordinal like:

public static Animal getAnimal(int aOrdinal) {
 for(Animal lAnimal : values()) {
   if (lAnimal.getOrdinal() == aOrdinal) {
     return lAnimal;
   }
 }
 return Animal.Dog; // default value required
}

Started work on a Calendar plugin

Posted by Jongerius under Development, Webdevelopment
1 Star2 Stars3 Stars4 Stars5 Stars6 Stars (No Ratings Yet)
Loading ... Loading ...

Since my last work on a custom combobox went so smooth I decided that it is time to try and build yet another custom plugin for JQuery. This time round I’m building a custom calendar object. Now I know these already exists, but this is mostly an experiment to build more experience in developing for JQuery.

As this plugin will require a bit more work then the combobox I have no idea as to when I can release a first usable version. But as soon as I do I will publish it here ;-) .


Image effects NextGen gallery failing

Posted by Jongerius under Development, Webdevelopment, WordPress
1 Star2 Stars3 Stars4 Stars5 Stars6 Stars (No Ratings Yet)
Loading ... Loading ...

It was recently brought to my attention that the WordPress plugin I use for posting images on this website was not working properly anymore, thanks for warning me of this issue. Well not working properly in the sense that images would get opened in the same window, with no options to navigate back to the post.

Initially I thought that this was caused by the plugin I use for this called NextGen Gallery. After all this plugin failed to do its job properly, but unfortunately that was a bit stupid thinking on my part. I should have realised that the plugin stopped working after an upgrade of the WordPress blog powering the website. For some reason the thickbox JQuery extension produced JavaScript exceptions.

I don’t know exactly why it doesn’t work like expected and I don’t really care either. Suffice it to say that changing a small piece of code in the ‘wp-includes/js/thickbox/thickbox.js’ fixed the issue. All I had to do is modify the tb_init function into the following:

function tb_init(domChunk)
{
     jQuery(domChunk).bind("click", tb_click);
}

I think it must have been some conflict in the JQuery versions or something, since it used to call the ‘.live‘ method on JQuery. But this was what was causing the exceptions. If anyone knows a more permanent fix for this issue please let me know.

« Previous PageNext Page »