2016/04/07

Just a Note:Git Submodule

紀錄 git submodule 多人共用的情境與步驟。

1. 第一個新增 submodule 的人
git submodule add -b [submodule_branch] [submodule_url] [submodule_folder] (submodule_folder 需不存在,會產生或更新 .gitmodules)
git submodule init (register submodule in git)
git submodule update (把 submodule 的檔案更新回來)
git add .
git commit -m "add submodule"
git push

2. 其他人
git pull (submodule 目錄會是空的)
git submodule init (register submodule in git)
git submodule update (把 submodule 的檔案更新回來)

3. 更新 submodule:
(1) 在 submodule 原始的 repository (不是在此系統的 repo 下)修改,按照標準 git 程序進行更新。
(2) 直接在此系統的 submodule 目錄下進行修改:
cd [submodule_folder]
git add [stuff]
git commit -m "[comment]"
git push origin HEAD:[submodule_branch]

4. submodule 有更新,第一個處理 submodule 更新的人
git submodule update --remote (更新 submodule 檔案及 local git 紀錄的 submodule hash)
git add .
git commit -m "submodule update"
git push (如此 remote server 的 submodule reference 才會更新,否則其他人都還是會用到舊版的 submodule)

5. 其他人
git pull
git submodule update


參考:
Git submodules: Specify a branch/tag
http://stackoverflow.com/questions/1777854/git-submodules-specify-a-branch-tag
Git Submodule 的認識與正確使用!
http://josephjiang.com/entry.php?id=342
Issue with adding common code as git submodule: “already exists in the index”
http://stackoverflow.com/questions/12898278/issue-with-adding-common-code-as-git-submodule-already-exists-in-the-index
How do I remove a Git submodule?
http://stackoverflow.com/questions/1260748/how-do-i-remove-a-git-submodule
git submodule update --remote vs git pull
http://stackoverflow.com/questions/19619747/git-submodule-update-remote-vs-git-pull
git-submodule(1) Manual Page
http://git-scm.com/docs/git-submodule

2015/11/22

Just a Note:Simple Git Server on Windows (Using git daemon)

As Server

f:
md reop
cd repo
git init --bare xxxx.git
git daemon --verbose --base-path=f:/repo --export-all --enable=receive-pack



  • --verbose:開啟詳細 log,加了之後除錯比較方便。
  • --base-path=f:/repo:告訴 deamon 你的 git repository 統一放在哪個目錄下,可以在此目錄下建立不同的 git repository。以上述的例子,就是 xxxx.git 的父目錄。
  • --export-all:允許 pull base path 下所有的 git repository
  • --enable=receive-pack:開放匿名存取,目前還沒研究怎麼在 git daemon 裡做 access control。

As Client

git config --global sendpack.sideband false

  • Client 要設定此參數,在 push 時才不會 hang 住。

git clone git://yourserver/xxxx.git

  • git://yourserver 便會指到 daemon 的 base path,後面的 xxxx.git 就是在 base path 下建立的 git repository。

2014/12/07

Just a Note: GCALDaemon 1.0 alpha 17 for Google Calendar API V3

Google 公告於 2014/11/17 停止支援 Calendar API v2,請使用 API v3。
As announced by Google, Google Calendar API v2 is a subject to the Deprecation Policy and was shut down on November 17, 2014. Please use APIv3 instead.

所以便試著將 GCALDaemon 提升至 API v3。
So I try to upgrade Google Calendar API to v3 for GCALDaemon.

我只有針對 Google Calendar 和 Rainlendar 同步處理的部分,修改了兩個功能:
1. config-editor 中的檔案同步設定。
2. sync-now (手動同步)
I only modified two function for synchronizing calendar events between Google Calendar & Rainlendar.
1. config-editor for File synchronizer.
2. sync-now (manually sync)

修改後的程式可以在 github 取得。
The modified source can be download from github.

