problem in search

problem when search for “V&R”
V%26amp%3BR
%26 -> &
%3B -> ;
%26amp%3B -> &

Solution: change & to encoded code in query sent to html
Add:
$srch_name=eregi_replace(“&”,”%26amp%3B”,$srch_name);
before the following code
if($srch_name !=”){ $req.=”&name=$srch_name”; }
if($srch_site !=”){ $req.=”&site=$srch_site”; }

Eat healthy

31 Simple Ways to Prevent Cancer: Reduce Your Risk

Consider this number: 10 million. That’s how many cases of cancer are diagnosed worldwide each year. Now consider this number: 15 million. That’s how many cases of cancer the World health Organization estimates will be diagnosed in the year 2020 — a 50 percent increase — if we don’t get our act together.

Most cancers don’t develop overnight or out of nowhere. Cancer is largely predictable, the end result of a decades-long process, but just a few simple changes in your daily life can significantly reduce your risk. Here are 31 great tips. Continue reading

missing ; before statement

To check Javascript error, use Firefox Web Developer Addon

Tool -> Error Console

Got javascript error as “missing ; before statement” although there was no missing “;”

Finally found the reason is that the javascript function used number at the beginning, like

2way_func = function(){ …..}

awk & Sed

Calculate sum of the file size

ls -l access_log.2008-12-20*|gawk ‘{a+=$5;} END {print a;}’

 

Edit special lines using regular expression

awk ‘/aaa/ ‘ filename

 

Change file names using sed

##Example: from access_log.2008-12-20.01.gz.1  to access_log.2008-12-20.01.1.gz

for file in `ls access_log.2008-12-20.*`

do

newname=`echo $file|sed ‘s/\(access_log.2008-12-20.[0-9][0-9]\).gz.\([0-9]*\)/\1.\2.gz/’`

size=`ls -l $file|awk ‘{print $5}’`

if [ $size -gt 100 ];then

  echo “$file-> $newname”

fi

mv -v $file $newname

done