Monday, September 8, 2008

vmware server on ubuntu 8.04 64bit

After installed vmware server 1.0.6 on ubuntu 8.04 64bit, I’ve encountered two problems:

1.
Unable to get the last modification timestamp of the destination file /etc/vmware/ssl/rui.key

solution: apt-get install ia32-libs

2.
Failed to launch vmware:
fwu@vm-master:~$ vmware
/usr/lib/vmware/bin/vmware: /usr/lib/vmware/lib/libgcc_s.so.1/libgcc_s.so.1: version `GCC_3.4′ not found (required by /usr/lib32/libcairo.so.2)
/usr/lib/vmware/bin/vmware: /usr/lib/vmware/lib/libgcc_s.so.1/libgcc_s.so.1: version `GCC_4.2.0′ not found (required by /usr/lib32/libstdc++.so.6)
/usr/lib/vmware/bin/vmware: /usr/lib/vmware/lib/libgcc_s.so.1/libgcc_s.so.1: version `GCC_3.4′ not found (required by /usr/lib32/libcairo.so.2)
/usr/lib/vmware/bin/vmware: /usr/lib/vmware/lib/libgcc_s.so.1/libgcc_s.so.1: version `GCC_4.2.0′ not found (required by /usr/lib32/libstdc++.so.6)
/usr/lib/vmware/bin/vmware: /usr/lib/vmware/lib/libgcc_s.so.1/libgcc_s.so.1: version `GCC_3.4′ not found (required by /usr/lib32/libcairo.so.2)
/usr/lib/vmware/bin/vmware: /usr/lib/vmware/lib/libgcc_s.so.1/libgcc_s.so.1: version `GCC_4.2.0′ not found (required by /usr/lib32/libstdc++.so.6)

solution:
fwu@vm-master:~$ sudo
mv /usr/lib/vmware/lib/libgcc_s.so.1/libgcc_s.so.1 /usr/lib/vmware/lib/libgcc_s.so.1/libgcc_s.so.1.bak
References:
http://ubuntuforums.org/showthread.php?t=312981
http://radio.javaranch.com/davo/2008/06/18/1213791596327.html

Friday, August 8, 2008

scim doesn’t launch in firefox under ubuntu

Update the following content into these 3 files then you will be able to switch to scim input in firefox.

/etc/X11/xinit/xinput.d/scim
/etc/X11/xinit/xinput.d/none
/etc/X11/xinit/xinput.d/default



#
# Use “X input Method” for all applications
#
# Per Ming’s Documentation in SCIM, XIM Input Method is activated
# not only for old X-applications but also for GTK and QT application.
#
# If a user wish to use, GTK Input Method, (s)he can right-click input
# area and select “Input Methods” and change from “X input Method” to
# “SCIM Input Method”.
#

XIM=SCIM
XIM_PROGRAM=/usr/bin/scim
XIM_ARGS=”-d”
XIM_PROGRAM_SETS_ITSELF_AS_DAEMON=yes
GTK_IM_MODULE=”scim-bridge”
QT_IM_MODULE=”scim-bridge”
DEPENDS=”scim,scim-anthyscim-cannascim-chewingscim-pinyinscim-hanglescim-primescim-skkscim-tables-additionalscim-m17nscim-uimscim-tables-jascim-tables-koscim-tables-zh”


Reference: http://ubuntuforums.org/archive/index.php/t-528382.html

Thursday, July 31, 2008

gnome NetworkManager disappeared under AspireOne Linpus

After an unclean shutdown of my new AspireOne, the gnome NetworkManager under linpus doesn’t show up, it was very fustrating that both wireless and wired network doesn’t work anymore. It turns out to be the connection profiles have been corrupted, to fix this just simply delete the connection profiles under the home directory:

rm -rf $HOME/.gconf/system/networking/connections

Thursday, July 17, 2008

JNI issues on linux

Problem #1: when compiling JNI component on a linux machine, it was missing tons of type definitions from jni.h. It appears libgcj-devel-version needs to be installed as the jni.h in it has the native datatype definitions.

