How to migrate / convert MSSQL .bak into Mysql / SQL

Here are the steps to follow in order to convert a MsSql (sql server) .BAK into mysql format:

  1. you need windows
  2. download and install Microsoft SQL Server Express
  3. download and install Microsoft SQL Server Management Studio Express
  4. download and install Mysql Migration Toolkit (included in Mysql Gui Tools only in Windows package, no linux version 🙁 )
  5. configure your MSSql server to listen on TCP connexion
  6. load your .bak in SQL Serveur management studio (right clic on database, restose database, from the unit, go to options tab and set a right path for the files listed in the .bak file, launch the recovery)
  7. in Mysql Migration toolkit, follow the wizard, it should be easy
Posted in Dev

Bug dans admin sfGuardUser

Un bug semble s’être glissé dans le formulaire d’administration du plugin symfony sfGuardUser.

“The item has not been saved due to some errors.” (when you try to save the form)

The fix :

It would seem the cause of the issue is on line 44 of the sfGuardUserAdmin form class.

Removing that solves the problem.

Mark required field in a Symfony Form (sfForm) with an asterisk

How to mark required / mandatories fields in a form based on sfForm ? (solution based on Dark-IT post, adapted and tested on Symfony 1.2)
Add in your lib/form directory a class name : RegistrationForm.php (you can name it as you want of course)

class RegistrationForm extends sfForm
{
public function configure()
{
// …
}

public function render($attributes = array())
{
$formatterObj = $this->widgetSchema->getFormFormatter();
if(!is_null($formatterObj)) {
$formatterObj->setValidatorSchema($this->getValidatorSchema());
}
return parent::render($attributes);
}

public function __toString()
{
try
{
return $this->renderUsing(‘Registration’);
}
catch (Exception $e)
{
self::setToStringException($e);
// we return a simple Exception message in case the form framework is used out of symfony.
return ‘Exception: ‘.$e->getMessage();
}
}
}

Add another class in your lib/form directory : sfWidgetFormSchemaFormatterRegistration.php

class sfWidgetFormSchemaFormatterRegistration extends sfWidgetFormSchemaFormatter
{
protected
$rowFormat = “\n

%label% %error%%field%%help%%hidden_fields%”,
$requiredTemplate= ‘

*’,
$validatorSchema = null;/**
* Generates the label name for the given field name.
*
* @param  string $name  The field name
* @return string The label name
*/
public function generateLabelName($name)
{
$label = parent::generateLabelName($name);

$fields = $this->validatorSchema->getFields();
if($fields[$name] != null) {
$field = $fields[$name];
if($field->hasOption(‘required’) && $field->getOption(‘required’)) {
$label .= $this->requiredTemplate;
}
}

return $label;

}

public function setValidatorSchema(sfValidatorSchema $validatorSchema)
{
$this->validatorSchema = $validatorSchema;
}
}

Now, you can use this extended form in your form. Simply change the extends directive with :

class MyGreatForm extends RegistrationForm
{
// …
}

Of course, you have to update your css, for example :

.requiredFormField
{
color: red;
}

Route vpn

Ajouter une route supplémentaire pour un host particulier, après connexion sur VPN :

route add -host gw

Vérification ensuite avec:

route

How to: Copy and Paste highlighted and intented source code in Open Office

Maybe you have some repport due, where few lines of code are needed, but Open Office Writer doesn’t handle .c source file, neither .py, .m
The solution:

sudo apt-get install highlight

gedit “~/.gnome2/nautilus-scripts/Highlight and open with OOO”

#!/bin/bash
#
highlight -o /tmp/highlight_temp_file.html $*
openoffice /tmp/highlight_temp_file.html
rm /tmp/highlight_temp_file.html

chmod +c “~/.gnome2/nautilus-scripts/Highlight and open with OOO”

And now, any right clic on a file, and it’s opened in OOO with nice colors.

Hercules Deluxe Webcam :compiling drivers for Ubuntu 8.10

Here again we are facing a crappy hardware with homebrewed drivers, not integrated: sunday morning, let’s compile something.
That’s a translated how to from here

Unplug the webcam

lsmod | grep ov

to check if any module is loaded, and remove it

sudo rmmod gspca_ov519sudo rm -r/lib/modules/`uname -r`/kernel/ubuntu/misc/media/ov511

sudo rm /lib/modules/`uname -r`/kernel/drivers/media/video/gspca

So let’s download the drivers’ sources:

wget http://www.rastageeks.org/downloads/ov51x-jpeg/ov51x-jpeg-1.5.9.tar.gztar -zxwf ov51x-jpeg-1.5.9.tar.gz

cd ov51x-jpeg-1.5.9/

sudo apt-get install build-essential linux-headers-`uname -r`

make

sudo make install

sudo modprobe ov51x-jpeg

echo “options ov51x-jpeg forceblock=1” | sudo tee -a /etc/modprobe.d/options

echo “options ov51x-jpeg force_palette=13” | sudo tee -a /etc/modprobe.d/options

tail -f /var/log/syslog | grep “ov51x”

and plug the webcam, something close to this should appears:

kernel: [324189.288878] ov51x_jpeg: USB OV519 video device found
kernel: [324189.656291] ov51x_jpeg: Sensor is an OV7648
kernel: [324189.758541] ov51x_jpeg: Device at usb-0000:00:1d.1-2 registered to minor 1

(control+c to quit)

gstreamer-properties

and the webcam shoud show up

If not, check the rights:

ls -l /dev/video*
crwxrwxrwx+ 1 root video 81, 0 2009-01-14 20:03 /dev/video0
crw-rw—-  1 root video 81, 1 2009-01-18 14:10 /dev/video1

The first one is good, but not the second webcam, only video access, so to correct it: create a simlink at the module initialisation:

sudo gedit /etc/udev/rules.d/80-programs.rules

And add this line:

KERNEL==”video[0-1]”, NAME=”video%k”, SYMLINK+=”%k”, MODE=”0666″

Restart the service

sudo /etc/init.d/udev restart

now check it works fine:

mplayer tv:// -tv driver=v4l:width=640:height=480:device=/dev/video0

Now you end up with a perfectly working webcam, it’s time to check out the new cross plateform opensource webcam instant messaging:a
http://www.qutecom.org/

(And to drop Skype)

Convert vob into flv

Here is the command line to convert a DVD vob file into FLV flash video with ffmpeg :

ffmpeg -i VTS_01_1.VOB -b 256000 -er 4 -ar 44100 -ab 96000 -f flv -s 570×456 -acodec libmp3lame -vol 1024 my_video.flv

ffmpeg + mp3 + intrepid ibex

You can now use ffmpeg with mp3 support without adding medibuntu repository.

You simply have to choose right ffmpeg codec package in :

apt-cache search libavc*

Mp3 support can be installed with :

sudo apt-get install libavcodec-unstripped-51