2014年9月10日 星期三

Design Pattern - CQRS



CQRS

ref:
http://johnnycoder.com/blog/2009/12/18/learn-domain-driven-design/
http://www.codeproject.com/Articles/555855/Introduction-to-CQRS

通常進行CRUD會有二個問題
collaboration 同時操作相同資料時
staleness 某筆資料, 當A查詢後, B修改

主要是想把二者責任分離
Command
Query

image source : http://www.udidahan.com/2009/12/09/clarified-cqrs/


image source : http://www.codeproject.com/Articles/555855/Introduction-to-CQRS



image source : http://msdn.microsoft.com/en-us/library/jj591573.aspx












































2014年9月5日 星期五

Facebook 自訂分享按鈕


1.在html tag內加入 xmlns:og、xmlns:fb屬性
<html xmlns="http://www.w3.org/1999/xhtml"
xmlns:og="http://ogp.me/ns#"
xmlns:fb="http://www.facebook.com/2008/fbml">

2.head tag加入
<meta name="og:description" content="" />
<meta property="og:title" content=""/>
<meta property="og:type" content="website"/>
<meta property="og:url" content=""/>
<meta property="og:image" content=""/> 縮圖, 可設定多圖
<meta property="og:site_name" content="" />
<meta property="fb:app_id" content="" />
<meta property="fb:admins" content=""/>

3.body tag裡面加入
<div id="fb-root"></div>
<script>
window.fbAsyncInit = function() {
  FB.init({appId: 'app id', status: true, cookie: true, xfbml: true});
};
(function() {
  var e = document.createElement('script'); e.async = true;
  e.src = document.location.protocol + '//connect.facebook.net/zh_TW/all.js';
  document.getElementById('fb-root').appendChild(e);
}());
</script>

4.清除facebook cache
https://developers.facebook.com/tools/debug

5.在要點擊分享的按鈕加上
<a href="https://www.facebook.com/sharer/sharer.php?u=url" target="_blank">分享到FACEBOOK</a>

<a target="_blank" onclick="return !window.open(this.href, 'Facebook', 'width=640,height=300')" href="http://www.facebook.com/sharer/sharer.php?u=url">分享到FACEBOOK</a>

補充
1.自動產生連結網站 http://www.sharelinkgenerator.com/