軟體正在統治世界。而軟體的核心則是演算法。演算法千千萬萬,又有哪些演算法屬於「皇冠上的珍珠」呢?Marcos Otero 給出了他的看法。
什麼是演算法?
通俗而言,演算法是一個定義明確的計算過程,可以一些值或一組值作為輸入並產生一些值或一組值作為輸出。因此演算法就是將輸入轉為輸出的一系列計算步驟。
—Thomas H. Cormen,Chales E. Leiserson,演算法入門第三版
簡而言之,演算法就是可完成特定任務的一系列步驟,它應該具備三大特徵:
有限
指令明確
有效
以下是 Marcos Otero 推薦的十大演算法:
1、合併排序、快速排序及堆排序
最好的排序演算法跟需求密切相關,很難評判。但是從使用上說,這三種的使用頻率更高。
合併排序由馮.諾依曼於...
2016年8月22日 星期一
IoC - Annotation (@Service)
At the moment, @Service serves as a specialization of @Component, allowing for implementation classes to be autodetected through classpath scanning. What this means is that you could annotate your service-layer classes with @Component, but by annotating them with @Service instead, your classes are more properly suited for processing by tools or associating with aspects, since @Service makes an ideal...
2016年8月19日 星期五
在blogger中插入程式碼
https://pjchender.blogspot.hk/2016/06/prism-syntax-highlighting.html
http://prismjs.com/#languages-list
http://www.opinionatedgeek.com/DotNet/Tools/HTMLEncode/Encode.aspx
var person = {
firstname: 'Jeremy',
lastname: 'Lin',
getFullName: function(){
var fullname = this.firstname + ' ' + this.lastname;
return fullname;
}
...
IoC - Annotation (@Autowired)

在 spring 早期版本,只能透過 xml 進行配置設定,這會讓設定與程式是分開的,當程式很大、類別很多時,維護非常不容易,現在 spring framework 提供 annotation 的方式,把設定直接寫在程式上,可大量減輕維護的工作量。這裡說明怎麼以 annotation (註釋) 的方式進行 IoC,這個簡單的例子是一家公司有老闆,也有員工,我們要印出老闆名字和員工人數,整個專案會有如下幾個檔案:
MyTest 是測試程式,內容如下:
package tw.idv.leader;
import org.springframework.context.ApplicationContext;
import...
2016年8月18日 星期四
Introduction to Spring 3 MVC Framework

Request Processing Lifecycle
Image courtesy: Springsource
Spring’s web MVC framework is, like many other web MVC frameworks, request-driven, designed around a central servlet that dispatches requests to controllers and offers other functionality that facilitates the development of web applications....
GitHub Pages
之前見過有人用 GitHub 來 host 網頁,但未有時間試,今日終於試左。
原來好簡單,只要開番一個 Repository 叫 xxx.github.io (xxx=GitHub用戶名稱) 就得
* 只可以 host 靜態網頁 ( ie HTML)
Limit:
GitHub Pages source repositories have a recommended limit of 1GB .
Published GitHub Pages sites have a 1GB recommended limit.
GitHub Pages sites have a recommended bandwidth limit of 100GB or 100,000 requests per month.
GitHub Pages sites have a recommended limit...
JSTL
JSTL Core <c:param> Tag
The <c:param> tag allows proper URL request parameter to be specified with URL and it does any necessary URL encoding required.
Example:
If you need to pass parameters to a tag, use the tag to create the URL first as shown below:
<c:url value="/index.jsp" var="myURL">
<c:param name="trackingId" value="1234"/>
<c:param name="reportType"...
2016年8月17日 星期三
OAuth 和 Facebook 登入原理

OpenID:用作「身份認證」,如果某網站支援 OpenID,你登入其他網站不需要記憶密碼,只要拿你的 OpenID 登入就好。
OAuth:用作「授權」,舉例而言,如果你需要授權某相片列印公司的網站取得你在 Facebook 的相片,只要該相片列印公司支援 OAuth,你也授權,那該公司就可以取得你在 Facebook 的相片。
OAuth有分1.0和2.0,只討論比較新的2.0
首先,分四個角色
資源擁有者 (Resource Owner): 擁有 Facebook 帳號的用戶 ( 用戶甲 )。
授權伺服器 (Authorization Server): kkbox向...