<?xml version='1.0' encoding='UTF-8'?><rss xmlns:atom='http://www.w3.org/2005/Atom' xmlns:openSearch='http://a9.com/-/spec/opensearchrss/1.0/' xmlns:georss='http://www.georss.org/georss' version='2.0'><channel><atom:id>tag:blogger.com,1999:blog-17722847</atom:id><lastBuildDate>Thu, 31 Dec 2009 17:15:14 +0000</lastBuildDate><title>mathie's tech+business bits</title><description>Ad Serving, Ad Management, Online Advertising, Entrepreneurship, Web Development, High Availability, Load Balancing, PHP, MySQL, AJAX</description><link>http://blog.trungson.com/</link><managingEditor>noreply@blogger.com (trungson)</managingEditor><generator>Blogger</generator><openSearch:totalResults>241</openSearch:totalResults><openSearch:startIndex>1</openSearch:startIndex><openSearch:itemsPerPage>25</openSearch:itemsPerPage><item><guid isPermaLink='false'>tag:blogger.com,1999:blog-17722847.post-2008306195606561853</guid><pubDate>Thu, 31 Dec 2009 16:04:00 +0000</pubDate><atom:updated>2009-12-31T09:15:14.964-08:00</atom:updated><category domain='http://www.blogger.com/atom/ns#'>mobile</category><title>PhoneGap fills a gap to the mobile world</title><description>Mobile is going wild! Mobile is going to take over! You hear this many many times in the news and I have to agree for the most part. It's the convenience, the portability, the accessibility, the entertainment, and also the un-productivity that makes mobile devices great. 

&lt;h4&gt;API to bridge web app and native app&lt;/h4&gt;
I just discovered PhoneGap.com the other day when trying to evaluate my options when trying to develop an iPhone app. I have not gotten into the technical documents or prototyping yet but it's a great concept and should be promoted to more web developers like myself.

&lt;h4&gt;Gap between web developers (HTML, CSS, JS, back-end) and Objective-C&lt;/h4&gt;
This is a big gap since I just got introduced to the Mac world not too long ago. Even with a formal university training in C, C++, Java, and many self-taught web techs, learning a new thing is good but takes time, which could mean a delay in other more important things. So the concept (ideally) of PhoneGap is great, you just simply port your existing fine-tuned web app to a native iPhone app of pretty much the same quality (of course optimized for the smaller screen). This is a great idea/business pitch, very simple to understand and yet fill a great need. 

&lt;h4&gt;Gap between a pro app builder and a single-web-service provider&lt;/h4&gt;
For us, we don't want to build a vast array of apps. We do not develop apps for other businesses. We simply want to port our existing web service (an ad management and tracking solution) to a native app so our client would access it anywhere, on their desktop and on the go. If doing the Objective-C way, we would need to either build it in-house or out-source to an app builder. Either way, we do not want to expose our core engines to the app (for security and modularity), so the app would use our API, which we already made public for our clients.

&lt;h5&gt;In-house&lt;/h5&gt;
If the app building process and knowledge can be used as our core competency, meaning we will focus into mobile apps, then it makes sense. If there is some overlap between these platforms and our existing development then it also makes sense. I like learning a new language, new things in general, but not when pushed by deadlines and pressure. However, it's quite a different world and frankly I don't see myself getting too deep into it, unless we have no other choice.

&lt;h5&gt;Out-sourcing&lt;/h5&gt;
Easy, fast, many options, developers, firm out there to compete for your business. However, this approach could get expensive with multiple app and on-going maintenance. We frequently add new features and improve existing ones on a daily basis. Upgrades are daily to weekly. With out-sourcing, we would need to request service from the external firm to push these new features and updates regularly. If the update frequency is slower, choosing to out-source would be a straight-forward decision.

&lt;h4&gt;Gap between different mobile platforms&lt;/h4&gt;
iPhone is still the biggest player in town, but more are becoming bigger like WebOS, Android. Call them what you want, copycats, imitators. It's part of the evolution and a needed one. So instead of paying one Objective-C team, one Java team (or other languages) to port your app, what's better than having to write one web app that works just from any browsers. Then port/compile it to a native app on all platforms with ease (ideally).

&lt;h4&gt;Reality&lt;/h4&gt;
Of course I understand PhoneGap is still in its very early stage with few up-to-date documentation/tutorials and an active codebase (unstable interface). But it will be stable and get more popular and more support. Of course you can argue that performance, stability, etc. cannot be the same as an fully native app written in Objective-C. Yes, but everything comes with some trade-offs. Some apps won't be able to use these API bridges (eg: graphic-intensive games) but some apps (like our ad management and ad serving solution) are ideal candidates for PhoneGap (and other similar alternatives). I have only been reading on PhoneGap and iPhone app processes recently. When can we stop learning and focus on doing? I guess the answer is never and if/when it happens, it's a bad thing. So the goal is to maintain a good balance and thing will flow along.&lt;div class="blogger-post-footer"&gt;&lt;img width='1' height='1' src='https://blogger.googleusercontent.com/tracker/17722847-2008306195606561853?l=blog.trungson.com' alt='' /&gt;&lt;/div&gt;</description><link>http://blog.trungson.com/2009/12/phonegap-fills-mobile-world-gap.html</link><author>noreply@blogger.com (trungson)</author><thr:total xmlns:thr='http://purl.org/syndication/thread/1.0'>0</thr:total></item><item><guid isPermaLink='false'>tag:blogger.com,1999:blog-17722847.post-7020146430068182990</guid><pubDate>Fri, 20 Nov 2009 04:33:00 +0000</pubDate><atom:updated>2009-11-19T20:36:59.272-08:00</atom:updated><category domain='http://www.blogger.com/atom/ns#'>jquery</category><title>DataTable jQuery Plugin - JavaScript inside a table cell</title><description>If the data source is AJAX and the cell has JavaScript, the node is created and assigned directly via nTd.innerHTML=data so any JavaScript code inside the cell won't get executed. To correct than you need the custom fnRender for that column.

&lt;textarea name="code" class="js"&gt;
fnRender: function (o) {
 var oTmp = document.createElement("div");
 oTmp.innerHTML = o.aData[5]; // just to let the browser parse HTML for me
 var aScripts = oTmp.getElementsByTagName("script");
 for (var i=0;i &lt; aScripts.length;i++) {
   // similar to jQuery core: inject into head, then remove (avoid re-eval)
   jQuery.globalEval(aScripts[i].text || aScripts[i].textContent || aScripts[i].innerHTML || "" );
   if (aScripts[i].parentNode) { aScripts[i].parentNode.removeChild(aScripts[i]); }
 } // rof
 return oTmp.innerHTML;
}
&lt;/textarea&gt;&lt;div class="blogger-post-footer"&gt;&lt;img width='1' height='1' src='https://blogger.googleusercontent.com/tracker/17722847-7020146430068182990?l=blog.trungson.com' alt='' /&gt;&lt;/div&gt;</description><link>http://blog.trungson.com/2009/11/datatable-jquery-plugin-javascript.html</link><author>noreply@blogger.com (trungson)</author><thr:total xmlns:thr='http://purl.org/syndication/thread/1.0'>0</thr:total></item><item><guid isPermaLink='false'>tag:blogger.com,1999:blog-17722847.post-2852698635335148473</guid><pubDate>Mon, 16 Nov 2009 16:01:00 +0000</pubDate><atom:updated>2009-11-16T08:28:28.770-08:00</atom:updated><category domain='http://www.blogger.com/atom/ns#'>sysadmin</category><title>Hadoop vs. MySQL</title><description>I just play with Hadoop, HBase, Hive, Pig via Cloudera's guide (thanks to Cloudera for bringing these packages to CentOS) for a couple days. Cloudera is going in the right direction, targeting the enterprises. Hadoop is definitely on the watch list as it matures. But right now, it's very technical and would not be suitable for the general public. I'm also disappointed on its performance for a smaller testing cluster (which I understand is unfair for what it's designed for). For its to shine, you would need both, the problem has to be big enough and the server farms has to be big enough. However, I think there are many companies that initially test Hadoop on a small cluster before actually investing more time and money into it. It's the first impression that makes a lasting impact. As it matures, I expect there will be overhead-reduction optimizations done on the small/low-end clusters.

