Thursday, April 17, 2014

ubuntu alias cd into directory

michaelz:~$ ls /home/git/repositories/serverConf/ibaobao/ conf etc mysql scripts usr michaelz:~$ alias cdibbs='cd /home/git/repositories/serverConf/ibaobao/' 
michaelz:~$ cdibbs
          michaelz:/home/git/repositories/serverConf/ibaobao$

Wednesday, April 9, 2014

mysqldump then mysql import: Access denied; you need (at least one of) the SUPER privilege(s) for this operation

When a database has view or triggers that is backed with mysqldump using one user say userB, and later on to be imported using another user. The following error would show up.
Access denied; you need (at least one of) the SUPER privilege(s) for this operation
mysql -u userA < schema.sql ERROR 1227 (42000) at line 65: Access denied; you need (at least one of) the SUPER privilege(s) for this operation
To fix the problem is that all the DEFINER=`userB` need to be changed to DEFINER=`userA`

Sunday, January 1, 2012

vpn server on EC2 Ubuntu

I followed instruction on Setting up a VPN-server on Amazon EC2 up to this line:

sudo iptables -t nat -A POSTROUTING -o eth0 -j MASQUERADE

Then need to configure /etc/ppp/pptpd-options as:

#refuse-pap
#refuse-chap
#refuse-mschap
require-chap
#require-mschap-v2
#require-mppe-128




Following Configuring a PPTP-VPN on iOS and Android
Make to disable encryption or choose no encryption

If connects well,
tail -f /var/log/syslog should look like:

Jan 2 03:23:30 ip-10-138-31-87 pptpd[6570]: CTRL: Client ???.93.139.47 control connection started
Jan 2 03:23:31 ip-10-138-31-87 pptpd[6570]: CTRL: Starting call (launching pppd, opening GRE)
Jan 2 03:23:31 ip-10-138-31-87 pppd[6571]: Plugin /usr/lib/pptpd/pptpd-logwtmp.so loaded.
Jan 2 03:23:31 ip-10-138-31-87 pppd[6571]: pppd 2.4.5 started by root, uid 0
Jan 2 03:23:31 ip-10-138-31-87 pppd[6571]: Using interface ppp0
Jan 2 03:23:31 ip-10-138-31-87 pppd[6571]: Connect: ppp0 <--> /dev/pts/2
Jan 2 03:23:31 ip-10-138-31-87 pptpd[6570]: GRE: Bad checksum from pppd.
Jan 2 03:23:31 ip-10-138-31-87 pppd[6571]: Warning - secret file /etc/ppp/chap-secrets has world and/or group access
Jan 2 03:23:32 ip-10-138-31-87 pppd[6571]: Deflate (15) compression enabled
Jan 2 03:23:32 ip-10-138-31-87 pppd[6571]: Cannot determine ethernet address for proxy ARP
Jan 2 03:23:32 ip-10-138-31-87 pppd[6571]: local IP address 192.168.0.1
Jan 2 03:23:32 ip-10-138-31-87 pppd[6571]: remote IP address 192.168.0.234

Thursday, December 16, 2010

create forum_openidnonce and forum_openidassociation

easy_install python-openid
Searching for python-openid
Reading http://pypi.python.org/simple/python-openid/
Reading http://www.openidenabled.com/openid/libraries/python/
Reading http://github.com/openid/python-openid
Download error: unknown url type: https -- Some packages may not be found!
Reading http://github.com/openid/python-openid/tarball/2.2.5
Download error: unknown url type: https -- Some packages may not be found!
Reading http://openidenabled.com/python-openid/
Reading http://github.com/openid/python-openid/tarball/2.2.4
Download error: unknown url type: https -- Some packages may not be found!
Best match: python-openid 2.2.5
Downloading http://pypi.python.org/packages/source/p/python-openid/python-openid-2.2.5.zip#md5=f89d9d4f4dccfd33b5ce34eb4725f751
Processing python-openid-2.2.5.zip
Running python-openid-2.2.5/setup.py -q bdist_egg --dist-dir /tmp/easy_install-8UpKN5/python-openid-2.2.5/egg-dist-tmp-GI5CT1
warning: no files found matching 'CHANGELOG'
warning: no files found matching '*.css' under directory 'doc'
warning: no files found matching '*.html' under directory 'doc'
zip_safe flag not set; analyzing archive contents...
Adding python-openid 2.2.5 to easy-install.pth file

