Monthly Archives: December 2009

The Java DOM API sucks

How it sucks
I recently wrote some code to filter nodes from a DOM and had issues with NullPointerExceptions:
NodeList nl = doc.getElementsByTagName(“mytag”);
for(int i = 0, n = nl.getLength(); i < n; i++) {
Element elt = (Element) nl.item(i);
if(…) {
elt.getParentNode().removeChild(elt);
}
}
The problem was that NodeLists are live, and removing elements while iterating changes the indexes. When I tried to [...]

Kubuntu 9.10

I just upgraded to Kubuntu 9.10. The upgrade pretty much just worked (unlike my horrible experience with the last one which left my computer unusable). A few settings got lost such as the default font size. Nothing broke, though.
A few annoyances did get fixed. Among them was the fact that in 9.04, Flash [...]

“sudo nice” versus “nice sudo”

While re-testing the script mentioned in my last post, I decided to play a little safer. I changed “sudo foo” to “nice sudo foo”. However, it turns out that on my machine (running Ubuntu 9.04), processes launched by sudo do not inherit niceness. From a web search, though, I gathered that they do on some [...]

killall is your friend

I created a backup script that needed to run as root. For convenience, I named the script backupWeb.sudo and created a script called backupWeb that would call backupWeb.sudo with sudo. Of course, I forgot the .sudo suffix, and the script launched itself recursively. The result was a less-lethal fork bomb.
My computer was nearly unresponsive. Thankfully, [...]