&lt;p&gt;Setting up MySQL is easy, scaling it is not so easy but there are many related software and technology to help you. But don't think you can just switch to Hadoop/HBase/Hive in a day. The selling point is there (no-limit scaling on commodity hardware at the core design) but there are many land mines that you could walk on if decisions are not evaluated carefully. Right now, I see Hadoop as one of the last resorts because you're running into a wall, exhausting RDBMS options and its related software/technology that help you scale, like memcache, message queues, load balancing, etc. You should not choose Hadoop just because you started a company and might get big in a couple years. Of course there are exceptions when you know your problem domain is only solvable in a distributed system. The popularity of Hadoop could change (or not) if the priority on Hadoop is to dominate both markets or just focus on the large farms.

&lt;p&gt;You face complexity when dealing with Hadoop/Hbase/Hive/HDFS (like setting up, breaking things down into tasks, and setting up batch operations). For many many applications, MySQL (or RDBMS) ain't going anywhere. I see smart companies use both for different parts of their operations. Unless Hadoop can do real-time, low-latency operations in distributed server farms effortlessly, there is no clear winner now, or ever. Maybe the trend on real-time search (Twitter, FaceBook) might be able to speed this up.&lt;div class="blogger-post-footer"&gt;&lt;img width='1' height='1' src='https://blogger.googleusercontent.com/tracker/17722847-2852698635335148473?l=blog.trungson.com' alt='' /&gt;&lt;/div&gt;</description><link>http://blog.trungson.com/2009/11/hadoop-vs-mysql.html</link><author>noreply@blogger.com (trungson)</author><thr:total xmlns:thr='http://purl.org/syndication/thread/1.0'>0</thr:total></item><item><guid isPermaLink='false'>tag:blogger.com,1999:blog-17722847.post-3481194634519339521</guid><pubDate>Sun, 15 Nov 2009 02:19:00 +0000</pubDate><atom:updated>2009-11-14T18:45:13.205-08:00</atom:updated><category domain='http://www.blogger.com/atom/ns#'>sysadmin</category><title>Hive troubleshooting</title><description>I am playing with Hadoop and Hive via Cloudera RPMs. The development status is very active, meaning it could be hard to track down the errors or find help with a specific one.

&lt;h4&gt;Permission of /tmp in HDFS&lt;/h4&gt;
&lt;pre&gt;
FAILED: Unknown exception : org.apache.hadoop.fs.permission.AccessControlException: Permission denied: user=mathie, access=WRITE, inode="tmp":hadoop:supergroup:rwxrwxr-x
&lt;/pre&gt;

Solution: You need to turn on full write permissions for /tmp
&lt;pre&gt;
sudo -u hadoop hadoop fs -chmod 777 /tmp
&lt;/pre&gt;

&lt;h4&gt;.hivehistory&lt;/h4&gt;
&lt;pre&gt;
[root@r2 tmp]# sudo -u hadoop hive
Hive history file=/tmp/hadoop/hive_job_log_hadoop_200911142019_988931842.txt
java.io.FileNotFoundException: /.hivehistory (Permission denied)
 at java.io.FileOutputStream.open(Native Method)
 at java.io.FileOutputStream.&lt;init&gt;(FileOutputStream.java:179)
 at java.io.FileOutputStream.&lt;init&gt;(FileOutputStream.java:131)
 at java.io.FileWriter.&lt;init&gt;(FileWriter.java:73)
 at jline.History.setHistoryFile(History.java:45)
 at jline.History.&lt;init&gt;(History.java:37)
 at org.apache.hadoop.hive.cli.CliDriver.main(CliDriver.java:298)
 at sun.reflect.NativeMethodAccessorImpl.invoke0(Native Method)
 at sun.reflect.NativeMethodAccessorImpl.invoke(NativeMethodAccessorImpl.java:39)
 at sun.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAccessorImpl.java:25)
 at java.lang.reflect.Method.invoke(Method.java:597)
 at org.apache.hadoop.util.RunJar.main(RunJar.java:155)
 at org.apache.hadoop.mapred.JobShell.run(JobShell.java:54)
 at org.apache.hadoop.util.ToolRunner.run(ToolRunner.java:65)
 at org.apache.hadoop.util.ToolRunner.run(ToolRunner.java:79)
 at org.apache.hadoop.mapred.JobShell.main(JobShell.java:68)
&lt;/pre&gt;

It means your $HOME folder is empty and it's trying to create /.hivehistory on the top level, which of course is not possible. Solution: make sure it's a real user with a $HOME ("echo $HOME" to check) and not via sudo

&lt;h4&gt;/etc/hive/conf/hive-site.xml&lt;/h4&gt;
&lt;pre&gt;
hive&gt; show tables;
FAILED: Error in metadata: javax.jdo.JDODataStoreException: SQL exception: Add classes to Catalog "", Schema "APP"
NestedThrowables:
java.sql.SQLNonTransientConnectionException: No current connection.
FAILED: Execution Error, return code 1 from org.apache.hadoop.hive.ql.exec.DDLTask
Time taken: 3.142 seconds
&lt;/pre&gt;
Even with embedded mode for metastore, if you run into this problem, look like an issue with Cloudera RPM for Hive that uses ${user.name} not being replaced properly.

Solution: change "${user.name}" to an regular folder and Hive works fine.&lt;div class="blogger-post-footer"&gt;&lt;img width='1' height='1' src='https://blogger.googleusercontent.com/tracker/17722847-3481194634519339521?l=blog.trungson.com' alt='' /&gt;&lt;/div&gt;</description><link>http://blog.trungson.com/2009/11/hive-troubleshooting.html</link><author>noreply@blogger.com (trungson)</author><thr:total xmlns:thr='http://purl.org/syndication/thread/1.0'>0</thr:total></item><item><guid isPermaLink='false'>tag:blogger.com,1999:blog-17722847.post-1058060153515101555</guid><pubDate>Wed, 11 Nov 2009 17:27:00 +0000</pubDate><atom:updated>2009-11-11T09:48:04.684-08:00</atom:updated><category domain='http://www.blogger.com/atom/ns#'>sysadmin</category><title>haproxy vs. LVS (layer 7 vs layer 4 load balancing)</title><description>We just deployed our first haproxy load balancer and still running several LVS-TUN load balancers. Even when advertised as a fast and lightweight, it's comparing with other layer-7 LB, not with layer-4 LB like LVS. 

&lt;h4&gt;Load Average / CPU Usage&lt;/h4&gt;
haproxy still requires much more resource. On the same really basic server (Pentium 3/4 or something really slow), LVS load average is always or near zero, even with many incoming requests. haproxy's load average is about 0.3 to 0.5

&lt;h4&gt;Features&lt;/h4&gt;
But the good thing about haproxy is that it has more features and flexible in term of configuration. LVS-TUN is best when the ISP allows packets to have LB's IP (spoofed packets). But if you don't have that option, haproxy is the next best thing. Assuming you don't need HTTP header inspection feature of haproxy, which LVS does not have because it's layer 4.

