Mar 21 2008

来自tencent

Category: 乱up当秘笈ssmax @ 23:05:21

今天一个很早就辞职的同事回来搞住房公积金的东西,陪他聊了半天,是书生的同学,现在书生混得风生水起啊,已经是一个部门的技术总监级别了,tencent里面的人事管理比我们正规太多太多了。。。里面工作有动力,就是可能累了点,嘿嘿

防沉迷那边催交货了,urs接口都没有做好,交个毛,等。

篮球群里面要订室内场,广州的室内场太少了,还有游泳池也少,继续寻觅中。

晚上mm生日请小组吃饭,终于见识到女人的威力了,俗话说三个女人一个墟,10几个女人,基本上不用插嘴了,在场的3位男士基本集体发呆,嗯嗯。。。


Mar 20 2008

vtune & solaris & dtrace

Category: 乱up当秘笈ssmax @ 23:07:04

今天向总过来说研究研究怎么搞java的性能测试。。。可能他要搞点测试数据来开展新项目了(**)果然是老板手下第一猛将。。。

首先就要试试M$的vtune,要收费,试用注册出错,exception,搞笑死。。。后来终于down下来了,400+m,明天再找台服务器装上去试试。。。

后面向总就把上次solaris推介的那本书拿出来,说有个dtrace不错,上次去开会的时候也听到过,提出的疑问貌似sun的人也不知道怎么回答,汗,还是要申请台机器装个solaris试试才知道。。。


Mar 19 2008

Beautiful Life [Ace of Base]

Category: 乱up当秘笈ssmax @ 11:07:37

You can do what you want just seize the day
What you’re doing tomorrow’s gonna come your way
Don’t you ever consider givin’ up, you will find, oooh

It’s a beautiful life, oh oh ooo
It’s a beautiful life, oh oh ooo
It’s a beautiful life, oh oh ooo
I just wanna be here beside you
stay until the break of dawn

Take a walk in the park when you feel down
There’s so many things there
that’s gonna lift you up
See the nature in bloom a laughing child
Such a dream, oooh

It’s a beautiful life, oh oh ooo
It’s a beautiful life, oh oh ooo
It’s a beautiful life, oh oh ooo
I just wanna be here beside you
I just wanna be here beside you
stay until the break of dawn

You’re looking for somewhere to belong
You’re standing all alone
for someone to guide you on your way
Now and Forever

It’s a beautiful life, oh oh ooo
It’s a beautiful life, oh oh ooo
It’s a beautiful life, oh oh ooo
I just wanna be anybody

Living in different ways
It’s a beautiful life
I’m gonna take you to a place I’ve never been
before oh yeah
It’s a beautiful life
I’m gonna take you in my arms and fly away
with you tonight

It’s a beautiful life, oh oh ooo
It’s a beautiful life, oh oh ooo

It’s a beautiful life, oh oh ooo
It’s a beautiful life, oh oh ooo
It’s a beautiful life, oh oh ooo
It’s a beautiful life
[x2]

挖坟老歌一曲


Mar 18 2008

torrents文件的java解释

Category: 技术ssmax @ 21:40:43

翻代码翻出n年前写的东西,当初还想做个tracker的,还去sourceforge申请个项目,没通过。。。怀念一下:

import java.util.*;

public class BitDecoder
{
 //0
 public static final byte ZERO_BYTE = 0x30;
 
 //9
 public static final byte NINE_BYTE = 0x39;
 
 //-
 public static final byte MINUS_BYTE = 0x2D;
 
 //:
 public static final byte COLON_BYTE = 0x3A;
 
 //d
 public static final byte d_BYTE = 0x64;
 
 //e
 public static final byte e_BYTE = 0x65;
 
 //i
 public static final byte i_BYTE = 0x69;
 
 //l
 public static final byte l_BYTE = 0x6c;
 
 //n
 public static final byte NULL_BYTE = 0x6e;
 
 //最大解释层数
 public static int MAX_LAYER = 8;
 
 private int now_layer = 0;
 private String index_key = “”;
 private int key_start = 0;
 private int key_end = 0;
 
