2016年1月13日 星期三

2015年12月30日 星期三

2015年6月23日 星期二

Create centos6 USB installer on Mac



原本想使用unetbootin來製做USB安裝程式,但搞老半天,
安裝到一半,就是會出現錯誤訊息



官網有講由 CentOS 6.5 起,你只需透過 dd 把 ISO 檔移至 USB 儲存器,便能利用它進行安裝

所以打開MAC

1.看看掛載的情況 diskutil list


/dev/disk2 就是隨身碟

2.卸載 diskutil unmountDisk /dev/disk2

3.用官網教的指令就能製做出來了

sudo dd if=CentOS-6.5-x86_64-minimal.iso of=/dev/disk2 bs=1m

2015年6月19日 星期五

AWS EC2 Build Tomcat And Single MongoDB


EC2

1.註冊

2.進到console home後,選Region

3.Launch Instance 

Key Pairs
  1. 產生[name].pem,並下載,登入時要用

Security groups

  1. 增加SSH TCP 22 PORT

會自己建立一個VPC

4.產生後,回到Instances 頁面

  1. 就會新增剛才建立的,可選上方的Connect,可以用 ssh [ubuntu]@[public_ip] -i $PATH/[name].pem 來登入


5.登入後,安裝tomcat, 放程式

sudo apt-get update
sudo apt-get install tomat7

  • /usr/share/tomcat7
  • /var/log/tomcat7
  • /etc/tomcat7

sudo service tomcat7 start
sudo apt-get install default-jdk
sudo apt-get install maven
git clone https://xxx@code.google.com/p/projectname/
git pull
./sudo mvn clean
./sudo mvn install
sudo vim /etc/tomcat7/server.xml

Mongodb

1.可由Launch Instance選擇AMI 或 Service -> CloudFormation 使用template來建立

先簡單化,這裡使用template, 並安裝在原來的VPC上,
且Replica Set只建一個

安裝過程中
Subnet-xxxxxx 要輸入 Network Interface 頁面裡 同一個VPC所對應的Subnet ID

會產一個新的instance

同樣方式連進去
ssh [ubuntu]@[public_ip] -i $PATH/name.pem

登入後,執行command

mongo
config = { _id: "r0", members: [ { _id:0, host:"127.0.0.1:27017" }] }
use testdb
db.createUser("root","password")

Send Email

選Service -> SES -> SMTP Settings
1.Server Name
2.Create My SMTP Credentials 要認證過的email,才收的到信
3.上線前,需於Support Center寫信給官方,才能離開sandbox

Ref

April 2015 





2014年10月26日 星期日

org.springframework.web.context.ContextLoaderListener


使用 Spring 3.2.x 時, 只要一讀取

    <listener>
        <listener-class>org.springframework.web.context.ContextLoaderListener</listener-class>
    </listener>

就會出現下面Exception

原來是因為我Tomcat使用了JDK1.8
若要用1.8, Spring必須upgrade成4才會支援1.8的byte code format

--
ERROR [org.springframework.web.context.ContextLoader] - <Context initialization failed>
java.lang.IllegalArgumentException
at org.springframework.asm.ClassReader.<init>(Unknown Source)
at org.springframework.asm.ClassReader.<init>(Unknown Source)
at org.springframework.asm.ClassReader.<init>(Unknown Source)

嚴重: Exception sending context initialized event to listener instance of class org.springframework.web.context.ContextLoaderListener
java.lang.IllegalArgumentException
at org.springframework.asm.ClassReader.<init>(Unknown Source)
at org.springframework.asm.ClassReader.<init>(Unknown Source)
at org.springframework.asm.ClassReader.<init>(Unknown Source)

2014-10-26 22:00:13,255 WARN [org.springframework.web.context.support.XmlWebApplicationContext] - <Exception thrown from ApplicationListener handling ContextClosedEvent>
java.lang.IllegalStateException: ApplicationEventMulticaster not initialized - call 'refresh' before multicasting events via the context: Root WebApplicationContext: startup date
at org.springframework.context.support.AbstractApplicationContext.getApplicationEventMulticaster(AbstractApplicationContext.java:347)
at org.springframework.context.support.AbstractApplicationContext.publishEvent(AbstractApplicationContext.java:334)

[org.springframework.web.context.support.XmlWebApplicationContext] - <Exception thrown from LifecycleProcessor on context close>
java.lang.IllegalStateException: LifecycleProcessor not initialized - call 'refresh' before invoking lifecycle methods via the context: Root WebApplicationContext: startup date
at org.springframework.context.support.AbstractApplicationContext.getLifecycleProcessor(AbstractApplicationContext.java:360)
at org.springframework.context.support.AbstractApplicationContext.doClose(AbstractApplicationContext.java:1057)
at org.springframework.context.support.AbstractApplicationContext.close(AbstractApplicationContext.java:1010)

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/

2012年3月7日 星期三

Subclipse



本文章介紹基本的合併流程, 以Subclipse為例


在要合併的目錄, 可以由 Team --> 列出Subclipse所有功能


假設bdp是trunk project, bdp2是branch project

1.首先將新專案bdp2分支 Trunk > Branch


2.Branch開發到一半, 若要跟Trunk合併, 這時要選擇bdp2(也就是branch的project)按右鍵, 
選Team -> 合併 ->
選擇 Merge a range of revisions













