Wednesday, July 05, 2006

Install apache2 and php on Dapper

To install and configure properly php for apache on dapper, you have to install the software:




sudo apt-get install apache2 libapache2-php5



The problem is that the php plugin is not enabled. To enable it, you have to run the command


sudo a2enmod php5



And restart the server:


sudo /etc/init.d/apache restart

Friday, June 02, 2006

Using an assembler code with ham in Linux

I have done a small code in ARM assembler for the game boy.
The program has to contain at minimum these lines:


.globl _start
_start:




And here are the steps to use it properly.



  1. Compile the source code:


    arm-thumb-elf-as prog.s -o prog.o -gdwarf2


    The option: -gdwarf2 is used to inform that we want a debug version

  2. Link the file:


    arm-thumb-elf-ld prog.o -o prog.elf




  3. Run the debugger:


    arm-thumb-elf-insight prog.elf




  4. Now, you have to open an other console, and type the command:


    vba -Gtcp


    It is used to inform that the emulator will hear on port 55555 the code sent by insight.


  5. You just have now to set the target settings with target: Remote/TCP, Hostname is blank and Port is 55555.

  6. Now you just have to connect to target, download and run...

libpng.so.2 on dapper

When I tried to use vba. I got the error:


***: error while loading shared libraries: libpng.so.2:
cannot open shared object file: No such file or directory


To avoid this error:

  1. Install libpn3:


    sudo apt-get install libpng3



  2. And rename it to libpng2:


    sudo ln -s /usr/lib/libpng.so.3 /usr/lib/libpng.so.2



Thursday, June 01, 2006

Mp3 not working in Dapper

Proprietary codecs are by default not installed in Lunix. Event if you installed them in Breezy, it will not work in Dapper, they seem to be deleted. To install it, simply run the command:



sudo apt-get install gstreamer0.10-ffmpeg gstreamer0.10-gl
gstreamer0.10-plugins-base gstreamer0.10-plugins-good
gstreamer0.10-plugins-ugly



It should work after...

Migrate from Breezy Badger to Dapper Drake

To upgrade your system. Simply run:



gksudo "update-manager -d"



And follow the instructions.

Sunday, May 14, 2006

tcl84.dll not available in cygwin

If you want to use insight or some graphical program in cygwin, it is possible to get an error that says that tcl84.dll is unavailable. To install it, you have to go in the setup and install the package: tcltk.

To install it, simply press the button on the left (skip by default), until you get the release you want.

Sunday, April 02, 2006

Accents in latex

I use kile to compile my latex code but I was not able to get accents on the dvi. Why, because I did not use the good packages.

What have I to write in the header? It is easy:

%Use the latin1 encoding
\usepackage[latin1]{inputenc}
%accents
\usepackage[cyr]{aeguill}
%yes, I am french
\usepackage[francais]{babel}

Sort a byte array in Java

The default algorithm used to sort a byte array is Arrays.sort(byte [] array). The algorithm used is a quicksort (complexity about =(nlog(n))). It is good for objects, but we have seen it is far better to use a countingsort algorithm.

Here is the code used:

public static void sort(byte toSort[], int offset, int length) {

//If we have less than this number of elements, we do the
//default sort else we use the countingsort algorithm
if (length < 45) {
Arrays.sort(toSort, offset, length);
return;
}
//It can go faster if we keep in memory an other array,
// but the class has to be synchronized.
//We initialize a new array
int temp [] = new int[256];
Arrays.fill(temp, 0);

//Count the number of elements
for (int i = offset; i < offset + length; i++) {
temp[toSort[i] + 128]++;
}
byte value = -128;
int ind = 0;
//Insert the bytes in the good order
for (int i = offset; i < offset + length;) {
while (temp[ind] == 0) {
ind++;
value++;
}
for (int j = 0; j < temp[ind]; j++) {
toSort[i++] = value;
}
value++;
ind++;

}
}

If there is less than 45 elements we have found that creating new arrays takes to much time and that the countingsort algorithm is not good enough.

The factor (sun sort)/countingsort has been calculated for some size of arrays. With 80 elements, the couting sort is about 50% faster. At 1280 elements, the couting sort algorithm is 4 times faster.

Sound with totem

By default, you cannot hear mp3 in totem. That is annoying because you will not have sound on most of the videos.

To get the sound in totem, you have to install gstreamer0.8-mad. It is in universe.


sudo apt-get install gstreamer0.8-mad


Yopu should have the sound now.

Ubuntu package not available

On a lot of forums, you can see:


sudo apt-get <package>


But sometimes this package is not available. What to do?

It is certainly that you did not add all the repositories available. Ubuntu comes with a preconfigured system that allows only to download ubuntu selected packages.

If your package is not present, you will have to add the repository...

The file containing repositories is /etc/apt/sources.list

By default, most of the repositories are commented (# symbol). Uncomment Universe (lines terminated by universe...) repositories and you should be able to download the package (most of the time).

Install iptables as a service

To add iptables as a service, you have to:

  1. Generate a iptable script in /etc/init.d/iptables

  2. Configure it as a service



Iptable script



Here is an example. This script only allows ssh, http, and https, and established connexions. It rejects everything else.

#!/bin/sh
IPTABLES=/sbin/iptables

case "$1" in
start)
echo -n "Starting IPTABLES... "

# Clear old rules
$IPTABLES -X
$IPTABLES -F
$IPTABLES -Z