&lt;h4&gt;Bandwidth Utilization&lt;/h4&gt;
LVS-TUN only takes the incoming portion of the requests so bandwidth requirement would be half of the full process (haproxy and same for LVS-NAT).

&lt;h4&gt;SSL&lt;/h4&gt;
LVS-TUN does it effortlessly because it does not deal with the content of the packets at all. haproxy can deal with SSL with 2 options: 

&lt;ul&gt;
&lt;li&gt;via TCP option (haproxy acts as a layer 4 LB). Pros: easy. Cons: you won't be able to get the client IP, which to some app is a deal breaker.&lt;/li&gt;
&lt;li&gt;Stunnel runs on the same machine as haproxy to process SSL then forward to haproxy as a standard request. Pros: client IP is passed with the provided patch on haproxy's website. Cons: could slow down the LB machine if there're many SSL requests, need to setup SSL when passing between haproxy and the workers for really secure data&lt;/li&gt;
&lt;/ul&gt;

&lt;h4&gt;Conclusion&lt;/h4&gt;
Both haproxy and LVS have their own space. Use LVS-TUN when possible for the best performance and scalability. haproxy is best when you need header inspection and LVS-TUN is not possible with the ISP/network.&lt;div class="blogger-post-footer"&gt;&lt;img width='1' height='1' src='https://blogger.googleusercontent.com/tracker/17722847-1058060153515101555?l=blog.trungson.com' alt='' /&gt;&lt;/div&gt;</description><link>http://blog.trungson.com/2009/11/haproxy-vs-lvs-layer-7-vs-layer-4-load.html</link><author>noreply@blogger.com (trungson)</author><thr:total xmlns:thr='http://purl.org/syndication/thread/1.0'>0</thr:total></item><item><guid isPermaLink='false'>tag:blogger.com,1999:blog-17722847.post-6096271369494485190</guid><pubDate>Sun, 08 Nov 2009 02:38:00 +0000</pubDate><atom:updated>2009-11-21T12:07:27.621-08:00</atom:updated><category domain='http://www.blogger.com/atom/ns#'>sysadmin</category><title>Monitor LSI MegaRAID under CentOS</title><description>Not very user friendly with documentation but I guess at least it runs!

&lt;textarea name="code" class="xml"&gt;
$ wget http://www.lsi.com/DistributionSystem/AssetDocument/support/downloads/megaraid/miscellaneous/linux/1.01.39_Linux_Cli.zip

$ unzip 1.01.39_Linux_Cli.zip

$ rpm -Uvh MegaCli-1.01.39-0.i386.rpm

$ /opt/MegaRAID/MegaCli/MegaCli64 -AdpAllInfo -a0
&lt;/textarea&gt;

&lt;h4&gt;Basic Monitor Script&lt;/h4&gt;
&lt;textarea name="code" class="xml"&gt;
#!/bin/sh
CONT="a0"
STATUS=0
MEGACLI=/opt/MegaRAID/MegaCli/MegaCli64

echo -n "Checking RAID status on "
hostname
for a in $CONT
do

NAME=`$MEGACLI -AdpAllInfo -$a |grep "Product Name" | cut -d: -f2`
echo "Controller $a: $NAME"
noonline=`$MEGACLI PDList -$a | grep Online | wc -l`
echo "No of Physical disks online : $noonline"
DEGRADED=`$MEGACLI -AdpAllInfo -a0 |grep "Degrade"`
echo $DEGRADED
NUM_DEGRADED=`echo $DEGRADED |cut -d" " -f3`
[ "$NUM_DEGRADED" -ne 0 ] &amp;&amp; STATUS=1
FAILED=`$MEGACLI -AdpAllInfo -a0 |grep "Failed Disks"`
echo $FAILED
NUM_FAILED=`echo $FAILED |cut -d" " -f4`
[ "$NUM_FAILED" -ne 0 ] &amp;&amp; STATUS=1

done

exit $STATUS
&lt;/textarea&gt;

Sample Output
&lt;pre&gt;
Checking RAID status on xxx
Controller a0:  MegaRAID SAS 8344ELP
No of Physical disks online : 4
Degraded : 0
Failed Disks : 0
&lt;/pre&gt;

&lt;h4&gt;Upgrade Firmware&lt;/h4&gt;
To determine the current firmware, run "MegaCli -AdpAllInfo -a0"
&lt;pre&gt;
Product Name    : MegaRAID SAS 8344ELP
Serial No       : P00253390X
FW Package Build: 7.0.1-0064

                    Mfg. Data
                ================
Mfg. Date       : 09/27/06
Rework Date : 00/00/00
Revision No     : 8

                Image Versions In Flash:
                ================
Boot Block Version : R.2.3.15
BIOS Version       : MT33
MPT Version        : MPTFW-01.18.79.00-IT
FW Version         : 1.12.220-0560
WebBIOS Version    : 1.1-33g-e_11-Rel
Ctrl-R Version     : 1.04-019A
&lt;/pre&gt;

Check the LSi website for the current downloads, in this case: 

http://www.lsi.com/storage_home/products_home/internal_raid/megaraid_sas/megaraid_sas_8344elp/index.html

&lt;pre&gt;
- Download the firmware, unzip
- Run "MegaCli -adpfwflash -f SAS1068_FW_Image.rom -a0"
&lt;/pre&gt;&lt;div class="blogger-post-footer"&gt;&lt;img width='1' height='1' src='https://blogger.googleusercontent.com/tracker/17722847-6096271369494485190?l=blog.trungson.com' alt='' /&gt;&lt;/div&gt;</description><link>http://blog.trungson.com/2009/11/monitor-lsi-megaraid-under-centos.html</link><author>noreply@blogger.com (trungson)</author><thr:total xmlns:thr='http://purl.org/syndication/thread/1.0'>0</thr:total></item><item><guid isPermaLink='false'>tag:blogger.com,1999:blog-17722847.post-584045813516868049</guid><pubDate>Fri, 06 Nov 2009 19:36:00 +0000</pubDate><atom:updated>2009-11-06T11:37:54.766-08:00</atom:updated><category domain='http://www.blogger.com/atom/ns#'>sysadmin</category><title>init.d script for gearmand</title><description>&lt;textarea name="code" class="xml"&gt;
#!/bin/bash
#
# gearmand        Startup script for the Gearman server
#
# chkconfig: - 85 15
# description: Gearman is a distributed job system.
# processname: gearmand
# config: /etc/sysconfig/gearmand
# pidfile: /var/run/gearmand/gearmand.pid
#
### BEGIN INIT INFO
# Provides: gearmand
# Required-Start: $local_fs $network
# Required-Stop: $local_fs $network
# Default-Start:
# Default-Stop:
# Short-Description: start and stop the Gearman server
# Description: Gearman is a distributed job system.
### END INIT INFO

# Source function library.
. /etc/rc.d/init.d/functions

if [ -f /etc/sysconfig/gearmand ]; then
        . /etc/sysconfig/gearmand
fi

[ -z "${PIDFILE}" ] &amp;&amp; pidfile="/var/run/gearmand/gearmand.pid"
[ -z "${LOCKFILE}" ] &amp;&amp; lockfile="/var/lock/subsys/gearmand"

gearmand=/usr/sbin/gearmand
prog=gearmand

RETVAL=0

start() {
        echo -n $"Starting $prog: "
        daemon --pidfile=$pidfile --user=gearmand $gearmand -d $OPTIONS
        RETVAL=$?
        echo
        [ $RETVAL = 0 ] &amp;&amp; (touch $lockfile; pgrep -f $gearmand &gt; $pidfile)
        return $RETVAL
}

stop() {
 echo -n $"Stopping $prog: "
 killproc -p $pidfile $gearmand
 RETVAL=$?
 echo
 [ $RETVAL = 0 ] &amp;&amp; rm -f $lockfile $pidfile
}

