随笔-77  评论-5  文章-2  trackbacks-0
  2009年9月10日
class Square{
public:
 Square(int x ) :value(x*x){
 }

Square(const Square& other) = delete;//rule 1

const Square & operator = (const Square& other) == delete;//rule 2
const Square & operator = (Square&& other) = delete;//rule3 

..
}

Square s = 9; //因为s没有初始化,会先用9 调用构造函数 Square(int x ) , 然后调用Square(const Square& other),和rule1 违背
Square s2(8);
 s= s2;//对应rule 2
 s= Square(9);//对应 rule3 
posted @ 2019-12-31 21:11 huohuo 阅读(1041) | 评论 (0)编辑 收藏
其实一直想学ruby,总是拖拖拉拉推了几年。 很多ruby的教材要么老厚一本 要么是东一榔头西一斧头,逻辑性不清楚 ruby语法还没说清楚就上rails了 这个教材挺好。 今天才发现argument 是实参,parameter是形参
posted @ 2014-07-07 22:20 huohuo 阅读(230) | 评论 (0)编辑 收藏
小新看到妈妈用订书机订了一个盒子,他就从打印机上面拿了几张a4纸,钉了一个像盒子的东西,当作他的百宝箱,把他的一些零零碎碎的东西放到他的百宝箱中。 有一天他看到了妈妈的首饰盒,他觉得很漂亮,就和妈妈说:妈妈,我把你这个盒子里面的东西放到我的那个百宝箱里面,你这个盒子给我当百宝箱吧。 妈妈当然不同意。小新很希望要个百宝箱,爸爸就问他:“你需要一个多大的百宝箱?” 小新比划了一个大小,他希望大一点,能装很多东西。爸爸问他是不是希望箱子能有很多分隔? 小新说不要分隔,但是百宝箱要有锁。 爸爸明白了---你就是要个能锁住的箱子嘛,我给你找个皮箱,带密码锁的。 第二天,爸爸上班回来,发现他平时用的笔记本电脑被小新锁在他的"新百宝箱"----密码锁皮箱里面了,密码是小新设的。 爸爸不知道密码,打不开皮箱,爸爸就和小新说:"帮爸爸把电脑拿出来,爸爸要给你查一个睡觉前讲的故事,不然今天就没故事听了"。 小新说:“你用手机也可以查的嘛,别以为我不知道”
posted @ 2014-01-20 21:49 huohuo 阅读(209) | 评论 (0)编辑 收藏
1 解析utf-8的中文字符问题,我修改了 ReportTask类里面的一个方法,增加了一个getJava().setVmArgs("-Dfile.encoding=utf-8")
2.覆盖率出不了数据   一方面注意制定datafile,把cubertura-instrument和cobertura-report的datafile设置为一个,另外junit里面也要设置一个系统属性,制定cubertura的datafile属性.  不制定datafile时,可能生成文件在当前运行ant的目录.但是我们ant任务中的junit测试任务,可能会使用不同的目录来作工作路径.这样会导致datafile不一致.

另外一个是要记得将javac 任务的debug="yes" ,因为只有debug =yes时,编译的代码才带有行信息,能显示覆盖.  当然常见的问题是junit的classpath中的instrument class目录放到原来被测class之前.




posted @ 2013-08-18 22:37 huohuo 阅读(479) | 评论 (0)编辑 收藏
下载putty的安装版本,安装之后有一个plink pscp程序。
plink程序负责调用ssh命令
pscp负责上传文件。

plink -l user -pw pass   hostname

但是因为plink会提示是否要保存密码,不能保证自动批处理运行,此时利用管道的能力来输入提示的结果

echo Y >yes.txt
plink -l user -pw pass   hostname <yes.txt
posted @ 2012-03-04 06:31 huohuo 阅读(583) | 评论 (0)编辑 收藏
/Files/lijinglin/storm.pdf
posted @ 2011-12-21 01:27 huohuo 阅读(277) | 评论 (0)编辑 收藏
/Files/lijinglin/zookeeper.ppt
posted @ 2011-12-21 00:33 huohuo 阅读(314) | 评论 (0)编辑 收藏
kafka pdf

/Files/lijinglin/F_1330_Narkhede_Kafka.pptx
posted @ 2011-12-20 22:53 huohuo 阅读(304) | 评论 (0)编辑 收藏
/Files/lijinglin/stormsrc.rar
posted @ 2011-12-19 02:15 huohuo 阅读(234) | 评论 (0)编辑 收藏

zookeeper集群安装

测试环境redhat5.5:
vmware建两台虚拟机(btw,似乎双核系统只能建俩,3个就死掉了)
192.168.229.129
192.168.229.130


