Category Archives: Software Development

Anything to do with web / software development

Pepipopum – automatically translate PO files with Google Translate

Edit: Since I wrote this in 2009, Google have withdrawn free access to the translation API. I’ll leave this post up for anyone using the paid version though…

If you’ve ever worked on localizing an application or website, you may be familiar with the .po files used with GNU gettext and compatible tools.

I’ve written a script which can take a .po file and translate any untranslated strings with Google Translate. This may not be a ‘release quality’ translation, but does speed up the job of a real translator, who can simply proof read and correct the machine-translated entries.

See it in action here: http://pepipopum.dixo.net

I’ve released the source under the Affero GPL too, so you can tweak or host it yourself. The version hosted above does have a one second delay between translations, so if you want to go faster you’re encouraged to do exactly that!

Hope someone else finds it useful.

There’s a bit of me in PHP!

Last October I found a bug in PHP’s SOAP module. It was pretty obscure bug in the way PHP used Digest authentication. As it was a showstopper for me, I submitted a bug report and wrote a patch to fix it.

It took a while, but my patch has finally been merged into the 5.* and 6.0 sources!

I’ve been using PHP for ten years, and so it’s perhaps a little surprising it’s taken me this long to give anything back. Truth is, this was the first time I’ve come across a bug which halted my development work.

It’s a tiny fix, 6 lines of code, but it makes me happy that after all this time, finally, there’s a bit of me in PHP! Hurrah for open source software!

Using Doxygen help in QtCreator

If you’re documenting your classes with Doxygen tags you might be wondering if you can use that help inside QtCreator and get those F1 tooltips whenever you hover a documented class or method.

I wondered the same thing, and it turns out Doxygen needed a little tweaking to make it work. Karsten Heimrich at Nokia rather kindly wrote a patch which will eventually make it into Doxygen, but if you have burning desire to try this, here’s what you do….

Patching Doxygen

Once I hear that Doxygen includes this patch I’ll remove this section – so if you’re reading this, you probably need to patch. So, lets grab the latest sources and apply the patch.

svn co https://doxygen.svn.sourceforge.net/svnroot/doxygen/trunk doxygen-svn
cd doxygen-svn/src
wget -O doxygen.diff http://blog.dixo.net/doxygen.diff
patch < doxygen.diff

cd ..

Then configure and build doxygen with any options you might need. Most people should be able to simply do this

./configure
make
make install

You should how have the patched doxygen in /usr/local/bin.

Generating the help

There are some Qt Labs posts on generating Qt Help from Doxygen, but here's a quick run through:

To generate a Qt .qch file you'll need the following entries in your doxygen configuration file


GENERATE_QHP = YES
QCH_FILE = /path/to/output/helpfile.qch
QHP_NAMESPACE = com.yourdomain.subdomain
QHP_VIRTUAL_FOLDER = yourfolder
QHG_LOCATION = /your/path/to/qt/bin/qhelpgenerator

Run patched doxygen and you should end up with a .qch file in the filename given by the QCH_FILE option. Almost done!

Installing the help in Qt Creator

  • Go to Tools -> Options -> Help, click "Add" and browse for the generated .qch file.
  • Click OK and your namespace should now be listed in the registered documentation box
  • Click OK to dismiss the options dialog
  • Now for the important bit - restart Qt Creator. If you don't do this, the help doesn't get propertly integrated into the IDE, at least on Qt Creator v1.1.

That's it! Now hover the mouse over one of your documented classes and you should get a tooltip suggesting you press F1.

Documentation nirvana! Again, my thanks to Karsten Heimrich for writing the patch, hope someone else finds this useful!

I’m a Qt Convert!

Once upon a time, I used to do a lot of GUI app development. My professional career started back in 1993 writing Windows 3.1 apps in C, and continued for several years, switching to C++ and using the MFC framework. But from about 1998 I found myself steadily doing less native GUI application development, and more and more web server based work.

While I enjoy all the work I do, I do miss being closer to the machine. The average PC is ridiculously powerful these days, but your average web application can’t do much with that power.

I’ve switched my home desktop to Ubuntu recently, and loving it. But, there’s a few Windows apps I miss. What’s a developer to do? What is a developer, skilled in C++ GUI development, to do, eh? Answer me that.

The recent release of Qt4.5 and it’s accompanying licence change couldn’t have come at a better time. I had an itch to scratch, and it looked gooood. One simple install, and you have a great IDE, a GUI designer, and a stack of great classes and widgets. I was sold on the ease of integrating a WebKit browser and the fact I could build a ECMAScript based scripting engine for my app. But there’s so much more! I was a little skeptical of the smoke and mirrors behind the signals and slots paradigm, but having used it for a weekend, I’m sold.

