Programming

Install PHP-APC on CentOS

  1. Yum up some packages:
    yum install make php-pear php-devel httpd-devel
  2. Install APC using pear (the pear installer is smarter than the pecl installer):
    When the installer asks about APXS, say ‘no’. 
    pear install pecl/apc
  3. Tell PHP to load APC:
    echo extension=apc.so > /etc/php.d/apc.ini
  4. Edit the file /etc/php.d/apc.ini, and add the following lines:
    apc.ttl="7200"
    apc.user_ttl="7200"
    apc.shm_segments="3"

PHP Graphing Packages

Perl Thread

Here are some discussion and informaton on Perl thread programming:

 

 

Source Code Ducomentation Tools

  • POD
    Perl
  • Doxygen
    C++, C, Java, Objective-C, Python, IDL (Corba and Microsoft flavors), Fortran, VHDL, PHP, C#, etc
  • RubyDoc
    Ruby

 

 

 

 

CDB Compilation Error: "mismatches non-TLS reference in cdb.a"

I tried to compile cdb-0.75 on CentOS, and got the following error:

cdb-0.75$ make
./load cdbget cdb.a buffer.a unix.a byte.a
/usr/bin/ld: errno: TLS definition in /lib/libc.so.6 section .tbss mismatches non-TLS reference in cdb.a(cdb.o)
/lib/libc.so.6: could not read symbols: Bad value
collect2: ld returned 1 exit status
make: *** [cdbget] Error 1

Module::Starter Over h2xs

I used to use h2xs to start my Perl extension modules. Now I am testing Module::Starter.

Before we start, here are some modules to install

Rotating Algorithms from 'Programming Pearls' by Jon Bentley

Orginal: http://ailab.kangwon.ac.kr/?module=file&act=procFileDownload&file_srl=22...

/* Copyright (C) 1999 Lucent Technologies */
/* From 'Programming Pearls' by Jon Bentley */ 
/* rotate.c -- time algorithms for rotating a vector

      Input lines:
             algnum numtests n rotdist

             algnum:

Convert Simplified Chinese to Traditional Chinese in a Drupal Project

If you have a Drupal website in Simplified Chinese, and now you want to to convert it into Traditional Chinese, or the other way around, here is how you can do it:

Configure PHP Securely

Make the following changes to /etc/php.ini:

# Do not expose PHP error messages to external users
display_errors = Off

# Enable safe mode
safe_mode = On

# Only allow access to executables in isolated directory
safe_mode_exec_dir = php-required-executables-path

# Limit external access to PHP environment
safe_mode_allowed_env_vars = PHP_

# Restrict PHP information leakage
expose_php = Off

# Log all errors
log_errors = On

# Do not register globals for input data
register_globals = Off

How to Install a Perl Module at a Custom Location

If you don't have permission to install a Perl module into the system Perl directories, you will not be able to use CPAN or yum or atp-get etc to install the module. You have to manually install it. Here are the steps:

  1. Download the module's package from search.cpan.org
  2. Install the package:

    $ tar zxf module-name.tgz
    $ cd module-name
    $ perl Makefile.PL PREFIX=/your-custom-dir
    $ make
    $ make test
    $ make install