CNAME redirect without domain provider support

Because of  domain provider limit, I cannot customize some URL redirection, then how to use URL redirect without DNS cname redirection support? It’s easy, for example, in this website, there is a fast url to redirect my customized admin address. Assumpt the fast path is “/cname”, then I will add following little changes to support CNAME like function in DNS.

1. Add new directory “cname” in my website root path.

2. Add one new “index.php”(default page file) into “cname”. Continue reading

One test about Singleton mode programming in a interview

What a pity! Because of being too nervous, I made mistakes on this little test! However, it’s really not a very relaxed atmosphere for me, and bad time for test! The problem is about,

“Please design a Singleton mode template for a class .”

When the interviewer checked my paper, he tipped me that my program can not guarantee only one instance of class, but my brain were thoroughly in a null at that time and didn’t get any better changes.

Now, I give my whole codes corrected as a lesson.

template<class T>
class Singleton
{
public:
    Singleton()
    {
    }

    virtual ~Singleton()
    {
    }

    static T* create()
    {
        pthread_mutex_lock(&_mutex);
        if (me == NULL)
            me = new T;
        pthread_mutex_unlock(&_mutex);

        return me;
    }

    static void destroy()
    {
        pthread_mutex_lock(&_mutex);
        if (me != NULL)
        {
            delete me;
            me = NULL;
        }
        pthread_mutex_unlock(&_mutex);
    }

private:
    static T* me;
    static pthread_mutex_t  _mutex;
};

template<class T>
T* Singleton<T>::me = NULL;

template<class T>
pthread_mutex_t Singleton<T>::_mutex = PTHREAD_MUTEX_INITIALIZER;

My test class and other codes are here,

class A
{
public:
    A()
    {
        Foo();
    }

private:
    void Foo()
    {
        std::cout << this << std::endl;
    }
};

int main()
{
    A* pa = Singleton<A>::create();

    A* pb = Singleton<A>::create();
    Singleton<A>::destroy();

    return 0;
}

class A is the test object, and in its constructor, its address will be printed. Unless “destroy()” function is called,  ”Foo()” function will only be called once in this Singleton mode. In the end, I remembered my faults in the interview mainly was – do not use “static” for function “create” and “destroy” in Singleton template class, of course the same problem  for private member “me” and “_mutex”.

I’m really not an active tester, but active doer.

Looking into ARM: 我为什么离开ARM加入MIPS?

本文是ARM原中国区技术行销经理Fei Zheping所著,从中我们大致可以了解ARM相关的发展和历史情况,也可顺便知晓些MIPS在国际国内的发展形势。很不错,不仅在其介绍ARM和MIPS的过去以及现在,更有对同是30岁人的一些思考的认同和共鸣。

几星期前刚递交辞职信的时候,很多朋友都表示了理解,他们都知道,经过近8年的努力工作,经历了ARM从无到大的整个本土化过程,我在ARM确实已经没有任何成长空间了。过去1年多时间里,我的生活是比较轻松的,顺便向认识的各位朋友汇报一下,我借此也安了家、结了婚,可爱的女儿到今天也正好11个月大了。古语云三十而立,三十过去好几年以后俺也终于立了家,不过在事业上,则还是其路漫漫。虽然安逸的生活人人向往,但现在我还不到那个阶段:我知道,应该是需要改变的时候了。

CHANGE, WE NEED

证明“Change I Need”似乎不费吹灰之力,然而,对于选择加入MIPS,论证过程可能就需要一点篇幅了,很多好友得知这个消息后,都来关切地询问个中的缘由。说实话,当1年前某位猎头朋友来第一次试探我的时候,我的第一反应也颇觉得有点意外。不是吗?就当时的市场境况来看:

ARM拥有1700多员工,5亿美金左右的年营收(其中处理器部门占60%左右),市场地位蒸蒸日上,在Intel的打压下知名度反而节节上升。

MIPS全球只有190名左右员工,年营收7千多万(全部是处理器部门的),刚刚经历了Chipidea并购又放弃的挫折,好不容易才回到扭亏为盈的正轨,在传统的网络和数字家庭市场里波澜不惊,在移动和消费市场上则乏善可陈。毫无疑问,在公司层面的比较上,ARM的形势好过MIPS很多。

