converting MySQL sysdate to local timezone

Problem
You are hosting your MySQL server in a shared host which is in a different country from your application’s local timezone, and you cannot change the MySQL system timezone, but you would like to use sysdate for date comparisons.

Solution
In your SQL query that you use for comparing with the system date/time, use the convert_tz function in MySQL, using the appropriate local time zone (ie Europe/London):
convert_tz(sysdate(),'SYSTEM','Europe/London')

Deploying a Rails project in a server that hosts the git repository

Problem
You want to deploy your project in a server (dreamhost), that also hosts your git repository. When you try to do that by only setting the set_repository, you get errors like ‘permission denied, please try again’, even though if you try to checkout the git repository on your server works.

Solution
Set your :repository as a file in your host as in:
set :repository, "file:///home/username/git_on_server/projects/repo_name.git"

Then also set up your local_repository, as in:
set :local_repository, "user_name@server_domain_name:/home/username/git_on_server/projects/repo_name.git"

Rails Passenger Staging environment problem in Dreamhost

Problem
You want to deploy your rails application using Passenger in Dreamhost, but on a staging environment. It doesn’t work just changing your Capistrano recipe or your environment files, as the default environment for passenger is ‘production’.

Solution
Looking at the Passenger documentation here, there are four different ways of achieving that by changing the RailsEnv option. If you don’t want to change the Apache configuration files, and as long as the option AllowOverride is on (which should be on Dreamhost), then you would need to create an .htaccess file in your application’s public folder with the following:

RailsEnv staging

Dreamhost – SquirrelMail – old-messages folder

Problem
You have left a message in a squirrel mail account in dreamhost for a long time and it gets archived by dreamhost. According to the dreamhost you should be able to get to your archived messages, by looking at the old-messages folder.
The problem is that just by logging in to squirrel mail the folder doesn’t get displayed on the left hand side.

Solution
Log on to squirrel mail and go to ‘Folders’ menu at the top.
In the ‘Create Folder’ put ‘test’ or anything that you would like in the text box, and make sure that in the dropdown box you select ‘INBOX.old-messages’, so your newly created folder is a subfolder of the ‘inbox/old-messages’ folder.
Create the subfolder, refresh the page, and in your left hand the old-messages folder should appear.

Thunderbird – GoogleMail

Problem
You want to add the Google calendar tab in your thunderbird but you don’t want to use the standard google mail calendar, but the one setup for your domain.

Solution
Install the Google Calendar add on in Thunderbird:

Tools -> Addons -> Get Add-ons and then search for Calendar (Google Calendar Tab)

The when thunderbird is restarted go and change the default domain for logging in to the calender in:

Tools – Add-ons -> Extensions

and select the Preferences in the Google Calendar Tab.

from there select the ‘Google Apps for your domain’ and then change the URL into something like:

‘http://www.google.com/calendar/hosted/your_domain_hosted_with_google

Help! I’m getting the message “libMagickWand.so.1: cannot open shared object file: No such file or directory” I know ImageMagick is installed! What should I do?

Problem
Cannot install RMagick as there is an error about nob being able to find some shared libraries.

Solution
After reading the RMagick installation FAQ it seem there is a problem with the LD_LIBRARY_PATH that cannot find the needed libraries as they are installed in /usr/local/lib instead of /usr/lib.
Doing a quick search revealed that people suggest that the LD_LIBRARY_PATH shouldn’t be changed, for various reasons.
So, the quick solution is to create a couple of symbolic links for the libraries that cannot be found, ie:

sudo ln -s /usr/local/lib/libMagickWand.so.4 /usr/lib/libMagickWand.so.4
ln -s /usr/local/lib/libMagickCore.so.4 /usr/lib/libMagickCore.so.4

ATI Radeon HD-4350 Mandriva 2010 Dual Monitor

Problem
Trying to get Mandriva 2010 to work on a dual monitor with an ATI Radeon HD 4350. Desktop used is a Dell Vostro 430 and two BenQ G920WL monitors.

Solution
After reading the articles here and here, the steps required were:

  • Select driver ATI Radeon HD 2000 and later (radeon/fglrx)
  • Don’t select proprietary driver from next screen
  • Run xrandr -q to find out the name of the monitors
  • From the output find out the current resolution (1440×900), names (VGA_1,DVI-I_2/analog) and maximum resolution (1440×900)
  • Edit the xorg.conf file (/etc/X11/xorg.conf) and add the Virtual 2880 900 (without quotes) underneath the Modes line in the Display Subsection
  • Save the file and restart the X server
  • Run again the xrandr -q command and make sure the maximum resolution has changed to 2880×900
  • Run xrandr –output DVI-I_2/analog –auto –right-of VGA_1 to put one screen next to the other
  • Follow the description here to set it up permanently on login

Problem with Sansa mp3 player automatic connection in Mandriva

Problem
After an upgrade my Sansa E260 is no longer automatically recognised in Mandriva and looking at the /var/log/messages displays the error:
reset high speed USB device using ehci_hcd and address 5

Solution
Run as su the following (maybe a couple of times), while the sansa is connected:
sudo rmmod ehci_hcd
sudo modprobe ehci_hcd