3.開發完成後, 要回主線 Trunk < Branch, 這時要選擇bdp(也就是trunk的project)按右鍵, 

選Team -> 合併 ->

選擇 Reintegrate a branch



4.選擇要回去的branch的同階目錄(若從WebContent開始合併, 就指到branch的WebContent)

5.每次合併的結果, 可從 Merge Results Tab查看


Ignored File - A file ignored by version control. You can control what resources will be ignored by going to Window → Preferences → Team → Ignored Resources.
Unversioned File - A file not under version control. These are typically new files that you have not committed to the repository yet.
New File - A versioned file that needs to be added to the remote repository. These are typically files you have either renamed, or moved to a different directory.
Deleted File - A deleted folder. These are folders that you have deleted locally without yet committing the changes to the repository. Note that files are usually removed from the view when they're deleted locally, so they are normally not seen with this icon.
Synchronized File - A file with no local changes.
Local Changes - A file with local, uncommitted changes.
Locked File - A locked file.
Needs Lock - A file that needs a lock to be edited. These are typically files that cannot easily be merged (i.e. binary files), but may have many editors. A file needs a lock when its svn:needs-lock property is set, and Subversion will attempt to make these files read-only in the file system to enforce proper lock negotation.
Conflicted File - A conflicted file. These are typically files that had a commit/update conflict that you marked to resolve later.
Tree Conflicted File - A file that has a tree conflict. These are typically files that have local changes, but have since been moved, removed, or renamed in the repository since the last local copy update.
External File - A file that is external to the project. Linked external files cannot be committed to the repository.
Switched File - A file that has been switched. These are files which belongs to a different working copy than their local parent directory.
In a synchronization view (e.g. via Synchronize with Repository or Commit), as previously described, there are icons which indicate which direction a change is occurring in as well as additional information about that change. These are described below:
Outgoing
Commit Changes - A file whose contents have been modified and will be committed to the repository.
Commit Addition - A file that will be newly added to the repository. This may coincide with a file removal in cases where a file is moved or renamed..
Commit Removal - A file that will be removed from the repository. This may coincide with a file addition in cases where a file is moved or renamed.
Property Change - A file with property changes, in the Commit dialog. On the Synchronize tab, property changes are currently reflected as a normal file modification (Commit Changes).

在上次commit後, 部份屬性有變動
由合併的目錄, 會記錄合併後相關訊息(svn:mergeinfo)
以trunk合併branch情境來看
假設 trunk/WebContent merge branch/WebContent
原本上次合併是由 100 ~ 120, 目前最新版本是121, 合併後也會記錄一個版本, 所以會變成122, 那麼mergeinfo這檔案就是記錄100 ~ 122版本, 但重點是我們還沒有commit
所以此訊息會提示, 我們上次commit是100 ~ 120, 合併後版本變成 100 ~ 122, 它希望我們能commit這版本
為了要記錄這次合併的版本, 所做的提示(因為我們可能在下一階又commit其他變動)
Incoming
Remote Changes - A file that has content changes committed to the repository that will be applied to the local copy.
Pull Addition - A new file that will be added to the local copy from the repository. Like the outgoing file addition, this may be the result of a move or rename.
Pull Removal - A file that will be removed from the local copy because it has been removed from the repository. Like the outgoing file removal, this may be the result of a move or rename.
Conflict
Conflicting Versions - A file that has been changed in both the local copy and repository independently, causing a need for conflict resolution. Fixing this condition involves opening up the conflict view or forcibly overwriting changes locally or remotely.
Synchronization Tree Conflict - A file that has a tree conflict. This can occur when there are new changes to a file on one end (either local or remote), and the file is moved, removed, or renamed on the other.
Finally, the Synchronize with Repository option opens the Synchronize tab (Synchronize Tab) with the following buttons:
Synchronize Source - Synchronizes the local copy with the currently selected repository when clicked. Selecting from the drop-down allows switching between different remote code bases.
Show Incoming - Shows only incoming changes (remote → local).
Show Outgoing - Shows only outgoing changes (local → remote).
Show Incoming and Outgoing - Shows both incoming and outgoing changes (remote ↔ local).
Show Conflicts - Shows conflicting changes.
Update Incoming - Updates all local resources with incoming changes after prompt.
Commit Outgoing - Brings up the commit dialog to commit all outgoing changes.
Show Changesets - Breaks up the change lists by revisions.

--

Conflict
Delete:只要是目錄有變動, 都算是
Add:
Edit:
Local:本機修改
Incoming:是别人修改, 你要Update或Merge進来

Tree Conflict
update情況
Local delete, incoming edit upon update
Local edit, incoming delete upon update
Local delete, incoming delete upon update (二邊都刪掉, 直接標記解決就行)

merge情況
Local missing, incoming edit upon merge
Local edit, incoming delete upon merge (當trunk合併branch, 若trunk修改此檔案, 但trunk刪除時)
Local add, incoming add upon merge (當branch回trunk, 若truck已有此檔案, 但trunk也新增)


測試:
Local delete, incoming edit upon update









最好是每次合併後, 都檢查一下是否有 Tree Conflict, 因為不是每次都有提示