August F.Y. Chao

Archive for 2009

Jquery UI Dialog Close within iframe

In 02 備忘錄 on 七月 29, 2009 at 7:26 午後

JQuery UI dialog close

December 17th, 2008 Posted in Web 2.0

We have a lot of situations to close a JQuery UI dialog from the dialog itself other than using the default close button. But the fuction dailog(”close”) will not work from the iframe since JQuery doesn’t support cross-window operations.

I am loading a Jquery UI dialog and inside it an iframe to show a form. After posting the forum via ajax I analyze the response and want to close the dialog (born from the parent window) or need to close the dialog when clicking on a “Cancel” button.
I have solved this problem by creating a method on the parent window that will close the dialog and then call that method from the child window.

Cancel button & onclick code inside the dialog iframe

<input name=”cancel” type=”button” value=”Cancel” onclick=”$(parent.document).find(’#closedailog’).trigger(’click’);” />

Code in parent window

<input id=”closedailog” name=”closedialog” onclick=”$(’.ui-dialog-titlebar-close’).trigger(’click’);” type=”submit” style=”display:none”/>

Put the parent window code any where in the parent window. The code will just trigger the click event of the dialog’s close button and will work better than using the function dailog(”close”) function.

My first post on iPhone

In 01 論, 04 哀哀, 博班生活 on 四月 28, 2009 at 3:15 午後

真好,哈!

波蘭成學醫捷徑

In 04 哀哀 on 四月 20, 2009 at 9:06 am

如果真的行,就去當黑傑克就好了!
不然就還是老老實實的把一個道理搞懂,就不用怕考試了~

波蘭成學醫捷徑 葉金川:特權
民視 (2009-04-12 20:55)

留學波蘭的醫學生,回國行醫,現在醫術遭到質疑,衛生署決定要修法,以後留學美、日、歐盟等9大地區的醫學生,都要經過學歷認證,才能考照,衛生署長葉金川更直接了當的說,這些留學生是特權,根本不公平。波蘭醫師的醫術,引發網路論戰,衛生署看出爭議,決定修改醫師法,包含波蘭在內的歐盟、美日紐澳等9大地區,以後回國當醫師,都要經過學歷認證和實習,讓孩子到波蘭學醫的父母很擔心,說他們沒有走後門,孩子對波蘭有很深的嚮往。

請政府相信波蘭醫學生的實力,因為學歷認證的錄取率不到5%,對國外學醫的留學生來說,公平性存有疑慮,但衛生署已經定調,傾向不設落日條款,希望立法院這個會期就能通過。

國內學醫很競爭,現在看來,有錢到國外學醫,似乎也不再是捷徑。

(以下為工商服務)

Ads by Google
法鼓佛教學院 招生 www.ddbc.edu.tw
師資堅強 圖資豐富 校園幽雅 生活清淨98學年度學生學費全免 僧眾學雜費全免

(以上為好學校)

digital sanitation engineering: Sorting Python Dictionary By Value

In 43_A 學人精, 博班生活 on 四月 9, 2009 at 12:55 午後

Original Page: http://blog.modp.com/2008/09/sorting-python-dictionary-by-value-take.html

Here’s why another reason why you should blog all your technical problems and solutions. Sometimes someone finds a better way.

In my original sorting a dict by value entry, I said the best way is:

sorted(adict.iteritems(), key=lambda (k,v): v)

Turns out I’m wrong. Gregg Lind (aka “write-only”) replied to the article with a comment pointing to his performance notes. PEP 0265 has the “best answer” that is at least 2x faster:

from operator import itemgetter
sorted(d.iteritems(), key=itemgetter(1))

Thanks all!

My performance test is here:

#!/usr/bin/env python                                                           

import cProfile

def sbv0(adict,reverse=False):
    return sorted(adict.iteritems(), key=lambda (k,v): v, reverse=reverse)

from operator import itemgetter
def sbv6(d,reverse=False):
    return sorted(d.iteritems(), key=itemgetter(1), reverse=reverse)

imax= 10000
dmax = 500
D = dict(zip([str(i) for i in range(dmax)],range(dmax)))
cProfile.run('for i in xrange(imax): sbv0(D, reverse=False)')
cProfile.run('for i in xrange(imax): sbv6(D, reverse=False)')

Results are

Old Way:
5020002 function calls in 6.623 CPU seconds

New Way:
     20002 function calls in 3.920 CPU seconds

台灣必去的100個景點(20/100)

In 02 備忘錄, 43_A 學人精 on 三月 30, 2009 at 10:50 午後

還要加油!!! 目前只有 20/100 而以~ 真遜呀~

Read the rest of this entry »

關於「以一打十」這回事

In 43_A 學人精 on 二月 5, 2009 at 6:34 午後

我空手道一段
跆拳道2段
柔道差點黑帶
練過八卦掌~
懂一些截拳
但詠春不懂
但我知道截拳是詠春的延伸

代表詠春有一個地位在

但並不是說學詠春就一定強 要看個人怎麼運用

我就看過一個鑽研10幾年詠春的年輕人 和一個泰拳對打 詠春被打掛

版上都在討論1打10有沒有這種可能??

那我可以說 一定有這種可能

我就曾經在街上目擊 一打五

一台車停紅燈 後面一台車狂按喇叭(我也覺得後面那台很機車~明明就紅燈)

變綠燈了 前面那台就故意不走 應該是賭爛到喇叭聲

後來後面那台就下來五個年輕人 其中一個帶棒球棒 就圍那台車

最後那個人下來了 我印象很深刻 他的脖子很粗 (看就知道很耐打)

開打 不到3分鐘 全躺 他還講手機 似乎幫他門叫救護車

他用的是柔道 和一些關節技 我過去看躺的人 一個肩膀脫臼

一個手挽脫臼 一個抱肚(應該是肋骨) 兩個昏了 

一個練過實戰的 和沒練過的五個人打一定贏 就算來沒練過的10個人來也一樣

並不是練過空手道 詠春 太極拳 打架就一定贏 最重要還是實戰

葉問本身年輕就很愛比武 和李小龍一樣 實戰經驗不是我們可以理解

所以當葉問打掛10個空手道 我絕對相信

Read the rest of this entry »