在 API v3 中,有兩項比較顯著的變更:
1. 授權方式:必須使用 OAuth 2.0,而不支援其他的授權方式。
2. Google 日曆的 private URL:無法透過 API 取得 private URL 了。
For API v3, there are two significant changes:
1. authorize method: Application must use OAuth 2.0 to authorize requests. No other authorization protocols are supported.
2. calendar private URL: We can't fetch calendar private URL from API anymore.

所以在開始使用新版 GCALDaemon 前,需要進行以下步驟。
So we have to follow steps below to use new GCALDaemon.

1. 從 My Google Drive 下載 GCALDaemon 並解壓縮。
1. Download GCALDaemon from My Google Drive and unzip.

2. 啟用 Google Calendar API。
2. Enable Google Calendar API.
(1) 開啟 Google Develop Console 並新增專案。
(1) Go to Google Develop Console and create a project.

(2) 啟用 Calendar API。
(2) Enable Calendar API.

(3) 新增 Client ID。
(3) Create Client ID.




(4) 下載 JSON,並更名為 client_secrets.json。
(4) Download JSON and rename to client_secrets.json.

(5) 將 client_secrets.json 放到 GCALDaemon/etc 目錄中。
(5) Put client_secrets.json into GCALDaemon/etc folder.

3. 執行 bin/config-editor-new.bat (或  bin/config-editor-new.sh),點選 "File synchronizer"。直接點選 "+New" 新增欲同步的日曆,不需要做 Account 的新增。
3. Execute bin/config-editor-new.bat (or bin/config-editor-new.sh) and click "File synchronizer", Just click "+New" to add Calendar you want to sync. Don't need to add Google Accounts.

4. 點選 "Refresh" 取得 Google Calendar 清單,此時會開啟瀏覽器,並要求授予管理日曆的權限。同意後,便可在下拉選單中看到你的日曆清單。
4. Click "Refresh" to fetch Google Calendar list from your default logged-in Google Account. There will show authorizing page in browser and you should click accept. Then you can get calendar list into combo box.



5. 選擇要同步的日曆,並指定對應的 iCal 檔案路徑。
5. Select the Calendar you want to sync and specify the iCal file location. Click OK.

6. 取得並複製該日曆的 ICAL 私人網址,只要保留 /calendar/ical/xxxxxxx/private-yyyyyyyy/basic.ics 的部分。
6. Open browser to get Google Calendar private URL. Copy the private address of ICAL and only keep the URL like /calendar/ical/xxxxxxx/private-yyyyyyyy/basic.ics

7. 回到 Config Editor 並修改步驟 5 新增的日曆,修改 Google Calendar 欄位,輸入步驟 6 取得的 URL。
7. Back to Config Editor and edit the calendar created on step 5. Change the Google Calender field to /calendar/ical/xxxxxxx/private-yyyyyyyy/basic.ics from step 6.


8. 儲存並離開 Config Edit。
8. Save and Exit config-editor.

9. 執行 bin/sync-now-new.bat (或 bin/sync-now-new.sh ) 進行同步。
9. Now you can execute bin/sync-now-new.bat (or bin/sync-now-new.sh ) to synchronize Google Calendar and the iCal file for Rainlendar.

2014/12/03

Just a Note:不常駐 GCALDaemon 又能自動同步 Google Calendar 和 Rainlendar 的方法

2014/11 Update:
Google 在 2014/11/17 停止對 Calendar API v2 的支援,所以 GCALDaemon 已經無法正確同步 Google Calendar 了。
所以在善心人士修正 GCALDaemon 前,也許只剩下購買 Rainlendar Pro 一途。
如果你真的還想要繼續用 GCALDaemon,可以參考這篇,但是說實話,程序複雜很多......


2014/09/11

Trip:東眼山國家森林遊樂區



中秋前一日,東眼山森林遊樂園。

