How to symbolic link a directory to Tomcat's webapp

Dec 18, 2015  | by Haixing Hu

I found that using the command sudo mount –bind olddir newdir gets me out of trouble. If you don’t have root access then this won’t work for you. See mount --help or man mount for some more info on binding but it basically mounts one directory on top of another so it has the same affect as a symlink but it gets around tomcat’s limitation with symlinks.

More precisely, executes the following command:

sudo mount --bind /path/to/your/app /var/lib/tomcat7/webapps/myapp

and then the /var/lib/tomcat7/webapps/myapp will be linked to /path/to/your/app.

How to implements the 'drop user if exists' in MySQL

MySQL has no DROP USER IF EXISTS ... syntax.

The following code imexplicitly creates the user and then drop the user.

GRANT USAGE ON *.* TO 'username'@'localhost' IDENTIFIED BY 'password';
DROP USER 'username'@'localhost';

辩证法与放屁

Feb 22, 2015  | by 佚名

第一堂课

在上课时,我放了一个屁——很普通的屁。既不很臭,当然也绝对不香。

可怕的是,教授正在讲辩证法。

“请你自己对这个屁作一下判断,”教授说,“它好还是不好?”

我只得说:“不好。”

“错了,”教授说,“任何事物都有矛盾组成,有它不好的一面,肯定有它好的一面。”

“那么说它好也不对了?”我问。

“当然。”教授说。

“它既好又不好。”

“错了。你只看到矛盾双方对立斗争的一面,没有看到他们统一的一面。”

我只好认真看待这个严肃的问题,仔细想了想说:“这个屁既好又不好,但不好的一面是主要的,处于主导地位。”

“错了。你是用静止的观点看问题。矛盾的双方会相互转换,今天处于主导地位一面,明天一定处于次要地位。”

“你是说明天全人类会为了我的这个屁欢呼雀跃吗?”

“不尽如此,但不能否认这种发展趋势。”

Maven over SOCKS proxy

Jun 20, 2014  | by Haixing Hu

Setup a SSH tunnel to as SOCKS proxy:

ssh -D 8085 yourname@your.gateway.com

Now tell maven to use the proxy we just created:

mvn -U clean install -DsocksProxyHost=127.0.0.1 -DsocksProxyPort=8085

Or export it to env for convenience.

export MAVEN_OPTS="-DsocksProxyHost=127.0.0.1 -DsocksProxyPort=8085"

How to create a manifest file with Maven

This tutorial will show you how to use the maven-jar-plugin to create a manifest file, and package / add it into the final jar file. The manifest file is normally used to define following tasks :

  1. Define the entry point of the Application, make the Jar executable.
  2. Add project dependency classpath.

© 2015 Haixing Hu with help from Jekyll Bootstrap and Twitter Bootstrap
This work is licensed under a Creative Commons License