Saturday, 8 August 2009

Installing Bugzilla

When installing the latest version of Bugzilla (3.4.1), running ./checksetup.pl gave a number of modules that required installing and suggested that they could all be installed using the command:
/usr/bin/perl install-module.pl --all
However, running this command gave me more errors:
checking for gcc… cc checking for C compiler default output… configure: error: C compiler cannot create executables check `config.log’ for details. Can’t exec “/usr/bin/make": No such file or directory at /usr/share/perl/5.10/CPAN.pm line 7698. SKIMO/FCGI-0.67.tar.gz /usr/bin/make – NOT OK 
These errors were generated because there is no compiler present to install the required modules. To compile modules it is a good idea to install build-essential:
apt-get install build-essential 
It would also be a good idea to install pg_config which comes with the package libpq-dev as this will also be needed later:
apt-get install libpq-dev 
It’s now possible to update CPAN by first accessing a CPAN shell:
perl -MCPAN -e shell 
Once inside the CPAN shell you can update CPAN with the following commands:
install Bundle::CPAN
reload cpan
exit 
You should now be able to successfully install the required modules with the original command:
/usr/bin/perl install-module.pl --all

Thursday, 6 August 2009

Compare two dates in C++

When comparing two dates that are of the data type string they will need to be first converted to date objects. Once this is done a simple comparison test is possible.

void compareDates(string date1, string date2) {
//create a time_t object
time_t rawtime;
time(&rawtime);

//create a tm structure and load in date1
struct tm * timeinfo1;
timeinfo1 = localtime(&rawtime);
timeinfo1->tm_year = atoi(date1.substr(6).c_str()) - 1900;
timeinfo1->tm_mon = atoi(date1.substr(3, 2).c_str()) - 1;
timeinfo1->tm_mday = atoi(date1.substr(0, 2).c_str());

//create a tm structure and load in date2
struct tm * timeinfo2;
timeinfo2 = localtime(&rawtime);
timeinfo2->tm_year = atoi(date2.substr(6).c_str()) - 1900;
timeinfo2->tm_mon = atoi(date2.substr(3, 2).c_str()) - 1;
timeinfo2->tm_mday = atoi(date2.substr(0, 2).c_str());

//compare the dates
if(timeinfo1 > timeinfo2) {
cout << "date1 is the latest date";
}
else {
cout << "date2 is the latest date";
}
This function takes two strings, date1 and date2. Both dates are in the format of dd-mm-yyyy. Note that the hyphens can be any character as the sub-strings ignores them.

The function works by creating two tm objects and loading in some demo time data from our time_t object at the beginning of the function. This creates two identical time/date objects. We then overwrite the dates in these objects with our two dates. Once complete we have our two identical date/time objects but now with our two dates overwriting the date parts.

The final lines simply compare the two dates and outputs whichever one is the latest.

Thursday, 5 February 2009

Easy Peasy Persistent Installation

After upgrading my EEE PC 901 to Easy Peasy 1.0 I was prompted with the install dialog each time I logged in. Not only was this annoying it was taking up valuable space on my hard drive.

To remove this prompt all that is required is to uninstall Ubiquity. You can do this either with the package manager or by using the command
sudo apt-get remove ubiquity
This will stop the annoying prompt to install each time but will also free up over 10MB of space

Wednesday, 7 January 2009

MP3 support in K3b

Due to MP3 being a patented format and Ubuntu's policy of not allowing patented software in their default installations, K3b isn't able to burn music CDs from MP3s out of the box.

Luckily adding MP3 support is very simple and only requires one extra package to be installed:
sudo apt-get install libk3b2-extracodecs