# See how we were called.
case "$1" in
  start)
 start
 ;;
  stop)
 stop
 ;;
  status)
        status -p $pidfile $gearmand
 RETVAL=$?
 ;;
  restart|reload)
 stop
 start
 ;;
  condrestart|try-restart)
 if status -p $pidfile $gearmand &gt;&amp;/dev/null; then
  stop
  start
 fi
 ;;
  *)
 echo $"Usage: $prog {start|stop|restart|reload|condrestart|status|help}"
 RETVAL=3
esac

exit $RETVAL
&lt;/textarea&gt;&lt;div class="blogger-post-footer"&gt;&lt;img width='1' height='1' src='https://blogger.googleusercontent.com/tracker/17722847-584045813516868049?l=blog.trungson.com' alt='' /&gt;&lt;/div&gt;</description><link>http://blog.trungson.com/2009/11/initd-script-for-gearmand.html</link><author>noreply@blogger.com (trungson)</author><thr:total xmlns:thr='http://purl.org/syndication/thread/1.0'>0</thr:total></item><item><guid isPermaLink='false'>tag:blogger.com,1999:blog-17722847.post-1790906606210199699</guid><pubDate>Thu, 05 Nov 2009 18:38:00 +0000</pubDate><atom:updated>2009-11-05T10:50:09.607-08:00</atom:updated><category domain='http://www.blogger.com/atom/ns#'>sysadmin</category><title>init.d script for stunnel on CentOS</title><description>You might need to modify some settings to suite your installation. I installed from source. 
&lt;pre&gt;
whereis stunnel
(might need to ln -s /usr/local/bin/stunnel /usr/sbin/stunnel)

vi /etc/init.d/stunnel
&lt;/pre&gt;
&lt;textarea name="code" class="xml"&gt;
#!/bin/bash
#
# stunnel      This shell script takes care of starting and stopping
#              stunnel
#
# chkconfig: 345 80 30
# description:  Secure tunnel

# processname: stunnel
# config: /etc/stunnel/stunnel.conf
# pidfile: /var/run/stunnel/stunnel.pid

# Source function library.
. /etc/rc.d/init.d/functions

# Source stunnel configureation.
if [ -f /etc/sysconfig/stunnel ] ; then
 . /etc/sysconfig/stunnel
fi

RETVAL=0
prog="stunnel"

start() {
 # Start daemons.

 echo -n $"Starting $prog: "
 if test -x /usr/sbin/stunnel ; then
   /usr/sbin/stunnel /etc/stunnel/stunnel.conf
 fi
 RETVAL=$?
 echo
 [ $RETVAL -eq 0 ] &amp;&amp; touch /var/lock/subsys/stunnel
 return $RETVAL
}

stop() {
 # Stop daemons.
 echo -n $"Shutting down $prog: "
 killproc stunnel
 RETVAL=$?
 echo
 [ $RETVAL -eq 0 ] &amp;&amp; rm -f /var/lock/subsys/stunnel
 return $RETVAL
}

# See how we were called.
case "$1" in
  start)
 start
 ;;
  stop)
 stop
 ;;
  restart)
 stop
 start
 RETVAL=$?
 ;;
  condrestart)
 if [ -f /var/lock/subsys/stunnel ]; then
     stop
     start
     RETVAL=$?
 fi
 ;;
  status)
 status stunnel
 RETVAL=$?
 ;;
  *)
 echo $"Usage: $0 {start|stop|restart|condrestart|status}"
 exit 1
esac

exit $RETVAL

&lt;/textarea&gt;&lt;div class="blogger-post-footer"&gt;&lt;img width='1' height='1' src='https://blogger.googleusercontent.com/tracker/17722847-1790906606210199699?l=blog.trungson.com' alt='' /&gt;&lt;/div&gt;</description><link>http://blog.trungson.com/2009/11/initd-script-for-stunnel.html</link><author>noreply@blogger.com (trungson)</author><thr:total xmlns:thr='http://purl.org/syndication/thread/1.0'>0</thr:total></item><item><guid isPermaLink='false'>tag:blogger.com,1999:blog-17722847.post-1599911562765534244</guid><pubDate>Fri, 30 Oct 2009 18:47:00 +0000</pubDate><atom:updated>2009-10-30T11:59:56.244-07:00</atom:updated><category domain='http://www.blogger.com/atom/ns#'>javascript jquery</category><title>jQuery - Avoid duplicate element's IDs</title><description>If the input element has an ID and it is duplicate with another element, it's likely cause an error. In this case, Firefox 3.5 and IE8 on Windows Vista has no problem while same browsers in Windows XP does not work.

&lt;h4&gt;Problem&lt;/h4&gt;
&lt;textarea name="code" class="html"&gt;
&lt;form id="myform"&gt;
&lt;input name="action" id="action" value="doSomething"&gt;
...
&lt;/form&gt;


&lt;form id="anotherform"&gt;
&lt;input name="action" id="action" value="doSomethingElse"&gt;
...
&lt;/form&gt;

...
$("#myform #action").val();
&lt;/textarea&gt;

That works in Vista and Mac OSX but not XP. It's rather weird it's a problem that depends on the OS and not the browser. Anyway, it's a mistake and duplicate IDs should always be avoid.

&lt;h4&gt;Solution&lt;/h4&gt;
&lt;textarea name="code" class="html"&gt;
&lt;form id="myform"&gt;
&lt;input name="action" value="doSomething"&gt;
...
&lt;/form&gt;

...
$("#myform input[name='action']").val();
&lt;/textarea&gt;&lt;div class="blogger-post-footer"&gt;&lt;img width='1' height='1' src='https://blogger.googleusercontent.com/tracker/17722847-1599911562765534244?l=blog.trungson.com' alt='' /&gt;&lt;/div&gt;</description><link>http://blog.trungson.com/2009/10/jquery-avoid-duplicated-elements-ids.html</link><author>noreply@blogger.com (trungson)</author><thr:total xmlns:thr='http://purl.org/syndication/thread/1.0'>0</thr:total></item><item><guid isPermaLink='false'>tag:blogger.com,1999:blog-17722847.post-1556379350692878515</guid><pubDate>Tue, 27 Oct 2009 23:21:00 +0000</pubDate><atom:updated>2009-10-27T16:24:18.301-07:00</atom:updated><category domain='http://www.blogger.com/atom/ns#'>jquery</category><title>jQuery form item highlighting</title><description>&lt;pre&gt;
$(document).ready(function(){
  $("input,textarea,select")
    .focus(function() {$(this).addClass("form-item-focus");})
    .blur(function() {$(this).removeClass("form-item-focus");});
});
&lt;/pre&gt;&lt;div class="blogger-post-footer"&gt;&lt;img width='1' height='1' src='https://blogger.googleusercontent.com/tracker/17722847-1556379350692878515?l=blog.trungson.com' alt='' /&gt;&lt;/div&gt;</description><link>http://blog.trungson.com/2009/10/jquery-form-item-highlighting.html</link><author>noreply@blogger.com (trungson)</author><thr:total xmlns:thr='http://purl.org/syndication/thread/1.0'>0</thr:total></item><item><guid isPermaLink='false'>tag:blogger.com,1999:blog-17722847.post-9158611692036062246</guid><pubDate>Fri, 23 Oct 2009 23:32:00 +0000</pubDate><atom:updated>2009-10-23T16:34:40.732-07:00</atom:updated><title>MOD files import into iMovies for Panasonic SDR-H18</title><description>This little trick is for iMovies to import MOD files automatically. Create this folder and copy MOD files to it: D:\MP_ROOT\101PNV01&lt;div class="blogger-post-footer"&gt;&lt;img width='1' height='1' src='https://blogger.googleusercontent.com/tracker/17722847-9158611692036062246?l=blog.trungson.com' alt='' /&gt;&lt;/div&gt;</description><link>http://blog.trungson.com/2009/10/mod-files-import-into-imovies-for.html</link><author>noreply@blogger.com (trungson)</author><thr:total xmlns:thr='http://purl.org/syndication/thread/1.0'>0</thr:total></item><item><guid isPermaLink='false'>tag:blogger.com,1999:blog-17722847.post-7399472817717702067</guid><pubDate>Fri, 23 Oct 2009 03:39:00 +0000</pubDate><atom:updated>2009-10-23T08:23:35.676-07:00</atom:updated><category domain='http://www.blogger.com/atom/ns#'>sysadmin</category><title>Centos and BOINC/World Community Grid</title><description>There are RPM packages for Fedora but doesn't seem one for CentOS. There is no updated instructions on running BOINC client via command line. 

