4/29/2009

install ant and svn ant on ubuntu 8.X or later

1 install and config the ant(JRE has installed)


sudo apt-get install ant ant-optional
echo ‘ANT_HOME=”/usr/share/ant”‘ | sudo tee -a /etc/environment

2 download the svnant

firefox http://subclipse.tigris.org/svnant.html

3 unzip svnant-1.2.1.zip, and put lib/*.jar files to your ANT_HOME/lib directory
4 test it with the following build.xml


<?xml version="1.0"?>
<project name="svn-test" default="Main" basedir=".">
<!-- Sets variables which can be used. -->
<property name="checkout" location="./svncheckout" />
<!-- Define the classpath which includes the jars that are required for svnant.jar -->
<path id="svnant.class.path">
<pathelement location="lib/svnant.jar" />
<pathelement location="lib/svnClientAdapter.jar" />
<pathelement location="lib/svnjavahl.jar" />
<pathelement location="lib/svnkit.jar" />
</path>

<typedef resource="org/tigris/subversion/svnant/svnantlib.xml" classpathref="svnant.class.path" />


<!-- Deletes the existing build, docs and dist directory-->
<target name="clean">
<delete dir="${checkout}" />
</target>

<!-- Creates the build, docs and dist directory-->
<target name="makedir">
<mkdir dir="${checkout}" />
</target>


<!-- Checkout the latest source code of svnant itself-->
<target name="svn">
<svn username="guest" password="">
<checkout url="http://subclipse.tigris.org/svn/subclipse/trunk/svnant/" revision="HEAD" destPath="${checkout}" />
</svn>
</target>

<target name="Main" depends="clean, makedir, svn">
<description>Main target</description>
</target>
</project>



edwin@Castor:~/Desktop/svnTest$ ant
Buildfile: build.xml

clean:
[delete] Deleting directory /home/edwin/Desktop/svnTest/svncheckout

makedir:
[mkdir] Created dir: /home/edwin/Desktop/svnTest/svncheckout

svn:
[svn] started ...
[svn] finished.

Main:

BUILD SUCCESSFUL
Total time: 1 minute 58 seconds

Installing MySQL 5.1 on ubuntu 8.X or later using apt

First, you need to edit /etc/apt/sources.list and add the dotdeb repository. This is the line you need to add for Lenny, but just change it to Etch if you haven’t upgraded yet (see my earlier post if you want to know how to do that)


deb http://packages.dotdeb.org lenny all

Then, update…

apt-get update

And then install 5.1

apt-get install mysql-server-5.1

set password for root

sudo mysqladmin -u root password admin

4/26/2009

Tunnelling MySQL Over SSH On ubuntu

Context:
1 local PC
2 Remote PC IP:192.168.0.51
3 My SSH user name on remote PC is edwin

1 build a tunnel By ssh:
I will open a local TCP port 3333 for tunnelling mysql; The syntax of SSH is


ssh -L LOCAL_PORT:hostname:REMOTE_PORT USER_NAME@SERVER_NAME or IP_ADDRESS.

or with sshpass

sshpass -p 'YOUR_PASSWD' ssh -o StrictHostKeyChecking=no -L 3333:localhost:3306 USERNAME@REMORT_HOST -p 22

We're using localhost as the hostname because we are directly accessing the remote mysql server through ssh. You could also use this technique to port-forward through one ssh server to another server.

#ssh -L 3333:localhost:3306 edwin@192.168.0.51

2 Connect reomote mysql using mysql command

#mysql -u root -p -h 127.0.0.1 -P 3333

4/24/2009

Auto login script with expect on Ubuntu 9.04

1 install expect
sudo apt-get install expect
2 write shell script as the following:


#!/usr/bin/expect -f
# Expect script to supply root/admin password for remote ssh server
# and execute command.

# set Variables
set password "YOUR_PASSWORD"
set ipaddr "REMOTE_HOSTNAME"
set port 22

set timeout -1
# now connect to remote UNIX box (ipaddr) with given script to execute
spawn ssh $ipaddr -l root -p 22
match_max 100000
# Look for passwod prompt
expect "*?assword:*"
# Send password aka $password
send -- "$password\r"
# send blank line (\r) to make sure we get back to gui
send -- "\r"
expect eof



3 save this file as edwin.ssh, and add X permission for it
4 use it

./edwin.ssh

Common Select usage:Where condation of datatime format for query rows

There are 8 different ways for select rows form table by filed formated as datatime

1. where date like '2005-01-%'
2. where DATE_FORMAT(date,'%Y-%m')='2005-01'
3. where EXTRACT(YEAR_MONTH FROM date)='200501'
4. where YEAR(date)='2005' and MONTH(date)='1'
5. where substring(date,1,7)='2005-01'
6. where date between '2005-01-01' and '2005-01-31'
7. where date >= '2005-01-01' and date <= '2005-01-31'
8. where date IN('2005-01-01', '2005-01-02', '2005-01-03', '2005-01-04', '2005-01-05', '2005-01-06', '2005-01-07', '2005-01-08', '2005-01-09', '2005-01-10', '2005-01-11', '2005-01-12', '2005-01-13', '2005-01-14', '2005-01-15', '2005-01-16', '2005-01-17', '2005-01-18', '2005-01-19', '2005-01-20', '2005-01-21', '2005-01-22', '2005-01-23', '2005-01-24', '2005-01-25', '2005-01-26', '2005-01-27', '2005-01-28', '2005-01-29', '2005-01-30', '2005-01-31')

4/20/2009

Install javaDocs and setup in eclipse on Ubuntu

The default installation of Eclipse did not include Javadoc,so here's how to get Javadoc installed and working.


First, enter


sudo apt-get install sun-java6-doc


The installer will prompt you to download a zip file containing the documentation from Sun. Bring up Firefox and head to Sun's website. Click the zip file to download the documentation(only english version enough, never japs).

When the download finishes, in another terminal, enter


sudo cp /path/to/zip/file/documentation.zip /tmp


Enter
sudo chown root:root /tmp/documentation.zip


to change the file permissions.

Back in the first terminal, hit enter, and the installer should continue. When it finishes, in Eclipse,


click Window -> Preferences -> Java -> Installed JREs, and click the JRE . Click Edit, and use Shift+Click to select all the JRE system libraries. Click Javadoc Location, and enter


file:/usr/lib/jvm/java-6-sun/docs/api/

in the box. Click Validate to test it (you can open it in your browser to double check), and click OK out of all the dialogs. Javadoc should now be working!

4/07/2009

Add tpl to HTML content type on Zend Studio Form Eclipse

The smarty deafult tempalte file type named "tpl" hasn't been supported by Zend Studio for Eclipse 6.1. So, you need to setup this content type to html. the solution is the following:

1 Open Preferences
2 Click HTML in General->Appearance->Content Type
3 Add "*.tpl" to File associations
4 Clink OK

Install Zend Server on Ubuntu 8.10

1 Add Zend server source list


deb http://repos.zend.com/deb/pe pe non-free

get public key and import it by sofware management editor

wget http://repos.zend.com/deb/zend.key


2 Set apache2's config to your workspace

The apache used by Zend Server is apache2,the config file locates in /etc/apache/
2.1 edit "/etc/apache2/sites-available/default"

<VirtualHost *:80>
ServerName localhost
ServerAdmin webmaster@localhost

DocumentRoot /home/edwin/Zend/workspaces/Odour-main/Public/
<Directory />
Options FollowSymLinks
AllowOverride None
</Directory>
<Directory /home/edwin/Zend/workspaces/Odour-main/Public/>
Options Indexes FollowSymLinks MultiViews
AllowOverride All
Order allow,deny
allow from all
</Directory>

ScriptAlias /cgi-bin/ /usr/lib/cgi-bin/
<Directory "/usr/lib/cgi-bin">
AllowOverride None
Options +ExecCGI -MultiViews +SymLinksIfOwnerMatch
Order allow,deny
Allow from all
</Directory>

ErrorLog /var/log/apache2/error.log

# Possible values include: debug, info, notice, warn, error, crit,
# alert, emerg.
LogLevel warn

CustomLog /var/log/apache2/access.log combined

Alias /doc/ "/usr/share/doc/"
<Directory "/usr/share/doc/">
Options Indexes MultiViews FollowSymLinks
AllowOverride None
Order deny,allow
Deny from all
Allow from 127.0.0.0/255.0.0.0 ::1/128
</Directory>

</VirtualHost>

2.2 edit first virtualHost (IP:192.168.6.1)


<VirtualHost 192.168.6.1:80>
ServerName ComServer
ServerAdmin webmaster@localhost

DocumentRoot /home/edwin/Zend/comWorkspace/Public/
<Directory /home/edwin/Zend/comWorkspace/Public/>

Options Indexes FollowSymLinks MultiViews
AllowOverride All
Order allow,deny
allow from all
</Directory>

ErrorLog /var/log/apache2/192.168.6.1.error.log

# Possible values include: debug, info, notice, warn, error, crit,
# alert, emerg.
LogLevel warn

CustomLog /var/log/apache2/192.168.6.1.access.log combined
</VirtualHost>



3 enable virturalHost


sudo a2ensite 192.168.6.1


4 restart the apache

4/03/2009

Resolution of No Sound in Wine On Ubuntu 8.10

I have used Wine successfully with Pulseaudio via padsp!!

First you have to run
Code:


padsp winecfg

and select the OSS output under Audio. The other outputs should be toggled off.Then you can use any program via "padsp wine yourprogram.exe".For example:running diablo 2 in wine

padsp wine diablo.exe

4/02/2009

installing Mysql with YUM in CentOs

1 install application
yum install mysql
yum install mysql-server
yum install mysql-devel
service mysqld start



2 Set the passwords for your root account like so

/usr/bin/mysqladmin -u root password 'new-password'
/usr/bin/mysqladmin -u root -h hostname password 'new-password'

3 config iptables for accessing by local network
#vi /etc/sysconfig/iptables
add "-A RH-Firewall-1-INPUT -m state --state NEW -m tcp -p tcp --dport 3306 -j ACCEPT"
# service iptables restart