2012年10月1日 星期一

Emacs for objective-c development

Emacs for obj-C development.md

To develop GNUStep program under Debian, we need 2 handy tools:

1. Auto complete for obj-c.
2. Source browsing.

For the first one, emacs has auto complete package support for after Emacs24. If you are using Debian wheezy, you have to build from source. Before compile, the pre-requisite packages are:

 $ sudo aptitude install build-essential libxpm-dev libgif-dev libtiff-dev libjpeg-dev libgtk2.0-dev libdbus-1-dev texinfo

Build with these pre-requisite packages can let your emacs customise the X fonts easily. And the build commands are :

$ ./configure --with-x-toolkit --with-xft
$ make
$ sudo make install

ps.: It seems that the default configuration does the same work.

The default install directory is /usr/local/bin.

Since Emacs24, in emacs package provides a convient way to install e-lisp plug-ins, add the following lines in your .emacs :

(require 'package)
(add-to-list 'package-archives 
    '("marmalade" .
    "http://marmalade-repo.org/packages/"))
(package-initialize)
(add-to-list 'load-path "~/.emacs.d")    ; This may not be appeared if you have already added.

Now open emacs, install the auto-complete package by :

M-x package-install [RET] auto-complete [RET]

After that, append the following lines in your .emacs

(require 'auto-complete-config)
(ac-config-default)
(add-to-list 'ac-dictionary-directories "~/.emacs.d/elpa/auto-complete-1.4/dict")
(add-to-list 'ac-modes 'objc-mode) ;;here load the objc-mode

Note : Here the version is 1.4, modify the version if necessary.

OK, now we should have the emacs support auto-complete for obj-c.

For the second one: Source browsing, can be done with Gnu Global (gtags).

Since the Debian/Ubuntu currently provide Global-5.7.1, which does not support '--encode-path' option, the option will be used in the plug-in. We have to build Global-6.2.4 from source then "configure" "make install", and complete the setup by copying gtags.el to ~/.emacs.d and append :

(add-to-list 'load-path "~/.emacs.d")    ; This may not be appeared if you have already added.
(autoload 'gtags-mode "gtags" "" t)

After that, the gtags command will be setup correctly. #

2012年9月29日 星期六

git-diff between branches

git-diff on different branches.md

Before we diff, we have 4 branches :

tomteki-Mac-Pro:HearingLite tom$ git branch

TestUSB
* master
multiLanguage
testKbd

tomteki-Mac-Pro:HearingLite tom$

We want to diff the EditProfileViewController.m, to get the idea of where it is :

tomteki-Mac-Pro:HearingLite tom$ git diff --name-only master testKbd | grep EditProfileViewController

Classes/EditProfileViewController.h
Classes/EditProfileViewController.m
HearingLite/EditProfileViewController.h
HearingLite/EditProfileViewController.m

tomteki-Mac-Pro:HearingLite tom$

The above command will diff between two branches (testKbd and master).

Assume it is restructured from HearingLite/ path to Classes/ path (if doesn't , git ls-files can help ), the next thing to do is really diff them :

 git diff master:Classes/EditProfileViewController.m testKbd:HearingLite/EditProfileViewController.m

In this note, we use the 'git diff --name-only' to get the path of our target file. And use 'git diff [branch] : [file path]' to diff the file in various branches.

2012年8月16日 星期四

Check members belonging to a group

Under Mac OS, sometimes we want to know whether we belongs to the 'admin' group :

dscacheutil -q group -a name admin
and we get the responses :
name: admin
password: *
gid: 80
users: root tom 

More details about this command are in man pages.

2012年7月23日 星期一

Linux USB to Ethernet 與 driver 驗證




App 如何指定可支援的機子?

上架時,遇到一個問題:若是想讓自己的 App 避開某些機子,如『不適合在 3gs 或其規格以下的機子執行』,該怎麼辦呢?

這裡提供了一個方法,搭配 Apple 所訂的 Device Compatibility Matrix,就能用規格來卡位。

例如:『不適合在 3gs 執行』這個條件,就根據 Matrix 來找出 3gs 不支援的功能,像是 "front-facing-camera" or "gyroscope" 都可以,把它設定到你的 App Plist 的 "required device capabilities",將來就可以在你的 iTunes App 黃頁,巨大 Icon 的下方,看到 3gs 沒有被列入了!

參考文件: App related resources.

2012年6月1日 星期五

統計程式碼

想要統計程式行數,又是 bash 新手等級,查到好心網友的指令:
 find . \( -name *.h -or -name *.c \) -print

拿 linux source 來試試,沒問題。但是在我的 project 下,出現 error:
find: paths must precede expression: CADebugMacros.h

修正後可以了:
 find . \( -name '*.h' -or -name '*.c' \) -print

最後加上 wc :
 find . \( -name '*.h' -or -name '*.c' \) -exec cat "{}" ";" | wc -l