How to repair a corrupt Zimbra database

11-05-2012 Alec Hussey 3 Comments

This seems to be a common problem which doesn’t seem to have a well documented solution which is easily to do. So I spent the time one day, when I had a corrupt Zimbra database to deal with, to make it relatively easy. You may be running into corrupt database issues after an update or upgrade that didn’t complete properly. When performing a database check, you will see messages similar to the following:

 error    : Table upgrade required. Please do "REPAIR TABLE `appointment`" or dump/reload to fix it!
 error    : Table upgrade required. Please do "REPAIR TABLE `data_source_item`" or dump/reload to fix it!
 error    : Table upgrade required. Please do "REPAIR TABLE `imap_folder`" or dump/reload to fix it!
 error    : Table upgrade required. Please do "REPAIR TABLE `mail_item`" or dump/reload to fix it!
 error    : Table upgrade required. Please do "REPAIR TABLE `pop3_message`" or dump/reload to fix it!


Filed under:
Tags: , ,

Simple Python Sendmail Script

Recently I found the need to have sendmail on one of my servers to send me email notifications, but didn’t want to have sendmail actually installed. So some python and smtplib made for an easy, ‘sendmail compliant’ alternative that I could use with services that interface with sendmail for email notifications. The python script is as follows:

#!/usr/bin/env python2
import sys, smtplib
PORT = 465
USER = "email_address_or_username"
PASS = "email_password_here"
ADMINS = ("",)
if __name__ == "__main__":
        message_text = ""
        for line in sys.stdin.readlines():
                message_text += line
        server = smtplib.SMTP_SSL(SERVER, PORT)
        server.login(USER, PASS)
        server.sendmail(USER, ADMINS, message_text)


Filed under:
Tags: , , , ,

Adding Custom Schemes to Kate on KDE 4

05-11-2011 Alec Hussey 1 Comment

Since the documentation for this seems to have disappeared I will save someone from the frustration of digging around to know how to do this. Suppose you would like to install a custom color scheme for Kate such as a nice dark color scheme like Zenburn for Kate.

$ wget
$ tar xfz 66209-zenburn-kate.tar.gz
$ cd zenburn
$ ./
./ line 3: /home/maddog39/.kde/share/config/kateschemarc: No such file or directory
./ line 4: /home/maddog39/.kde/share/config/katesyntaxhighlightingrc: No such file or directory

As you can see you, you run into a slight problem since the paths have changed slightly since KDE3. So instead, do the following.

$ cd zenburn
$ cat ./kateschemarc.zenburn >> ~/.kde4/share/config/kateschemarc
$ cat ./katesyntaxhighlightingrc.zenburn >> ~/.kde4/share/config/katesyntaxhighlightingrc

It’s quite straight forward, just take the contents of each of each file and append it to the end of their respective files in the KDE4 config directory.

Then to select Zenburn (in this case) as the default color scheme, go to: Settings > Configure Kate > Editor Component > Fonts & Colors. At the bottom of the dialog will be an option for Default schema for Kate, hit the drop down box and select your default schema, and hit Apply to save your settings. You may have to restart Kate for your changes to take affect.

Filed under:
Tags: , , , , ,

Statically Linking Qt Applications on Linux

This article constitutes the second part of Building Qt for Static Linking which demonstrates how to actually compile your Qt application statically against the Qt libraries. This part will be relatively straight forward considering that the hard part of configuring Qt for your needs is already done.

When using self-built versions of the Qt libraries you will need to rerun qmake against your project in order for it to create a Makefile which uses your newly generated Qt library. Assuming you are using the default install path, the following set of commands will rebuild your Qt application using your new library.


Filed under:
Tags: , , ,

Building Qt for Static Linking on Linux

It is sometimes helpful when writing applications at all, let alone Qt applications, to statically link against the libraries your application depends on. By default Qt only provides a dynamic library, either an SO or a DLL, and thus you must recompile a version of Qt which generates a statically linkable library (usually a .a file). The following instructions show you how to accomplish this on a Linux system, however, a similar process applies for other operating systems including Windows.

The very first thing you must do before doing anything is to obtain the Qt source code. You will want to go to the Qt downloads page and head down to the Qt libraries section. Above the list of available downloads is a small section which mentions the source code packages. Download one and extract the entire tar ball onto your machine. Here is a link to the latest version of the Qt libraries as of this writing. I will assume that if you are reading this guide you know how to extract a tarball and move into the extracted directory via the command line.