Installed /usr/local/lib/python2.7/site-packages/python_openid-2.2.5-py2.7.egg
Processing dependencies for python-openid
Finished processing dependencies for python-openid
/home/osqa/osqa-server# python manage.py syncdb --all
Syncing...
Creating table forum_openidnonce
Creating table forum_openidassociation
No fixtures found.

Synced:
> django.contrib.auth
> django.contrib.contenttypes
> django.contrib.sessions
> django.contrib.sites
> django.contrib.admin
> django.contrib.markup
> forum
> south

Tuesday, December 14, 2010

Errors were encountered while processing: procps

There seems to be problem with installing procps.

dpkg -i --force-all /var/cache/apt/archives/procps_1%3a3.2.8-9ubuntu3_amd64.deb
(Reading database ... 30892 files and directories currently installed.)
Preparing to replace procps 1:3.2.8-9ubuntu3 (using .../procps_1%3a3.2.8-9ubuntu3_amd64.deb) ...
Unpacking replacement procps ...
Setting up procps (1:3.2.8-9ubuntu3) ...
start: Job failed to start
dpkg: error processing procps (--install):
subprocess installed post-installation script returned error exit status 1
Processing triggers for man-db ...
Errors were encountered while processing:
procps

The solution for me is to remove the package from /var/cache/apt/archives/procps_1%3a3.2.8-9ubuntu3_amd64.deb
and downloaded a newer verion from http://debomatic64.debian.net/natty/aptcache/procps_1%253a3.2.8-9ubuntu5_amd64.deb

then dpkg -i procps_1%3a3.2.8-9ubuntu3_amd64.deb installation was successful.

Friday, December 3, 2010

JNDI datasource

The following resource need to put into an context element. The default Tomcat has $CATALINA-HOME/conf/context.xml, so the resource can be put into that file.



< resource auth="Container" driverclassname="com.mysql.jdbc.Driver" maxactive="100" maxidle="30" maxwait="10000" name="jdbc/TestDB" password="testTwo" type="javax.sql.DataSource" url="jdbc:mysql://localhost:3306/testDb/testTable" username="testTwo">

And in web.xml:

Tuesday, November 30, 2010

ivy target depends on target from a different project

As the value of  depends attribute. it can be composed from project name and target name.


eg:
\
 



In your-project.xml

 

tomcat on vps

1 GB memory is needed to smoothly run an app on Tomcat.

/var/tomcat/bin# ./shutdown.sh
Using CATALINA_BASE:   /var/tomcat
Using CATALINA_HOME:   /var/tomcat
Using CATALINA_TMPDIR: /var/tomcat/temp
Using JRE_HOME:        /usr/java/jdk1.6.0_21/jre
Using CLASSPATH:       /var/tomcat/bin/bootstrap.jar
Error occurred during initialization of VM
Could not reserve enough space for code cache

http://stackoverflow.com/questions/286007/how-to-tune-tomcat-5-5-jvm-memory-settings-without-using-the-configuration-progra

$CATALINA_HOME/bin/export JAVA_OPTS="-XX:MaxPermSize=64m -Xms16M -Xmx64m"


Saturday, October 9, 2010

find ANT_HOME on ubuntu

Similar to JAVA_HOME, ant home can be found:



/usr/share/ant is my ANT_HOME
In case of using Ivy, ivy.jar can copied into /usr/bin/share/ant/lib

set JAVA_HOME for ant on ubuntu

To file java home(where jre/jdk) is installed on ubuntu:


 Then you add to
/etc/environment
the following line
JAVA_HOME="usr/lib/jvm/java-6-sun/jre"


ant JAVA_HOME is not defined correctly:






now Ant finds the java home

Thursday, October 7, 2010

Find that process running at a port and kill it

In Windows (7), You can list all the processes and the port it is running at by:
netstat -ano

To kill a process, replace pid with process id from previous step

taskkill /pid 5844  /F


In Ubuntu, You can find the process running at a port using grep

