Total Pageviews

2014/10/21

How to copy text from Notepad++ to Microsoft Word and keep its color to distinguish keywords


Notepad++ can distinguish between different languages source code can be written in. For example, a language could distinguish certain keywords that have to be differently interpreted, and as such it can be useful to distinguish these keywords using another color or font. 


For example.
The language is Java.

The language is SQL.


Scenario
If we would like to copy SQL statement from Notepad++ to Microsoft Word in my system design document, but it seems cannot keep its color to distinguish keywords. 
For example.

Resolution
Step1. Select text you would like to copy.

Step2. Plugins --> NppExport --> Copy RTF to clipboard

Step3. Paste text to Microsoft word


2014/10/16

How to display Tradition Chinese Character in Git Bash

Problem
Why I cannot display Tradition Chinese Character in Git Bash correctly?

Solution
You need to edit three files under git\etc

1. edit gitconfig file and append configuration as following:
1:  [gui]  
2:  encoding = utf-8   
3:  #log编码  
4:  [i18n]  
5:  commitencoding = utf-8   
6:  #支持中文路径  
7:  [svn]  
8:  pathnameencoding = utf-8   

2. edit git-completion.bash file and append configuration  as following:
1:  #正常顯示中文  
2:  alias ls='ls --show-control-chars --color=auto'  

3. edit inputrc file and append configuration  as following:
1:  #bash中可以正常输入中文  
2:  set output-meta on   
3:  set convert-meta off  

Check Result

2014/10/15

JRebel - Reload any changes without restart server

As a developer, we do not want to waste time to restart server again and again to see the implace of code changes.
You can try JRebel to save your time.

If you are using Eclipse, here has good step-by-step installation and configuration guide: http://manuals.zeroturnaround.com/jrebel/ide/eclipse.html

For more information, please check http://zeroturnaround.com/software/jrebel/learn/

Demo

Here has code snippet, and it will print debug message as entering this method
1:    @RequestMapping(value = "/query/tab1", method = RequestMethod.POST, consumes = MediaType.APPLICATION_JSON_VALUE, produces = MediaType.APPLICATION_JSON_VALUE)  
2:    public @ResponseBody  
3:    List findTab1(@RequestBody Fms420rFormBean formBean, Alerter alerter) {  
4:      log.debug("test");  
5:      List dataList = service.queryTab1(formBean.getYear(), formBean.getMonth());  
6:      if (CollectionUtils.isEmpty(dataList)) {  
7:        alerter.info(Messages.warning_notFound());  
8:      } else {  
9:        alerter.info(Messages.success_find());  
10:      }  
11:      return dataList;  
12:    }  

And the console will print "test" debugging message as entering this method:
1:  19:15:45,493 INFO [stdout]  [20123] DEBUG gov.nta.fms.web.rest.Fms420rResource - test  

In order to test JRebel, I just modified the debug message to "JRebel test" and submit query without restart application server
1:    @RequestMapping(value = "/query/tab1", method = RequestMethod.POST, consumes = MediaType.APPLICATION_JSON_VALUE, produces = MediaType.APPLICATION_JSON_VALUE)  
2:    public @ResponseBody  
3:    List findTab1(@RequestBody Fms420rFormBean formBean, Alerter alerter) {  
4:      log.debug("JRebel test");  
5:      List dataList = service.queryTab1(formBean.getYear(), formBean.getMonth());  
6:      if (CollectionUtils.isEmpty(dataList)) {  
7:        alerter.info(Messages.warning_notFound());  
8:      } else {  
9:        alerter.info(Messages.success_find());  
10:      }  
11:      return dataList;  
12:    }  

See....I don't redeploy and restart application server, but the console print the up-to-date debug message. 
1:  19:16:19,742 INFO [stdout]  [20123] DEBUG gov.nta.fms.web.rest.Fms420rResource - JRebel test  

It's because of JRebel reload any changes classes automatically. 
When you change any class or resource in your IDE, the change will reflect in you application immediately, skipping the build and redeploy phases.




