報導說人在 18~25歲的記憶是最鮮明的。
我很幸遇的成為了你們最鮮明的一部分
然而,我的18~25歲只留下黯淡的哀傷
隨著年紀漸漸增長,已經不適合再成為他人記憶中最鮮明的一部分
才瞭解到
青春的逝去,不是在於時間
而是在於無法參與。
This blog is about my anxiety and eagerness. Please don't spread anything and don't let me know you're watching.
2015年7月24日 星期五
2015年7月11日 星期六
Love Aotupsy
Figuring out you and meLove autopsy,這真的是很戲謔的用法。
Is like doing a love autopsy
They could operate all day long
And never figure out
What went wrong
Love autopsy
Love autopsy
Love....
What went wrong
隨著時間過去,對印象逐漸模糊了,Love autopsy 的次數越來越少。
剩下的,只有疑惑 "What went wrong?"
能否再找到 way back to love,已經越來越疑惑
Way Back Into Love
最近不由自主地想起了這首歌「Way back into love」,有一種心境都被說出來的感覺。
I've been living with a shadow overhead
I've been sleeping with a cloud above my bed
I've been lonely for so long
Trapped in the past, I just can't seem to move on
I've been hiding all my hopes and dreams away
Just in case I ever need them again someday
I've been setting aside time
To clear a little space in the corners of my mind
All I wanna do is find a way back into love
I can't make it through without a way back into love
I've been watching but the stars refuse to shine
I've been searching but I just don't see the signs
I know that it's out there
There's got to be something for my soul somewhere
I've been looking for someone to shed some light
Not somebody just to get me through the night
I could use some direction
And I'm open to your suggestions
All I wanna do is find a way back into love
I can't make it through without a way back into love
And if I open my heart again
I guess I'm hoping you'll be there for me in the end
There are moments when I don't know if it's real
Or if anybody feels the way I feel
I need inspiration
Not just another negotiation
All I want to do is find a way back into love
I can't make it through without a way back into love
And if I open my heart to you
I'm hoping you'll show me what to do
And if you help me to start again
You know that I will be there for you in the end
2015年4月8日 星期三
Introduction to Marketing
Introduction to Marketing
Two kinds of market in the extreme opposite side.- Seller Market
- Buyer Market
In Buyer Market, the profit does not comes from volume, but from the creating value.
Customer share. Build up customer loyalty, that means, they want to pay premium price for your service time after time and after time. It's difficult to get a new customer, but it's cheaper to retain customers over time.
In the buyer market, the profit comes from customer loyalty, premium price and cross selling.
Marketing Orientations
- Product Orientation - Persuade customer to want what the firm has
- Focus on volume and market share, sales as many as you can
- Generic Products
- Bigger company wins
- Larger market share and lower cost
- Lower cost is big strategic advantage
- Marketing Orientation - Persuade firm to offer what the customer wants
- Differentiated product/service
- Increase product quality and deliver better product
- Experience Orientation - Think about the transaction over time. Manage the customer's entire experience with the firm
- Focus on transformation
- customers become as co-creator of value
- Trust Orientation - Prioritize building a relationship of trust and discipline.
Three Principles of Marketing
- Principle of Customer Value
- Principle of Differentiation
- Principle of Segmentation, Targeting and Positioning
Tools to deliver these three marketing principles: 4P of Marketing
- Product - Seller puts into the exchange
- Promotion - The way the seller communicates the benefits about the product to customers
- Place - The way the seller delivers the product to the customer
- Price - Buyer puts into the exchange
2015年4月4日 星期六
2014年11月17日 星期一
Extending Automake Rules
最近在試著把 node.js 放進公司的專案當中。
人生就是有那麼多的 but,就是會有專案跟你用的 building system 不一致,你被迫要 merge 兩個不同的 building system。
node.js 的 building system 沒有考慮過被當作 sub-project 的狀況,無法在 source code 以外的資料夾進行編譯。用比較精確的說法來說,就是 node.js 的 building system 沒有區分 build tree 和 source tree,無法進行 VPATH builds (又稱作 parallel builds,因為 parallel build 常會讓人誤以為是分散式編譯,所以大家才會又發明一個饒口的 VPATH builds)
這其實是滿不好的設計。以前遇到這類型的專案,大多都是為了政治因素, 不給其他專案用的反智現象。但是 node.js 應該只是開發者不了解這個需求,或者還沒有人嘗試過使用 node.js 成為子專案,所以也沒有人回報這個需求。
首先先看了這篇:Third-Party MakefileS
當中說到,利用 SUBDIRS 和 DIST_SUBDIRS 可以讓 make 進入 sub-project 執行 Makefile。這方法其實只解決了一半問題,在 node.js 以及大多數的 open source project都會面臨到另外一個問題。
大多數 open source project developers 通常會將 ${builddir} 和 ${srcdir} 分開,也就是說,程式碼和編譯的資料夾,是不同的地方。如果用 SUBDIRS 和 DIST_SUBDIRS,則 make 會在 ${builddir} 去找只存在 ${srcdir} 的 sub-project。
舉例來說,如果我的專案叫做 utils,然後我把 node.js 放到 utils/nodejs 資料夾下,然後在 utils/Makefile.am 這樣寫:
接下來編譯的時候,建立一個 build-utils 資料夾,然後執行
則在 make 的時候,make 會跟我說找不到 nodejs 資料夾。訊息如下:
這是因為 nodejs 是在 utils 底下,而不是在 build-utils 底下,所以 make 自然找不到。這時候有兩種解法。
這是一種 Adapter 的概念,用自己的 Makefile,去包裝他人的 Makefile。
如果不使用 -f 指定 makefile 的話,make 讀取 makefile 的順序是 GNUmakefile, makefile, 和 Makefile,所以大多數的專案都會使用大寫的 Makefile,好讓有需要時,小寫的 makefile 派上用場。
其實 Makefile 是大寫還是小寫,也可以看出一個 open source project 功力,通常很多人使用的專案會知道要用大寫的版本。
這時候要讓 VPATH builds 裡面生出能夠優先讀取的 Makefile,所以通常會在 source tree 當中增加一個 makefile.in 或 GNUmakefile.in,然後在 configure.ac 當中利用 AC_CONFIG_FILES 生成 VPATH builds 的 makefile/GNUmakefile。如果原生的 makefile 檔名是 Makefile,則 makefile.in/GNUmakefile.in 的內容應該如下:
這個新的 Makefile.am,要把原生 Makefile 的 rule 轉接到 Automake 的 rule 上,做一個 rule adapter。
Makefile proxy 的做法是將原來的 makefile 改名,然後利用 make -f 的方式,執行真正的 Makefile。舉例來說,可以將原來的 makefile 改名為 makefile.real,然後讓 Makefile.am 當中去執行 $(MAKE) -f makefile.real。
為了要保留原來 Automake 所提供的參數,所以通常會在 $(MAKE) -f makefile.real 之後,加上 `$(AM_MAKEFLAGS) target`
Makefile.am 會像這樣:
不論是哪一招,都無法克服一個問題就是:如果這個專案不 support VPATH builds,則不管是哪一招都沒有漂亮的解決方案。如果該專案要支援 VPATH builds (而且通常你會需要支援),則需要重寫該專案的 Makefile
人生就是有那麼多的 but,就是會有專案跟你用的 building system 不一致,你被迫要 merge 兩個不同的 building system。
node.js 的 building system 沒有考慮過被當作 sub-project 的狀況,無法在 source code 以外的資料夾進行編譯。用比較精確的說法來說,就是 node.js 的 building system 沒有區分 build tree 和 source tree,無法進行 VPATH builds (又稱作 parallel builds,因為 parallel build 常會讓人誤以為是分散式編譯,所以大家才會又發明一個饒口的 VPATH builds)
這其實是滿不好的設計。以前遇到這類型的專案,大多都是為了政治因素, 不給其他專案用的反智現象。但是 node.js 應該只是開發者不了解這個需求,或者還沒有人嘗試過使用 node.js 成為子專案,所以也沒有人回報這個需求。
首先先看了這篇:Third-Party MakefileS
當中說到,利用 SUBDIRS 和 DIST_SUBDIRS 可以讓 make 進入 sub-project 執行 Makefile。這方法其實只解決了一半問題,在 node.js 以及大多數的 open source project都會面臨到另外一個問題。
大多數 open source project developers 通常會將 ${builddir} 和 ${srcdir} 分開,也就是說,程式碼和編譯的資料夾,是不同的地方。如果用 SUBDIRS 和 DIST_SUBDIRS,則 make 會在 ${builddir} 去找只存在 ${srcdir} 的 sub-project。
舉例來說,如果我的專案叫做 utils,然後我把 node.js 放到 utils/nodejs 資料夾下,然後在 utils/Makefile.am 這樣寫:
SUBDIRS = nodejs
接下來編譯的時候,建立一個 build-utils 資料夾,然後執行
cd build-utils
../utils/configure
make all
則在 make 的時候,make 會跟我說找不到 nodejs 資料夾。訊息如下:
Making all in nodejs
/bin/sh: line 0: cd: nodejs: No such file or directory
這是因為 nodejs 是在 utils 底下,而不是在 build-utils 底下,所以 make 自然找不到。這時候有兩種解法。
第一招 - Makefile Adapter
如果使用的是 GNU make 的話,一種方式是增加一個新的 Makefile,讓 make 優先讀取,而這個優先讀取的 Makefile,去 include 原來的 Makefile。這是一種 Adapter 的概念,用自己的 Makefile,去包裝他人的 Makefile。
如果不使用 -f 指定 makefile 的話,make 讀取 makefile 的順序是 GNUmakefile, makefile, 和 Makefile,所以大多數的專案都會使用大寫的 Makefile,好讓有需要時,小寫的 makefile 派上用場。
其實 Makefile 是大寫還是小寫,也可以看出一個 open source project 功力,通常很多人使用的專案會知道要用大寫的版本。
這時候要讓 VPATH builds 裡面生出能夠優先讀取的 Makefile,所以通常會在 source tree 當中增加一個 makefile.in 或 GNUmakefile.in,然後在 configure.ac 當中利用 AC_CONFIG_FILES 生成 VPATH builds 的 makefile/GNUmakefile。如果原生的 makefile 檔名是 Makefile,則 makefile.in/GNUmakefile.in 的內容應該如下:
# First, include the real Makefile
include Makefile
# Then, define the other targets needed by Automake Makefiles. (A rule-wrapper to original Makefile)
.PHONY: dvi pdf ps info html check
dvi pdf ps info html:
check: test
這個新的 Makefile.am,要把原生 Makefile 的 rule 轉接到 Automake 的 rule 上,做一個 rule adapter。
第二招 - Makefile Proxy
第二招原理也是很像,主要的目的是在避免 include Makefile。因為有些專案就是那麼白目,make file 的檔名會用 makefile 或者是 GNUmakefile,使得 Makefile Adapter 無法使用。Makefile proxy 的做法是將原來的 makefile 改名,然後利用 make -f 的方式,執行真正的 Makefile。舉例來說,可以將原來的 makefile 改名為 makefile.real,然後讓 Makefile.am 當中去執行 $(MAKE) -f makefile.real。
為了要保留原來 Automake 所提供的參數,所以通常會在 $(MAKE) -f makefile.real 之後,加上 `$(AM_MAKEFLAGS) target`
Makefile.am 會像這樣:
all-local:
cd subdir && $(MAKE) -f $(srcdir)/Makefile.real $(AM_MAKEFLAGS) all
不論是哪一招,都無法克服一個問題就是:如果這個專案不 support VPATH builds,則不管是哪一招都沒有漂亮的解決方案。如果該專案要支援 VPATH builds (而且通常你會需要支援),則需要重寫該專案的 Makefile
2013年12月14日 星期六
初學者指南:如何客製化自己的 streambu
This article is revised from http://www.mr-edd.co.uk/blog/beginners_guide_streambuf
這篇廢話很多,所以我砍掉廢話,寫了精簡版。
上圖是從 cplusplus.com 所剪出來的圖,從這圖中,我們可以看到很清楚的概念。ostream與istream提供了所有 stream 的抽象界面,而streambuf提供了buffer的抽象界面。ostream/istream與buffer的關係,是所謂的strategy,一旦更換buffer,則ostream/istream就彷彿換了個行為一般。fstream與stringstream就是利用這個方式,藉由filebuf與stringbuf來修改ostream與istream的行為。
std::streambuf 在概念上,就是一個 array,被 stream 物件所使用。input stream 會 re-filled 這個 array;或者 output stream 會 flush 且清空這個 array。
當插入一筆資料到 ostream,這筆資料就會被寫進 buffer 的 array。當這 array overflows,那比資料就會被 flush 到目的地。並且此 array 的狀態會被重新設定,好寫入更多的資料。
給 ostream 使用的 pointer 有
一般來說,pbase() 和 epptr() 不會改變,只有 pptr() 會隨著 ostream 不斷地寫入而改變。
Input pointer 有:
相同的,eback() 與 epgtr() 一般來說不會改變。只有 gptr 會隨著 istream 不斷地讀取資料而改變。
我們只需要 override overflow() 和 sync()。當 pptr() == epptr() 的時候,overflow 會被執行。overflow() 應該要把 contents (包含發生 overflow 的那個 CharT) 寫入資料當中,並且 return 一個不是 traits_type::eof() 的直回去。
sync() 負責把目前的 data 寫入 target 當中,即使 buffer 尚未 full。舉例來說,如果 std::flush 被寫入了,應該要立即寫入 target。如果 sync() 失敗,應該要 return -1。
setg用來設定前述的 ostream buffer,我們只需要設定 pbase() 和 epptr()。系統會自動設定 pptr() 為 pbase()。
這篇廢話很多,所以我砍掉廢話,寫了精簡版。
Background of Stream Buffer
在 C++ STL 中,stream 只是一種操作界面,其實並不負責真正的資料搬移動作。真正的資料搬移,是在一個特別的類別 - streambuf 當中完成。舉個例子來說,ofstream 並不負責把資料搬到檔案當中,真正負責搬資料動作的,是 filebuf,但是ofstream決定資料搬移的時機;類似的是 stringtream 和 stringbuf 的關係,stringbuf 負責真正的資料搬移,而stringstream決定了搬移的時機。上圖是從 cplusplus.com 所剪出來的圖,從這圖中,我們可以看到很清楚的概念。ostream與istream提供了所有 stream 的抽象界面,而streambuf提供了buffer的抽象界面。ostream/istream與buffer的關係,是所謂的strategy,一旦更換buffer,則ostream/istream就彷彿換了個行為一般。fstream與stringstream就是利用這個方式,藉由filebuf與stringbuf來修改ostream與istream的行為。
std::streambuf 在概念上,就是一個 array,被 stream 物件所使用。input stream 會 re-filled 這個 array;或者 output stream 會 flush 且清空這個 array。
當插入一筆資料到 ostream,這筆資料就會被寫進 buffer 的 array。當這 array overflows,那比資料就會被 flush 到目的地。並且此 array 的狀態會被重新設定,好寫入更多的資料。
重點提示
- 所有的 stream buffer 都是繼承 std::streambuf base class。衍生物件必須要透過 override std::streambuf 的 virtual functions 來識做自己的特殊行為。
- stream buffer 就是一個 array,當資料都被移出 buffer 時,istream 會重新 fill 這個 array;而當資料都被移入 buffer 之後,ostream 會呼叫 flush 並且清空這個 array。
Internal Array
Streambuf 使用了六個 pointer 來維持 array的資料 - 三個 for input,三個 for output。給 ostream 使用的 pointer 有
- pbase() - 指向 array 的第一個 element
- pptr() - put pointer,指向下一個被 ostream 寫入的 element
- eppter() - the end of array
Input pointer 有:
- eback() - 指向 array 的最後一個 element。
- gptr() - the get pointer - 指向 buffer 下一個應該被送入 istream 的 element
- epgtr() -the end of array
Example 1 - New OStream
這例子當中,我們的 buffer 是要給 ostream 使用。每次 ostream 呼叫 operator << 時,我們便將資料搬到 buffer 當中。當 buffer 已經滿了,無法再寫入時,會呼叫 overflow()。我們只需要 override overflow() 和 sync()。當 pptr() == epptr() 的時候,overflow 會被執行。overflow() 應該要把 contents (包含發生 overflow 的那個 CharT) 寫入資料當中,並且 return 一個不是 traits_type::eof() 的直回去。
sync() 負責把目前的 data 寫入 target 當中,即使 buffer 尚未 full。舉例來說,如果 std::flush 被寫入了,應該要立即寫入 target。如果 sync() 失敗,應該要 return -1。
setg用來設定前述的 ostream buffer,我們只需要設定 pbase() 和 epptr()。系統會自動設定 pptr() 為 pbase()。
訂閱:
文章 (Atom)