Problem #2: if you see an error message such as the following when executing JNI components:
wrong ELF class: ELFCLASS64 (Possible cause: architecture word width mismatch)
Chances are that your jni shared library .so was compiled to be 64bit but your JDK/JVM is 32-bit! just use 64-bit java to run it instead

Thursday, June 12, 2008

PHP failed when calling imagecreate

1. download libjpeg source code from here

2. manually change your Makefile before compiling PHP, make sure this is added:
-I/path/to/jpegsrc

GDLIB_CFLAGS = -I/usr/opt/distfiles/src/php-5.2.5/ext/gd/libgd -DHAVE_LIBPNG -DHAVE_LIBJPEG -I/opt/distfiles/src/jpeg-6b

3. make;make install or cp libphp5.so to replace your current one in apache
Reference: http://ca.php.net/gd

Friday, June 6, 2008

vmware server unable to see USB devices

vmware server under ubuntu is unable to see some USB devices
two ways to fix this:

1. execute this command:
mount -t usbfs none /proc/bus/usb

2. add the following to /etc/fstab
usbfs /proc/bus/usb usbfs auto 0 0

Reference:
http://www.blog.arun-prabha.com/2007/04/11/running-windows-under-ubuntu-edgy-using-vmware/

Wednesday, May 28, 2008

extract project lead email list in JIRA

select p.pname, ub.username, ps.propertyvalue from userbase ub,propertyentry pe, propertystring ps, project pwhere ub.id=pe.entity_id and pe.property_key=’email’ and ps.id=pe.id and p.lead=ub.username order by p.pname

Reference:http://confluence.atlassian.com/display/JIRA/Database+Schema

Tuesday, April 22, 2008

extract the last field in unix shell script

scratch notes on aws exacting the last field!
echo “ABC.123.QIP.ERR” | awk -F. {’print $(NF-0)’}

- dot after F is the field deliminator
- minus zero is the field to extract from backwards of the string

Monday, April 14, 2008

dvd burning failed in ubuntu gutsy

Not sure if this started to happen after gutsy upgrade, but DVD burning failed on random basis… until I run the following commands everytime before burning then it would be successful.

hdparm -d1 -X66 -c1 -Y /dev/hdc
hdparm /dev/hdc

Tuesday, April 1, 2008

subversion with apache integration apr-util issue

I was compiling subversion 1.4.0 to be integrated with apache httpd 2.2.8. Everything went smoothly during the compilation process until I tried to access subversion through http, it shows the error message below everytime and resulted in error 500 in the browser:

