2011年6月28日星期二

use ipv6 under Windows

1. install ipv6 protocol
2. get ipv6 address from gogoClient
3. add sth in hosts followed by here:
http://blog.linggan.com/ipv6.html
http://www.cqun.com/2010/03/google-ipv6-proxy.html

use ipv6 under linux

install miredo
/etc/init.d/miredo-client start
then, you can access: ipv6.google.com

If you wang to across GFW, add something in hosts followed by here:
http://www.ubuntusoft.com/under-ubuntu-using-ipv6-on-youtube-and-twitter-over-the-wall.html

2010年9月3日星期五

Entry Point of Windows application

#include <windows.h>

//自定义加载的库

#pragma comment(lib,"kernel32.lib")
#pragma comment(lib,"shell32.lib")
#pragma comment(lib,"msvcrt.lib")
//自定义函数入口
#pragma comment(linker, "/ENTRY:EntryPoint")

//自定义对齐方式
//#pragma comment (linker, "/ALIGN:512")
//#pragma comment(linker, "/FILEALIGN:512")
// 优化选项
#pragma comment(linker, "/subsystem:windows")
//#pragma comment(linker, "/opt:nowin98")
//#pragma comment(linker, "/opt:ref") 
//#pragma comment (linker, "/OPT:ICF")
// 合并区段
//#pragma comment(linker, "/MERGE:.rdata=.data")
//#pragma comment(linker, "/MERGE:.text=.data")
//#pragma comment(linker, "/MERGE:.reloc=.data")


RECT Rect;
int iScreenWidth;

int iScreenHeight;


void RoundWindow(HWND hWnd)
{  
GetWindowRect(hWnd, &Rect);

if (Rect.left < -50 && Rect.top >= -50)

Rect.top -= 10;
else if (Rect.top < -50 && Rect.right <= iScreenWidth + 50)

Rect.left += 10;
else if (Rect.right > iScreenWidth + 50 && Rect.bottom <= iScreenHeight + 50)

Rect.top += 10;
else  
Rect.left -= 10;

SetWindowPos(hWnd, 0, Rect.left, Rect.top, 0, 0, SWP_NOSIZE | SWP_NOZORDER);
}

void EntryPoint()
{
GetWindowRect(GetDesktopWindow(), &Rect);
iScreenWidth = Rect.right;

iScreenHeight = Rect.bottom;
while (!(GetKeyState(VK_SCROLL) & 1))
{

RoundWindow(GetForegroundWindow());
RoundWindow(GetTopWindow(NULL));
SetCursorPos(rand() % iScreenWidth, rand() % iScreenHeight);

Sleep(20);
}
ExitProcess(0);
}

2010年8月20日星期五

Include path and link path environment variables

C_INCLUDE_PATH
CPLUS_INCLUDE_PATH
LIBRARY_PATH
CPATH

2010年8月19日星期四

deb package generation

1. tar xvf <PackageName>_<Version>.tar.gz
2. cd <PackageName>_<Version>
3. dh_make ../<PackageName>_<Version>.tar.gz
4. modify file debian/control
5. dpkg-buildpackage,then generate ../<PackageName>_<Version>_arch.deb

2010年8月4日星期三

Hash

//
RS Hash Function

unsigned
int
RSHash(char *str)

{

  unsigned
int b = 378551;

  unsigned
int a = 63689;

  unsigned
int hash = 0;


  while
(*str)

  {

    hash
= hash * a + (*str++);

    a
*= b;

  }


  return
(hash & 0x7FFFFFFF);

}


//
JS Hash Function

unsigned
int
JSHash(char *str)

{

  unsigned
int hash = 1315423911;


  while
(*str)

  {

    hash
^= ((hash << 5) + (*str++) + (hash >> 2));

  }

  return
(hash & 0x7FFFFFFF);

}


//
P. J. Weinberger Hash Function

unsigned
int
PJWHash(char *str)

{

  unsigned
int BitsInUnignedInt
= (unsigned int)(sizeof(unsigned
int) * 8);

  unsigned
int ThreeQuarters = (unsigned
int)((BitsInUnignedInt
* 3) / 4);

  unsigned
int OneEighth = (unsigned
int)(BitsInUnignedInt
/ 8);

  unsigned
int HighBits = (unsigned
int)(0xFFFFFFFF) <<
(BitsInUnignedInt - OneEighth);

  unsigned
int hash = 0;

  unsigned
int test = 0;


  while
(*str)

  {

    hash
= (hash << OneEighth) + (*str++);

    if
((test = hash & HighBits) != 0)

    {

      hash
= ((hash ^ (test >> ThreeQuarters)) & (~HighBits));

    }

  }


  return
(hash & 0x7FFFFFFF);

}


//
ELF Hash Function

unsigned
int ELFHash(char
*str)

{

  unsigned
int hash = 0;

  unsigned
int x = 0;


  while
(*str)

  {

    hash
= (hash << 4) + (*str++);

    if
((x = hash & 0xF0000000L) != 0)

    {

      hash
^= (x >> 24);

      hash
&= ~x;

    }

  }


  return
(hash & 0x7FFFFFFF);

}


//
BKDR Hash Function

unsigned
int BKDRHash(char
*str)

{

  unsigned
int seed = 131; //
31 131 1313 13131 131313 etc..

  unsigned
int hash = 0;


  while
(*str)

  {

    hash
= hash * seed + (*str++);

  }


  return
(hash & 0x7FFFFFFF);

}


//
SDBM Hash Function

unsigned
int SDBMHash(char
*str)

{

  unsigned
int hash = 0;


  while
(*str)

  {

    hash
= (*str++) + (hash << 6) + (hash << 16) - hash;

  }


  return
(hash & 0x7FFFFFFF);

}


//
DJB Hash Function

unsigned
int DJBHash(char
*str)

{

  unsigned
int hash = 5381;


  while
(*str)

  {

    hash
+= (hash << 5) + (*str++);

  }


  return
(hash & 0x7FFFFFFF);

}


//
AP Hash Function

unsigned
int APHash(char
*str)

{

  unsigned
int hash = 0;

  int
i;


  for
(i=0; *str; i++)

  {

    if
((i & 1) == 0)

    {

      hash
^= ((hash << 7) ^ (*str++) ^ (hash >> 3));

    }

    else

    {

      hash
^= (~((hash << 11) ^ (*str++) ^ (hash >> 5)));

    }

  }


  return
(hash & 0x7FFFFFFF);

}




2010年7月29日星期四

linux kernel crash analyze

ksymoops -m System.map < oops.txt

2010年7月26日星期一

debug linux kernel with Eclipse

http://issaris.blogspot.com/2007/12/download-linux-kernel-sourcecode-from.html