How to disable warnings

When we are using a third party library in software development, we may encounter a lot of warning during the compilation. It is possible to disable warnings using compiler flags. This will disable warnings for all codes, it is thus useless when we want the higher warning level in our code.

I have encountered some « unused variable » warning in adding source code in my project. I have disabled these warnings in adding this line just after the variable declaration : __attribute__ ((unused))

I have found the documentation here.

How to use diff in svn folder

The diff program is used to find differences between files. To know more about diff :

But, if we use diff in svn folder, it can find a difference between files inside .svn. Here is the line of code I’m using :
cd /where/is/my/svn/folder
diff -r -x .svn /folder/source /folder/dest > file

With these parameters, diff doesn’t look into .svn folder.

Temperature Information in Ubuntu Linux

One day I had some troubles with my computer. Sometimes it crashes both spontaneously and sporadically. I thought it was because the CPU’s temperature was to hight. So here is a command line to know more about the CPU’s temperature on linux (I’m using Ubuntu 9.10)

cat /proc/acpi/thermal_zone/*/*

But this line shows me that the temperature of my CPU was completely normal. I think that my computer has some power problems, but impossible to discover the cause of crashes. Fortunately, it seems to work now…

System pause in linux script

Sometimes, you need to make a pause in your Linux script. For instance, you want to see the result of your script when you’re executing it from the window system. In my case, when I want to open an executable script file from gnome, it asks me if I want to open it in a new bash. If I say yes, it executes it and close the window. I don’t have the time to see any output, so I’m writing this at the end :
read a

The system wait for a keyboard input. The input is finish after pressing the « enter » key. Pressing it, the window closes itself (when executing from the window system)

Unix command to delete .svn folders

I have found on the web a useful command to delete .svn folders in your local svn repository. I found it here.

The command line is as follow :

find ./ -name .svn -exec rm -rf {} \;

The command find will search in the ./ directory each element whose -name is .svn. Don’t forget to go into your svn directory with the cd command. After each successful research, the -exec command will execute rm -rf with the path found by find put into the {} brackets. The result is that each .svn folder found is deleted.

HTML Redirection

My first useful post will talk about Html Redirection. It’s useful to know how make redirection.

Why do we need this stuff?

For instance, if you have moved an html page, but too many links point on this, you have to make a redirection page. If you are using a domain but your website is somewhere else, you can use this. If your website is in one folder, you can also do this.

So, I’m going to make it simple. There is 3 ways to make a redirection. The first one is to ask people to click on an link, like this : <a href="">Please go here</a>

The second way is to write this line in the head of the Html page : <meta http-equiv="refresh" content="0; url=" />

With this method, you can chose the time the redirection can make in content attribute. In the example above, the redirection is effective as soon as the page is loaded. If you want the redirection to be effective in five seconds, you have to write the line like this : <meta http-equiv="refresh" content="5; url=" />

The third way is the quickest way to make a redirection. You can write directly in the Html header with PHP to make a redirection. This is a code example :

//The order of lines bellow is important for compatibility
header('Location: '); //New address
header('HTTP/1.1 301 Moved Permanently');
header('Status: 301 Moved Permanently'); //For compatibility

Notice that for using php code, you have to create a PHP file. For instance : index.php

I’m using this code for my website. So, it’s working 😉