Archive for the ‘Lang Code’ Category
Eclipse can not start after installed WTP
Saturday, July 4th, 2009How to change file limit in Fedora Linux
Saturday, July 4th, 2009ulimit command
Saturday, July 4th, 2009PHP object assign alway by reference
Saturday, April 4th, 2009Different from what we discuss before about regular variable type, object assignment always by reference:
class A {
public $a = 'a';
}
$a = new A();
$b = clone $a;
$c = $a;
$b->a = 'b';
echo $a->a, "\n";
$c->a = 'c';
echo $a->a, "\n";
Output:
a c
We use clone to make a copy of object. Please note that default clone operation is shallow copy. You have to overload the __clone method if you want deep copy of the object.
PHP return by reference
Saturday, April 4th, 2009We can ask a function return by reference by adding a & before function declare. See example:
function & pass(& $a) {
return $a;
}
function duplicate(& $a) {
return $a;
}
$a = array('a'=>'a');
$b = duplicate($a);
$c = & pass($a);
$b['a'] = 'b';
echo $a['a'], "\n";
$c['a'] = 'c';
echo $a['a'], "\n";
output is:
a c
You will see, the trick here is: don’t forget to put an ‘&’ before the function of assign operation. Otherwise, the assign operation will make a copy of the returned reference.
temperary fix of Fedora 10 x86_64 snmpd segment fault
Wednesday, December 3rd, 2008Set static ip on Fedora 9
Saturday, May 17th, 2008Install an external jar into local Maven repository
Sunday, May 4th, 2008Sometimes, you project will have dependency on a jar which is not in official maven repository, and maybe it is propriety jar file which will never be part of maven repository. In this case, you have to put it to your local repository your self to solve the dependency.
There is a install plug in to do this job, which is something like:
mvn install:install-file -DgroupId=<your_group_name> \ -DartifactId=<your_artifact_name> \ -Dversion=<snapshot> \ -Dfile=<path_to_your_jar_file> \ -Dpackaging=jar \ -DgeneratePom=true
For example, you want to install the danga’s memcached client plugin, you can do:
mvn install:install-file -DgroupId=com.danga \ -DartifactId=memcached \ -Dversion=2.0.1 \ -Dfile=java_memcached-release_2.0.1.jar \ -Dpackaging=jar \ -DgeneratePom=true
This will add the memcache jar into your local Maven2 repository under groupId com.danga and artifactId memcached, you can then edit your pom.xml adding this dependency.
However, the maven eclipse can not recognize it since it always search from public repository.
Maven Project Layout
Saturday, May 3rd, 2008src/main/java Application/Library sources
src/main/resources Application/Library resources
src/main/filters Resource filter files
src/main/assembly Assembly descriptors
src/main/config Configuration files
src/main/webapp Web application sources
src/test/java Test sources
src/test/resources Test resources
src/test/filters Test resource filter files
src/site Site
LICENSE.txt Project’s license
README.txt Project’s readme
