For c++, we know that new and delete appear in pair, but is it necessary to set a pointer to NULL after delete it?

Say we have:

class A {};
 
A *a = new A;
// do something with a
delete a;
 
a = NULL;  // Do we need to do this?

Read the rest of this entry

 

Cytoscapeweb makes a nice presentation of the world, which could be shown in it nodes, edges and shapes.

Moreover, events could also be bound to the elements using javascript.

However, there seems no API for developers to trigger an event using javascript instead of by user clicking mouse or tap a key.

We can bind an event to an element in cytoscapeweb by :

vis.addListener(evt, [gr], fn) 

and accordingly, I suppose there should be a trigger API to fire the event, but there isn’t.

Alternative way to simulate an event, which I mean somehow like to move the cursor and click, is not possible.

Read the rest of this entry

,

 jQuery brings us a new javascript style, including selector, chain operation and so on.

However, the most meaningful one, which gets more and more people involved, is its plugin mechanism. 

Present there are hundreds of millions of plugins online, which have really reduce the complexity of writing javascript.

Well, most of the time, the plugins work fine; but for some times, they refuse to work on the future or live elements, which are added or modified by javascript later.

like, you have a plugin:

 

/**
 * the original plugin, to add s and t to the element text.
 * you can call $("p").pg(1, 2) for existing elements,
 * however it doesn't work for futher/live elements,
 * such like <p>33333</p> in this example, which is added later dynamically.
 */
$.fn.pg = function(s, t) {
    return this.each(function() {
 
        $(this).mouseenter(function() {
            $(this).text(parseInt($(this).text()) + s + t);
        }).next().text(
        // how many times I have been bound to the element.
        parseInt($(this).next().text()) + $(this).data('liveplugin.pg'));
    });
};

 

, which takes no effects on further added "p" elements.

Read the rest of this entry

,

 Following code has been tested with jQuery 1.3.2 version .

All the JavaScript code mentioned in this blog should be tried on firebug.

The super popular live method was added to jQuery 1.3 . It works just great. Except when it does not work. As per the documentation this method does not work in following cases: blur, focus, mouseenter, mouseleave, change, submit .

How binding events work in jQuery

1
2
3
$('a').click(function(){   console.log('clicked'); }); 

Read the rest of this entry

 

行文原因

 

为什么要写这篇文章? 因为我对于度娘和谷爹里搜索到关于这个问题的文章耿耿于怀, 忿忿不已. 这些文章都只说了个所以, 却没说然.

在这篇文章里, 我将详细地说一下Incomplete Object的成因, 以及这其中session, serialize及unserialize引起的问题和所起的作用

Read the rest of this entry

这里说的乱码问题包括:

一,开发的页面出现乱码,

二,从数据库取值或插入时出现乱码,

三,phpmysql页面出现乱码。

Read the rest of this entry

 

江城风雨再轻狂,不须让,思又长。梦里无期,此生既何妨。
纵使霸王新生在,知后殇,还信邦。
绍华却逝人彷徨,些许伤,终难藏。
万语千言,只道愿康祥。
若是相逢会有时,是别来,当无恙。


两千风雨戚戚
几番甜蜜依依
夜梦金风再起
人非物是
莫道那时不羁

 

问题(需求):

1. 每次打开第一页时,显示的记录不同。

2. 但是从第一页后的其他页面(第二页,第三页,。。。)返回第一页时,还是那个第一次打开第一页的那些记录

3. 每页记录不能重复

 

其实看起来很简单的一个问题,但是加上分页的要求之后,变得稍微有点复杂。

如果是随机从数据库取一条记录,最直接的方式,就是order by rand() limit 1:

Read the rest of this entry

,

 

好黑

 

我固执地不去扳开关

因为我记得有一根蜡烛在记忆的某处

它曾给我带来过光明和希望

所以我固执地在黑暗中找寻

我相信它能给我带来心灵的慰藉

多过电流带来的亮度

 

Read the rest of this entry