下载2011年12月15日的最新zookeeper
加压到
/opt/zookeeper-3.4.0/
配置/opt/zookeeper-3.4.0/conf/zoo.cfg
可以把那个例子考过来
Java代码 复制代码 收藏代码
  1. # The number of milliseconds of each tick   
  2. tickTime=2000  
  3. # The number of ticks that the initial    
  4. # synchronization phase can take   
  5. initLimit=10  
  6. # The number of ticks that can pass between    
  7. # sending a request and getting an acknowledgement   
  8. syncLimit=5  
  9. # the directory where the snapshot is stored.   
  10. do not use /tmp for storage, /tmp here is just    
  11. # example sakes.   
  12. dataDir=/opt/zookeeper-3.4.0/data/zookeeper   
  13. dataLogDir=/opt/zookeeper-3.4.0/data/log   
  14. # the port at which the clients will connect   
  15. clientPort=2181  
  16. #   
  17. # Be sure to read the maintenance section of the    
  18. # administrator guide before turning on autopurge.   
  19. #   
  20. # http://zookeeper.apache.org/doc/current/zookeeperAdmin.html#sc_maintenance   
  21. #   
  22. # The number of snapshots to retain in dataDir   
  23. #autopurge.snapRetainCount=3  
  24. # Purge task interval in hours   
  25. # Set to "0" to disable auto purge feature   
  26. #autopurge.purgeInterval=1  
  27. server.1=192.168.229.129:2888:3888  
  28. server.2=192.168.229.130:2888:3888  

修改/opt/zookeeper-3.4.0/bin/zkServer.sh
Java代码 复制代码 收藏代码
  1. status)   
  2.     # -q is necessary on some versions of linux where nc returns too quickly, and no stat result is output   
  3.     #STAT=`echo stat | nc -q 1 localhost $(grep "^[[:space:]]*clientPort" "$ZOOCFG" | sed -e 's/.*=//'2> /dev/null| grep Mode`   
  4.     STAT=`echo stat | nc localhost $(grep "^[[:space:]]*clientPort" "$ZOOCFG" | sed -e 's/.*=//'2> /dev/null| grep Mode`  

以上这些多台机器一样

log和data都在dataDir下面
如果找不到log了用大招:
ps -ef|grep zookeeper
ls -l /proc/123123/fd
其中有一个是log
然后dataDir建立一个文件myid
在192.168.229.129上
echo 1 >/opt/zookeeper-3.4.0/data/zookeeper/myid
在192.168.229.130上
echo 2 >/opt/zookeeper-3.4.0/data/zookeeper/myid
对应zoo.cfg里面的
注意一定是数字


然后zkServer.sh start 
启动
zkServer.sh status
看状态
echo ruok|nc localhost 2181         
//are you ok?
echo dump|nc localhost 2181
echo stat|nc localhost 2181
echo srst|nc localhost 2181
zkServer.sh stop
posted @ 2011-12-16 03:48 huohuo 阅读(1318) | 评论 (0)编辑 收藏

 

public class Util {
 final static int LINE_COUNT = 16;
 final static int WORD_COUNT = 2;
 public static StringBuffer toHex(byte b)
 {
  byte factor = 16;
  int v = b & 0xff;//去掉byte转换之后的负数部分。
  byte high = (byte)( v / factor);
  byte low = (byte)(v % factor);
  StringBuffer buf = new StringBuffer();
  buf.append(toHexLow(high)).append(toHexLow(low));
  return buf;
 }
 private static char toHexLow(byte b)
 {
  if(b > 16 || b < 0 )
  {
   throw new IllegalArgumentException("inpt parameter should less than 16 and greater than 0");
  }
  if(b < 10){
   return (char)('0' + (char)b);
  }
  else{
    return (char)('A' + (b-10));

  }
 }
 
 public static StringBuffer toHex(int val)
 {
  StringBuffer buf = toHex((byte)(val >>24 & 0xff)).append(toHex((byte)(val>>16&0xff)));
  return buf.append(toHex((byte)(val>>8&0xff))).append(toHex((byte)(val & 0xff)));
 }
 
 /**
  * 打印二进制数组
  * @param arr
  * @param off
  * @param len
  */
 public static void printBytes(byte [] arr,int off,int len)
 {
  if(arr == null || len <= 0 || off <0 || off + len > arr.length){
   return;
  }
  
  int count = 0;
  
  for(int i = off; count < len; ++i)
  {
   System.out.print(toHex(arr[i]));
   
   ++ count;
   if(count% WORD_COUNT == 0)
   {
    System.out.print(' ');
   }
   if(count % LINE_COUNT == 0)
   {
    System.out.println();
   }
  }
 }
 
 public static void main(String[] args) {
  byte[] arr = new byte[256];
  for(int i = 0; i < 256;++i )
  {
   
   arr[i] = (byte)i;
   
  }
  
  printBytes(arr,0,256);
  printBytes(arr,240,16);
  
  System.out.println(toHex(1));
  System.out.println(toHex(0xffffffff));
  System.out.println(toHex(0xeeffaacc));
 }
}




另外c++写好的小端序的int数据,用java读入如此处理
 private static int convertInt(byte[]  arr)
 {
  if(arr == null || arr.length != 4)
  {
   throw new IllegalArgumentException("bytes array error");
  }
  int val = (arr[0] & 0xff) | (arr[1] & 0xff)<<8 | (arr[2] & 0xff)<<16 | (arr[3]&0xff)<<24;
  return val;
 }


