Sphinx and ReST syntax for Python documentation

Sphinx is a tool that ease the creation of documentation for computer languages such as Python but also C/C++. The Sphinx syntax is an extension to the ReST (or RST) syntax. The drawback is that you need to learn another language, but it remains quite simple and its advantage is that it remains human readable (useful for the docstrings in Python!).

I put a rough guide to the Sphinx and ReST syntax. It can be found on my main page Sphinx and ReST guide. I consider it as a draft, but it should already be of interest for some of you.

Posted in Python | Tagged , , | Leave a comment

Python ressources

Python is a script language that has evolved into a “do whatever you want”. It is now a versatile tools, which is really powerful and contains more and more modules to really do whatever you want. Python documentation provides a very good and complete overview of all the standard modules that are available by default.
For scientific development, I would recommand to use the following two librairies

They provide a matlab-like syntax. Many more libraries (scientific or not) can be found within the Pypi directory, which is like a sourceforge website.

Posted in Uncategorized | Leave a comment

Awk: how to convert PNG files into PDF

Here is a method to convert a bunch of PNG files into another format (here PDF). This method works under linux and uses both awk and convert commands (the conversion is made with the convert command).

The following script generates the commands that are required to perform this task. Here, we redirect the output into a shell file (runme.sh) that can be executed later on.

ls *.png | awk '{print "convert  " $1 "  " substr($1, 1,length($1)-4)".pdf"}'  > runme.sh
chmod 755 runme.sh
./runme.sh

Some explanations:

ls *.png |

sends a list of PNG files to awk (thanks to the pipe sign).

substr($1, 1, length($1)-4)

The substr() function (from AWK) replaces the .png extension into .pdf

The convert command does the real work, that is the conversion and accepts many optional arguments that you can play with to be more specific about the output format (size, resolution, …).

Posted in Linux, Uncategorized | Tagged | Leave a comment

Language C: resources

Posted in Computer Science | Tagged | Leave a comment

How to include HTML within another HTML

To include another HTML document within a n HTML document, use this command:


<! --#include virtual="temp.xml"-->

Tip: the main HTML file should have a shtml extension.

Posted in Computer Science | Tagged | Leave a comment

Install Apache and test PHP

Under fedora, install apache


sudo yum install php

Then, you should edit httpd.conf in /etc/httpd/conf and add


AddType application/x-httpd-php3 .php3

or equivalent

Then, under Fedora, go to system/service and start the httpd service. Alternatively type


sudo service httpd start

Finally, create a PHP script, called test.php, as follows (and copy it to /var/www/html/):


<?php
phpinfo();
?>

Then, to see the results, open the following URL http://localhost/test.php

Posted in Computer Science, Linux | Tagged , | Leave a comment

PHP: how to initialise a user directory

In the /etc/httpd/conf/httpd.conf, change the Userdir to public_html


<IfModule mod_userdir.c>
UserDir public_html
</IfModule>

and uncomment the section “Directory”

Posted in Internet related | Tagged | Leave a comment

Convert documents into PDF with conv2pdf

Sometimes, you want to convert a document into a PDF and there is no such options in you preferred software. For instance, in OpenOffice you have the save option as PDF, so there is no problem here. However, in some other software (I won’t give any name; I let you guess) it is not always possible. More generally, let us say that the output is buggy. I had the case where links were not rendered probably. In such situations, you want to use an external tool. I tried to convert in postscript and then to use tools such as ps2pdf. Again, there were rendering issues. So, I looked around on the web and found conv2pdf . It provides a very simple interface to convert documents into PDF. I have used it a few times and it was just brilliant, in particular for the links.

Of course dedicated software such as OpenOffice becomes better and better. Links were working well the last time I used them. But just in case, it is good to know that this service exists and works.

Posted in Internet related | Tagged | Leave a comment

HTML and CSS: differences between Class and ID

In HTML language, an ID identifies a specific element within a page and must be unique, whereas
CLASS marks an element as members of a group and can be used multiple times.

The question is why not always using Class over ID ? One of the main reason may be related to javascript that intensively uses ID such as in the function getElementById(). Another reason is that an element may have both a class and an ID.


<div class="tab" id="tab1" > Tab 1 </div>
<div class="tab" id="tab2" > Tab 2 </div>

Then in your CSS you access to the class or id as follows:

div.tab { background-color: #F00; }
div#tab1 { text-decoration: none; }

Posted in Internet related | Tagged , | Leave a comment

Fedora 14, slow network

One common reason for having a slow network under Firefox with a Fedora distribution is related to iptables. Many proposed solution can be found on the web and suggest to deactivate the Ipv6 option in Firefox. This is done by typing

about:config

as a web site name. Just click on the link Accept the risk, I’ll be careful.. In the filter tab, type ipv6. Switch it to true. Restart Firefox (not sure it is required to be effective).

Although this solution works on older version of Fedora (for instance 13), it was unsuccessful under Fedora 14. Today, I’ve noticed a few error messages during the boot time that are related to the file modprobe.conf. For instance:


ip6tables: Applying firewall rules: WARNING: Deprecated config file /etc/modprobe.conf, ...

After a few searches on the web, especially the forums.fedoraforum.org/ website, it seems that indeed this file is deprecated. I decided to remove it (actually, just to be sure not to lose any information, I renamed it):


sudo mv /etc/modprobe.conf /etc/modprobe.conf.old

I rebooted. And guess it. Yes, the network is now as fast as it should be.

Posted in Internet related, Linux | Tagged , | 4 Comments