直接写
js
function imgError(image) {
image.onerror = null; // prevent event bubble
image.src = "/images/noimage.gif";
return true;
}
html
使用 jQuery
```js
$("img").error(function () {
$(this).unbind("error").attr("src", "broken.gif");
});
//If you use this technique you can use the "one" method to av继续阅读 »
For the performance tuning, the simplest way is to record how many time is elapsed in a function. The only difficulty we’re facing is that: there maybe many exit for a function. Thanks to C++’s constructor/deconstructor feature, it’s easy for developer to record the elsaped time.继续阅读 »
Question
Write a function that takes an unsigned integer and returns the number of ’1' bits it has (also known as the Hamming weight).
For example, the 32-bit integer ’11' has binary representation 00000000000000000000000000001011, so the function should return 3.
解说
这道题的意思是统计32位整数二进制格式下的‘1’的个数。
more
Solution
rig继续阅读 »
xmake provides some api, which can detect whether exist some library functions.
```lua
target("test")
-- checks some libc functions from the header files: wchar.h and stdlib.h
add_cfuncs("libc", nil, {"wchar.h", "stdlib.h"}, "wcscat",
继续阅读 »