7/05/2013

PHP5.4+MySQL5.5+HTTPD+CentOS6.4

0. Download and install VirtualBox 4.2.6
   https://www.virtualbox.org/wiki/Downloads

1. Download CentOS 6.4
   http://ftp.jaist.ac.jp/pub/Linux/CentOS/

2. Install + configure Network

3. Update yum
  yum update
  yum install gcc kernel-devel kernel-headers

 Restart your centos system

4. Install Virtual LinuxAddtions
    If you meet error with[Building the OpenGL support module  [FAILED]] , please use the following command
export MAKE='/usr/bin/gmake -i'

./VBoxLinuxAdditions.run


if you still have errors, please try

/etc/init.d/vboxadd setup

5. Start your httpd 
   service httpd start
    #auto start 
   chkconfig httpd on  

6.   install repos for php-5.4 
   rpm -Uvh http://rpms.famillecollet.com/enterprise/6.4/remi/x86_64/remi-release-6-2.el6.remi.noarch.rpm
    rpm -Uvh http://ftp.riken.jp/Linux/fedora/epel/6/x86_64/epel-release-6-8.noarch.rpm
   
   #check yum repo for remi.repo epel.repo
  ls /etc/yum.repos.d/

7.  install php 5.4
   yum --enablerepo=remi install php php-string

8. Install mysql 5.5
  yum --enablerepo=remi install mysql mysql-server
  #auto start when PC start
 chkconfig mysqld on
   

5/29/2013

performance of array_map vs foreach loop


The following is one example for two ways:


$arrayOfNumbers = array();
for($i=1; $i<= 10000; ++$i) {
    $arrayOfNumbers[] = rand(1, 99999);
}
$maxHeap = new SplMaxHeap ();
#first way
# Avg Time: 0.92856907844543s
array_map(array($maxHeap, 'insert'), $arrayOfNumbers);
#second way
# Avg Time: 1.3148670101166
foreach($arrayOfNumbers as $number) {
    $maxHeap->insert($number);
}



It is due to the difference between Callback functions and normal functions.
In the second one, iteration of array using foreach, each iteration calls "insert" function and wait for the execution (function return control) and proceed to next iteration.
But in the array_map function, "insert" happens as callback function, it calls "insert" and don't wait for the result and call insert with next item in the array. So it is faster.


http://www.myresearch.biz/download/IJITCC2012.pdf

5/20/2013

PHP header Redirect for 301 Redirect permanently vs 302 Redirect Temporarily

1. PHP Redirect Code (permanent redirects)

Code 1. 
<?php
header("HTTP/1.1 301 Moved Permanently");
header("Location: http://www.researchbib.com");
?>

2. it is not same with (temporarily redirects)

Code 2.
<?php
header("Location: http://www.researchbib.com"); 
?>

====
<?php
header("HTTP/1.1 302 Moved Temporarily");
header("Location: http://www.researchbib.com");
?>

Please be careful.

If you set A page with code 1 or code 2, it is different for google index result.

Code 1: Google will index http://www.researchbib.com and url is http://www.researchbib.com, which means google will throw away A url. The google will dispaly www.researchbib.com link when usr search this page.

Code 2: Goodle will inex the contents from http://www.researchbib.com and url is A. The google will dispaly A link when usr search this page.



2014 1st International Conference on Non Conventional Energy