XMLDom::Save() Permission Problem

I had been hitting my head against the wall when I couldn’t get an edited XML file to save due to file permissions, even though I know that it was OK.

For some odd reason, when I went to save the XML file, it would try to write the file to the root directory, instead of the current working directory (where the file is read from).

As such, using realpath() to keep the complete system path to the XML file when you load it will make sure that DOM isn’t trying to save to the incorrect directory:

$myfile = 'myxml.xml';
$myfile = realpath($myfile);
$doc = new DOMDocument('1.0');
$doc->load($myfile);

// Let's just add a couple of elements for good measure
$root = $doc->documentElement;

$title = $doc->createElement('title');
$title = $root->appendChild($title);

$text = $doc->createTextNode('This is a title');
$text = $title->appendChild($text);

$doc->save($myfile);

Getting Started With Amazon As a CDN – Part 1

cloudfrontlogo

Content delivery networks are all the rage now, so I’m looking at creating a CDN that will work nicely with my WordPress installation.

Rather than just blindly use a plugin, I want to make the code trustworthy and reusable among other blogs that I manage. Certainly the easiest way to get a CDN working on your blog is to use the Jetpack plugin from Automattic. This transparently turns the content on your blog into a CDN-delivered bowl of web content.

Some people might not want the full weight of the Jetpack plugin or to use the WordPress CDN so here we go. I’m going to step through the process that I used to get a CDN working myself. Continue reading Getting Started With Amazon As a CDN – Part 1

Ugly Font In NetBeans on Ubuntu

NetBeans Logo

A couple of times I’ve hit an issue whenever I install NetBeans on Ubuntu.

The fonts in the menu and explorers become bold. This is mostly not an issue, but when you are editing files the font changes from normal to bold so that you know that you have unsaved changes.

This appears to be a bug with the Oracle JDK, but it’s Ubuntu’s fonts that are triggering it. The easiest way to fix this until there is some proper resolution is to run the the following command to remove the fonts.

sudo apt-get remove fonts-unfonts-core

This will remove the fonts causing the issues. Restart NetBeans for the changes to take effect.

See the bug report at NetBeans for more information

Other Places

moonlighting

I’ve been somewhat busy latey so this isn’t the typical technical blog post, but rather a pointer that my regular readers can find me posting semi-frequently on here but also in other places.

That’s right, I’ve joined the ranks of the unpaid professional blogger and so you can find me writing with my friends over at BlackBerryOS.com about BlackBerry news.

Keeping with the BlackBerry news, I’m also the co-host over at QuickBerryPodcast.com where we record weekly.

So, business should resume as normal over time here as I’m steering clear of posting more RIM or BlackBerry related content. Instead, I’ll be sticking with the dry technical ideas and how tos.

Enjoy!