Using bash shell to auto-detect linux OS types(centos,debian,others)

August 18th, 2010

#!/bin/bash
#linux_type.sh
os="";
grep "centos" /etc/issue -i -q
if [ $? = '0' ];then
os='centos'
fi

grep "debian" /etc/issue -i -q
if [ $? = '0' ];then
os='debian'
fi

if [ $os = "" ];then
echo "not a valid system os"
exit 1
fi
Save the above code as linux_type.sh,chmod +x ./linux_type.sh.Then,execute the bash script to get the result.

Small fix to Google Syntax Highlighter for WordPress

August 15th, 2010

1.Where to put <pre></pre>

If you put source file in the 'Virsual' mode of your wordpress editor,you should then change to 'HTML' mode and enclose the source code with <pre></pre>.

2.About <pre> name='code'(use <pre lang='code'> to substitute <pre name='code'>)

By defualt,Google Syntax Highlighter for WordPress use <pre name='code'> to declare it's css's beginning.However,you'll find the 'name' attribute lost when you switching from Virsual to HTML.We can solve the problem by using the W3C standard attribute of <pre> tag,that is <pre lang='code'>.

Here are the steps:

Find wp-content/plugins/google-syntax-highlighter/Scripts/shCore.js,locate to line 364,substitute
<pre class="html" lang="code">if(_73[i].getAttribute("name")==_71){</pre>
to<!--more-->
<pre class="html" lang="code">if(_73[i].getAttribute("lang")==_71){</pre>
And that's all about the revision.Afterwards,use <pre lang="code" class="..."> when you want to highlight your code.

Apache server statistics:SetHandler,.htaccess,server-info,server-status

August 11th, 2010

<Files "server-info.php">
SetHandler server-info
</Files>

<Files "server-status.php">
SetHandler server-status
</Files>
Just put them in one of your .htaccess files,and then access the file:
http://yourdomain.tld/server-info.php
http://yourdomain.tld/server-status.php
you'll see the lamp server configure infomation and the current status of your server(how many concurrent people on your site,etc.).