Archive for May, 2007

apachectl restart vs stop start

This is a note to myself as much as anything:

apachectl restart is not the same as apachectl stop followed by apachectl start

In particular, the ServerLimit configuration item will not be re-read if restart is used.

Comments (1)

My problem with Guice

I went to a presentation at my local Java User’s Group last Monday on Guice. I’m a long time Spring user (and fan), so I was interested to see what benefits it had over Spring.

I came away with the impression that Guice looks pretty interesting, but its main benefit over Spring is the lack of XML. That’s okay I guess (although I personally think the case against XML is often overstated). I certainly wouldn’t be opposed to using Guice in a project based on what I saw - except for one thing….

My big issue with Guice is the fact that it appears to be invasive. Based on the presentation I saw it seemed that you need to instrument your code with @Inject annotation for the dependency resolver to provide that dependency. That’s fine in your application code, but it means wrappers seem to be required for third party libraries. However, there are some hints from the documentation that this isn’t the case (’Observe the Java type and the optional “binding annotation” of the element to be injected‘). OTOH, ’sometimes you can’t use annotations, and you need to manually wire up an object (a 3rd party component for example). When this comes up, you write a custom provider‘ (See http://code.google.com/p/google-guice/wiki/SpringComparison). That’s kind of confusing, and something I’ll need to investigate more.

All in all - an interesting option, and one that certainly replaces PicoContainer as the best code-centric dependency injection container.

Comments (1)

DWR Callback closures inside loops

I’ve been doing a fair bit of Javascript lately. Like anytime I learn a new language I look back at code I wrote a week ago and thing OMG… what was I thinking!?

One useful thing I learnt today was how to use the DWR closure callback pattern inside a loop.

My original code looked like this:


var taggedLinks = $$(".taggedlink");

for(var i=0; i < taggedlinks.length; i++) {
	RatingApi.getRating(taggedLinks[i].href, {
		callback: function(data) {
			displayRating(data, taggedLinks[i]);
		}
	});
}

Where RatingApi.getRating(..) is a DWR AJAX call. It’s fairly clear what the problem is: the displayRating function is called when RatingApi.getRating returns. Obviously the value of i will be not what was expected.

The solution looks like this (thanks Ben!):


var taggedLinks = $$(".taggedlink");

for(var i=0; i < taggedlinks.length; i++) {
	var remoteCall = {
		index : i,
		callback: function(data) {
			displayRating(data, taggedLinks[this.index]);
		}
	};	

	RatingApi.getRating(taggedLinks[i].href, remoteCall);
}

Comments (6)

Desktop Tower Defense

Yes, I’m probably the last person on the planet to try and, and yes, it may well be the spawn of Satan. In fact, I think it’s likely society will collapse due to desktop tower defense addiction.

Oh well. I’m not going to worry about that until after I’ve had just one more go (Whatever you do, DON’T CLICK ON THAT LINK)…

Updated: I’ve written a short Desktop Tower Defense Strategy Guide.

Comments (1)

Sunshine disinfects.. unless you live in Australia

So I’ve been quite interested in the work TheyWorkForYou have been doing in the UK. It seemed like a good idea to do something similar for Australia - after all we have an election due soonish, and what’s another project to add to my list?

I figured that a good thing to start with would be to create some kind of API to give access to Member of Parliament’s financial interests. After all, it was only a few months ago when the former Federal Minister for Aging Santo Santoro had to resign over his financial dealings.

I was hoping I’d be able to find a page on the Parliament website which I could screen scrape and use as a data source for an API. After quite a lot of searching I was forced to send an email asking for help.

From that inquiry I found that neither the Senate nor the Representative’s Register of Pecuniary Interests is available online, or in any electronic form at all. The only way to see it is to physically go to Canberra, make an appointment and then copy the it which interest you.

As tempting as that sounds, I think I might start somewhere else….

Comments

BadMagicNumber take 4

Yes, I’ve moved my blog (again), this time to Wordpress. If you are reading this then all code to redirect feeds has worked. Visits to posts on mackmo.com should be redirect here, too.

I’ve been blogging since early 2003 (although I lost the dates for everything prior to June 2003 in a small domain-name related accident). It’s pretty amazing how far blogging tools have come in that time.

Now all I need to do is use these wonderful tools a little more often than I have been.

Comments