Blog

  • Got to write something

    It has been a long time since my last post. Not because there is nothing to write, but too much to write on.

    • My trip to Zhangjiajie (张家界) and Fenghuang (凤凰)

    During Apr 16th and 19th, I was in Zhangjiajie/Fenghuang with my colleagues. It is an annual event when company acknowledges the employees\’ contribution in a fairly material way. For me, this trip is a tragedy:

    As the camera was brought to Europe by my wife, I borrowed a camera from Linghu. His camera was equipped with a 1G CF card, which surely was not enough for 3 days\’ shooting. So I bough a 4G CF card. Due to time constraint, I had no time to test that CF card and brought it with me. It turned out that this CF card was bad. After about 100+ pictures taken, the camera will prompt me saying Err CF. I took no pictures during this trip. What a horrible experience!

    When I returned home, I went to the shop and talked to the JS to swap a new one for me. Luckily, this time the CF card is working fine after dumping a lot of MP3 on it.

    As I said earlier, I am not very fond of natural scenes. Zhangjiajie is famous for its natural scenes. My mood is even deteriorated with the broken CF card. Anyway, when I reached Fenghuang, I felt better because it has some cultural landscapes. It is also the hometown of Shen Congwen (沈从文). So I bought 2 books there for my own collection.

    When I departed from Shanghai PVG to Zhangjiajie, the flight was delayed for almost 1 hour. But the return flight was even worse. I did not get to my home bed until 0400 hr the next morning. Tired and exhausted.

    One thing very remarkable was that at the dinner in Zhangjiajie\’s last night, the group had a wonderful team activity. Boys and girls sang songs in alternative turns and we did drank a lot of beers!

    • The earthquake in Yushu

    Just within less than 2 years, we experienced another national disaster. A huge earthquake occured in Yushu. This originally-unknown-to-most-of-us-city became the national and international focus.

    I felt deeply sorry for the lost lives. But as I had always said, there is no reason to exaggerate how brave we are in fighting against the catastrophe, how many people we managed to save out of the ruins. There is no winner in front of nature, especially in front of a natural disaster.

    WE SHOULD ASK OURSELVES: WHY THIS SHOULD HAPPEN? WHY NO ALARMS? WHY SO MANY PEOPLE DIED?

    and most importantly:

    WHO ARE THE PEOPLE RESPONSIBLE?

    The deepest sorrow brought by Wenchuan earthquake is not alleviated yet and now we have to face a similar situation again. Is there any kind of same root cause between the two, and with other natural, non-natural disaster? Are there someone really doing a serious investigation into it?

    • The volcano eruption in Iceland

    My wife SMS me when I was in Zhangjiajie that she may not be able to come back on time as most of the airports in Europe were stopped. I comforted her by saying that the situation will definitely become better and the interesting thing to say is that, in such a circumstance, it is safer to stay on the ground than flying in the air!

    Later, I heard that the flights are somehow resumed. So I am expecting my wife to come back as soon as possible. Dear LPP, I miss you, very much.

    Ironically, the earth during these days are greener than it used to be because there should have been much more carbon-dioxide released by airplanes during these days than that relesed by the volcano itself!

    =======

    So much for today. When I really want to write something, I will. I promise.

  • Read Gmail in two panes

    Haha, this is a very interesting trick that it can make you read Gmail in browsers in two panes. The left is the message list, and the right is the message body.

    Normally, when you start to read Gmail in your browser, it looks like this:

    It sometimes is very annoying as you lose the power to navigate from one mail to another mail directly. However, the following trick will help you out in FireFox:

    • Download and install this extension: User Agent Switcher;
    • In Firefox (after restarted), select Tool and you will see a new menu item saying Default User Agent;
    • Create a new User Agent named to whatever you like;
    • The User Agent of this newly created one must be set to Mozilla/5.0 (iPad; U; CPU OS 3_2 like Mac OS X; en-us) AppleWebKit/531.21.10 (KHTML, like Gecko) Version/4.0.4 Mobile/7B334b Safari/531.21.10;
    • Now switch to this new UA and go to your Gmail.

    The UI of Gmail will look like this:

    You may notice that the UA set above is actually simulating iPad. That\’s right! 2-pane Gmail reading is actually firstly implemented in iPad!

    This article is sourced from Download.com. The original URI is: http://news.cnet.com/8301-27076_3-20001675-248.html.

    If you are using Safari or Chrome, you may want to take a look at the above URI as it tells you how to tweak your Safari and Chrome to read Gmail in two panes.

    Enjoy!

  • I need to remember my password… and username!

    I have so many passwords to remember, and usernames. Sometimes I just forget whether or not I have registered at a site, and if yes, what is my password and username combination.

    I used to trust my memory very much, trying to remember all the passwords and usernames in my brain. But recently, I found it quite disturbing as I am aging and my memory is not as good as it used to be.

    Luckily enough, I found this FREE password manager: MyPadLock. I can just remember ONE password and all others will be stored (encrypted) in a single location.

    mypadlock.jpg

    It is a very good program. I love it.

  • An Android application with map

    I had read a few tutorials on how to develop an Android appication with map display. Today I had actually built one. I would like to summarize the key points/steps in making this application work.

    1. First of all, get an Android Map API Key from Google.

    This actually involves two steps. Firstly, you will have to create a key store to sign your Android application. This is quite easy and straightforward. Secondly, apply an Android Map Key from Google: http://code.google.com/intl/zh-CN/android/maps-api-signup.html. To make this work, you have to know where is your key store file is located (as created in the above step) and also have the JDK tool named keytool. From the command line, type:

       keytool -list -keystore the-path-to-your-key-store-file

    It will prompt you to enter the password to the key store and will generate a MD5 finger print for this particular key store file. Copy this MD5 finger print to the above URI and Google will give you the Android Map API Key immediately. It is strongly suggested to save this Key information.

    1. Create an Android application.

    Note: It must be created with target set to: Google APIs. You should not set the application target to Android x.x or it will not be running properly.

    Note: The target of the AVD that runs the map application must also be set to Google APIs.

    The coding of the application is actually quite simple. There are only two points to be highlighted:

    1. The application must be granted ACCESS_FINE_LOCATION and ACCESS_INTERNET permissions;
    2. The mapview controll used in the view must be provided with the API key generated in Step 1. It will look something like this:
    <com.google.android.maps.mapview android:apikey="your" android:clickable="true" android:enabled="true" android:id="@+id/myMapView" android:layout_height="fill_parent" android:layout_width="fill_parent" api="" here="" key=""></com.google.android.maps.mapview>

    With these settings, the map application can eventually run successfully.

    However, in my implementation, the map shown in my AVD is only grids, no actuall maps at all. But in real machine (mine is Nexus One), the application is running correctly.

  • My plan in FY1011

    In my previous post published around a year ago, I had listed down 3 major things that I would like to complete in FY0910:

    • To complete the re-design of my rsywx.net; Status: Done;
    • To complete the development of goushipi; Status: Done but not able to host it because: 1. My personal web server has been blocked; and 2. my current host does not support Python (in particular TurboGears);
    • To complete the translation of one book. Status: In progress. However, I have finished the translation of another book to Chinese.

    So for this year, I will make another 3 major tasks for me to accomplish:

    1. Finish the translation of the book mentioned above;
    2. Develop a good Android program;
    3. Stay healthy.
  • Now an era is over (or just began?)

    Google.cn is now redirected to google.com.hk. It is a clear message from Google, which I quote:

    On January 12, we announced on this blog that Google and more than twenty other U.S. companies had been the victims of a sophisticated cyber attack originating from China, and that during our investigation into these attacks we had uncovered evidence to suggest that the Gmail accounts of dozens of human rights activists connected with China were being routinely accessed by third parties, most likely via phishing scams or malware placed on their computers. We also made clear that these attacks and the surveillance they uncovered—combined with attempts over the last year to further limit free speech on the web in China including the persistent blocking of websites such as Facebook, Twitter, YouTube, Google Docs and Blogger—had led us to conclude that we could no longer continue censoring our results on Google.cn. … Figuring out how to make good on our promise to stop censoring search on Google.cn has been hard. We want as many people in the world as possible to have access to our services, including users in mainland China, yet the Chinese government has been crystal clear throughout our discussions that self-censorship is a non-negotiable legal requirement. –Source: http://googleblog.blogspot.com/2010/03/new-approach-to-china-update.html

    The motivation for this move is straightforward: The cyber attacks from China on those Gmail accounts, and the non-negotiable legal requirement for self-censorship to operate in China. The result is also clear: > We believe this new approach of providing uncensored search in simplified Chinese from Google.com.hk is a sensible solution to the challenges we\’ve faced—it\’s entirely legal and will meaningfully increase access to information for people in China.

    ===========

    Well, there are still certain logic inferences I have to make myself clear. The simplest fact that can be established is that: there WAS censorship in Google.cn search results in the past. Google is fully aware of this. I am also not THAT naive to believe that the cracking on Gmail accounts just occurred this once in last December. My questions will be: why Google decided to pull out NOW? What is acutally Google trying to defend and preserve? Well, it is obviously not the censorship thing as we all know Google.cn has been running under censorship for years. It is the cracking issue, aka, intrusion to personal privacy that Google really wants to defend. And there is no crystal clear relationship between censorship and cracking! I mean, cracking does not necessarily mean a search engine should run under censorship or un-censorship! Will the move of Google.cn to google.com.hk help to stop the cracking? I don\’t think so. Besides, the Google mail service is all the while being served outside of China. THE LOGIC SIMPLY DOES NOT FOLLOW.

    ==========

    I can\’t stop myself from imaging this scene inside of my head. It is from the famous trilogy by Italo Calvino Our Ancestors: The Baron in the Trees (I nostri antenati), that wonderful, admirable, unique boy: Kozmo (I am not if my spelling is correct). He decided to move onto the tree and never touch the ground again after some quarrel with his family. Well, I do believe, Kozmo\’s move is more logical.

    =========

    Nevertheless, I still admire Google\’s boldness in making this decision. A uncensored search engine will allow me to explore more when I want. It is definitely a right thing to do for any search engine. We are now more and more dependent on search engines and the sites a good search engine recommends when we key in a phrase. This is remarkable. As my wife had correctly pointed out, after my purchasing of one dictionary and one encyclopedia, Who is reading these books now? Yes, she is absolutely right. I am depending on a good search engine, in most of the cases which is Google, to provide me the righteous results. Now I am even happier to learn that it is not censored anymore. Being transparent is the first and perhaps the most important step to take to Be No Evil. Censorship is evil by itself so applying censorship is helping to do evil. And in Chinese, we have an idiom for that: 为虎作伥 , which can be translated as: after being eaten by a tiger, you still serve the tiger to help him to hunt for more innocent people. Transparancy has never become so important in such a enclosed, corrupted land. It has proven itself to be a great and efficient tool. It just reminds me another theme from another famous writer, Milan Kundera. In his novel Immortality, when at the end, he wrote about how Agnes yearned to hold a piece of Forget-Me-Not in her hand as the last, un-noticed symbol of beauty. Transparent is beautiful.

  • Is Google.cn really going to pull out China?

    A BTer just said in The group that Google wiil no later than today to announce it’s decision to pull out its China operation. I am keeping a view on it.

    Nevertheless, it will mark a giant milestone in China’s Internet (or, to be more precise, Intranet) history.

  • 杯具的一本词典

    最近刚刚买了一本词典:Oxford Advanced Learner\’s Dictionary

    我对牛津词典一向是很信任的,所以在当当上也没有做太多的比较,就买了这本。

    到手后看了一下,发现这本词典的名字很具有误导性。

    作为一个Advanced Learner,作为一本给Advanced Leaner的词典,这本词典中居然没有下面这几个单词:

    • sphygmomanometer:血压计
    • acrophobia:恐高症
    • agromania:旷野独处症

    但是,它有claustrophobia(幽闭恐怖症)。

    我只是随便查了几个而已。BTW,这几个单词,我都是在Word Power Made Easy这本书里学来的。

    显然,我对Advanced Learner的理解和牛津对其的理解完全不同…… 杯具了……

  • I do solemnly declare…

    The rumor came about a few days ago: Google will pull out its China operation and the site dedicated for China.

    Well, the final result is not out yet. But I would like to make my personal statement here:

    I am trying very, very hard not to trigger the G-point of the fcking GFW and thus my blog is full of techniques, books, my lifes, movies, musics, travels, etc. Strictly, no political stuffs. Yet, I am still becoming the victim of this fcking censorship: my personal server was blocked because GFW blocked access to port 80.

    I can try another port, say 1984 or 1989. But fewer people will be able to do that just to get access to my site. I have to transfer all my files and web service to outside of the wall.

    ===========

    Now, since the censorship is actually hurting a used-to-be good people. I decided to be evil. And now, coupling with the declaration from Google, I hereby make the following statements:

    1. If Google pulls out of China – you know what I mean – I will stop my blog composition in Chinese and will solely compose my blog in English;1
    2. As I have already been hurt by trying to be good, I will be evil in your (the GFW\’s) eyes. I am already hurt, you can\’t hurt me further.

    1. Note on 2022/03/21: As you can see, most of my blogs are still in Chinese.  

  • CodeIgniter和Flex的结合

    BT话痨群的后台中有一个彩蛋,只有资深BT才知道。

    这个彩蛋是肾上开发的,目的是测试CI和Flex(Flash)的结合。

    在这个彩蛋中,解决了一下几个问题:

    • 用CI生成Flex需要的数据(XML格式);
    • 用Flex的HTTPService来获得数据并呈现;
    • 用CI来包含生成的SWF文件并最终以Nice URI呈现。

    一、用CI生成Flex需要的数据(XML格式)

    function xml_weekday()
    {
            $timespan=time()-mktime(8,0,0,2,22,2010);
            $this->load->model('Sitemodel');
            $data['qd']=$this->Sitemodel->getNoticeCountWeekday();
            $this->load->view('welcome_xml_weekday_view', $data);
    }

    请注意,我这里用了CI中控制器(Controller)来实现数据的获得,而且复用了models里的方法。这样做的好处是,在Flex中可以用一个URI来获取数据。 数据的输出是用load->view实现的,而在那个view文件中,我只是简单的按照XML格式输出数据而已:

    $nl=n;
    echo '<?xml version=1.0 encoding=utf-8??>'.$nl;
    echo '<catalog>'.$nl;
    foreach($qd as $i)
    {
        $nc=$i->nc;
        $dw=$i->dw;
        echo <notice dw="$dw">.$nl;
        echo <count>$nc</count>.$nl;
        echo </notice>.$nl;
    }
    echo '</catalog>';

    二、用Flex的HTTPService来获得数据并呈现

    Flex端的编写相对简单。关键代码如下:

    <application initialize="weekday.send()" layout="absolute" xmlns:mx="http://www.adobe.com/2006/mxml">
        <httpservice id="weekday" url="http://www.?????.com/status/index.php/welcome/xml_weekday"></httpservice>
        <panel color="0xffffff" height="300" layout="vertical" title="?????.com站点统计" width="600">
            <areachart color="0x323232" dataprovider="{weekday.lastResult.catalog.notice}" height="100%" id="chartStatus" showdatatips="true">
                <horizontalaxis>
                    <categoryaxis categoryfield="dw"></categoryaxis>
                </horizontalaxis>
                <series>
                    <areaseries displayname="话痨数量" form="segment" yfield="count"></areaseries>
                </series>
            </areachart>
        <button click="weekday.send()" counts="" label="Get"></button>
        </panel>
    </application>

    关键是使用HTTPService部件来获得数据。它的URL属性由于在第一步的准备工作,可以是一个很漂亮的URI。

    三、用CI来包含生成的SWF文件并最终以Nice URI呈现。

    再次回到PHP中,在controller中我创建了一个action,来调用对应的嵌入了SWF的模板:

    <embed align="middle" allowscriptaccess="sameDomain" bgcolor="#869ca7" height="100%" loop="false" name="main" play="true" pluginspage="http://www.adobe.com/go/getflashplayer" quality="high" src="http://www.?????.com/status/system/application/views/bspmq.swf" type="application/x-shockwave-flash" width="100%">
    </embed>

    这个文件基本上可以由Flex自己生成,只要稍作修改以符合要求即可。 在BT群话痨系统中,你可以用http://xxxxxxxxxxxx/status/index.php/welcome/swf 来看到效果: