2014年5月2日 星期五

世代交替

漸漸感受到世代交替的重要性,公司(政府)能不能轉型,往往在於是否改革方能用新的方式 ,作法或技術來處理同樣的問題。

如果還是想拿舊的方式,態度面對新的產業,有時直接會被產業淘汰掉,淘汰的速度比較像是溫水煮青蛙,慢慢的但你發現時已經無力回天。

工程技術人員也一樣,如果只是在公司把事情完成,沒有嘗試與其他技術人員交流,尤其是新創公司的開發者,他們往往會用新的技術與工具來加速開發,等到你想換另一份工作時,就會發現怎麼產業完全不同,自己會的東西已經沒有需求!


看到50多歲還能在矽谷打拼的工程師,真的是不簡單!希望自己到那年紀還能有這樣的熱誠,但口袋可以麥可麥克!

2014年5月1日 星期四

Git and git-p4

Perforce is great source version tool for owner of company, because it's centralize control and can track each client behavior. But I don't like it anymore.
So I used Git to manage my local repo that is sync from perforce server. Use git to track my local commits and use p4/p4v to submit changes to Perforce server. But the work flow will complex and waste time(file always locks to read only with p4).

Few couple months passed, I found the tool git-p4 that can manage p4 repo like remote git branch. That similar like git-svn tool (git 與 git-svn 簡單教學)

The git-p4 is wrote by python and it integrates to git source tree. you need turn off the compile flag(ON_PYTHON) when you compiling git. In official build on git website, the NO_PYTHON is enable, so you can't use it with git-p4.

$ git p4
fatal: git was built without support for git-p4 (NO_PYTHON=1).

Please clone the git and switch to tag v1.9.2
$ git clone https://github.com/git/git
$ git checkout v1.9.2 -b v1.9.2

Follow INSTALL document to compile and install git, Please make sure the python already install in your environment (NO_PYTHON will turn OFF when you compile)
$ make prefix=/usr all 
$ sudo make prefix=/usr install

Check your git and git-p4 are ready to use

$ git --version
git version 1.9.2

$ git-p4
usage: /usr/bin/git-p4  [options]

valid commands: clone, rollback, debug, commit, rebase, branches, sync, submit

Try /usr/bin/git-p4  --help for command specific help.

Add p4 alias to your ~/.gitconfig

[alias]
    p4 = !/usr/bin/git-p4

Don't forget your p4 command and environemnt

$ export P4CLIENT=[your_client_name]
$ export P4HOST=[perforce_server_ip]:1666
$ export P4USER=[login_user_name]
$ export P4EDITOR=vim


Now, you can clone a proj from perforce.

# Clone a repository and covert all change list to git log
$ git p4 clone //depot/path/project@all myproject

# Clone a repository without log
$ git p4 clone //depot/path/project myproject
  
# Do some work and commit to your local git repo
$ git add foo.py
$ git commit foo.py
# Submit your local commit to remote repo (Perforce server)
# git p4 will create a change list for commit
$ git p4 submit

# Synchronize with Perforce (almost like 'git fetch' and 'get pull')
$ git p4 rebase
All done, enjoy it! :)

2014年4月23日 星期三

安裝 Xcode 5.1 Command line tools 所引起的問題

在 MacOS 10.9.2 上面如果有安裝 xcode command line tools,當你在裝第三方packages (python pip or ruby gem)而且有compile native library (大部份應該都是 c library),請記得加入這樣的 flag 在你環境上:


Ruby

sudo  gem update --verbose

export ARCHFLAGS="-Wno-error=unused-command-line-argument-hard-error-in-future"
sudo gem update --verbose


Python

pip install xxx

export ARCHFLAGS="-Wno-error=unused-command-line-argument-hard-error-in-future"
pip install xxx


不然就會感受到 compiler 很熱情地抱怨...

./ruby_xml_encoding.h:11:51: note: passing argument to parameter 'xencoding' here
VALUE rxml_new_cstr(const char* xstr, const char* xencoding);
                                                  ^
1 warning generated.
compiling ruby_xml_xpointer.c
linking shared-object libxml_ruby.bundle
clang: error: unknown argument: '-multiply_definedsuppress' [-Wunused-command-line-argument-hard-error-in-future]
clang: note: this will be a hard error (cannot be downgraded to a warning) in the future
make: *** [libxml_ruby.bundle] Error 1


Gem files will remain installed in /Library/Ruby/Gems/2.0.0/gems/libxml-ruby-2.7.0 for inspection.
Results logged to /Library/Ruby/Gems/2.0.0/gems/libxml-ruby-2.7.0/ext/libxml/gem_make.out
Updating mini_portile
Fetching: mini_portile-0.6.0.gem (100%)
Successfully installed mini_portile-0.6.0
Parsing documentation for mini_portile-0.6.0
Installing ri documentation for mini_portile-0.6.0
Installing darkfish documentation for mini_portile-0.6.0
Updating nokogiri
Building native extensions.  This could take a while...
ERROR:  Error installing nokogiri:
 ERROR: Failed to build gem native extension.