約莫兩個小時的車程,初次拜訪東眼山。整個森林遊樂區腹地極廣,涵蓋了東眼山、親子峰兩處登山步道,以及較為緩和的東眼山林道、景觀步道、森林知性步道。
因為沒有事先做功課,所以一時間也不知道該怎麼走比較適當,所以便選擇先東眼山林道,打算抵達造林紀念石後,再看狀況評估後續路程。
整個林道起伏不大,但都是碎石路,且正午時分樹蔭又相對少了些,走來有些痛腳且悶熱,所以抵達化石區後便決定折返。
當下評估狀況,覺得不適宜再登高,所以決定捨棄親子峰和東眼山登山步道,計畫循森林知性步道+景觀步道前往餐廳、再到遊客中心。

從化石區折返後,選擇了過了景觀亭的第一個岔路離開林道。高聳參天的柳杉、原始潮濕的步道,景觀與林道迥異。
沿途全無人跡,所幸並無岔路,所以走來倒也輕鬆愉快,直到經過了往親子峰的登山口,遇到了第一批反方向來的遊客。
接著到了一個三岔路口,卻僅標示著親子峰的方向,本想詢問坐在路旁休息的一對男女,最後決定選擇往較多人過來的方向前進。

炙熱的陽光消失,且飄起了細雨。心想著趕快抵達餐廳避雨,順便看看有甚麼能填肚子的。
不知道何時一個著藍色衣服的小男孩超越我們,獨自一個人在步道中前進,且看來神色自若,我回頭望了望,不見其他大人的身影,暗忖著這小朋友怎麼這麼大膽在山中獨自一人,感覺就像他家後院一樣。
小男孩三步併兩步地前進,很快就遠離了我的視線,但過沒多久,便聽到遠處傳來哭聲,並清晰地喊著喊著「我要找爸爸、我爸爸不見了」。
我們加快了步伐,來到了一個四岔路口,看到小男孩蹲在路口不遠處、南面的步道上。正準備過去他身邊時,卻瞥見小男孩突然用餘光看向我們,然後又繼續哭喊著相同的字句。
心中升起一陣違和感,所以便停在路口,喊了他兩聲,小男孩沒搭理,逕自在步道上來回跑著、哭著。
正盤算著該怎麼處理、同時也在研究路線時,剛才坐在路旁休息的男女從後方出現,小男孩也看到他們,並開始往回走。
我以為那就是小男孩的爸媽,但很快便知道不是。小男孩依然哭喊著繞過我們走向那對男女,男的叫他牽著阿姨的手、又問了他一些問題,便說「我們帶你去餐廳,那裡有廣播」。
剛剛還哭天搶地的男孩突然就噤聲乖乖地跟著他們走,而男女也毫不遲疑地往某條草高及腰的岔路前進。

我還在研究該怎麼走。
他們也要去餐廳?跟他們走就好了?看看指標,四岔路只有三個指標,餐廳的指標卻指向兩條岔路的中間?再看看路線示意圖,他們走的方向似乎是往林道的方向?
雖然有很多問號在腦中浮現,但想了想,還是決定按照自己的方向感前進,沿途看到更多的遊客迎面而來,讓我更加確定自己沒走錯。

那對男女和小男孩呢?
抵達餐廳後,稍做等候,並未看見三人,而沿途也沒看到像是在找尋小孩的家長,更不用說一直到離開園區為止,根本沒有聽到任何廣播。
抱著很多疑問離開園區,突然大雨滂沱,躲進了布列塔尼咖啡莊園等雨停,然而沒花費什麼體力且悠閒地享用過咖啡的我,卻在回程時疲憊到不得不停下車在路邊休息後才能再繼續騎車。

我們心中都有許多疑惑,但直到隔天晚上才拿出來討論。
小男孩甚麼時候出現的?我們走的路一直沒岔路,後方也都沒人,遇到的第一批人是和我們反方向的。
原本神色自若、步伐輕快的小男孩,怎麼突然就在路邊放聲大哭?
哭的時候咬字怎麼還能那麼清楚?
「我要找爸爸、我爸爸不見了」,感覺就是要喊給路人聽的......
那對男女走的路線,顯然不是往餐廳的路(雖然可以到,但是比較繞)。