posted @ 2011-11-02 21:36 huohuo 阅读(5370) | 评论 (0)编辑 收藏
1.修改当前的hostname可以用
hostname  myname
此时只是修改了内存内部的,下次启动又恢复了
2.机器在启动的时候会调用/etc/rc.d/boot.localnet
脚本看后面的附录,这个脚本会判断当前的$HOSTNAME变量是否设置,没有设置就会读取/etc/HOSTNAME
来设置主机名。
3.因此要修改hostname,
 3.1 修改/etc/HOSTNAME文件
 3.2 修改当前的$HOSTNAME变量
 3.3 停掉/etc/rc.d/boot.localnet
 3.4 启动 /etc/rc.d/boot.localnet
因此执行脚本如下:
 export HOSTNAME=myname
 echo $HOSTNAME>/etc/HOSTNAME
  /etc/rc.d/boot.localnet stop
 /etc/rc.d/boot.localnet start


附录:/etc/rc.d/boot.localnet

case "$1" in
  start)
        # clean up old yp bindings
        rm -f /var/yp/binding/*.[12]

        #
        # set hostname and domainname
        #
        XHOSTNAME=""
        test -f /etc/HOSTNAME && {
            read XHOSTNAME < /etc/HOSTNAME
        }
        test -n "$HOSTNAME" -a "$HOSTNAME" != '(none)' && {
            echo Using boot-specified hostname \'${HOSTNAME}\'
            XHOSTNAME="$HOSTNAME"
        }
        test -n "$XHOSTNAME" && {
            echo -n Setting up hostname \'${XHOSTNAME%%.*}\'
            hostname ${XHOSTNAME%%.*}
            rc_status -v -r
        }

        XDOMAINNAME=""
        test -f /etc/defaultdomain && {
            read XDOMAINNAME < /etc/defaultdomain
        }
        test -n "$XDOMAINNAME" && {
            echo -n Setting up NIS domainname \'$XDOMAINNAME\'
        }
        domainname "$XDOMAINNAME"
        test -n "$XDOMAINNAME" && {
        rc_status -v -r
                         


posted @ 2011-10-27 22:21 huohuo 阅读(16353) | 评论 (3)编辑 收藏
http://www.infoq.com/cn/articles/hadoop-config-tip

http://hadoop.apache.org/common/docs/r0.19.2/cn/cluster_setup.html

http://wenku.baidu.com/view/be021f3667ec102de2bd8964.html

这个装完带验证url
http://wenku.baidu.com/view/373ed21fb7360b4c2e3f64ce.html
posted @ 2011-10-25 06:50 huohuo 阅读(177) | 评论 (0)编辑 收藏
/Files/lijinglin/LINUX_SHELL.part2.rar
/Files/lijinglin/LINUX_SHELL.part1.rar
/Files/lijinglin/diveintopython3.rar
posted @ 2011-10-25 06:45 huohuo 阅读(171) | 评论 (0)编辑 收藏
1.安装suse
装好vmware workstation8,跑到open suse,下载suse11的光盘iso文件,将iso文件映射到vmware的光驱做安装。
2.安装vmwaretools,用root用户执行
vmware安装目录中的linux.iso中带有的VMwareTools*.gz
执行vmware-install.pl
一路回车,中途碰到问题,提到找不到kernel header文件,
The path "" is not a valid path to the 2.6.37-1-1.2-desktop kernel

参照网上文件
安装了kernel-devel ,还是碰到问题,,又安装了kernel-desktop-devel*.rpm
再试用 rpm -ql kernel-desktop-devel,
发现这个包的文件都安装的 /usr/src/linux-2.6.37.1-1.2-obj/
下面,于是我采用这个路径/usr/src/linux-2.6.37.1-1.2-obj/i586/desktop/include
结果安装成功。这个vmwaretools主要是为了提供一个和主操作系统共享文件目录的作用吧。
安装起来还是比较费劲的。
posted @ 2011-10-25 05:51 huohuo 阅读(2257) | 评论 (0)编辑 收藏
 透明gif动画读写伸缩例子

今天找了第三方的代码,然后自己修改了部分,实现了透明动画gif的读写,jdk 5下测试通过。

虽然jdk6支持gif的读写,但是很多系统没有升级到jdk6,不可能为了一个gif读写伸缩功能就要升级到jdk6.

这个例子里面使用了开源的gifdecoder animatedgifencoder。
开源的gifdecoder有个bug,透明色经常被它变为黑色,这样很不好。

另外GifUtil类里面有伸缩gif图的例子,有些人图伸缩之后存会gif会出现颜色变多了,超过gif的256色,
因此伸缩也是有特别注意的地方。


具体看代码吧,没有太多空解释
posted @ 2009-09-10 19:53 huohuo 阅读(2120) | 评论 (0)编辑 收藏