 public BitDecoder(String key)
 {
  if(key!=null)
   index_key = key;
 }
 
 public void reset(String key)
 {
  now_layer = 0;
  key_start = 0;
  key_end = 0;
  if(key!=null)
   index_key = key;
  else
   index_key = “”;
 }
 
 public String getkey()
 {
  return index_key;
 }
 
 public int getKeyStart()
 {
  return key_start;
 }
 
 public int getKeyEnd()
 {
  return key_end;
 }
 
 //解出int,用String保存
 private BTDecodeObj decode_int(byte [] bytes,int index) throws Exception
 {
  int till_index = ++index;
  
  byte workingbyte = bytes[till_index];
  
  if(workingbyte == MINUS_BYTE)
  {
   workingbyte = bytes[till_index+1];
   if(workingbyte == ZERO_BYTE)
    throw new Exception(“number -0 is not allowed”);
   else if(workingbyte == e_BYTE)
    throw new Exception(“only minus is not allowed”);
   else if(workingbyte>NINE_BYTE || workingbyte<ZERO_BYTE)
    throw new Exception(“number must be 0-9”);
   else
    till_index++;
  }
  
  while(true)
  {
   workingbyte = bytes[till_index];
   if(workingbyte == e_BYTE)
    break;
   else if(workingbyte>NINE_BYTE || workingbyte<ZERO_BYTE)
    throw new Exception(“number must be 0-9”);
   else
    till_index++;
  }
  
  if(bytes[index]==ZERO_BYTE && till_index!=index+1)
   throw new Exception(“number 0 must be alone”);
  else  
   return new BTDecodeObj(new String(bytes,index,till_index-index),till_index+1);
 }
 
 //解出String
 private BTDecodeObj decode_string(byte [] bytes,int index) throws Exception
 {
  int colon_index = index;
  byte workingbyte = 0x00;
  while(true)
  {
   workingbyte = bytes[colon_index];
   if(workingbyte == COLON_BYTE)
    break;
   else if(workingbyte>NINE_BYTE || workingbyte<ZERO_BYTE)
    throw new Exception(“string length must be 0-9”);
   else
    colon_index++;
  }
  
  if(bytes[index] == ZERO_BYTE && colon_index!=index+1)
   throw new Exception(“string length 0 must follow by :”);
  
  index = Integer.parseInt(new String(bytes,index,colon_index-index));
  colon_index++;

  return new BTDecodeObj(new String(bytes,colon_index,index,”8859_1″),colon_index+index);
 }
 
 //解出List
 private BTDecodeObj decode_list(byte [] bytes,int index) throws Exception
 {
  now_layer++;
  if(now_layer > MAX_LAYER)
   throw new Exception(“too many list or dictionary layer!”);
  
  index++;
  ArrayList resultlist = new ArrayList();
  
  BTDecodeObj tempobj = null;
  
  while(bytes[index] != e_BYTE)
  {
   tempobj = bdecode(bytes,index);
   index = tempobj.getIndex();
   resultlist.add(tempobj.getObj());
  }
  
  now_layer–;
  return new BTDecodeObj(resultlist,index+1);
 }
 
 //解出dict
 private BTDecodeObj decode_dict(byte [] bytes,int index) throws Exception
 {
  now_layer++;
  if(now_layer > MAX_LAYER)
   throw new Exception(“too many list or dictionary layer!”);
  
  index++;
  HashMap resultmap =  new HashMap();
  
  BTDecodeObj tempobj = null;
  String lastkey = “”;
  String nowkey = null;
  
  while(bytes[index] != e_BYTE)
  {
   tempobj = decode_string(bytes,index);
   nowkey = (String)tempobj.getObj();
   if(nowkey.compareTo(lastkey) <= 0)
    throw new Exception(“dictionary lexicographically order error!”);
   
   lastkey = nowkey;
   index = tempobj.getIndex();
   if(key_start==0 && index_key.equals(lastkey))
   {
    key_start = index;
   }
   
   tempobj = bdecode(bytes,index);
   index = tempobj.getIndex();
   if(key_start!=0 && index_key.equals(lastkey))
   {
    key_end = index;
   }
   
   resultmap.put(nowkey,tempobj.getObj());
  }
  
  now_layer–;
  return new BTDecodeObj(resultmap,index+1);
 }
 
