HTML5 – Play sound/music with <audio> tag @ 1

Next: HTML5 – Play sound/music with <audio> tag @ 2

With HTML5, we can easily play audio file with the <audio> tag. Here is an example.

<html>
  <head></head>
  <body>
    <audio controls loop autoplay>
      <source src="music.ogg" type="audio/ogg" />
      <source src="music.mp3" type="audio/mp3" />
      Your browser does not support the audio element.
    </audio> 
  </body>
</html>

Continue reading HTML5 – Play sound/music with <audio> tag @ 1

對與錯的人生邏輯課

作者: Fernando Savater

這是一本哲學家爸爸寫給兒子的一本書。

每個人一生中都會不停面對新的挑戰、問題、環境等不同狀況,當面對這些狀況時我們不得不作出選擇,而大部份時間這些選擇都沒有很清晰的最佳答案,更甚者在選擇上往往充滿一些普世價值觀的衝突。

即使是最無私、最聰明的人亦未能肯定作出最善的決擇,更何況在價值觀被嚴重扭曲的現今社會生活的普通人。一個不重視倫理學的社會只會繼續禮樂崩壞。

“倫理學就是探求如何生活得更好的一種理智行為。”這裡的好不是你的屋子有多大或你的收入有多好,而是對自己、社會、人類共同體更善的生活。

記住不要以消極的態度面對每個人生的決擇,即使你放棄選擇也不能否認你擁有選擇的自由,因為放棄選擇也是一種選擇。所以沙特(Jean-Paul Sartre)說人是「被處以自由之刑」

作者: Fernando Savater

CSS – Hide broswer scrollbar

I am working on a website with content flying from the left to the center. When the animation starts, the horizontal scroll bar is shown and then disappeared as the animation completed. This causes a little shake on the content movement. A simple workaround is to disable the horizontal scroll bar by setting the body overflow-x to hidden.

body {
  overflow-x: hidden;
}

 

Done =)

Reference: StackOverflow – Disable browsers vertical and horizontal scrollbars

Drupal 7 – Customize region template file for specific content type

We can add preprocess function for regions such that we can add customization before rendering the region template file(.tpl.php).
Drupal 7 – Check if the current loading page is the node view page of a specific content type

Sometimes we may even want edit the template file(.tpl.php) for specific content such as a content type node view. In Omega theme, there are different regions and by default they will use the following template files.

<drupal>/sites/all/themes/omega/omega/templates

  • region--branding.tpl.php
  • region--content.tpl.php
  • region--menu.tpl.php
  • region--sidebar_first.tpl.php
  • region--sidebar_second.tpl.php
  • region.tpl.php

Continue reading Drupal 7 – Customize region template file for specific content type

Drupal 7 – Check if the current loading page is the node view page of a specific content type

I try to preprocess the content region of the Omega theme for a specific content type. So i have to check the content type inside the <subtheme>_alpha_preprocess_region(&$vars) function so that the preprocess modification only applies to that content type. In that case, we could make use of the menu_get_object() provided by the Drupal API.
Continue reading Drupal 7 – Check if the current loading page is the node view page of a specific content type

Drupal 7 – Disable certain regions by conditions using Context and Delta

We have talked about how to disable certain regions using the Context module.
Drupal 7 – Disable certain regions by conditions using Context

But seems that it may not work for certain themes and regions. Luckily, there is another module called Delta which could be served as an alternative. Delta not only could disable the region but it could alter any theme settings for specific context condition. Let’s take a look now.
Continue reading Drupal 7 – Disable certain regions by conditions using Context and Delta

Drupal 7 – Disable certain regions by conditions using Context

Context could help you to manage the layout. In the past, i would use the Page manager of Chaos Tool Suite and Panels to control the layout but now i have completely move to the Context module. You can decide which regions should be hidden.

However, i found that it may not work for certain regions and so i raise it in the Context project page. I will keep my eyes on it.
Context – Disable regions
Continue reading Drupal 7 – Disable certain regions by conditions using Context

Dream BIG and go for it =)