2014年3月11日 星期二

學HTML, CSS, JS, jQuery的好幫手

學HTML, CSS, JS, jQuery

朋友和我分享的學習網站,做得很酷,在此跟大家分享!
http://ccsp.ntumobile.org/webdev/html.html#/

2014年3月5日 星期三

Git 恢復

Git 恢復

復原已被更動的檔案

Changes not staged for commit:
  (use "git add <file>..." to update what will be committed)
  (use "git checkout -- <file>..." to discard changes in working directory)

        modified:   benchmarks.rb
$ git checkout -- benchmarks.rb
$ git status
On branch master
Changes to be committed:
  (use "git reset HEAD <file>..." to unstage)

        modified:   README.txt
在上述文字可看到該變更已被復原。


2014年2月9日 星期日

網頁嵌入PDF、影音、聲音、Flash、youtube

網頁嵌入PDF、影音、聲音、Flash、youtube


要把影音、聲音、Flash以及PDF檔嵌入網頁中,embed語法是通用的語法。如下:

<embed src="檔案位置網址" width="寬度" height="高度"></embed>

參考資料:
http://lmcmultimedia.blogspot.tw/2012/06/pdfflashhtml.html

2014年2月7日 星期五

html anchor

Anchor

An anchor with an id inside an HTML document:
<a id="tips">Useful Tips Section</a>
Create a link to the "Useful Tips Section" inside the same document:
<a href="#tips">Visit the Useful Tips Section</a>
Or, create a link to the "Useful Tips Section" from another page:
<a href="http://www.w3schools.com/html_links.htm#tips">
Visit the Useful Tips Section</a>

2014年2月1日 星期六

講英文卡住怎麼辦?學會這5句保證救援成功 !轉自:「商業週刊」

講英文卡住怎麼辦?學會這5句保證救援成功

常聽見老外和老外之間的談話,沒聽清楚就問對方Pardon? 而我們如果沒聽清楚、沒聽懂別人的英文,就會開始怪自己差,搞得人人有種英語原罪似的。沒想到、講不出來,在溝通中是很正常的事,去掉英文的罪惡感,是英文進步的第一步。一時想不起,直接說,不要支支吾吾。怎麼直接說呢?
1.It's on the tip of my tongue...(話就在我嘴邊,什麼來著......tongue是舌頭,tip是尖端,tip of my tongue多傳神的畫面,就要想起來,但吐不出來。
2.How shall I put it?(我該怎麼說好呢?)有時候是沒想到,不知怎麼措辭,可以用這句;有時候是別人問你一個問題,你不必直接給答案,理一下思緒,就用How shall I put it?
3.What's the word for it...(這個怎麼說來著......剛好卡在一個單字,就用這句,停頓一下,旁邊如果有懂了的人,就會幫你補上這個字。
4.Now, let me see.(讓我想想。)講到一半找不到字,直接說Now, let me see.對話中停下來想想,讓對方適時插入也會讓對話更豐富。
5. Now, where was I?(我剛說到哪兒了?)老美說話中斷之後,要繼續話題,卻忘了說到哪裏,常會自言自語說:Now, where was I? Oh, yes(嗯,我剛才談到哪裏?啊,想起來了。)
有時候沒想起,你的聽眾就會幫你補充訊息,注意是where was I,用過去式動詞,要幫人補充的話,就用過去進行式。例如:
A: Now, where was I ?
B: You were telling me about your travels in Europe.
http://www.businessweekly.com.tw/KBlogArticle.aspx?ID=6075&pnumber=1

2014年1月21日 星期二

difference between two strings in python

import difflib

s1 = "abcdefghijklmnop"
s2 = "abcdefghi"
s = difflib.SequenceMatcher(a=s1, b=s2)
for block in s.get_matching_blocks():
    print "match at a[%d] and b[%d] of length %d" % block

ref. http://stackoverflow.com/questions/1209800/difference-between-two-strings-in-python-php

2014年1月20日 星期一

Python sort dic by keys, values. sort list

Python dict sort keys, values

>>>numbers = {'first': 1, 'second': 2, 'third': 3, 'Fourth': 4}
>>> [key for key in sorted(numbers.keys())]
['Fourth', 'first', 'second', 'third']
>>> [value for value  in sorted(numbers.values())]
[1, 2, 3, 4]

#################################################

sort by key:
>>> dic={'hello': 1, 'aa': 2,'b':3}
>>> sorted(dic.items())
[('aa', 2), ('b', 3), ('hello', 1)]
------
>>> sorted(dic.items(),key=itemgetter(0))


sort by values:
>>> dic={'hello': 1, 'aa': 2,'b':3}
>>> sorted( dic.items(), key= lambda x:x[1] )    #dic.items()取出了x=[key,value],sort 是用x[1]
[('hello', 1), ('aa', 2), ('b', 3)]
>>> sorted(dic.items(),key=lambda x:x[1],reverse=True)
[('b', 3), ('aa', 2), ('hello', 1)]
------
>>> sorted(dic.items(),key=itemgetter(1))

##################################################

>>> students = [('john', 'A', 15), ('jane', 'B', 12), ('dave', 'B', 10),]

用 operator 函数来加快速度, 上面排序等价于:(itemgetter的用法)
>>> from operator import itemgetter, attrgetter
>>> sorted(students, key=itemgetter(2))

用 operator 函数进行多级排序
>>> sorted(students, key=itemgetter(1,2))  # sort by grade then by age
[('john', 'A', 15), ('dave', 'B', 10), ('jane', 'B', 12)]

ref. http://www.pythoncentral.io/how-to-sort-python-dictionaries-by-key-or-value/
ref. http://obroll.com/how-to-sort-dictionary-by-keys-or-by-values-in-python/
ref. http://gaopenghigh.iteye.com/blog/1483864