Rails – Integrate Autotest and RSpec in Linux

I am learning Rails 3 @ Ruby on Rails Tutorial by Michael Hartl. A very nice and detail tutorial with many examples for beginners. Highly recommended.

But i got some problems when i tried to setup the Autotest for the RSpec framework. Autotest is a continuous testing tool which run the test suite automatically based on the files you have changed. RSpec is a Behavior Driven Development (BDD) framework for Ruby. After a few hours of struggling, i finally made it work.

1. Create a new Rails project without the default Test::Unit framework.

  • rails new sample_app -T

Continue reading Rails – Integrate Autotest and RSpec in Linux

Drupal – Add Configurable Values to Block

In previous posts, we created a custom module implement the hook_block() function.

 

We haven’t implemented the block configurable values. Let’s do it now.

We want the block to store a number and a string. so we add these 2 fields in the block configuration page. Here is the new custom.module. Continue reading Drupal – Add Configurable Values to Block

Drupal – Show Database Data in Block by SQL

Previous related posts:

 

The above posts show you how to create and customized the content of a block. Sometimes, we may need to show some database data in the block. So we need to write a SQL. For example, i want to show a list of node titles and the corresponding url links of the Song content type.

1. Modify the custom.module Continue reading Drupal – Show Database Data in Block by SQL

笑傲江湖

作者: 金庸

之前看完金庸小說都沒有很強烈的感覺,但今次就有另一番滋味。
何謂正派? 何謂魔教? 正派中不乏卑鄙無恥,陰險奸詐的小人; 魔教中亦可以俠義之士。

令狐沖不像郭靜,沒有拯救世界之抱負,係人心險惡的江湖上寧可過著瀟灑自在過自己喜歡的隱士生活。真正地笑傲江湖。

想到自己常常與朋友討論社會問題時感覺的孤獨,都會覺得如果可以像令狐沖一樣笑傲江湖其實也不錯。但我仍想堅持自己的所相信的,它應該可以低受時間的洗禮。

係後記中金庸先生提到寫笑傲江湖的時候正值文化大革命,而係故事中並沒有交待背景年代,因為這年代其實係人類歷史中從來就沒有消失過。(看到這裡真的很感動)

Drupal – Customize Block Template File

In the Drupal template architecture, you can customized a specific block just by creating a .tpl.php file in the theme folder. For example, the block.tpl.php determine all the block layout in your Drupal theme.

We can also override the design layout of the block in our customized module which we created yesterday(Drupal – Create a Block). First we have to create the corresponding .tpl.php for our block. In this case, we need a block-[module-name].tpl.php.

So create the block-custom.tpl.php

<strong>Hello World</strong>
<!-- get the block details from the $block variable -->
<p>Subject:<?php print $block->subject ?></p>
<p>Content:<?php print $block->content ?></p>

Continue reading Drupal – Customize Block Template File

Drupal – Create a Block

You can create your own block and customized its content. Drupal provides the hook_block() function for block creation. We can implement this function in our customized module.

1. Create a customized module by creating the following files.
<drupal_root>/sites/all/modules/custom/custom.info

name = Custom module
description = A custom module which create a block
core = 6.x

Continue reading Drupal – Create a Block

Drupal – Using Node Reference in View

Sometimes we may want to create mapping in content types. Say, i created an Artist and a Song content types. when i select an artist, i want it to select all the songs which belongs to that artist also. In that case, we need a node reference field in the Artist content type such that every song is mapped to an artist.

So first, create the Song content type with default fields. Then create some songs and fill in the lyrics as node body. Continue reading Drupal – Using Node Reference in View

陶傑 – 中國父母從未想子女成為領袖人才

美國大學為什麼是四年?
 

聖母大學的高層來香港,會見少數精英家長,介紹大學的幾個獎學金名額。
聖母大學在芝加哥市外一百五十公里,環境蒼葱,成立於前清道光鴉片戰爭割讓香港之後六年,歷史悠久。校舍為歐洲舊建築,十月楓紅、圓塔、尖頂、青石小路,好似童話仙境。
大學校長說:聖母大學並非只頒授學位,全美排名第十七位,培養領袖人才。
 

我聽了這句話,嚇了一跳,私下警告校長:來到遠東,要尊重中國國情。此地人士送子女受教育,總的來說目的是為他們培養一技之長,從未想子女成為「領袖人才」。
中國的「領袖」,不是民主的美國,首先必不是「人才」,流血出位,逆向淘汰,不是槍桿子暴君,必是庸才。第二,領袖第一代靠暴力,到後來必屬欽點,中國千年以來的四大書院,為京師培養讀書人,絕不敢在書院裡教出幾個想奪位的皇帝,否則即是抄家誅九族的大逆死罪。所以,香港特區的「元首」,也不敢以領袖自居,而自稱「做好呢份工」,是打工仔。 Continue reading 陶傑 – 中國父母從未想子女成為領袖人才

Dream BIG and go for it =)