Showing posts with label code. Show all posts
Showing posts with label code. Show all posts

Monday, February 02, 2009

How to find the installed gtk+ and glade versions

If you need to find the currently installed versions of gtk+ and libglade,you can use the following commands to find them:

$>pkg-config --modversion gtk+-2.0
$>pkg-config --modversion libglade-2.0

Happy programming.

Wednesday, January 16, 2008

Mass substitution with Perl Command Line

For changing all occurrences of a several expression in a file, Perl with command line options can be very helpful. The following shows a pretty general example:

$> perl -i.bck -ep 's/search_term/replace_with/g' filename

The above command will check the "filename" file and, replace all occurences of "search_term" with the "replace_with" term. "-i" option tells Perl to backup the file with a ".bck" extension before any operation.

Monday, January 14, 2008

Replacing certain values in matlab vectors

In Matlab if you need to replace certain values with a single value you can simple do this,

>u(find(isnan(u))) = [];

Using this will find and remove all the NaN (Not a Number) values.

If you want to remove any value you can simple use find again,

>u(find(u=9999)) = [];


This will remove all the values of u = 9999.

Be aware that applying this will make your vector shorter if there is any value removed.

Monday, January 07, 2008

Manually install Perl modules with CPAN.pm

From your shell run

$> perl -MCPAN -e shell

command, it will ask you a few questions. Answer the questions, which are the basic settings for the local installation directory. You can set it up to a local directory within your home directory. Then simply type the following to install any module.

$> install Date

will install the latest Date module for Perl.

For further details see CPAN web site