Friday, May 30, 2008

[perl] Regular expressions

* Oneliner to remove spaces at the beginning and at the end of a string (trim)
$string =~ s|^(\s*)(.*?)(\s*)$|$2|s;

* Replacing "::" by "/" . This can be useful when you want to see if you can load a module at run time

$module =~ s|::|/|g;
eval "require $module.pm";

Tuesday, May 27, 2008

[mysql] - Dropping tables without caring about relationships

On Mysql, to avoid having a
"Cannot delete or update a parent row: a foreign key constraint fails"
message when dropping tables with relationships between them, you can set the flag
SET FOREIGN_KEY_CHECKS=0;
at the very beginning of your sql script.

Monday, May 19, 2008

[Tip] How to concatenate pdf files

Sometimes, I received some few documents in pdf format and I would rather read them as a whole document than to close one page and open the next one.

The tool "pdftk" can be used to concatenate the different pdf files to create 1 file containing the whole

See this tutorial on how to use it

Friday, May 2, 2008

Which Linux version am I running?

I can't never remember which version of GNU/Linux I'm running on. I know I use Ubuntu but is it Gutsy Gibbon? Hoary Hedgehog? Feisty Fawn?

I just found out about a tool called lsb_release.

lsb_release is a tool created by the LSB (Linux Standard Base) that returns information about the distribution name, version, codename... So this tool should be available on most of the GNU/Linux distribution.

The output will look like this:

cyril@merlin:~$ lsb_release -a
No LSB modules are available.
Distributor ID: Ubuntu
Description: Ubuntu 7.10
Release: 7.10
Codename: gutsy


Time to upgrade to Hardy Heron