Bottom line is that I spent more time writing my app than figuring out the framework. There’s hardly any “boilerplate” crap in each class. Once you’ve written your first signal and slot handler, you’re away. It’s all thriller, and no filler :)

As if that wasn’t exciting enough, recompiling for Windows and Mac is easy too. Qt doesn’t just get you closer to your machine, it gets you closer to *all* machines. Hallelujah, Flying Spaghetti Monster be praised, I’ve rediscovered a love of programming I didn’t know I’d lost.

Anyway…..

I don’t want to say too much about the app I’m writing, aside from the fact that it’s aimed at geocachers. It’s called Ammotin, and will probably get released much later in the year. I think it will be spectacular, because Qt has got me so fired up and focussing on the app, that I don’t need to worry too much about the framework.

Am I over excited?

Using Qt Creator with Ubuntu 8.10

The recent change of licencing model for the Qt toolkit got it a lot of press recently. My GUI-based development experience is all Windows based, using MFC and wxWidgets. As I’ve found myself using Ubuntu and OSX a lot more recently, the idea of using Qt to write software to run on Windows, Linux or OSX has some appeal. Of particular interest was the ease with which you can integrate WebKit, allowing you to embed web capabilities into a cross-platform app with ease.

Installation under Ubuntu 8.10 is straightforward, but I’m writing this post just to note the install steps I took. Hope it helps someone!

  • Download and install the SDK, which includes an IDE
  • Once installed, there’s a few packages you’ll need to ensure your first build completes:
  • sudo apt-get install libfreetype6-dev libfontconfig-dev libxrender-dev libsm-dev libglib2.0-dev

Now you’re good to go!

Edit: Edvaldo in the comments noted he needed to install some additional packages as follows:

  • sudo apt-get install libxext-dev libxext6-dbg x11proto-xext-dev

Stack Overflow

Stack Overflow opened its doors yesterday after a closed beta test period of 6 weeks or so. At first glance, it’s a programming support forum, but it has interesting mechanisms to ensure the signal-to-noise ratio is high.

Borrowing from the idea of XBox360 achievement points, Stack Overflow awards its registered users “badges” for partipating in the site and exploring its features. Some badges are easily won, such as “Autobiographer” for completing your profile. Others might take some time, such as “Necromancer”, for successfully resurrecting a year old question with a popular answer!

Added to that is a system of karma, or reputation, where your contributions to the site are voted on. If someone likes one of your answers, or thinks you asked a good question, they can vote you up, giving you more reputation points. If your answer is the preferred answer to a question, you get even more. It works both ways, if you post something dumb or irrelevant, it will get voted down, lowering your reputation .

The key thing is that your reputation level influences which site features you have access to. It gradually exposes more moderation features to you as you contribute more to the site. For example, earn 2000 reputation points and you get the ability to edit and delete other people’s posts.

If it works, the site will practically run itself, but it will be interesting to see how much people try to game it and abuse additional privileges. Some of these ideas might even be applicable to how Geograph’s moderation system works, so it is doubly interesting to me.

Anyway, if you have a programming question, give it a try. Most questions seem to get answered withing a few minutes, and it certainly beats Googling and getting one of those paywalled Experts Exchanges pages!

VMWare enable 100% reduction in server electricty costs from August 12th!

How? By stopping you running any virtual machines!

I’m about to evaluate VMWare ESXi server both for work and various side projects.

Sadly, VMWare tripped up today, by rendering it impossible to start a virtual machine if the date was August 12th 2008 or later. The VMWare forums are awash with disgruntled customers, starting with irate aussies as their country was one of the first to enjoy the excitement of August 12th. Aside from a short KB article, VMWare are staying tight lipped, and being a little tardy with it, promising a fix in 36 hours.

While ESXi may be free now, I’ll be taking a closer look at the alternatives. Hopefully VMWare will publish something which restores confidence…

Geohash PHP class

geohash.org popped up recently with a method of generating short hash codes for geographical locations. The codes have some interesting properties and the algorithm is documented on wikipedia.

I recently started doing a Project Euler problem a day as a fun diversion. I found the geohash algorithm intriguing, so it became my “Euler problem” for the day!

Having done it, I’m not sure I’ll find a use for it myself, but if anyone else finds it handy, do let me know!

Download it here.

Munin plugin for graphing MySQL slave delay

I wanted to track the delay of a mysql slave server in Munin, and found nothing appropriate after a quick google. So, in case anyone else finds it useful, here is a plugin which will allow you to do just that.

Here’s a typical graph:

Slave Delay Graph

Download: mysql_slave (1 Kb)

EDIT: I wrote this so I could better understand the recovery time of a slave which had 13 hours of updates to catch up on. While it was good for that, it’s less useful for the day-to-day lag as munin will only be polling it every 5 minutes. A better way would be to use mk-heartbeat to get a more accurate moving average.