netsat -ano --program |grep 8080

and
kill porcessNumber

eg.



11814 is process running at port 8080.

Friday, September 24, 2010

how to find router ip address for any router of any OS

type tracert google.com from commandline

For example as in Ubuntu:

The first IP address is your computer's IP. 10.1.1.1 is the router's IP

Saturday, September 18, 2010

/etc/hosts file format

The format of /etc/hosts is:

How to find out the format?
type man 5 hosts in terminal

why 5?
5 is the section number of a man page, it means file formats
ref:http://en.wikipedia.org/wiki/Man_page



Extra:

The etc/hosts file specifies the hostname or computer name your current shell is running.
In my case, my computer name is zhang-laptop and my login name is zhang, so my bash looks like:

zhang@zhang-laptop:~$

And my etc/host file is:
zhang@zhang-laptop:~$ cat /etc/hosts
127.0.0.1 localhost
127.0.1.1 zhang-laptop
    #added
    #127.0.0.2    domainhound
    #127.0.0.2    zhangmichael.com

# The following lines are desirable for IPv6 capable hosts
::1 ip6-localhost ip6-loopback
fe00::0 ip6-localnet
ff00::0 ip6-mcastprefix
ff02::1 ip6-allnodes
ff02::2 ip6-allrouters
ff02::3 ip6-allhosts

how do you file the hosts file format?


Ref:
http://www.freebsd.org/doc/handbook/configtuning-configfiles.html
http://www.freebsd.org/cgi/man.cgi?query=hosts&sektion=5

Friday, August 13, 2010

/etc/alternatives/-->Debian alternatives system

Where is location of java on ubuntu?
Finding out the answer is not just use "whereis java" or "which java":

The alternatives directory lead to the alternative concept. when you type java, it could refer to a different real java location if a new version has just installed.
Eg. I was using java 5, typing java would start JVM 5; after installing java 6, type java would start JVM6.

Intuitively, I think having this extra level of indirection is useless...

Saturday, August 7, 2010

burst.net vps outrage counter

I have purchased the cheapest VPS from burst.net and I think it is the cheapest around.
However, there had been at least three outrages during the last three month. When I say at least three outrages. Because each time I type top, the uptime is different, there had been three occasions.

Now I am going to keep a record of outrages, every time when i type top, if system had been done, i would put a record here.

08/Aug/10 top - 04:42:16 up 3 days,

swap on VPS(OpenVS)

I have problem starting java virtual machine on my VPS. The cause is there is not enough heap to be allocated for JVM.

$ java
Error occurred during initialization of VM
Could not reserve enough space for object heap
Could not create the Java virtual machine.
The fix for me is that my java is OpenJDK, so I uninstalled it and reinstalled the Sun implementation and fixed the problem.



Related stuff:
This came down to my VPS has only 500mb memory. I want to try if adding more swap can solve the problem. And ended up finding out Swap is not allowed on OpenVS. from this link. http://forums.vpslink.com/linux/1567-how-create-swapfile-your-vps.html

When I tried to create swap file according to https://help.ubuntu.com/community/SwapFaq  I get:

   swapon failed: Operation not permitted
Burstnet suggested me to increase my memory.
I would want to if there are other solutions..

Friday, July 23, 2010

hulu

Monday, June 21, 2010

Clang to analyze IPhone Project

After learned how to use xcodebuild from previous post then using scan-build is easy

Just append scan-build in front of "xcodebuild command " eg

for me the command is:

~/Desktop/Application/checker-234/scan-build xcodebuild -configuration Debug -sdk iphonesimulator4.0

And you can view the output as it instruct:

Now, I have 21 bugs need to be fixed.
Publish Post

xcodebuild

To build using xcodebuild, you need to run xcodebuild from the directory containing your project (i.e. the directory containing the projectname.xcodeproj)

then type:
xcodebuild -configiuration Debug/Release -sdk iphonesdk
the example used
xcodebuild -configuration Debug -sdk iphonesimulator4.0

Nagvigate Man Page

After type "man find" on bash:
you can type:
h -help
up - go up one line
down - go down one line
f -forward one window
b -backward one window
/pattern -search for pattern
n -next match for the  searched pattern
N -previous match for the searched pattern