Archive - Jun 2007

Learning Notes

in

To find how many CPU clocks have been run from the start of the program to now:

#include <time.h>
clock_t clockcycle;
clockcycle = clock();

CLOCKS_PER_SEC is a constant that shows how many CPU clocks per second. Divide the clock_t by CLOCKS_PER_SEC you get how many seconds the program runs.

563

According to Ferris Research, spam would cost the world $50 billion, a bit less than Vietnam's GDP. How much better would the world be if I have that money... (Answer:Non. But I won't spend it to annoy peoples' blog.)

— Mgccl

Loop multiple associative array at the same time

Today, someone in asked me a question in Qunu asked me a question to loop though 2 associative array at the same time.

Suppose, 2 associative arrays, $a and $b. They have some information corresponding to each other according to their position, but they are not numeric arrays, and it is not possible to manipulate one array's value or key to get another array's key.

My suggestion is to loop though 2 arrays with foreach separately, build them as 2 numeric array and then we will have a numeric key to access them.

foreach($a as $key=>$var){
$num_a[] = array($key=>$var);
}
foreach($b as $key=>$var){
$num_b[] = array($key=>$var);
}

Two foreach loops... if there is more arrays like this, there will be a lot more loops. If the key's information want to be preserved,

The qunu user told me a better code, use each().

foreach($a as $akey=>$avar){
$tmpb = each($b);
$bkey = $tmpb['key'];
$bvar = $tmpb['value'];
}

I didn't have time to ask who he was before he quits from the room.

Zong-Go mobile

in

Zong, part of Echovox, is a platform for mobile applications. There is a API so you can create services running on their platform.
how zong work.
Zong pays money if you get subscribers, and the easiest program possible is RSS parsing service. You supply the RSS URL and set the price and they will do everything else for you. Easy money baby

Notes for June 28

in

One day, when I'm rich, I will send all the cows to Alaska.
Take that Wendy's, No frozen beef!

There are funny people in my family...
"I want it extra large, and the pizza person looks me like he is trying to say 'you sure? I don't think you can eat it all'. how stupid are people these days, Doesn't he know I won't be the only one eating it?"

I wish my friends are around so I can use "That's what she said!" and hi5 everyone...

Great thyme we had.
Yeah, time seems pass very fast.
No, I mean thyme, the plant.

Honey Pot that kill bots