這應該是 Apple 為了避免出現類似 iOS 7.0.4 裡面的 gotofail bug,所設下的 flag。
有一好沒兩好...

2014年3月25日 星期二

讓 vim 支援 multiple cscope DB

之前發現blog,有幾篇文章是比較熱門的,尤其是這篇(用 vim 有效閱讀 Android framework 程式碼),被點閱的次數還不少。不過看了之前寫的plugin,還是覺得寫得很差,都是可以動就好。

所以前幾天有點時間,就把部分拿來重寫,大致上已經修改完畢。大家可以到multi-cscope-db(github去看看。

安裝的方式跟以往相同,不過建議用 vundle 來管理你的 vim plugin。
我把 goproj.sh 的部分,移動到 vim script 裡面。所以不需這隻 shell。以後只需要在 vim 的 command line 打入

:CSBuild

就可以建立新的 DB 或是更新 DB 內容,相信這樣應該會比較好用些。

目前預設支援:

*.aidl
*.cc
*.h
*.c
*.cpp
*.java
*.py

當加上越多副檔名支援,更新或是新建  DB 的時間就會花比較多。

Fork and enjoy it! :)
歡迎討論!


2014年2月23日 星期日

Docopt - 比 argparse 更方便的 command line parser

其實不管用任何語言 c or python 在寫 console program 的時候,都會遇到一個討厭但是你又不得不做的東西,那就是 arguments parsing,就是輸入一堆參數,然後對應到不同的功能。

在 python 裡面其實已經有些 build-in module 可以用 ( argparse ),不過說真的,這 module 不得我心,寫起來覺得累贅,有點麻煩。改個小地方就要重寫一部分,加上一個參數,就會增加不少行數。

呼!這樣我寫完就下班了,人生苦短啊!

所以我就開始找相關的 module,竟然有個很方便的 module - docopt (PyCon UK 2012)。

不廢話,看個影片:




很美吧!簡潔有力,人生是彩色的啊!

作者很厲害把註解直接拿來做 parser 所需要的 patten,順便拿來當 help file。然後給你個dictionary 然後就打完收工。

這樣就完了嘛?還沒,不用急著開 terminal,現在是什麼時代,一定有提供web的試用版本(話說正式版也是免費的)。

http://try.docopt.org/

Installation:


GitHub: https://github.com/docopt/docopt

直接用 pip 來安裝

(env) $ pip install docopt 

其實不要以為只有 python 有這些東西,其實 Ruby, PHP, Lua, CoffeeScript 都已經有移植的版本!

一年多就有四個移植的版本,真是有趣啊!
這也就是 opensource 的本質與好處吧!

歡迎大家互相交流! :)








About 2014

新的年,很多東西改變了,環境也改變了,不變的是希望成長的心態,期望還可以在進步。

這Blog也荒廢很久,沒有在更新。其實去年兩年一直有在想要找時間重新來寫些東西,不過就是沒有個起頭,也是因為身邊很多事情需要自己去處理,所以也沒有太多的精力來寫文章。

一直到了最近,開始覺得自己好像退步,很多東西變得不夠敏銳,似乎有老化的傾向。所以是該準備來重新開始寫一些文章,記錄自己看到的事情與觀點。

這兩年主要的火力都放在cloud的部份去發展,所以python變成我的主力語言,雖然偶爾也會寫其他的語言,不過python的強大,很難讓我在去適應(應該是懶得關係)其他的語言。 
期望自己在今年還是能夠些比較深入的文章,不是那邊LDS。
看看可不可以介紹些好用的python module與開發上的想法。


2013年7月7日 星期日

這兩年

這兩年經歷了很多事情:
工作:
1. 嘗試自己創業接案
2. 加入一家Startup
3. 搞倒了Startup,換到一家大一些的公司去。

私人:
1.  一年內整理了三間房子,分屬不同的處理方式(很累啊!)
  • 大型工程:打掉重練,自己做統包
  • 中型工程:全部自己來
  • 小工程:請人來做
2. 手工戒指與國外求婚
3. 準備結婚的事情
4. 家人的健康問題

其實還有好多事情,已經沒辦法馬上記憶起來,不過我真的過的很充實啊!只是口袋沒有充實的感覺。。。

突然覺得長大好可怕,肩膀上的東西慢慢開始不同了。
不過日子還是要過,加油吧!

我應該要來重新開始寫blog才對...