2014/10/14

How to find out the PID (process ID) of processes in Windows

Problem
If I would like to find out the PID of javaw.java proecess, how do I do?
Windows task manager seems does not have PID information.

Solution 1
View-->Selected Columns-->Checked PID-->OK

Then we can find out the PID information.


Solution 2
Open command prompt, and execute tasklist /fi "Imagename eq JAVAW.exe"
Then we can get the PID information
映像名稱                       PID 工作階段名稱      工作階段 #    RAM使用量
========================= ======== ================ =========== ============
javaw.exe                    10368 Console                    1  1,620,884 K



Reference

2014/10/01

[閱讀筆記] 拆開獲利的糖衣



  1. 債券價格的變動與利率負相關,利率上升,債券價格會下跌;利率下降,債券價格會上漲
  2. 短期投資來說,股票的波動大於債券。但是,若是拉長到30年,股票的波動只有債券的一半,但報酬好很多
  3. 波動是投資主要風險,但不是唯一風險。對許多長期投資者來說,如果採用波動不夠大的投資組合,這樣的投資成本長期看來會造成更大的壞處
  4. 多頭市場是在悲觀中生成,在懷疑中成長,在樂觀中成熟,在亢奮中消逝
  5. 股市是經濟的領先指標,投資人不會等經濟資料顯示經濟復甦才開始投資,他們會提前哄抬股價
  6. 如果你的投資期間很長,長期來說,由於貨幣升貶本質是零和、不規則的循環,貨幣對全球投資組合的影響會互相抵消,接近于零
  7. 貨幣的波動很大,長期來說,投資人很難掌握短期的市場時機,靠交易外匯獲利
  8. 如果每個人都在關注某一件事,你知道你可以放心忽略那件事,往別的方向看,關注大家沒注意的事,以及可能對未來市場走向有很大影響的事
  9. 衡量市場氛圍往往不是一種科學,反而更像藝術


2014/09/30

2014/09 南投

溪頭漢光樓

大學池


溪頭天空步道




竹山紫南宮



2014/09/25

[閱讀筆記] 漫步華爾街


  1. 市場經常反應過度,因此最好遠離眼前時髦的股票,專注於購買那些目前失寵的股票
  2. 尋找價值的投資人,要選擇本益比低、股價與帳面價值比低的股票。價值是基於目前的現實而非未來
  3. 股價與帳面價值比低的股票,未來報酬通常較高
  4. 選擇低本益比的股票比較好,如果成長實現,將帶來加倍利潤;若成長失敗,損失也有限
  5. 股票是衡量機制,不是投票機制
  6. 購買可展期的定期保險,你可以不斷更新保單而不必重新體檢。所謂「遞減」的定期保險是,保單更新時保額可逐次降低,因為隨著時間逝去,需要的保險會跟著遞減
  7. 決定股票報酬三因素:購買時的股利報酬率、盈餘成長率、本益比的改變
  8. 債券的報酬決定於購買時債券到期日的報酬率、利率的改變對債券價格的影響 
  9. 平均成本投資法是指在一段很長的時間中,每隔一段時間已一定的金額購買投資標的,如此可以大大減低股票投資風險,因為不會發生所有股票都在最高點的情形
  10. 投資普通股票和債券的持有期越長,風險就越低,但是你得有耐性忍受過程中,投資價值逐年波動的情形
  11. S&P 500指數的表現,長期優於共同基金與機構投資人的平均績效。成長型和價值型共同基金能勝過股票指數的,屈指可數
  12. 四項成功選股原則:只購買至少維持五年盈餘成長超過平均的股票、不購買股價高於合理價值的股票、購買有故事題材的股票、盡可能減少進出
  13. 事實上,少數表現超群、打敗超群的人,其成功有99%可能來自運氣,雖然人們自吹自捧自己的行動,但是那多半來自機運,較少來自偉大的構想