&lt;pre&gt;
1) Download and run boinc_6.2.15_i686-pc-linux-gnu.sh
2) Run "./boinccmd –project_attach www.worldcommunitygrid.org &lt;Key&gt;" 
(Log into WCG, the key can be found on menu My Profile, near the bottom)
4) Run "./run_client --daemon" to begin the client
5) Check "tail stdoutdae.txt -f" for output
&lt;/pre&gt;

You might need to install these for dependencies:
&lt;pre&gt;
yum install libXcomposite
yum install libXdamage
&lt;/pre&gt;&lt;div class="blogger-post-footer"&gt;&lt;img width='1' height='1' src='https://blogger.googleusercontent.com/tracker/17722847-7399472817717702067?l=blog.trungson.com' alt='' /&gt;&lt;/div&gt;</description><link>http://blog.trungson.com/2009/10/centos-and-boincworld-community-grid.html</link><author>noreply@blogger.com (trungson)</author><thr:total xmlns:thr='http://purl.org/syndication/thread/1.0'>0</thr:total></item><item><guid isPermaLink='false'>tag:blogger.com,1999:blog-17722847.post-7300065960883404096</guid><pubDate>Fri, 16 Oct 2009 17:28:00 +0000</pubDate><atom:updated>2009-10-16T10:29:45.779-07:00</atom:updated><category domain='http://www.blogger.com/atom/ns#'>sysadmin</category><title>Optimizing TCP stack under CentOS/RHEL Linux</title><description>This is from one of our pretty old servers
&lt;pre&gt;
more /etc/sysctl.conf
# Kernel sysctl configuration file for Red Hat Linux
#
# For binary values, 0 is disabled, 1 is enabled.  See sysctl(8) for
# more details.

# Controls IP packet forwarding
net.ipv4.ip_forward = 0

# Controls source route verification
net.ipv4.conf.default.rp_filter = 1

# Controls the System Request debugging functionality of the kernel
kernel.sysrq = 0

# Controls whether core dumps will append the PID to the core filename.
# Useful for debugging multi-threaded applications.
kernel.core_uses_pid = 1

# From: http://forum.ev1servers.net/showthread.php?s=&amp;threadid=19647
# Decrease the time default value for tcp_fin_timeout connection
net.ipv4.tcp_fin_timeout = 30
# Decrease the time default value for tcp_keepalive_time connection
net.ipv4.tcp_keepalive_time = 1800
# Turn on the tcp_window_scaling
net.ipv4.tcp_window_scaling = 0
# Turn off the tcp_sack
net.ipv4.tcp_sack = 0
# Turn off the tcp_timestamps
net.ipv4.tcp_timestamps = 0
# Enable TCP SYN Cookie Protection
net.ipv4.tcp_syncookies = 1
# Enable ignoring broadcasts request
net.ipv4.icmp_echo_ignore_broadcasts = 1
# Disable ICMP Redirect Acceptance
net.ipv4.conf.all.accept_redirects = 0
# Enable bad error message Protection
net.ipv4.icmp_ignore_bogus_error_responses = 1
# Don't Log Spoofed Packets, Source Routed Packets, Redirect Packets
net.ipv4.conf.all.log_martians = 1
# Make more local ports available
# net.ipv4.ip_local_port_range = 1024 65000
# Increase maximum amount of memory allocated to shm
kernel.shmmax = 1073741824
# Improve file system performance
vm.bdflush = 100 1200 128 512 15 5000 500 1884 2
# This will increase the amount of memory available for socket input/output queues
# net.ipv4.tcp_rmem = 4096 25165824 25165824
# net.core.rmem_max = 25165824
# net.core.rmem_default = 25165824
# net.ipv4.tcp_wmem = 4096 65536 25165824
# net.core.wmem_max = 25165824
# net.core.wmem_default = 65536
# net.core.optmem_max = 25165824
&lt;/pre&gt;&lt;div class="blogger-post-footer"&gt;&lt;img width='1' height='1' src='https://blogger.googleusercontent.com/tracker/17722847-7300065960883404096?l=blog.trungson.com' alt='' /&gt;&lt;/div&gt;</description><link>http://blog.trungson.com/2009/10/optimizing-tcp-stack-under-centosrhel.html</link><author>noreply@blogger.com (trungson)</author><thr:total xmlns:thr='http://purl.org/syndication/thread/1.0'>0</thr:total></item><item><guid isPermaLink='false'>tag:blogger.com,1999:blog-17722847.post-6519585731333033011</guid><pubDate>Tue, 22 Sep 2009 16:13:00 +0000</pubDate><atom:updated>2009-09-22T09:15:17.820-07:00</atom:updated><category domain='http://www.blogger.com/atom/ns#'>jquery</category><title>Debugging jQuery selector</title><description>Selectors are really powerful, but how to you know what/which elements were chosen? Use this statement
&lt;textarea name="code" class="js"&gt;
var str = $(e).parents("form tr").map(function() { return this.tagName; }).get().join(", ");
alert(str);
&lt;/textarea&gt;&lt;div class="blogger-post-footer"&gt;&lt;img width='1' height='1' src='https://blogger.googleusercontent.com/tracker/17722847-6519585731333033011?l=blog.trungson.com' alt='' /&gt;&lt;/div&gt;</description><link>http://blog.trungson.com/2009/09/debugging-jquery-selector.html</link><author>noreply@blogger.com (trungson)</author><thr:total xmlns:thr='http://purl.org/syndication/thread/1.0'>0</thr:total></item><item><guid isPermaLink='false'>tag:blogger.com,1999:blog-17722847.post-1299389331233760738</guid><pubDate>Fri, 07 Aug 2009 01:12:00 +0000</pubDate><atom:updated>2009-08-06T18:14:05.497-07:00</atom:updated><category domain='http://www.blogger.com/atom/ns#'>sysadmin</category><title>PHP Error - DOMDocument not found</title><description>If you see this error when your PHP version is already 5.x, make sure you install "yum install php-xmlrpc" and might have to restart the web server (just to be sure).

&lt;pre&gt;PHP Fatal error:  Class 'DOMDocument' not found in xxx&lt;/pre&gt;&lt;div class="blogger-post-footer"&gt;&lt;img width='1' height='1' src='https://blogger.googleusercontent.com/tracker/17722847-1299389331233760738?l=blog.trungson.com' alt='' /&gt;&lt;/div&gt;</description><link>http://blog.trungson.com/2009/08/php-error-domdocument-not-found.html</link><author>noreply@blogger.com (trungson)</author><thr:total xmlns:thr='http://purl.org/syndication/thread/1.0'>0</thr:total></item><item><guid isPermaLink='false'>tag:blogger.com,1999:blog-17722847.post-717631515181580073</guid><pubDate>Wed, 22 Jul 2009 23:29:00 +0000</pubDate><atom:updated>2009-07-22T16:36:47.118-07:00</atom:updated><category domain='http://www.blogger.com/atom/ns#'>sysadmin</category><title>Gotchas with gettext in PHP</title><description>Be careful when you first try gettext in PHP, it can be very unreliable/unpredictable because of different naming conventions.