 private BTDecodeObj bdecode(byte [] bytes,int index) throws Exception
 {
  if(bytes[index]>=ZERO_BYTE && bytes[index]<=NINE_BYTE)
   return decode_string(bytes,index);
  else if(bytes[index] == d_BYTE)
   return decode_dict(bytes,index);
  else if(bytes[index] == l_BYTE)
   return decode_list(bytes,index);
  else if(bytes[index] == i_BYTE)
   return decode_int(bytes,index);
  else
   throw new Exception(“torrent bencode format error!”);
 }
 
 public Object bdecode(byte [] bytes) throws Exception
 {
  BTDecodeObj resultobj = bdecode(bytes,0);
  if(resultobj.getIndex() != bytes.length)
   throw new Exception(“torrent bencode format error,length exception!”);
  
  return resultobj.getObj();
 }
 
 public int getNowLayer()
 {
  return now_layer;
 }

 public static class BTDecodeObj
{
 Object obj = null;
 int index = 0;
 
 public BTDecodeObj(Object obj,int index)
 {
  this.obj = obj;
  this.index = index;
 }
 
 public Object getObj()
 {
  return obj;
 }
 
 public int getIndex()
 {
  return index;
 }
}
}


Mar 18 2008

Hex转换

Category: 技术ssmax @ 21:28:58

n年前的课题了,今天要用,都忘记了,记录一下

byte to hex 直接java方法:

// convert a single byte b to a 2-char hex string
// with possible leading zero.
String s2 = Integer.toString( ( b & 0xff ) + 0x100, 16 /* radix */ )
		.substring( 1 );

字典法和反向转换,记录自己在无线时候写的一个:

        /*
         *取得byte的16进制字符串
        */     
        private static final String HexString = “0123456789ABCDEF”;
       

        public static String getHexString(byte [] msg_byte)
        {
                StringBuffer sb = new StringBuffer(msg_byte.length * 2);
                for(int i =0;i<msg_byte.length;i++)
                {
                        sb.append(HexString.charAt(0xf&msg_byte[i]>>4)).append(HexString.charAt(msg_byte[i]&0xf));
                }
                return sb.toString();
        }      
               
        public static byte[] getBytesFromHexStr(String s)
        {              
                try    
                {              
                        int i = s.length();
                        byte result[] = new byte[i >> 1];
                        for(int k = 0; k < i;)
                                result[k >> 1] = (byte)(Integer.parseInt(s.substring(k,k+=2),16));
                        return result;
                }
                catch(Exception ex)
                {
                        //ex.printStackTrace();
                        return null;
                }
        }


Mar 17 2008

不抛弃,也不放弃

Category: 乱up当秘笈ssmax @ 17:03:02

早上2/3/4点都醒了一次,但是貌似没动力,没爬起来,最后老爸在5点起来开电视,听到声音就弹起来了,看下半场,火箭打铁王今天好变态。。。8d2防到kb一点脾气都没有了。。。豪取22连胜。

回到公司,头有点晕,工作也有点烦乱,中午12点给服务器加索引,去掉ipv6,停机了1个小时,搞得手忙脚乱了,下午游戏那边又扔了台服务器过来,把mysql和resin装上,脑袋已经塞成一团了,上去打球发泄一下,出了一身汗,感觉才好点。。。

笨蛋不要放弃也不要逃避,没事的。


Mar 16 2008

火箭·对联

Category: 乱up当秘笈ssmax @ 11:09:41

上联:一星二老三龙套,镇四方斩五关六将,蹿七八九榜排名,十分看好!

下联1:十分九板八助攻,断七球盖六帽进五佳,打四三二位全能,一号翠西!

下联2:十人九勇八争先,抢七星跃六名坐五强,战四三二位无惧,一心夺魁!

貌似第二联好一点,嘿嘿。。。


Mar 15 2008

【转贴】火箭,谢谢你

