2009年7月12日星期日

Python 多行程式碼註解小技巧   [+/-]

Ticore's Blog

最近稍微開始看一些 Python 的語法
其實 Python 語法沒有很複雜
與一般語言最大不同大概就是在於程式碼縮排是強制的
也沒有直接支援多行註解,一般好像都是採用多行字串宣告當作註解用
提到註解~
記得以前分享過的 ActionScript 多行程式碼註解小技巧
那就舉一反三,在 Python 語言上也如法泡製一下

首先是快速的打開或是關閉整個區塊的程式碼
這樣是多行註解的

#'''
print "Multiline comment block"
#'''

只要拿掉一個 #,就可以快速的打開整塊多行註解

'''
print "Multiline comment block"
#'''

再來進階版,快速的在兩個區塊程式碼作切換
以下程式碼有分 Block 1, 2
這樣是打開 Block 1,關閉 Block 2

#'''
print "Block 1"
'''
print "Block 2"
#'''

只要拿掉一個 #,就會變成
關閉 Block 1,打開 Block 2
很方便吧!

'''
print "Block 1"
'''
print "Block 2"
#'''

相關連結:
ActionScript 多行程式碼註解小技巧

Read more...

2009年7月6日星期一

Firefox 3.5 render iframe bug   [+/-]

Ticore's Blog

前一陣子 Firefox 3.5 正式發表了
增加許多新的特色功能
不過都還沒來得及測試新功能
使用上就已經先發現了 Firefox 3.5 的 Bug
主要是在渲染 Flash Plugin 與 iframe 重疊畫面時不正常

假如頁面上同時有 flash 與 iframe 內容
將 flash html 屬性 wmode 設為 opaque
並且用 CSS z-index, position 將 iframe 疊在 flash 內容上
此時用滑鼠來回移動選擇 flash TextField 內的文字
就會發現 iframe 內容閃個不停

Firefox 3.5 Bug demo html:

<html><head>
<meta http-equiv="Content-Type" content="text/html; charset=utf-8" />
<title></title>
<style>
#flashContent {
 position: absolute;
 z-index: 1;
}
#iframe {
 position: absolute;
 width: 400px;
 height: 100px;
 top: 100px;
 left: 150px;
 z-index:2;
}
</style></head>
<body onload="document.getElementById('FlashID').focus();">
<div id="flashContent">
    <object id="FlashID" type="application/x-shockwave-flash"
          data="flashMovie.swf" width="400" height="300">
      <param name="wmode" value="opaque" />
    </object>
</div>
<div id="iframe">
  <iframe width="400" height="100" src="iframe.html"></iframe>
</div></body></html>

正常的畫面:

渲染錯誤畫面:

實際執行時,用滑鼠慢慢的選取 Flash 文字
就會發現這兩種畫面不斷交替閃爍

以上的 Bug 主要發生在 windows 版本的 Firefox 3.5
在 Mac, Ubuntu 上都沒有遇到這樣的情況

Firefox 3.5 iframe bug sample file

Read more...