&lt;textarea name="code" class="php"&gt;
$vLang = 'vi_VN';
$vDomain = 'MyApp';
putenv("LANGUAGE=".$vLang);
putenv("LANG=".$vLang);
bindtextdomain($vDomain,AS_BASEDIR.'locale');
bind_textdomain_codeset($vDomain,"UTF-8");
setlocale(LC_ALL,$vLang.".utf8",$vLang.".UTF8",$vLang.".utf-8",$vLang.".UTF-8",$vLang);
textdomain($vDomain);
&lt;/textarea&gt;

&lt;h4&gt;MyApp.po vs MyApp.mo&lt;/h4&gt;
PO is the human-readable and you perform the translation in here. MO is the binary file and it's cached by Apache. Thus, you need to restart Apache (XAMPP) after each change to MyApp.po, then recompile it via "msgfmt MyApp.po -o MyApp.mo". If you forgot to recompile, it won't have any of the new modifications.

&lt;h4&gt;Folder Structure&lt;/h4&gt;
&lt;pre&gt;
/MyApp/locale/vi_VN/LC_MESSAGES/MyApp.mo
/MyApp/locale/da_DK/LC_MESSAGES/MyApp.mo
/MyApp/locale/en_US/LC_MESSAGES/MyApp.mo
&lt;/pre&gt;&lt;div class="blogger-post-footer"&gt;&lt;img width='1' height='1' src='https://blogger.googleusercontent.com/tracker/17722847-717631515181580073?l=blog.trungson.com' alt='' /&gt;&lt;/div&gt;</description><link>http://blog.trungson.com/2009/07/gotchas-with-gettext-in-php.html</link><author>noreply@blogger.com (trungson)</author><thr:total xmlns:thr='http://purl.org/syndication/thread/1.0'>0</thr:total></item><item><guid isPermaLink='false'>tag:blogger.com,1999:blog-17722847.post-4260686507443412619</guid><pubDate>Sat, 27 Jun 2009 23:25:00 +0000</pubDate><atom:updated>2009-06-27T16:34:03.179-07:00</atom:updated><category domain='http://www.blogger.com/atom/ns#'>mac</category><title>I hate iPhotos</title><description>When I got my first Mac, which is the alum MacBook, I got really excited on using iPhotos and imported nearly 10,000 photos from different collections. The default setting is to use a single library file to manage everything. Importing is very simple and that's why it's deadly. Now the problems I have with iPhotos: very inconvenient when sharing with PC, exporting does not write EXIF tags so your taken time are not preserved, which is really terrible. Now I cannot search on how to switch existing photos from using an iPhoto database to an external source (photos are stored as their own files). There are some photo workflows to do this but it's very tedious and not practical for the number of events and photos I have.

From my experience, I find that Mac software have huge hype that attract users, like me, but they're not the best or perfect by any measures and filled with bugs, defects, and feature requests. I guess I was led into believing that software on Mac somehow just works, like many Mac fanboys would like you to believe. I should know from my own experience as a software developer, no software is perfect, no matter on which platform.&lt;div class="blogger-post-footer"&gt;&lt;img width='1' height='1' src='https://blogger.googleusercontent.com/tracker/17722847-4260686507443412619?l=blog.trungson.com' alt='' /&gt;&lt;/div&gt;</description><link>http://blog.trungson.com/2009/06/i-hate-iphotos.html</link><author>noreply@blogger.com (trungson)</author><thr:total xmlns:thr='http://purl.org/syndication/thread/1.0'>0</thr:total></item><item><guid isPermaLink='false'>tag:blogger.com,1999:blog-17722847.post-2470283872185970653</guid><pubDate>Sat, 30 May 2009 15:13:00 +0000</pubDate><atom:updated>2009-05-30T08:15:45.015-07:00</atom:updated><category domain='http://www.blogger.com/atom/ns#'>sysadmin</category><title>rrdtool and No font found</title><description>Recently we did an upgrade to CentOS 5.3 and rrdtool stopped working, specifically, rrdgraph. The reason is that there is no font installed in the system (not sure why, you can check it via "fc-list"). To fix this, do an "yum install xorg-x11-fonts-Type1" and make sure you see some fonts listed in "fc-list". Also assume you already have fontconfig.&lt;div class="blogger-post-footer"&gt;&lt;img width='1' height='1' src='https://blogger.googleusercontent.com/tracker/17722847-2470283872185970653?l=blog.trungson.com' alt='' /&gt;&lt;/div&gt;</description><link>http://blog.trungson.com/2009/05/rrdtool-and-no-font-found.html</link><author>noreply@blogger.com (trungson)</author><thr:total xmlns:thr='http://purl.org/syndication/thread/1.0'>0</thr:total></item><item><guid isPermaLink='false'>tag:blogger.com,1999:blog-17722847.post-7809145701756617705</guid><pubDate>Thu, 28 May 2009 01:19:00 +0000</pubDate><atom:updated>2009-05-27T18:23:42.568-07:00</atom:updated><category domain='http://www.blogger.com/atom/ns#'>sysadmin</category><title>apf vs. newly assigned IP address</title><description>If you try to ping/traceroute and got this message, there are several places to look. First, disable the firewall and if it works again then you know it's the firewall. In this case, APF. An call to "iptables -L -n" might be able to narrow down the root cause.

&lt;pre&gt;
PING 173.x.x.x 56(84) bytes of data.
ping: sendmsg: Operation not permitted
ping: sendmsg: Operation not permitted
ping: sendmsg: Operation not permitted
&lt;/pre&gt;

&lt;h4&gt;Edit conf.apf&lt;/h4&gt;
Switch this off (from 1 to 0) and "service apf restart".
&lt;pre&gt;
# Block all ipv4 address space marked reserved for future use (unassigned),
# such networks have no business talking on the Internet. However they may at
# some point become live address space. The USE_RD option further in this file
# allows for dynamic updating of this list on every full restart of APF. Refer
# to the 'internals/reserved.networks' file for listing of address space.
BLK_RESNET="0"
&lt;/pre&gt;&lt;div class="blogger-post-footer"&gt;&lt;img width='1' height='1' src='https://blogger.googleusercontent.com/tracker/17722847-7809145701756617705?l=blog.trungson.com' alt='' /&gt;&lt;/div&gt;</description><link>http://blog.trungson.com/2009/05/apf-vs-newly-assigned-ip-address.html</link><author>noreply@blogger.com (trungson)</author><thr:total xmlns:thr='http://purl.org/syndication/thread/1.0'>1</thr:total></item><item><guid isPermaLink='false'>tag:blogger.com,1999:blog-17722847.post-652038808965249189</guid><pubDate>Sat, 16 May 2009 16:20:00 +0000</pubDate><atom:updated>2009-05-16T09:34:50.492-07:00</atom:updated><title>Will WolframAlpha make the lazy lazier?</title><description>WolframAlpha is launching right now. I just tried a few and see the cheat sheet. The interface is nice and the results were presented beautifully and logically. I'll definitely use it for its designed purposes and Yahoo for the rest of search queries.

&lt;p&gt;If this type of computational search engine were widely available like it is now when I was in school, I probably would not spend any time trying to solve the problem manually and just punching numbers instead. For example, why should I know one gallon is 128 ounces, 1 acre = 43560 sqft? I suspect the same question can be asked for other search engines, including generic engines like Google and Yahoo. Stupid people will become stupider because of the vast amount of information that is available to consume without any thoughtful digestion.