Category: 乱up当秘笈ssmax @ 23:33:07

转自光华,原作者anyestar 

火箭,谢谢你

我想说的是,我一直以来都并不是一个纯火箭球迷。虽然喜欢TMAC是从魔术时代就开始的,虽然也很喜欢姚明并且希望他能打好,但是一直到他们被小牛挡在第一轮之前,我都并不是一个纯火箭球迷。

也许我更喜欢米勒的三分球,当年我看着史上最强的步行者在鲨鱼面前被蹂躏,那次我很难过;
也许我更喜欢AI的电光石火,当年凭印象很讨厌他,但是在看着他击败我钟爱的三杆火枪之后,我开始爱上他,并且一直追随他被鲨鱼挡驾;
然后我开始喜欢火箭,也许我一直喜欢的就是弱者,或者说是弱者战胜强者的戏码。所以后来我挑上了火箭。
看着他们一次次被打败,然后爱上他们。
后来火箭变强了,我却并没有不喜欢他们。先进的联盟里,火箭有最多我喜欢的队员。

翠喜·我要干拔·麦克格雷迪和姚·大杀器·明以外,当年在76人给我留下深刻印象的迪肯莫·手指饼干·木桶伯、灰熊当年的模范球员肖恩·总统·巴蒂尔,这些球员本身就已经足够让我喜欢上这支球队。
当今年他们低谷的时候,我也骂他们,这是我看球以来第一次因为一支球队的不争气而愤怒。
然后他们开始反弹,一切都进行得很好。

我开始回忆起奥拉朱旺时代的那个火箭,虽然那支火箭与现在除了一根全明星肉棒加一群乱枪打鸟手以外似乎没有什么相同之处。但是那支火箭——他们是冠军啊。
当火箭九连胜的时候,我开始希望他们能拿冠军,虽然似乎他们肯定做不到。
十二连胜的那天,我在看BBS。BBS上人们弹冠相庆,而之前姚明整赛季报销的乳沫早已经被合集风干。
我知道姚明报销的消息是在电视这个一向比较慢的媒体上,但是斩钉截铁,绝没有一点乳沫味道。然后大家都疯了。
十二连胜他妈有什么用。我罕见地在和同学聊起来的时候吐了句脏话。
十三连胜。
十四连胜。
十五连胜。
超甜蜜十六连胜。
超超甜蜜十七连胜。
超超超甜蜜十八连胜。
超超超超甜蜜十九连胜。
连胜一路进行,大家又都疯了。

休斯顿?乱枪打鸟?就是投死你?火箭男子篮球队打出的这波连胜真是犹如言情剧一样曲折。
休斯顿的这群男人们基情无限地说:do it for yao.看到这句话的那天,我用家里新装的IPTV看了集结号,眼泪哗哗的。

大叔是我要特别提的一个人。
吉祥物大叔说,我是一个中锋。其他人在身后补上:他和奥尼尔打过,他和尤因打过,他和奥拉朱旺打过,他和贾巴尔打过,他和张伯伦打过……不管了,他是一个中锋。
大叔当年在鹰队和76人队的时候都给我很深刻的印象,但是没有一次比得上这次。虽然大叔当年很准的跳勾现在变成了僵尸勾手,虽然他现在除了扣篮(不是灌篮)什么进攻手段都不会,但是大叔可是NBA现役球员中名字最长没有之一年纪最大可能没有之一的球员呢。
用某个和我有相同外号的篮球解说员的话说:虽然你年轻,但是我是木桶伯啊。
于是一个一个猛人都被盖了,附送大叔的手指一根。这份“荣幸被大叔赏帽”名单太长,我只需举出文斯·我还是半人半神(经)·卡特和泰森·空接空到手疼·钱德勒就足够。大叔可是脚长(chang2)得跳起来都不离地的男人啊。