Filed under:
Tags: , , , ,

Integrating Uploadify with Django

29-07-2011 Alec Hussey 5 Comments

As multimedia becomes more and more prevalent these days, an interactive file uploader becomes extraordinarily useful. I ran into such a situation recently when developing a Django web application of my own. In this case I chose to use Uploadify because I’ve used it in the past, it integrates well with jQuery, and in my experience has been not only the easiest to work with but the least problematic.

Working with flash-based file upload systems is relatively easy with Django assuming that they send a standard POST request to the server and you understand the way Django chooses to handle file uploads. Django provides file upload handlers which may be modified to perform more sophisticated tasks during file uploads if you wish, but in this case we will stick with the built in upload handlers. When you upload a file to a Django view it takes the name of the upload field in your template and puts that name into the request.FILES dictionary where the value of that entry is an UploadedFile object or a subclass thereof. This UploadedFile object contains basic information about the file being uploaded including its file name as it was uploaded and its complete size. In addition, it gives you file-like access methods to the uploaded data which allow you, the programmer, to decide how the data gets stored.


Filed under:
Tags: , , , , , ,

Banshee 1.8 Status Update Script for Pidgin

08-04-2011 Alec Hussey 1 Comment

As it turns out, I was not the only one who wanted my Banshee song changes to appear in my status on Pidgin. My original script was written for the prerelease version of Banshee 1.0 and since then, Banshee has made some minor changes to the DBus API which effectively break the functionality of my old script. In addition, my script never supported song names with UTF-8 characters in them and thus some people using other locales had issues using the script. Recently I took the time to rectify both of these issues and am providing a much improved updated version of my original plugin.

The same instructions still apply from before so simply refer to the original post for further instruction regarding desktop environment integration and the like.

Update: Also confirmed to be working on Banshee 2.x.


Filed under:
Tags: , ,

Integrating TinyMCE with Django

Many people often want What You See Is What You Get (WYSIWYG) editors when creating content from within their web applications. This can be either in the Django admin control panel or for the end user. One of the most flexible and useful of the WYSIWYG editors currently available is TinyMCE due to its extensive plugin library and robust feature set. Integration with Django is relatively simple given that you extend the functionality of built in classes.

The first thing we will need to do is create a custom widget from forms.Textarea found in the django.forms module. We accomplish this by inheriting the Textarea class and overriding the constructor and render methods. Defining the relative path (on your web server) to the TInyMCE javascript source is also required here. So be aware that you will need to change that path to suite your environment. You may also want to change the content_css variable to include your sites’ main CSS file. The following is the source code for which should be place in your projects root directory.


Filed under:
Tags: , , , ,

Using the Rcon protocol with Python

26-11-2009 Alec Hussey 5 Comments

Within the PC gaming community, it is quite useful to be able to control or monitor your servers programmatically. The almost universal standard being Rcon or “Remote Connection.” The protocol is overall very simple, it only requires a standard UDP socket and that you send a packet header with the login credentials per each request you make.

We will start by importing the python socket module and creating a UDP connection to the server.

import socket
if __name__ == "__main__":
   sock = socket.socket(socket.AF_INET, socket.SOCK_DGRAM)
   # Connect to CoD4 server at
   # Will also work for most other games in a similar fasion
   sock.connect(("", 28960))


Filed under:
Tags: , , , ,

Configuring the PlayStation 3 Controller on Linux

16-12-2008 Alec Hussey 3 Comments

A couple of months ago I stumbled upon a slew of information related to using the PS3 controller as a joystick on Linux. I immediately took my PS3 controller and started experimenting with the documentation out there for doing this sort of thing. Unfortunately however, not everything mentioned in this documentation worked correctly. For instance, I was not able to use a joystick on the controller to control the mouse without a separate piece of middleware. This was because the application I used (the only decent one I was able to find) to signal key presses for every button press on the controller, is unmaintained and had a blocker bug with mouse emulation.

You will need two components in order to make this work: the first being QJoyPad to bind controller buttons to keys, and JoyMouse to use one of the joysticks on the controller to control the mouse. Also remember that I am only using the USB cable to use the controller rather than using it via Bluetooth. I will post directions for using Bluetooth and the accelerometers in the controller at a later date, if I am able to get a hold of a Bluetooth adapter. Nevertheless, the tools are the same.


Filed under:
Tags: , , , ,