Programming

Install Python 2.5 on CentOS/4

If you need more recent version of python on CentOS, you have to install it yourself. Do not override the default /usr/bin/python.

 

Download the latest python 2.5 from http://www.python.org/ftp/python.

wget http://www.python.org/ftp/python/2.5.6/Python-2.5.6.tgz

 

tar zxf Python-2.5.6.tgz 
cd Python-2.5.6
./configure --prefix=/opt
make
make install

Lightweight PHP Framework

I was looking for a lightweight PHP framework. Some projects just don't want the frameworks with heavy footprint, like zend does. 

PHP Fat-Free Framework may be the one that wins in this category. I will post some update after I try it out.

Gentoo Allows Switching PHP Version

Maybe they had it before, but I just noticed this today, that we can install more than one versions of PHP, and then use eselect to switch the version.

In short, we can set in /etc/make.conf:

PHP_TARGETS="php5-3 php-5-2"
PHP_INI_VERSION=production

Then call eselect to see what php versions we have available in apache:

# eselect php list apache2 

Without "PHP_INI_VERSION=production", a dev version of php.ini will be installed.

Perl: Convert Chinese Text in UTF-8 Encoding to Text in GB2312 Encoding

To convert Chinese document written in UTF-8 encoding into text in gb2312 encoding, here is a sample Perl code using the module Encode::HanConvert and Encode::HanExtra:

Setup GWT Development on Mac OS 10.6

Setup Eclipse and Ant

  1. Download Eclipse IDE for Java Developers
  2. Extract the above tar ball, and copy the extracted directory into /Applications
  3. Download Apache Ant
  4. Extract the above tar ball, and copy the extracted directory into somewhere like /System/Library/ApacheAnt
  5. Edit $HOME/.bash_profile, add
    JAVA_HOME=/Library/Java/Home
    ANT_HOME=/System/Library/ApacheAnt

Search for More Recent PHP RPM Packages on CentOS-5

I found this guy http://www.atoomnet.net/php/  offers the RPM and SRPM for the more recent php packages on CentOS.

Another one here: http://www.jasonlitka.com, or http://www.jasonlitka.com/media/SRPMS/ for the SRPM.

  

Set up Redmine/Mongrel as Service on CentOS

The original post is here http://www.how-to-linux.com/2008/12/set-up-mongrel-as-a-service-and-star...

Below are my modified steps in order to get it to work.

Step 1. Create a file /etc/mongrel/redmine.conf:
# mkdir /etc/mongrel
# vi /etc/mongrel/redmine.conf

and put the following into the file:

CPAN "couldn't Untar" error

I tried to install something via CPAN, but kept getting this error. Even "perl -MCPAN -e 'install CPAN'" gave such error:

Using Tar:/bin/tar xvf /root/.cpan/sources/authors/id/A/AN/ANDK/CPAN-1.9402.tar:
Couldn't untar /root/.cpan/sources/authors/id/A/AN/ANDK/CPAN-1.9402.tar

It wasn't permission, because I was running from root. Maybe the memory. Since this is a OpenVZ container, we would check the /proc/user_beancounters

# cat /proc/user_beancounters

Gprof for Benchmarking C and C++ code

First, you compile the program using "-pg" option:

$ gcc -pg -o a.out test.cc

or 

$ g++ -pg -o a.out test.cpp

Then run the program:

$ a.out

This will generate a file "gmon.out". We will use gprof to view it:

$ gprof a.out gmon.out

Read the man page of gprof to understand the output.

Install Net::Packet

We were not able to install the CPAN module Net::Packet. The error messages indicated that it could not find Net::Libdnet module.

Next, we tried to install Net::Libdnet, but got the error "Libdnet.xs:37:18: error: dnet.h: No such file or directory". That means, we are missing a libdnet.

So, we installed libdnet through yum (from "epel" repos):

# yum install libdnet libdnet-devel

("epel" repos is the Fedora extra package repos).