Random

Web design and interface

There are many different websites running on different themes.
Some websites have the same kind of sections, but presented in a different way.
For example, the navigation is on the right instead of left. Recent comment bar is showing on the bottom instead of top or w/e.
Each time I go on a website I have to get used to the interface.
If I'm only going to use this website once, it still take time to find information I need.

Semantic web is nice. Because I can ignore all the web design, and apply my own set of templates on all of them.

Semantic web NOW!

I have to complain because I have nothing better to do. Now I'm happy and going back to study for the midterm.

I wish I can get paid for complaining.

Let me google that for you

I must share this link. I'm sure a lot of people know this site already.
Let me google that for you.
I made a Chinese translation for that site a long time ago.

I forgot this site until these days when people start to ask problems that are so easy to answer from Google.

Go use this when ever someone ask one of those common questions.

I don't mind people ask me questions. Especially questions that do require me to think, or things not easily googled. Like "how would you do this problem?", "when will the school play start tomorrow?"(btw I never know when the school play starts).
I don't like to answer to some questions that's perfectly google-able.

It's like asking me "what does this word mean?" when there is a dictionary right beside you.

Infinite loop

I saw this joke.

Boss to Secretary: I want to go to Beijing for a few days. Come with me.
secretary to husband: I have to go to Beijing with the boss.
husband to mistress: my wife won't be at home for a few days.
mistress to student: I won't be teaching you for a few days.
student to grandpa(boss): I don't have classes for a few days, let's have a fishing trip.

so, now, as you can see, the reverse happens, where boss->secretary->husband->mistress->student change their plans...
How can this problem be resolved?

Maybe one of them had enough with this and chose to do one thing anyway.

Maybe one of them become scientific and start investigate.

I don't know...

Edit: Helie offered a solution!

Obviously, the solution is to go fishing IN BEIJING

Tags:

225 boxes

225 boxes from USPS arrived yesterday, packed inside 9 large boxes.

a stack of 9 boxes img 1

a stack of 9 boxes img 2

Totally random.
few days ago a conversation like this with Kirkland.

K: Do you like boxes?
M: Yes
K: Do you like large boxes or small boxes?
M: Large boxes
K: Do you like a lot of boxes or a few boxes?
M: I like a lot of boxes.

That's the result. 225 boxes sent to my house.

I heard someone planning a prank in my school, where people use cardboard boxes to block the hallway from B-wing to C-wing. Epic. put water in it so anyone knock it down gets really wet!

So what did I do with these boxes? I throw them away.
My dad returned home and freaked out, he found this extremely irrational and ordered me to get rid of those things.
At first I thought of dissolve the cardboard, then I found there is no sulfuric acid in my fridge. Lame.
200 boxes are thrown out today. I left 25 just in case I have to use it for something evil.

Tags:

A Large Random Number Generator

I used a lot of time to make it, after I failed last time, I thought there are better ways to work around. Here is how it works:
1. Subtract the minimal value from the maximal value
2. Generate the numbers for the digits by using rand()
3. Combine the digits
4. Check if it is too large or not, if is, redo 2, if not,go on.
5. Add the minimal value to the random value.

In worst case, by chance, 10 random number need to be generated before we get a good one. Numbers like 100000, 10000.
In best case, only one will be generated, numbers like 99999, 9999
In average, one out of 5 generation, because average number are 500000

function bcrand($min, $max){
	bcscale(0);
	if(bccomp($max,$min)!=1){
		return 0;
	}
	$top = bcsub($max,$min);
	$length = strlen($top);
	$rand ='';
	$n = 0;
	while(9*$n < $length){
		if($length - 9*$n >= 9){
			$rand .= mt_rand(0,999999999);
		}else{
			$rand .= mt_rand(0,str_repeat('9',$length-9*$n));
		}
		++$n;
	}
	while(bccomp($rand,$top)==1){
		$rand = substr($rand,1,$length).mt_rand(0,9);
	}
	return bcadd($rand,$min);
}

I saw another function, also called bcrand(), in PHPRPC[CHINESE], a implementation of RPC in PHP, you can find it in the bcmath.php inside the file. Here is the function for the people who can not read the Chinese website.

function bcrand($n, $s) {
    $lowBitMasks = array(0x0000, 0x0001, 0x0003, 0x0007,
                         0x000f, 0x001f, 0x003f, 0x007f,
                         0x00ff, 0x01ff, 0x03ff, 0x07ff,
                         0x0fff, 0x1fff, 0x3fff, 0x7fff);
 
    $r = $n % 16;
    $q = floor($n / 16);
    $result = '0';
    $m = '1';
    for ($i = 0; $i < $q; $i++) {
        $rand = mt_rand(0, 0xffff);
        if (($q - 1 == $i) and ($r == 0) and ($s == 1)) {
            $rand |= 0x8000;
        }
        $result = bcadd(bcmul($m, $rand), $result);
        $m = bcmul($m, '65536');
    }
    if ($r != 0) {
        $rand = mt_rand(0, $lowBitMasks[$r]);
        if ($s == 1) {
            $rand |= 1 << ($r - 1);
        }
        $result = bcadd(bcmul($m, $rand), $result);
    }
    return $result;
}

This version is different because it returns a random n-byte number, for example, bcrand(20,0) could return 634834.
I found mine is pretty fast :-)

Honey Pot that kill bots