Author Archives: Thomas Cokelaer

Allocation 2D arrays in C (and freeing memory)

By convention, when dealing with 2D array, the first dimension refer to the rows, and the second to the columns. To create a 2D array (double pointer) in C, you first create a 1D array of pointers (rows), and then, … Continue reading

Posted in Uncategorized | Tagged | Leave a comment

RPy2 substitute function does not work

I’m using rpy2 to call R package from Python, which works pretty well most of the time. Yet, I’ve encountered an issue with the R function called substitute that do not behave as expected when called from rpy2. Consider the … Continue reading

Posted in Computer Science | Tagged , | Leave a comment

Set the default printer under linux

If you want to set the default printer, you can use the command line interface and type: export PRINTER=printer-nameexport PRINTER=printer-name If you want to set the default printer permanently, and if your shell is bash (most common by default), you … Continue reading

Posted in Linux | Tagged , | Leave a comment

super() function in Python raises a TypeError

Playing with class inheritance, I came across an unexpected behavior of super() function, which is used in the inheritance process. Consider this simple example of a class MyGraph thah inherits from a DiGraph class from networkx: import networkx as nx … Continue reading

Posted in Python | Tagged , | 7 Comments

a2ps usage

a2ps is a unix tool that ease the formatting of text files before printing. a2ps inputfile -o output.psa2ps inputfile -o output.ps Print code that span over more than 80 columns. You will need to decrease the font size (-f 7), … Continue reading

Posted in Linux | Tagged | Leave a comment

How to generate a PDF reference of an R package

If you have the Rd files in a man directory, then in a shell command, you can use this command: R CMD Rd2dvi –pdf –title=’Test of foo’ -o /tmp/foo.pdf man/*.RdR CMD Rd2dvi –pdf –title=’Test of foo’ -o /tmp/foo.pdf man/*.Rd

Posted in Computer Science | Tagged , | Leave a comment

HTML password protected

Password protecting a website (or a sub directory within a website) can be done easily thanks to two special files called .htaccess and .htpasswd First, in the directory that you want to be protected, copy and paste the following code … Continue reading

Posted in Internet related | Tagged | Leave a comment

pdf2ps font issues

Sometimes, when converting a PDF file to a PS file using ps2pdf, some fuzzy fonts may appear. A solution is to provide the fonts within the documents by using: pdf2ps -dEmbedAllFonts=true <input> <output>pdf2ps -dEmbedAllFonts=true <input> <output>

Posted in Linux | Tagged , | 2 Comments

scp does not work: wrong bashrc

When I tried to use scp to copy a file on a distant machine: scp -v filename username@xxx.xxx.xxx:/home/usernamescp -v filename username@xxx.xxx.xxx:/home/username it looked as if the SCP command works but the file is not copied. The interactive option (-v) does … Continue reading

Posted in Linux | Tagged , , | 3 Comments

How to resize images with awk and convert

If photos in a directory are too large, you may want to use a script to automatically convert all the files into another format. AWK and convert tools can help you. The following command should convert all the files with … Continue reading

Posted in Linux, photos | Tagged , | Leave a comment