不过,说实话,跳槽,或者选择一份工作的时候,我想绝大多数人应该都是从个人角度来考虑衡量的吧?很多人希望找一个形势好的公司,其实质无非也就是希望得到一个更好的环境、更大的平台、更多的资源支持、“可能”更好的收入、“可能”更容易的工作难度(比如对市场和销售人员来讲,东西更好卖一些,呵呵)等等。多少经历过几年职场风雨的人,都不会太混淆公司和自我之间的区别——如果你不是老板,这个公司就不是你的——相当程度上,个人的发展前景或发展计划,跟公司形势之间不一定是紧耦合的。能够把自己完全压上去的公司,能够对之付出家一般感情的公司,在这个星球上,应该是越来越少了吧?——如果你是一位职场菜鸟,万一看到这里的时候,也不要灰心叹气,就我自己来说,也是经过很多年的历练之后(n>7),才想明白这点的,而且现在回忆起以前那么多年把人家公司当成自家公司一样拼命打拼的经历,还是很沉浸的,不后悔,我认为这是一个成长的过程。

在这里我要非常坦诚地说明,从ARM跳到MIPS,我是有非常多的个人考虑驱动的,有些个人的想法可能说出来有点直白,有些表达可能会有点口语化,应该都无妨吧?牵涉ARM与MIPS的一些比较评论,尽量不以屁股决定脑袋,绝对不会涉及商业机密。

(1)我在ARM已经头顶玻璃,没有什么新的发展空间了,这点一开始就讲过了。
(2)MIPS的机会
MIPS是星球上第一个RISC研究项目的结晶,由计算机大牛John L. Hennessy领导的小组早在1981年就开始设计。关于这位牛人John,大家可以参考最近的一篇网文《从一个微处理器强人的传奇经历谈本土处理器创新》(http://www.eetrend.com/news/100025470 ),文章主角虽然是另一个处理器同行公司Tensilica的老板Chris Rowen,对于Chris的老师John着墨不是很多,但是已经足够让我们一窥其斑。从技术甚或学术角度来看,MIPS大概是最最干净和有效的RISC架构体系了(我在ARM的时候其实没认真研究过MIPS的架构细节,这一点是某位真正成功设计出大量产CPU,并对ARM和MIPS做过深入研究的朋友告诉我的,当我还在ARM时,他见我一次就抱怨一次)。全世界学习处理器架构设计的人,无不以MIPS作为学习和研究目标的。至今在处理器本身的许多技术路线上,也要领先ARM 两年以上,比如多处理(多线程和多核)、64位等等。不过,在商业上,ARM架构比MIPS成功许多,以年化的收入来衡量的话,ARM收入比MIPS大约多4倍,以出货片数计的话,差距更大(大至约9-10倍)。 Continue reading

Why your Acer notebook battery stay shorter time in Linux than in Windows?

As a Linux hobbit, you may find that your Acer notebook(maybe other notebooks as well) stay shorter in lion power with an Nvidia VGA chipset and one integrated VGA chipset in your CPU. And it seems you always work under standalone Nvidia vga card, cannot switch to integrated one.  This is just a guess for me at first.

But after you installed dual boot system, in Windows 7, for example, your battery tips longer time to use.  That’s because Nvida vga driver can not support Linux, in other word, Nvidia do not provide you a solution to switch between standalone VGA and integrated one.

This thread “NVIDIA Optimus独显集显切换将支持Linux”  verify my guess, and bring me one good news, you can later enjoy fun under Linux to support automatically switch between vga cards by Nvida optimus tech.

Flash camera show: let your body drive

http://www.208-lesite.peugeot.fr/#1_A9_THE_SECRET_REVELATION

This is just a media show for Peugout. But the technique used here about photo taking is very wonderful. You are interactive with the picture on your screen. Once you played the game after clicking “Entrez”(i.e, “enter” in English, I guess), u will get your show in the end.

Of course, if you decline opening webcam online, you cannot continue. Continue reading

Hello, WordPress!

Though, being a PHP programmer long times ago. But little chance to touch some open source softwares in PHP language, like wordpress. After I created this PHP-based site, manufactured by wordpress, I’m shocked by some features.

Yeh, you know the administration panel of wordpress is powerful. Behind this, modulization techniques for web programming are funtastic. Continue reading