&lt;p&gt;However, on the other side, the argument can be made to reduce the time we spend on low-end or fundamental computations and focus our effort into solving a bigger problem. This is true when you have a good foundation and already been trained or knew how to get the information. Knowing what is possible is more important than the steps to implement it.

&lt;p&gt;In summary, each generation has a new set of tools that help (or prevent, depending on who you talk to) them to solve problems. My suggestion to kids, students in highschool and university undergraduates is to learn the formulas, the theories and practice them manually with pencil and paper. Then once you really understand them, you can use tools, software to solve them for you. Conversely, if you depends on the tools too early, you will never bother to understand the basics and when a more challenging problem that is beyond the scope of these tools, you'd be screwed and at lost for any direction toward a solution.&lt;div class="blogger-post-footer"&gt;&lt;img width='1' height='1' src='https://blogger.googleusercontent.com/tracker/17722847-652038808965249189?l=blog.trungson.com' alt='' /&gt;&lt;/div&gt;</description><link>http://blog.trungson.com/2009/05/will-wolframalpha-make-lazy-lazier.html</link><author>noreply@blogger.com (trungson)</author><thr:total xmlns:thr='http://purl.org/syndication/thread/1.0'>0</thr:total></item><item><guid isPermaLink='false'>tag:blogger.com,1999:blog-17722847.post-3363012558645185397</guid><pubDate>Tue, 31 Mar 2009 22:32:00 +0000</pubDate><atom:updated>2009-04-03T21:40:50.094-07:00</atom:updated><category domain='http://www.blogger.com/atom/ns#'>sysadmin</category><title>Getting started with EC2 tutorial</title><description>I just start playing with EC2 today and these are some useful notes and observation. The small standard instance is quite slow, only scores 50 under Unixbench-WHT. Our quads E5405 are around 410+, Q9550 is at 650-750.

I also was confused about S3 versus EBS. The console management makes life much easier, but could be improved even further. This is what you do after attaching a EBS volume to an instance:

&lt;blockquote&gt;mkfs -t ext3 /dev/sdx
mkdir /mnt/data-store
mount /dev/sdx /mnt/data-store&lt;/blockquote&gt;

For CentOS AMI (ami-0459bc6d), you need to run this to be able to customize the AMI and build your own

&lt;blockquote&gt;depmod -a
modprobe loop&lt;/blockquote&gt;

As for performance, it's pretty disappointing indeed. I ran Unixbench WHT 4.1 and small instance only got 51 (CentOS 5 32-bit) and the large instance got 111 (CentOS 5 64-bit). If you run an instance 24/7, it's much more expensive for the same performance of a dedicated server. Our quad core servers usually get 600+ on the same test. The price you pay for EC2 is "on-demand", meaning that you need to automate it to the point scaling up during peak is seamlessly and not having to run a single or even multiple instances all the time.&lt;div class="blogger-post-footer"&gt;&lt;img width='1' height='1' src='https://blogger.googleusercontent.com/tracker/17722847-3363012558645185397?l=blog.trungson.com' alt='' /&gt;&lt;/div&gt;</description><link>http://blog.trungson.com/2009/03/getting-started-with-ec2-tutorial.html</link><author>noreply@blogger.com (trungson)</author><thr:total xmlns:thr='http://purl.org/syndication/thread/1.0'>0</thr:total></item><item><guid isPermaLink='false'>tag:blogger.com,1999:blog-17722847.post-6709424841431094479</guid><pubDate>Tue, 10 Mar 2009 17:47:00 +0000</pubDate><atom:updated>2009-03-10T10:49:13.889-07:00</atom:updated><category domain='http://www.blogger.com/atom/ns#'>mac</category><title>Brother 5440CN Control Center in Mac OSX</title><description>If you turned off Control Center from starting up at boot, you can find it again in this folder. It took me a while trying to find it under Spotlight, /Applications without luck.

&lt;pre&gt;
/Library/Printers/Brother/Utilities/
&lt;/pre&gt;&lt;div class="blogger-post-footer"&gt;&lt;img width='1' height='1' src='https://blogger.googleusercontent.com/tracker/17722847-6709424841431094479?l=blog.trungson.com' alt='' /&gt;&lt;/div&gt;</description><link>http://blog.trungson.com/2009/03/brother-5440cn-control-center-in-mac.html</link><author>noreply@blogger.com (trungson)</author><thr:total xmlns:thr='http://purl.org/syndication/thread/1.0'>0</thr:total></item><item><guid isPermaLink='false'>tag:blogger.com,1999:blog-17722847.post-985350407885145198</guid><pubDate>Sat, 07 Mar 2009 23:17:00 +0000</pubDate><atom:updated>2009-03-07T15:42:34.926-08:00</atom:updated><category domain='http://www.blogger.com/atom/ns#'>sysadmin</category><title>Adaptec RAID under CentOS</title><description>Download the Storage Manager RPM for your card model and architecture from their site http://www.adaptec.com/en-US/support/raid/


If you run /usr/StorMan/arcconf and get this error:
&lt;blockquote&gt;
./arcconf: error while loading shared libraries: libstdc++.so.5: cannot open shared object file: No such file or directory
&lt;/blockquote&gt;

Do this
&lt;blockquote&gt;
export LD_PRELOAD=/usr/StorMan/libstdc++.so.5
&lt;/blockquote&gt;

&lt;pre&gt;
root@r StorMan]# ./arcconf 

  | UCLI |  Adaptec uniform command line interface
  | UCLI |  Version 5.30 (B17509)
  | UCLI |  (C) Adaptec 2003-2008
  | UCLI |  All Rights Reserved

 COPYBACK      | toggles controller copy back mode
 CREATE        | creates a logical device
 DATASCRUB     | toggles the controller background consistency check mode
 DELETE        | deletes one or more logical devices
 FAILOVER      | toggles the controller autotomatic failover mode
 SNAPSHOT      | creates a copy of a logical device
 GETCONFIG     | prints controller information
 GETLOGS       | gets controller log information
 GETSTATUS     | displays the status of running tasks
 GETVERSION    | prints version information for all controllers
 IDENTIFY      | blinks LEDS on device(s) connected to a controller
 KEY           | installs a Feature Key onto a controller
 MODIFY        | performs RAID Level Migration or Online Capacity Expansion
 RESCAN        | checks for new or removed drives
 ROMUPDATE     | updates controller firmware
 SETALARM      | controls the controller alarm, if present
 SETCONFIG     | restores the default configuration
 SETCACHE      | adjusts physical or logical device cache mode
 SETNAME       | renames a logical device given its logical device number
 SETPRIORITY   | changes specific or global task priority
 SETSTATE      | manually sets the state of a physical or logical device
 TASK          | performs a task such as build/verify on a physical or logical device
&lt;/pre&gt;

Get info
&lt;pre&gt;
[root@r StorMan]# ./arcconf getconfig 1
Controllers found: 1
----------------------------------------------------------------------
Controller information
----------------------------------------------------------------------
   Controller Status                        : Optimal
   Channel description                      : SAS/SATA
   Controller Model                         : Adaptec 3405
   Controller Serial Number                 : 7C2102FD
   Physical Slot                            : 3
   Temperature                              : 32 C/ 89 F (Normal)
   Installed memory                         : 128 MB
   Copyback                                 : Disabled
   Background consistency check             : Disabled
   Automatic Failover                       : Enabled
   Defunct disk drive count                 : 0
   Logical devices/Failed/Degraded          : 1/0/0
   --------------------------------------------------------
   Controller Version Information
   --------------------------------------------------------
   BIOS                                     : 5.2-0 (12379)
   Firmware                                 : 5.2-0 (12379)
   Driver                                   : 1.1-5 (2409)
   Boot Flash                               : 5.2-0 (12379)
   --------------------------------------------------------
   Controller Battery Information
   --------------------------------------------------------
   Status                                   : Optimal
   Over temperature                         : No
   Capacity remaining                       : 99 percent
   Time remaining (at current draw)         : 3 days, 1 hours, 11 minutes