$IPTABLES -A INPUT -m state --state ESTABLISHED,RELATED -j ACCEPT
$IPTABLES -A INPUT -p tcp --dport ssh -j ACCEPT
$IPTABLES -A INPUT -p tcp --dport 80 -j ACCEPT
$IPTABLES -A INPUT -p tcp --dport 443 -j ACCEPT
$IPTABLES -A INPUT -j DROP

echo "done."
;;
stop)
echo -n "Stopping IPTABLES... "
$IPTABLES -X
$IPTABLES -F
$IPTABLES -Z

echo "done."
;;

restart)
echo -n "Restarting IPTABLES... "
$0 stop > /dev/null
sleep 1
$0 start > /dev/null

echo "done."
;;

*)
echo "Usage: $0 {start|stop|restart}"
;;
esac


Configuring the service


I think we can put iptables in each init level. But I have decided to start this service after network service, it is the level 1. To do that, simply write.


sudo update-rc.d iptables start 99 1 .


Okay, how does it work:


  • iptables is the name of the script

  • start : We want to start the service

  • 99: is the id of the service, each service is started from the init level, and for each level the order depends on the id. We just run iptables as the last service.

  • 1: is the init level


You should get the message:

Adding system startup for /etc/init.d/iptables ...
/etc/rc1.d/S99iptables -> ../init.d/iptables

Install gcc on Ubuntu

If you only install gcc, you will get an error saying that standard libraries are lacking.

You have to install an other package: build-essential.

To install gcc:

sudo apt-get install gcc build-essential

Install and configure webalizer on Ubuntu

  1. install webalizer

    sudo apt-get install webalizer

    If webalizer is not found, you have to add sources in /etc/apt/sources.list: can comment the universe sources.

  2. Enable the apache2 hostname resolution: go into /etc/apache2/apache2.conf: Change

    HostnameLookups Off

    into

    HostnameLookups On


  3. By default webalizer is not well configured: it does not check in the good log. In /etc/webalizer.conf: Change

    LogFile /var/log/apache2/access.log.1

    to

    LogFile /var/log/apache2/access.log


  4. Test webalizer:

    sudo webalizer

    If you get a warning like warning: Truncating ...
    It is because you did not put the hostnameLookup. If afterward, you get this message, it can be because you are attacked by a virus...

  5. Run webalizer as a cronjob. This has to be run as root: Edit the root cronjobs by running the command:

    sudo crontab -e

    and add the line:

    0 * * * * webalizer

    With that line, every hour webalizer is run

Use the static xerces library on linux

  1. Download the source code
  2. Compile and install it following the instructions.
  3. Go into $xerces/objs
  4. Make an archive:

    ar cru libxerces-c.a `find . -name "*.o"`

  5. Congratulations, you have now a static xerces library

Create a new module with CVS

If you want to create a new module, let's say newdir:
  1. go into the directory newdir.
  2. Run the command:
    cvs import newdir vendor version 

    vendor and version are not important, you can write what you want.
  3. Write a comment.
  4. Now you have a new module, you just have to checkout, to be sure that the file is ok.
I did not write -d ... because in my environment variables: CVSROOT and CVS_RSH are defined.

Using C++ and fortran using visual studio and visual fortran

To avoid declaring always __stdcall for each external C procedure, the default Calling convention has to be set in Properties/Fortran/External Procedures

PHP4 with Apache2 on Gentoo

  1. edit /etc/make.conf and add "apache2" in your use flags
  2. emerge mod_php apache2
  3. Edit the file /etc/apache2/conf/apache2.conf and add these lines
    LoadModule php4_module extramodules/libphp4.so
    AddType application/x-httpd-php .php .phtml
    AddType application/x-httpd-php-source .phps
    ServerName "localhost"
    alias /@mydir@/ "@path@"
    <directory>
    Order deny,allow
    Allow from all
    </directory>
    where @mydir@ is the name you want to access from the internet and @path@ is the path to your the directory containing sources.
  4. restart apache
     /etc/init.d/apache2 restart 
  5. You should be able to access your page at: http://localhost/@mydir@/...

Xerces static library

To use the xerces C++ parser with a static library, we suppose you already have used xerces with dynamic library and that the project is correctly configured:

  1. download the source code at: http://xml.apache.org/xerces-c/download.cgi
  2. Open the $xerces_src\Projects\Win32\VC7\xerces-all\xerces-all.sln
  3. Right-click on the XercesLib
  4. Change configuration Type: Static library (.lib)
  5. Compile Xerceslib
Open your project:
  1. Put the library in the "resource files" directory.

GSL

We had to use the GSL (Gnuwin32) library but we had some problems: an access violation when trying to call the
sl_multimin_fminimizer_alloc

function. The exact error was:

(LIBGSL.DLL): 0xC0000005: Access Violation

To avoid this error, the macro GSL_DLL has to be declared.

Xerces dynamic library

To use xerces C++ with visual studio 6:

  1. Download the xerces zip file at: http://xml.apache.org/xerces-c/download.cgi and unzip it.
  2. Go in Project->Settings->C/C++.
  3. Insert into the "additional include directories", the path to the xerces include directory.
  4. right-click on resource files and select: add files to folder... Select the needed librarires in the xerces lib directory.
  5. In the execution directory (or in system32), you have to put the xerces dlls.
Now it should work properly