以上花了很大的篇幅说大叔。然后继续说火箭。
火箭的亢奋开始感染每个人,连运气都站在他们这边。总之他们就是能投得进。他们的史蒂芬·投得进·诺瓦克投得进,拉斐尔?也投得进?阿尔斯通也投得进,肖恩?底角就是投得进·巴蒂尔不但底角进别地方也进,但是这些都赶不上卢瑟?无脑?海德居然开始有脑,路易斯·我是欧洲人·斯科拉居然开始很美式地防守,以及卡尔·不折叠不可以折叠还要加滑行·不是马龙·不是武藤·兰德里的发猛。
这已经不是言情剧了,这就是一部励志大片。

一个没有过荣誉的过气的超级巨星来到一家球队,有个好脾气的外国大个子是这个球队的老大。他们经过几年配合(从剧本来说这段可以用来倒叙和插叙)之后,还是失败了。他们的教练离开,只有新的教练,几个不知道能不能用的新秀,几个有时候用来搞砸事情的配角,还有个老兵(所有这种片子里都有个老兵,这个老兵一般都会挂)。然后他们要开始面对战斗,新的战斗。

当过气巨星开始厌倦生活——他打得不好,还受了伤——之后,球队开始连胜。那个好脾气的外国大个子在场上发出吼声,他很久没这么爽地吼过了。
他说,兄弟,我们等你。等你回来。
过气球星什么也没说,他只是伸出手,与大家相握。没人知道他在想什么,没人知道外界的传言是不是真的。
然后他回来了,他笑着说我不会拖你们后腿的。有一句话他并没有说。
刷得分变成刷助攻,他们继续连胜。一切都很光辉。
然后十二连胜了。所有人都疯了。配角某吼着:我们不可战胜!
大个子说:兄弟,呵呵。
巨星——不过气了——笑笑,伸出手。
然后晴天霹雳——大片里都这样——大个子倒下了。他只能在场边看着自己的伙伴在训练场上无心恋战地受着煎熬。
这个时候,很少说话的那个人说:兄弟,我们等你。等你回来。
然后他投进一个高难度的干拔,笑了:我们会打到你能回来的那一天。
然后大家很平静地站成一圈,一起低声说:Let’s do it for Yao.

接着是继续的连胜,所有人开始燃烧。老兵脱掉自己长久以来都没脱下的热身服,站起身来,人们发现自己已经很久没有看到那样伟岸的他。
镜头划过疯狂的配角们,疯狂的少年们,不疯狂但越来越优秀的老新秀。
21连胜。
巨星面无表情地对着天空。你当年给我一个19连败,今天我赢回来,还加上两场利息。

我不知道连胜什么时候会结束。
我知道连胜结束的那天我不会哭。
我知道那个时候我会微笑地写下这个故事的结局。没事,我们依然抱有希望。

也许很久以后,当巨星真的过气的时候,他会抱着自己的小孙子,小孙子抱着篮球。
小孙子:爷爷,你当年是不是用35秒投进过13分啊?
爷爷:呵呵,那不算什么。
小孙子:那爷爷最辉煌的时候呢?
爷爷:你知道吗,当年有一个多月,没有一支球队能够战胜我们,一支也没有。
小孙子:可是你们也没有拿到冠军啊?
爷爷:冠军年年有,可是2x (x>=1)连胜,几十年出一个呢。

写到这里,这篇文章该结束了。我想谢谢火箭,毕竟在传奇越来越少的今天,他们给了我们又一次传奇。当我们老的时候,我们也可以说:当时我是个火箭迷,看着他们一场一场地连胜,很幸福。


Mar 15 2008

真正的历史第二,21连胜

Category: 乱up当秘笈ssmax @ 17:42:55

昨晚打游戏一个不小心打过头了,两点多才睡。。。今早一早就爬起来看球,tnnd竟然只有tvants有直播,好不容易占了一个位置,看的时候很卡,受不了,最后看文字直播去了,然后边看第三节文字边看第一节录像。。。汗得很。。。

