jQuery – Implement touch and gesture based interaction using TouchSwipe

Here is an example for a simple swiping implementation using TouchSwipe.

<!doctype html>
<html>
<head>
  <title>Eureka! - TouchSwipe Example</title>
  <style type="text/css">
    #box {
      background-color: green;
      width: 400px;
      height: 225px;
      line-height: 225px;
      text-align: center;
    }
  </style>
</head>
<body>
  <div id="box">Swipe here!</div>
  <script src="http://ajax.googleapis.com/ajax/libs/jquery/1.10.2/jquery.min.js"></script>
  <script type="text/javascript" src="js/jquery.touchSwipe.min.js"></script>
  <script type="text/javascript">
    $("#box").swipe({
      swipe: function(event, direction, distance, duration, fingerCount) {
        $(this).text("You swiped " + direction );
      }
    });  
  </script>
</body>
</html>

 

Done =)

Reference: TouchSwipe: a jQuery plugin for touch and gesture-based interaction

Drupal 7 – Fix the empty space below the Zen theme Page Bottom region

I was using Drupal Zen theme and found that there was a empty space below the Page Bottom region. To remove that space, try applying the following CSS on the wrapper <div>.

/* Fix the empty space below page bottom */
#page-bottom-wrapper {
  overflow: hidden;
}

Done =)

Reference: zen – Extra Space Below Footer in Drupal 7

陶傑 – 殖民地文官

英國撤出香港,留下一批英國人訓練的政務官、行政官、專家。他們如何面對一個中國化的香港,是「後殖民史」上另一場文明與野蠻的角力。

大衛連的「桂河橋」,探討英國行政人在第二次世界大戰期間,陷入日軍集中營之後的專業意志。英國的上司不在了,由阿歷堅尼斯主演的軍人,受日軍統治,日本人要他率領部下,建一座桂河橋,主角繞開了政治效忠的問題,只執着於專業的中立,在不凡處境,在艱難的時期,他只能將交付下來的任務做好。

到日軍失利,盟軍反攻,英美司令部與他恢復了聯絡,最新的任務是將桂河橋炸掉。阿歷堅尼斯也沒有選擇,不論桂河橋花了幾多心血建成,時勢變了,要你炸掉,你就要動手。

英國人為香港留下的文官,有一套英式的制度保障。英國自己沒有什麼廉政公署,因為英國文化沒有貪污的基因。廉政公署是英國人為中國人的民族性貼身訂造的,難得的是,也贏得中國人內心的讚美,雖然中國的「中紀委」也想模仿,但限於民族基因,永遠不可能學得到。
Continue reading 陶傑 – 殖民地文官

陶傑 – 頂撞了又如何

英國政府解密英中談判香港前途。港督尤德聲稱代表香港,隨英國代表團北上。中國的鄧小平說:香港發了幾多鈔票,沒有人知道。但華文傳媒報道:據說尤德當面「頂撞」鄧小平,說:我知道。

尤德在鄧小平面前講實話,不足為奇。中國人這個「頂撞」一詞,卻甚為趣致。

尤德沒有刻意「頂撞」誰,他只對中國鄧小平出於無知的說法,表示「不同意」。不同意就是不同意,彼此地位相等。但在中國人的語境裏,嚇死了,因為什麼「海瑞罵皇帝」啦、「十奏嚴嵩」啦、「彭德懷上萬言書」啦,凡此種種,並非「表達歧見」,而是下奴對上主的不敬,故曰「頂撞」。

尤德不是鄧小平的家奴。眼看鄧小平這個土包對香港的無知,尤德不跟你客氣,直言糾正,無所謂頂撞不頂撞。即使真的頂撞,又有什麼問題?

尤德在英中會議對鄧小平說了一個「不」字,在英語世界,不成為新聞。在中國人的奴才意識裏,尤德好像頂撞了他們的皇帝,犯了大逆罪。
Continue reading 陶傑 – 頂撞了又如何

Ant – Stop the script without failing the build

We can use the <fail> Ant task to exit the Ant script but this will fail the build.

Sometimes we may have some checking during the build such that it could exit peacefully without build failure in certain cases. So in this case, we can’t use the <fail> Ant task.

A workaround is to use the <if> Ant-contrib task to create a boolean variable and whether continue or not could be determined by checking this boolean in the <target> if attribute.

Here is an example:
build.xml
Continue reading Ant – Stop the script without failing the build

陶傑 – 拼爺

許多中國大陸人士不了解:英國殖民地管治時,為什麼你們香港人從來不曾要求民主?

這個問題,只要智商正常,都知道答案。二十年來,我是這樣教育(不錯,Educate)大陸的中國人:

如果你認為香港人也是中國人,中國人的民族性,確實不太熱衷什麼西方的民主,他們只需要一個「好皇帝」。

請閣下由歷史長河的角度來看:自從一八四二年,香港人一百五十多年,十分幸運,由維多利亞女皇開始,愛德華七世、佐治五世、愛德華八世、佐治六世,然後是伊利沙伯二世,香港人擁有過六位好皇帝。

香港人的好運氣,大陸中國人沒有:道光、咸豐、同治、光緒、袁世凱、毛澤東,不是暴君,就是平庸而低能的皇帝。你們千百年來祈求出現而沒有遇上的好皇帝,香港人一生下來就有了。你們今天還在「呼喚」的明君唐太宗、文景之治什麼的,香港人覺得不稀罕。只要有好皇帝,香港人也是中國人,還要什麼民主?
Continue reading 陶傑 – 拼爺

Dream BIG and go for it =)