[Mon Mar 17 16:04:17 2008] [error] [client 10.225.32.40] Could not fetch resource information. [500, #0][Mon Mar 17 16:04:17 2008] [error] [client 10.225.32.40] Could not open the root of the repository [500, #22][Mon Mar 17 16:04:17 2008] [error] [client 10.225.32.40] Can’t set position pointer in file ‘/path/to/repo/db/revs/11857′: Invalid argument [500, #22

It turns out that subversion linked with a different version of apr-util than apache httpd, see blow:

[user@hostname bin]$ ldd ./httpd grep aprlibaprutil-1.so.0 => /path/to/httpd-2.2.8/lib/libaprutil-1.so.0 (0×00ca0000)libapr-1.so.0 => /path/to/httpd-2.2.8/lib/libapr-1.so.0 (0×0035b000)
[user@hostname bin]$ ldd /path/to/httpd/modules/mod_dav_svn.so grep aprlibaprutil-0.so.0 => /path/to/subversion/lib/libaprutil-0.so.0 (0×00111000)libapr-0.so.0 => /path/to/subversion/lib/libapr-0.so.0 (0×00ca4000)

The reason is that subversion-deps-1.4.0.tar.gz comes with an older version of apr-util than the one in apache httpd 2.2.8.To resolve this issue, simply copy the new version of apr and apr-util source to subversion build directory and recompile:

cp -pR ../httpd-2.2.8/srclib/apr/ apr
cp -pR ../httpd-2.2.8/srclib/apr-util/ apr-util
make clean; ./configure –prefix=/path/to/subversion –with-apxs=/path/to/httpd/bin/apxs ; make ; make install

Wednesday, March 19, 2008

apache htpasswd password generator

I had to generate random password for a whole bunch of apache httpd users, so I’ve written a script that generates a 8 digit random password:

#!/bin/sh
if [ $# -ne 2 ]
then
echo “passwdgen.sh passwordfile username”
exit
fi

PASS=`date +%N md5sum - cut -c1-8`
echo $2:$PASS
if [ ! -f $1 ]
then
touch $1
fi
/$APACHE_HTTPD_HOME/bin/htpasswd -bm $1 $2 $PASS

Monday, March 17, 2008

Windows XP bizarre problem - Mup.sys hanging issue

I’ve encountered one Windows XP SP2 desktop with weird hanging issue during boot-up. There was no recent software/hardware installation on the box, it just decided to start hanging during boot-up then reboots itself, these steps goes into an infinite loop.

After trying to get into safe mode, I can see it is hanging while loading Mup.sys. However, still no luck can’t even get into safe mode… After various attempts, the only way that I could boot-up the machine is to unplug all USB devices, interesting thing is that once I boot into Windows I can plug all the USB devices back and everything works just fine.

The solution to fix this issue was that I had to backup the files of the current user account, create a new one and delete the current user completely. The magic worked well, I can now boot up back into Windows normally. The cause of this hurts my brain, just another MS Windows myth…

Sunday, March 16, 2008

extract WAV from DVD with mplayer

I found several post on the web using transcode, unfortunately it didn’t work well for me and kept on coredump.

It turns out mplayer can do the same job with less trouble, below is a script that allows you to extract tracks from a specific range of chapters of a track with selected audio channel.

#!/bin/bash
for i in `seq 1 33`;
do
`echo mplayer -vo null -ao pcm -ao pcm:file=track$i.wav:fast dvd://2 -chapter $i-$i -aid 129;`
done

1 33 - this means to rip from chapter 1 to 33
dvd://2 - this is the track that you want to extract the chapters from
aid 129 - 129 is the audio stream ID that you want to select

You can use lsdvd to get the details of the DVD.
use soundconverter to convert it to MP3.

References:
http://www.larsen-b.com/Article/186.html
http://www.mplayerhq.hu/DOCS/man/en/mplayer.1.txt

Tuesday, March 4, 2008

k3b startup failed in Ubuntu

This is another bad side effect after an update in Ubuntu Gutsy.
For some reason k3b failed to startup and it was working right before the packages update! I kept on getting the following error:

X Error: BadDevice, invalid or uninitialized input device 159
Major opcode: 148
Minor opcode: 3
Resource id: 0×0
Failed to open device
X Error: BadDevice, invalid or uninitialized input device 159
Major opcode: 148
Minor opcode: 3
Resource id: 0×0
Failed to open device
kdecore (KLocale): WARNING: Definition of PluralForm is none of NoPlural/TwoForms/French/OneTwoRest/Russian/Polish/ Slovenian/Lithuanian/Czech/Slovak/Arabic/Balcan/Ma cedonian/Gaeilge/Maltese: Definition of PluralForm - to be set by the translator of kdelibs.po

I have tried to reinstall k3b, kdelibs and etc. Nothing helped, luckliy I found the following threads:

http://ubuntuforums.org/showthread.php?p=4409467 http://ubuntuforums.org/showthread.php?t=695073&page=2
The solution was:
sudo apt-get remove language-pack-kde-en

It seems language-pack-kde-en cause some conflict during k3b startup when your ubuntu has other languages installed.

Sunday, March 2, 2008

ubuntu gutsy keyboard delay problem

My keyboard started acting really weird after upgraded to Ubuntu Gutsy 7.10. There is a noticeable delay between key strokes, or sometimes the keys repeated itself like crazy. This strange behaviour was really annoying and drove me nuts. After googling and tried to fix it myself, none of the solution fixed my problem. Eventually I discovered the following message kept on repeating in /var/log/messages

usb 1-2: reset low speed USB device using ohci_hcd and address 5

I tried to unplug my USB mouse and webcam, changed them into another USB ports then the messages stopped. Apparently that was the cause of the keyboard issue and more! I had failed to burn several DVDs with k3b and other burning tools previously, it was also contributed by this crazy USB port behaviour. Still not sure what is this problem, perhaps incompatibility with some USB ports on the motherboard or my USB port has problems…

Thursday, February 28, 2008

load balance & fail-over with tomcat using apache proxy_ajp_module proxy_balancer_module

In the past, we have been using mod_jk as the connector to front apache http server for tomcat, it does load balance and fail-over nicely. Now apache has modules such as proxy_ajp_module and proxy_balancer_module that would serve the same purpose, but with simpler configuration. Below is the VirtualHost config in apache httpd:
NameVirtualHost *:8080
<VirtualHost *:8080>

<Location /balancer-manager>
SetHandler balancer-manager
</Location>

<Proxy balancer://ajpCluster>
BalancerMember ajp://localhost:8109 route=jvm1
BalancerMember ajp://localhost:8209 route=jvm2
</Proxy>

ProxyPass /balancer-manager !
ProxyPass / balancer://ajpCluster/ stickysession=JSESSIONID nofailover=On
</VirtualHost>

On the tomcat end there are a few things needs to be changed in server.xml:

Uncomment the section where it defines the AJP connector and change the port number:
<!– Define an AJP 1.3 Connector on port 8009 –->
<Connector port=”8109″ enableLookups=”false” redirectPort=”18443″ protocol=”AJP/1.3″ />

This part I totally forgot which took me a while to realize that I did not define the jvmRoute name in tomcat. This would be appended to the JSESSIONID cookie so it knows which tomcat to route to:
<Engine name=”Catalina” defaultHost=”localhost” jvmRoute=”jvm1">

Now when you hit http://hostname:8080/ it hits the apache httpd server and it would route you to the least loaded tomcat that is up running.
http://hostname:8080/balancer-manager
would show you the status of the load balancer and tomcat servers.

I have tested this worked well with JIRA.

Tuesday, February 26, 2008

revert back to an old revision in subversion

Someone restructured the code and directories then committed into the repository, but it was discovered what has been done is on the wrong track. Now we want to revert back to a revision before all these bad changes. The changes were between revisions 2737 - 2738, we wanted to go back to revision 2736 to start over, issue the command:

svn merge -rHEAD:2736 .

Now we can start over from revision 2736, commit it into the repository as revision 2739, the missing files and directories would be copies from revision 2736.

Friday, February 15, 2008

sort process on linux by memory/cpu usage

sort by memory usage:
ps -eo pid,ppid,rss,vsize,pcpu,pmem,cmd -ww –sort=pmem

sorty by cpu usage:
ps -eo pid,ppid,rss,vsize,pcpu,pmem,cmd -ww –sort=pcpu

Thursday, February 14, 2008

response headers that prevents browser to cache JSP

// Set to expire far in the past.response.setHeader(”Expires”, “Tue, 23 May 1995 12:00:00 GMT”);
// Set standard HTTP/1.1 no-cache headers.response.setHeader(”Cache-Control”, “no-store, no-cache, must-revalidate”);
// Set IE extended HTTP/1.1 no-cache headersresponse.addHeader(”Cache-Control”, “post-check=0, pre-check=0″);
// Set standard HTTP/1.0 no-cache header.response.setHeader(”Pragma”, “no-cache”);

Friday, January 25, 2008

JNDI names of TransactionManager in J2EE application servers

java:comp/env/UserTransaction - Generic
java:comp/UserTransaction - Resin 2.x, Oracle OC4J (Orion), JOnAS (JOTM), BEA WebLogic
java:comp/TransactionManager - Resin 3.x, Geronimo
java:/TransactionManager - JBoss
jta/usertransaction - WebSphere (J2EE 1.2)

java:comp/UserTransaction - WebSphere (J2EE 1.3)

Friday, January 18, 2008

nvidia cuda environment on fedora core

All files required can be downloaded from:http://www.nvidia.com/object/cuda_get.html#linux


  1. change to boot into text mode before installing NVidia drivervi /etc/inittabchange: id:5:initdefault:to: id:3:initdefault:reboot (to text mode)
  2. install NVidia driver provided from the cuda download pagesh NVIDIA-Linux-version.-pkg1.run
  3. add the following into Section “Screen” of /etc/X11/xorg.confOption “SLI” “off”Option “ProbeAllGpus” “True”
  4. add the red part into /boot/grub/grub.confuppermem 524288kernel /vmlinuz-2.xxxxxxxx ……….. rhgb quiet vmalloc=256MBpci=nommconf
  5. install cuda package
  6. change to boot back to GUI modevi /etc/inittabchange: id:3:initdefault:to: id:5:initdefault:reboot (back to X GUI mode)
  7. install freegult package, it is required for cuda SDK samples:rpm -ivh freeglut-version.rpmrpm -ivh freeglut-devel-version.rpm
  8. add /usr/local/cuda/lib into /etc/ld.so.conf/sbin/ldconfig
  9. install CUDA SDK
  10. please make sure your SELinux setting is disabled:System -> Administration -> Security Level and Firewall -> SELinux -> SELinux Setting: Disabled
  11. add /usr/local/cuda/bin to your path


You are ready to CUDA!

Wednesday, January 16, 2008

remove unwanted revisions in subversion

In one of those days, people committed stuff should not be in a source code repository into the subversion repository by accident, or sometimes not being disciplined and lack of understanding in source code repository…
There’s no easy button to remove the unwanted revisions in subversion. The svndumpfilter that came with subversion distribution is the tool that is able to exclude or include revisions with filename/dirname, unfortunately if there are “copies” in revisions that refers to the stuff that you wanted to filter out, svndumpfilter would break without finishing filtering the rest of revisions.
This problem can be avoided by writing a script to utilize svndumpfilter, svnlook and etc., copy path/files that has dependcies on other revisions. There are already scripts such as svndumpfilter2 and svndumpfilter3 out there. svndumpfilter2 is a python script that eliminates the copy dependencies revisions that you wanted to filter out. You can download svndumpfilter2 from: http://tartarus.org/~simon-anonsvn/viewcvs.cgi/svn-tools/svndumpfilter2

Assuming the directories that you want to keep are trunk, branches tags:

$SVN_HOME/bin/svnadmin dump /path/to/repo ./svndumpfilter2 /path/to/repo trunk branches tags > clean.dump

$SVN_HOME/bin/svnadmin load /path/to/repo < clean.dump

Your repo is now clean without those revisions taking up your HDD space.

Tuesday, January 15, 2008

compile mysql 5.0.45 under freebsd 6.2

I had mysql4 running on my server, now I wanted to install mysql5 on the same box but also kept mysql4 co-exist. My choice was to compile mysql from source to a custom location. It is to be installed in: /opt/mysql-5.0.45/

After regular compilation and installation, FreeBSD complained about cannot find libmysqlclient_r.
From the INSTALL-SOURCE text file it indicated:
* If your client programs are using threads, you must compile a thread-safe version of the MySQL client library with the `–enable-thread-safe-client’ configure option. This creates a `libmysqlclient_r’ library with which you should link your threaded applications. See *Note threaded-clients::.

So what I was missing was the option
–enable-thread-safe-client

Below is the working config options that I’ve used:
./configure –prefix=/opt/mysql_5.0.45 –with-extra-charsets=complex –with-unix-socket-path=/opt/mysql-5.0.45/tmp/mysql.sock ;
make ; make install

The mysql5 libraries have been installed in:
/opt/mysql-5.0.45/lib/mysql

Now mysql5 libraries has to be added to the shared library path, add the following line to: /etc/ld-elf.so.conf
/opt/mysql-5.0.45/lib/mysql

Reload the ldconfig
/etc/rc.d/ldconfig restart

Remember to create /opt/mysql-5.0.45/my.cnf and change the port number so it doesn’t conflict with the mysql4 instance.
Now mysql5 is ready to be started!