----------------------------------------------------------------------
Logical device information
----------------------------------------------------------------------
Logical device number 0
   Logical device name                      : raid 10
   RAID level                               : 10
   Status of logical device                 : Optimal
   Size                                     : 139798 MB
   Stripe-unit size                         : 256 KB
   Read-cache mode                          : Enabled
   Write-cache mode                         : Enabled (write-back)
   Write-cache setting                      : Enabled (write-back) when protected by battery
   Partitioned                              : Yes
   Protected by Hot-Spare                   : No
   Bootable                                 : Yes
   Failed stripes                           : No
   --------------------------------------------------------
   Logical device segment information
   --------------------------------------------------------
   Group 0, Segment 0                       : Present (0,0) 3LQ1330009747KV9
   Group 0, Segment 1                       : Present (0,1) 3LQ1SJ7009747KHQ
   Group 1, Segment 0                       : Present (0,2) 3LQ2TB3009746GYX
   Group 1, Segment 1                       : Present (0,3) 3L17LJ6009750G35


----------------------------------------------------------------------
Physical Device information
----------------------------------------------------------------------
      Device #0
         Device is a Hard drive
         State                              : Online
         Supported                          : Yes
         Transfer Speed                     : SAS 3.0 Gb/s
         Reported Channel,Device            : 0,0
         Reported Location                  : Connector 0, Device 0
         Vendor                             : SEAGATE
         Model                              : ST373455SS
         Firmware                           : 0002
         Serial number                      : 3LQ1323Y00009747KV9
         World-wide name                    : 5000C50004962A3
         Size                               : 70007 MB
         Write Cache                        : Enabled (write-back)
         FRU                                : None
         S.M.A.R.T.                         : No
      Device #1
         Device is a Hard drive
         State                              : Online
         Supported                          : Yes
         Transfer Speed                     : SAS 3.0 Gb/s
         Reported Channel,Device            : 0,1
         Reported Location                  : Connector 0, Device 1
         Vendor                             : SEAGATE
         Model                              : ST373455SS
         Firmware                           : 0002
         Serial number                      : 3LQ12SJ70747KHQ
         World-wide name                    : 5000C50004961D8
         Size                               : 70007 MB
         Write Cache                        : Enabled (write-back)
         FRU                                : None
         S.M.A.R.T.                         : No
      Device #2
         Device is a Hard drive
         State                              : Online
         Supported                          : Yes
         Transfer Speed                     : SAS 3.0 Gb/s
         Reported Channel,Device            : 0,2
         Reported Location                  : Connector 0, Device 2
         Vendor                             : SEAGATE
         Model                              : ST373455SS
         Firmware                           : 0002
         Serial number                      : 3LQ12T009746GYX
         World-wide name                    : 5000C500049604F
         Size                               : 70007 MB
         Write Cache                        : Enabled (write-back)
         FRU                                : None
         S.M.A.R.T.                         : No
      Device #3
         Device is a Hard drive
         State                              : Online
         Supported                          : Yes
         Transfer Speed                     : SAS 3.0 Gb/s
         Reported Channel,Device            : 0,3
         Reported Location                  : Connector 0, Device 3
         Vendor                             : SEAGATE
         Model                              : ST373455SS
         Firmware                           : 0002
         Serial number                      : 3LQ17LJ60000G35
         World-wide name                    : 5000C500049FE35
         Size                               : 70007 MB
         Write Cache                        : Enabled (write-back)
         FRU                                : None
         S.M.A.R.T.                         : No


Command completed successfully.
&lt;/pre&gt;&lt;div class="blogger-post-footer"&gt;&lt;img width='1' height='1' src='https://blogger.googleusercontent.com/tracker/17722847-985350407885145198?l=blog.trungson.com' alt='' /&gt;&lt;/div&gt;</description><link>http://blog.trungson.com/2009/03/adaptec-raid-under-centos.html</link><author>noreply@blogger.com (trungson)</author><thr:total xmlns:thr='http://purl.org/syndication/thread/1.0'>2</thr:total></item><item><guid isPermaLink='false'>tag:blogger.com,1999:blog-17722847.post-6558488275316248254</guid><pubDate>Tue, 10 Feb 2009 20:09:00 +0000</pubDate><atom:updated>2009-02-10T12:12:16.430-08:00</atom:updated><category domain='http://www.blogger.com/atom/ns#'>javascript</category><category domain='http://www.blogger.com/atom/ns#'>php</category><title>Compact JS code using PHP</title><description>This is a simple function to minimize JS code, it's very simple and probably fail with more complex cases. But hey, might be useful for someone for something! We would suggest using JSMin::minify() instead.

&lt;textarea name="code" class="php"&gt;
/** compact JS code */
 function compactJS($pContent) {
  $pContent = str_replace("\r\n","\n",$pContent);
  $pContent = preg_replace("/^\/\/.*/",'',$pContent); // begining w/ //
  $pContent = preg_replace("/[^:]\/\/.*/",'',$pContent); // not those http://
  $pContent = str_replace("\t",'',$pContent);
  $pContent = str_replace("\n",'',$pContent);
  $pContent = preg_replace("/\s+/",' ',$pContent);
  $pContent = preg_replace('/\s?([\{\};\=\(\)\/\+\*-])\s?/',"\\1",$pContent);
  return $pContent;
 }
&lt;/textarea&gt;&lt;div class="blogger-post-footer"&gt;&lt;img width='1' height='1' src='https://blogger.googleusercontent.com/tracker/17722847-6558488275316248254?l=blog.trungson.com' alt='' /&gt;&lt;/div&gt;</description><link>http://blog.trungson.com/2009/02/compact-js-code-using-php.html</link><author>noreply@blogger.com (trungson)</author><thr:total xmlns:thr='http://purl.org/syndication/thread/1.0'>0</thr:total></item><item><guid isPermaLink='false'>tag:blogger.com,1999:blog-17722847.post-8187678385431309260</guid><pubDate>Sun, 01 Feb 2009 17:32:00 +0000</pubDate><atom:updated>2009-02-01T09:36:02.333-08:00</atom:updated><category domain='http://www.blogger.com/atom/ns#'>linux</category><category domain='http://www.blogger.com/atom/ns#'>sysadmin</category><title>FreeNX is cool</title><description>If you ever need to access a CentOS (RHEL for that matter) server remotely, use FreeNX. It's very easy to install, just follow the instructions on this page:

http://wiki.centos.org/HowTos/FreeNX

Just a note, you can leave the authentication via password (assuming you have a strong one) instead of a key-based pass-through authentication. The instructions are still pretty much the same, only you don't have to perform some steps.

Performance: wow, it's pretty fast and it looks just the same as my own desktop. I'm using the NoMachine Client for Ubuntu 8.10.&lt;div class="blogger-post-footer"&gt;&lt;img width='1' height='1' src='https://blogger.googleusercontent.com/tracker/17722847-8187678385431309260?l=blog.trungson.com' alt='' /&gt;&lt;/div&gt;</description><link>http://blog.trungson.com/2009/02/freenx-is-cool.html</link><author>noreply@blogger.com (trungson)</author><thr:total xmlns:thr='http://purl.org/syndication/thread/1.0'>0</thr:total></item></channel></rss>