Mysql Migration Toolkit : UTF8 conversion issue

Mysql Migration Toolkit has an issue with varchar different from varchar(255) : it considers that it is not useful to force utf8 for these fields !

Here is a solution, found here :

Dans la fenêtre “Source Database”, activer le bouton “Advanced” et compléter le champ “Connection string” avec :
jdbc:jtds:sqlserver://server:1433/database;user=user;password=password;useUnicode=true;domain=

Dans la fenêtre “Target Database”, activer le bouton “Advanced” et compléter le champ “Connection string” avec :
jdbc:mysql://server:3306/?user=user&password=password&useServerPrepStmts=false&useUnicode=true

,en remplaçant bien sur “server” et “database” par leurs valeurs respectives.

Ensuite, ne pas modifier les options qui permettent de changer l’encodage des caractères : les valeurs par défaut font l’affaire. Et voilà !

Posted in Dev

US keyboard on login screen (and console)

This is a fucking bug in Ubuntu 9.04, my keyboard is in qwerty during login screen and in azerty in gnome.

To fix it, you have to reconfigure your console with (if you’re french, choose France / Alternative) :

sudo dpkg-reconfigure console-setup

Reboot your computer and enjoy !

tolerant php strtotime

If you want to enlarge strtotime php function to be tolerant about funny date (especially in mail header), here is a little function :

function strtotime_tolerant($time)
{
$datetime_header = strtotime($time) ;
if ($datetime_header === false)
{
if (preg_match(‘/(Wen, .*)/’, $time))
{
$time = (preg_replace(‘/(Wen,) (.*)/’, ‘Wed, ${2}’, $time));
}
if (preg_match(‘/(Sut, .*)/’, $time))
{
$time = (preg_replace(‘/(Sut,) (.*)/’, ‘Sat, ${2}’, $time));
}
if (preg_match(‘/(Tues, .*)/’, $time))
{
$time = (preg_replace(‘/(Tues,) (.*)/’, ‘Tue, ${2}’, $time));
}
if (preg_match(‘/(.* \d\d:\d\d:\d\d) (.\d{4})/’, $time, $matches))
{
$time = $matches[1].’ ‘.$matches[2];
}

if (preg_match(‘/(.* \d\d:\d\d:\d\d) (\d{4})/’, $time))
{
$preg_time = (preg_replace(‘/(.* \d\d:\d\d:\d\d) (\d{4})/’, ‘${1} +${2}’, $time));
}
if (preg_match(‘/(.* \d\d:\d\d:\d\d) (UT)$/’, $time))
{
$preg_time = (preg_replace(‘/(.* \d\d:\d\d:\d\d) (UT)$/’, ‘${1} ${2}C’, $time));
}
if (preg_match(‘/(.* \d\d:\d\d:\d\d) (CEDT)$/’, $time))
{
$preg_time = (preg_replace(‘/(.* \d\d:\d\d:\d\d) (CEDT)$/’, ‘${1} +0200’, $time));
}
if (preg_match(‘/(.* \d\d:\d\d:\d\d) (.0060)/’, $time))
{
$preg_time = (preg_replace(‘/(.* \d\d:\d\d:\d\d) (.0060)/’, ‘${1} +0100’, $time));
}

if(isset($preg_time))
{
$time = $preg_time;
}
}

return strtotime($time);
}

Posted in Dev