Step1 : Install Wireshark in VirtualBox OS (Linux).
Step2 : Excute command "sudo chmod u+s /usr/bin/dumpcap"
(refer:http://softsmith.blogspot.com/2008/10/non-root-wireshark.html)
Step3 : Change VirtualBox network Promiscuous mode to "Allow All". Done!
2012年2月15日星期三
2012年1月26日星期四
2012年1月19日星期四
Generate random number in a loop and call srand one time when function be called
In stdlib.c, the random seed "holdrand= 1L".
If you don't change random seed,
random sequence will be same when you execute program.
To change seed can use srand().
In some situation, function will be called repeatedly.
You want to call srand() just one time, how to do??
There is a soluation.
Because the first rand() value will be 1804289383.
We can design the code:
=======================================
int GetRandomNum() {
int tempnum = rand();
if ( 1804289383 == tempnum ) {
srand( time(NULL) );
}
for ( int i = 0 ; i < ( maxnum - minnum ) ; i++ ) {
outValue = minnum + tempnum%( maxnum - minnum + 1 );
if ( outValue != xx ) {
return outValue;
}
tempnum = rand();
}
}
=======================================
It will guarantee "srand()" will be executed once.
Have fun!!
If you don't change random seed,
random sequence will be same when you execute program.
To change seed can use srand().
In some situation, function will be called repeatedly.
You want to call srand() just one time, how to do??
There is a soluation.
Because the first rand() value will be 1804289383.
We can design the code:
=======================================
int GetRandomNum() {
int tempnum = rand();
if ( 1804289383 == tempnum ) {
srand( time(NULL) );
}
for ( int i = 0 ; i < ( maxnum - minnum ) ; i++ ) {
outValue = minnum + tempnum%( maxnum - minnum + 1 );
if ( outValue != xx ) {
return outValue;
}
tempnum = rand();
}
}
=======================================
It will guarantee "srand()" will be executed once.
Have fun!!
2011年12月13日星期二
Install Pagavcs and Pagavcs-bigmem
WARNING!!!!!
There is a bug that right-click menu does not display when using new version pagavcs (1.4.56).
The solution is under below, install old version Pagavcs and Pagavcs-bigmem.
==========================================
1. Download Pagavcs 1.4.41 and Pagavcs-bigmem 1.0.0.
2. Do not add software path: deb http://pagavcs.googlecode.com/svn/repo karmic main, nor you will install new version Pagavcs automatically.
3. Install Pagavcs first, then Pagavcs-bigmem.
4. If there is no affect, log out then log in, and type $nautilus -q.
5. Have fun!
P.S. pagavcs-bigmem is used to fix that svn's total file size is too big. For example, up to 2GB.
There is a bug that right-click menu does not display when using new version pagavcs (1.4.56).
The solution is under below, install old version Pagavcs and Pagavcs-bigmem.
==========================================
1. Download Pagavcs 1.4.41 and Pagavcs-bigmem 1.0.0.
2. Do not add software path: deb http://pagavcs.googlecode.com/svn/repo karmic main, nor you will install new version Pagavcs automatically.
3. Install Pagavcs first, then Pagavcs-bigmem.
4. If there is no affect, log out then log in, and type $nautilus -q.
5. Have fun!
P.S. pagavcs-bigmem is used to fix that svn's total file size is too big. For example, up to 2GB.
訂閱:
文章 (Atom)