當你想著這小孩怎麼沒人陪,就突然聽到他的哭喊,雖然前一刻他還神色自若......
當你在岔路研究要怎麼到餐廳,突然有人也說要去餐廳,毫不遲疑地就走向其中一條岔路,但卻是方向錯誤且沒有指標的那條......

2014/07/21

Just a Note:Jetty Runner

說明:
Jetty/Howto/Using Jetty Runner

下載:
Jetty Runner Download

看起來只有 for Jetty 7.x 和 8.x 的版本,不過應該已經足夠。

基本的需求是:
1. 把 Web Application 當作 stand alone 的應用程式部署。
2. 檔案愈少愈好。

如此便只需要 jetty runner 的 jar 檔和 application 的 war 檔共兩個檔案,透過 command line 便可以啟動 application,如此對 Application Server 的依賴度就會降低。

啟動程式:

java -jar jetty-runner.jar --path /myapp myapp.war

2014/07/17

Why Do I Choose Redmine for Issue Tracking?

必須先說明,工作以來用過 Mantis、Clear Case、Trac、Redmine 等 Issue Tracking System,Clear Case 要商用軟體就不用談了,真正有實際架設經驗的只有 Trac 和 Redmine,會選用 Redmine 作為主要 Issue Tracking 系統的原因如下,主要還是跟 Trac 進行比較:

1. 原生支援整合 Subversion、Git。
 這段分析對 Trac 比較不公平一些,之前使用 Trac 時,經歷了整合 Subversion 1.4.x、1.5.x、1.6.x 和 Git,每一階段都很痛苦,因為 python 的版本、Trac 版本、相關 plugin 版本的配合著實令人頭痛。後來改用 Redmine 時,Subversion Server 已經固定使用 1.6.x 版,所以只要選用支援的版本,基本上就可以無痛整合;另外隨著 Git 的普及,原生整合 Git 對我來說也是相當重要的功能。我之前同時嘗試用 Trac 和 Redmine 整合 Git,但最後 Trac 沒有試成功,而 Redmine 則是無痛整合。

2. 較完整的使用者/權限管理/設定,使用者亦可自行進行密碼變更。
 之前用 Trac,沒有使用者自行管理密碼的功能(可能需要額外安裝 plugin),使用者的密碼都是管理者設定後便固定不變,其實這樣有點怪。

3. 較完整的專案管理/設定
 原生支援 multiple projects、子專案,透過 Web 管理介面便可進行專案的建立與設定。Trac 則是需要先建立一個 template,每要開一個新的專案,就需要複製實體目錄,再手動進行 config 的修改,操作門檻較高,且基本上 Trac 各專案均為獨立個體,只能透過 Web Server 設定,「假裝」有一個統一的入口。

4. 原生支援 wiki/論壇/行事曆功能
 Trac 原生只有 wiki,論壇、行事曆均需額外安裝 plugin。真的經歷過安裝 Trac plugin 的痛苦,便能體會原生支援的美好。

5. Email 通知功能
 Redmine 原生支援。Trac 大概也是得安裝 plugin 吧......

6. 外部系統可整合 Redmine 的使用者,達到 Single Sign-On 的目的。
 目前已將 Subversion、Git、Jenkins 的登入統一由 Redmine 控管。



當然我的需求和考量的點不見得對每個專案與環境都適用,僅供大家參考。

網路上都說 Trac 架設的門檻高,根據經驗的確如此,當要使用其他 plugin 時,更是痛苦。不過嚴格說起來,其實 Redmine 的架設也不是真的很容易,要感謝 Bitnami 提供相當完整的 Installer,讓這些系統的架設變得更為容易。