Monthly Archives: June 2011

How to automate virtual machine creation and runing on virtualbox by command line

Many times we need to create a linux virtual machine by command line. It is very useful for batch vm operation, automation, regression test, integration test… Here’s the steps to create a functional linux virtual machine (works on windows host … Continue reading

Posted in linux, virtualization | Tagged , , , , | 2 Comments

Speed up your eclipse as a super fast IDE

Follow these steps to speed up your eclipse as a super fast IDE , it works for 32 & 64 bit version eclipse/jdk on my windows 7 x64. 1.Disable antivirus software, or add your jdk & eclipse & workspace & … Continue reading

Posted in java | Tagged , , , , | 56 Comments

How to start with wireless network on Debian squeeze

How to automatically keep an active network always on desktop, && use wireless network sudo apt-get install network-manager sudo apt-get install wicd sudo apt-get install firmware-iwlwifi Option 1: sudo apt-get install network-manager-gnome To use network-manager-gnome in Xfce (or Gnome) you … Continue reading

Posted in linux | 2 Comments

How to fix battery indication in debian squeeze on Acer Aspire

Problem:   acpi could not detect battery status, and shows unkown battery as: $acpi Battery 0: Unknown, 0% Firstly, if you are on Acer Aspire xxxx (mine is Aspire 4745G), you need to upgrade the bios to a new version (such … Continue reading

Posted in linux | Leave a comment

maven打包web项目时同时打包为war和jar文件

首先在pom.xml文件中指定war的打包方式,war 然后在pom文件的plugins节点下面增加如下内容即可mvn package时同时生成war, jar包。为了 mvn package install, mvn package deploy能够同时部署jar包,我们增加了后面2节点的配置: <!– package jar on package –> <plugin> <groupId>org.apache.maven.plugins</groupId> <artifactId>maven-jar-plugin</artifactId> <executions> <execution> <id>make-a-jar</id> <phase>compile</phase> <goals> <goal>jar</goal> </goals> </execution> </executions> </plugin> <!– install jar to local repository –> <plugin> <groupId>org.apache.maven.plugins</groupId> <artifactId>maven-install-plugin</artifactId> <executions> … Continue reading

Posted in java | 2 Comments

配置无密码的ssh登录时仍然需要输入密码

配置了无密码的ssh后,登录服务器时仍然需要密码。 出于安全的考虑,~/.ssh 和~/.ssh/authorized_keys必须只有所有者有权限,其他人没有任何权限,才可以使用无密码ssh登录。 可以尝试如登录服务器上,运行如下命令来解决: chmod 700 ~/.ssh chmod 600 ~/.ssh/*

Posted in linux | Leave a comment

如何使得apt-get install从多个repository并行下载

从http://www.mattparnell.com/linux/apt-fast/ 下载apt-fast.sh,拷贝到/usr/local/bin目录: wget http://www.mattparnell.com/linux/apt-fast/apt-fast.sh chmod +x apt-fast.sh sudo cp apt-fast.sh /usr/local/bin 推荐使用 apt fat with aria2c 来从多个源下载来提高速度, wget http://www.beyondlinux.com/blog/wp-content/uploads/2011/06/apt-fast_aria2c.txt -O apt-fast_aria2c.sh chmod +x apt-fast_aria2c.sh sudo cp apt-fast_aria2c.sh /usr/local/bin 然后使用 apt-fast_aria2c.sh install xxxx来安装软件包,设置多个mirrors时,速度会比apt-get install快上很多倍。 如: sudo apt-fast_aria2c.sh install mplayer smplayer cdcd

Posted in linux | Tagged , | Leave a comment

不同的开发语言在性能上的两个重要差别

不同的开发语言在性能上的重要差别,除了编译执行与解释执行的效率之外,还有两个重要的差别,一个是方法调用的性能差别,另一个是对象的创建与回收效率。 前阵子用C++(我用的VC 2010)写一个搜索本地文件的小程序,把一段代码提取为方法之后(参数使用了引用避免对象拷贝的开销),竟然发现性能有非常明显的下降,这说明C++(准确地说是VC++)的方法调用成本是相当高的。 我们在用Java处理大量的计算和IO操作时,大量的对象产生与销毁,经常会导致频繁的Full GC,Full GC的时候系统的服务几乎停滞,大大影响了系统的性能。 因此Java的内存回收效率是非常低的。 另一个方面,我们在用java时,不论方法调用的层次有多深,都几乎不会影响系统的执行性能,说明java的方法调用性能是非常高的。 Perl社区曾尝试使用纯Perl移植Lucene,然后试图通过不断的profiling和tuning来改善Perl版本Lucene的性能,最终发现由于Perl语言方法调用的成本过高,且对象的频繁创建和销毁导致性能低下而未能如愿。 参考: http://wiki.apache.org/lucy/MinimizingObjectOverhead

Posted in c++, design, java | Leave a comment

面向对象的纯C语言

前几天lucene的c语言版本Lucy发布0.1版本。Lucy的代码中使用了面向对象的C扩展Clownfish。 Clownfish是一种很小的面向对象的语言,用于定义面向对象的接口。Clownfish包含一个编译器,允许类用C语言或者一种host语言实现,或者两者的组合。最早Clownfish用于Kino Search中,后来KinoSearch演变为Lucy,Lucy中继续使用Clownfish。参考: http://search.cpan.org/~creamyg/KinoSearch-0.311/clownfish/lib/Clownfish.pm 其他的使用面向对象的C的方法: http://www.bolthole.com/OO-C-programming.html http://www.bolthole.com/OO-C-2.html http://home.comcast.net/~fbui/OOC.html http://www.accu.informika.ru/acornsig/public/articles/oop_c.html 当然也可以使用C++或者objective c,但object c能运行的平台比较有限。

Posted in c++, search engine | Tagged , , | Leave a comment

通信协议与序列化方案的纠结: Protocol Buffer, thrift or hessian?

最早我用hessian作为java搜索服务中的通信协议和序列化方案。松耦合,部署,调用方便。这两年很多人跟我提起protocol buffer,thrift。特别是最近从不少地方的信息看到很多地方在用,也找到一些改用protocol buffer或者apache thrift的理由: 1.在趋势科技的时候,病毒清理引擎里面用的也是protocol buffer作为序列化,实际上在Trend,PB用的很广泛。 2. Jeff Dean推荐分布式系统中使用Protocol Description Language。 (理由是协议描述语言支持接口的版本演进,即可以自动忽略不认识的属性,但不是如很多中文文章翻译中所说的为了减少通信的代码量。) 参考: http://www.parallellabs.com/2010/12/02/jeff-dean-on-google-system-architecture/ http://peopleyun.com/?p=794 3.Quora也在用Protocol Buffer。参考Quora’s Technology Examined 更为重要的是,在我们项目中.net以hessian协议调用java的过程中多次出现接口中的类版本变化,导致无法调用,且hessian并不显示有提示作用的错误信息。 调试和定位问题相当的困难和耗时。因此决定尝试 PB和thrift, 对比了两者, 发现thrift更好用, 1. thrift支持map 2. thrift提供各种语言的RPC实现,不用另外再写RPC服务器。 3. thrift官方原生版本可以自动生成各种语言的客户端,大大减少开发工作量。 参考 ”thrift与protocol buffer的比较“ (注意两点,1.有评论者说thrift runtime不支持windows,实际上现在支持的 2.另一个说开始的测试结果表明Hessian比PB要快,但后来重新测试PB要快。) 但不方便的是thrift也同protocol buffer一样,需要编写定义文件, 需要生成代码, 代码中有一堆生成的方法和属性, … Continue reading

Posted in java | 2 Comments