每次在山猫需要追分的时候,杰拉德-华莱士的三分总能显灵,菲尔顿再上进1球后,山猫还是在努力地迫近比分,阿尔斯通机敏的抢断把自己送上罚球线,2罚1中,比赛还有最后2分钟,火箭依然10分领先。接下去的进攻,火箭尽管没有能够达成,但是麦克-哈里斯的进攻篮板却给火箭争取到了宝贵的时间,山猫砍分双人组理查德森和奥卡福抓紧时间在10秒内连拿4分,但是比赛时间还有最后1分钟,山猫队进入犯规时段。麦克-哈里斯2罚只有1中,随后被海德替下,但是在防守端不可逾越的大叔帽掉了奥卡福的扣篮,使得山猫快速得分的计划完全被打破,阿尔斯通成功地2罚全中后,火箭89比80领先,比赛只剩下53秒,奥卡福的扣篮再次遭到神圣牧师-穆托姆博光环手指的无情封盖,丰田中心再度沸腾!21连胜到手!麦迪的三分浪投只是为了宣泄心中那不可抑制的喜悦,理查德森抢投三分不中后,休斯顿火箭队,迎来了自己的第21场连胜!

奥卡福没有看电视?还是他没有听过穆大叔的名号?现在在他试图灌篮紧接着得到穆式摇手指大礼后,他应该了解了。可惜年轻人就是不长记性,又一次尝试,又一次闭门羹。

湖人今天又输给了黄蜂,现在是按西部战绩领先火箭,下场就是决定谁是西部第一了,听说送水工发功干掉了加索尔,难道要22连胜?正在考虑后天3点半要不要起来看看。。。


Mar 14 2008

apache 2 internal dummy connection

Category: 技术ssmax @ 22:54:17

这几天mima的机器经常死,看了一下apache的log,发现很多::1的请求

 ::1 – – [13/Mar/2008:23:59:02 +0800] “GET /” 400 460 “-” “-”

看不懂,到apache 的userlist里面问了一下,原来是::1是ipv6的本机表示,真实out了,ipv6都不知道。。。

然后就用tcpdump看了一下

tcpdump -A -s0 -i any tcp src host ::1

发现了请求内容,原来是。。。Apache internal dummy connection。。。汗啊汗,开头我还以为linux中木马了。。。

google了一下,官方没有找到什么说明,找到一个blog有写一点

http://vdachev.net/blog/2007/02/01/apache-internal-dummy-connection/ 

I Google’d for “(internal dummy connection)”. There were only a few results explaining what was really happening… many of them were rumors. I found an entry in Yenya’s blog with the same issue. It suggested this is a replacement in Apache 2.x of sending signals to its processes as signals are not available on all platforms. This means during graceful restart, instead a SIGUSR1 to be sent to all child processes, a subrequest is made. The CodeSearch results seem to confirm this. Now, let’s say my server is running ~100 processes and I change anything in my configuration. Would this mean ~100 subrequest at a time ? Yeah, this would be an overhead (over- an already loaded server’s -head) ! Oh, my web servers is being gracefully reloaded each time a log is rotated… ~50 times.  

It seems this feature exists in the whole 2.x series so a downgrade to 2.0 would not solve this issue. It’s just in versions prior to 2.2.0 there was no indication of such internal requests. Some people proposed switching to Worker MPM. However people say that on 2.6.x boxes (my case) Prefork MPM runs faster. Additionally, PHP is not thread-safe by default (the Worker MPM is thread based) and it should be compiled with Zend Thread Safety libraries (–enable-experimental-zts). I don’t think it’s worth… It would be great if there was a way to switch back to the old behaviour on platforms that support it… it’s odd otherwise. Now I’ve disabled the logging for the default website and I’ve left mod_redirect (as I don’t think Apache would follow redirects internally).

P.S.: I suppose signals are also used to terminate a child then the number of request reaches MaxRequestsPerChild, so I experimentaly disabled this limit as it’s used to protect the system from any memory leaks in child processes. However, I haven’t noticed any by now. I hope this will decrease the number of signals sent to the child processes. Let’s check this out…

大概就是一种新的内部通信机制,代替了发进程信号,好像是2.0就开始有了,但是2.2没有从log中过滤,不知道有什么影响,在官方的buglist上面看到好像2.2.6有点问题,tmd服务器刚好就是2.2.6,下周顺便升级了丫的。。。


« Previous PageNext Page »