顯示具有 environment 標籤的文章。 顯示所有文章
顯示具有 environment 標籤的文章。 顯示所有文章

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年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.

2011年1月24日 星期一

Difference between .bash_profile and .bashrc Files

以下內容是從這裏節錄出來的:

.bash_profile is executed for login shells, while .bashrc is executed for interactive non-login shells.

就是說,當你使用 login console 或用 ssh login 時, .bash_profile 會被調用。
如果只是在 GNOME, KDE 或 emacs 裏面,打開一個 shell command 時, .bashrc 會被調用。

那麼作 global 設定時,就是這兩種情形分別對應到 /etc/profile /etc/bash.bashrc 啦!
其中,若是需要在 login 時,也希望 bashrc 被調用,就可以在 profile 裏面 source bashrc.

2011年1月23日 星期日

Install sun-java5-* in debian squeeze

Debian Squeeze 已經把 sun-java5-* (亦即 java 1.5 )拿掉了,統統換成了 sun-java6-* (亦即 java 1.6)「註:這裡 * 代表 jre, bin, jdk, demo 等等部份」。
可是 Android 開發環境會檢查 java 環境,仍然需要 java 1.5 ,怎麼辦呢?
可以用 dpkg --force-depends 強制安裝 sun-java5-*  ,方法如下:

1. 首先下載 Lenny 版本的 package :
sun-java5-bin_1.5.0-22-0lenny1_i386.deb
sun-java5-jre_1.5.0-22-0lenny1_all.deb
sun-java5-demo_1.5.0-22-0lenny1_i386.deb
sun-java5-jdk_1.5.0-22-0lenny1_i386.deb

2  因為 bin 依賴於 jre , jre 依賴於 bin, jdk 依賴於 demo, demo 依賴於 jdk 。
所以用強制 depends 選項(把依賴關係列為 warning 而非 error )就可以順利安裝,指令為:
#> dpkg --force-depends -i  sun-java5-bin_1.5.0-22-0lenny1_i386.deb\
  sun-java5-jre_1.5.0-22-0lenny1_all.deb\
  sun-java5-demo_1.5.0-22-0lenny1_i386.deb\
  sun-java5-jdk_1.5.0-22-0lenny1_i386.deb

3. 切換內定 java version :
#> sudo update-java-alternatives -s java-1.5.0-sun
如果出現一堆跟 firefox plugin 的錯誤訊息,像這樣:
update-alternatives: error: alternative /usr/lib/jvm/java-1.5.0-sun/jre/plugin/i386/ns7/libjavaplugin_oji.so for firefox-javaplugin.so not registered, not setting.
...
不用管它,因為我們 compile Android 時應該不會用到 firefox 的 java plugin。

4. 驗證 java version :
#> javac -version
應該就可以看到 java 1.5 的訊息了!
#


2010年11月26日 星期五

忽然想要列印 man page 怎麼辦?

老 Unix 玩家應該覺得很簡單,但對於新手的我還是要紀錄一下:
1. 先由命令查閱要列印的 man page 再哪裡? 例如 :
tom@glest:~/temp$ man -w groff
/usr/share/man/man1/groff.1.gz
2. 原來是有壓縮的,知道後就可以印了:
tom@glest:~/temp$ zcat `man -w groff` | groff -m man -T ps - | lpr

這裡 groff 是排版用的指令,輸入格式為 man page ,輸出格式為 ps 。
That's it !

p.s. 當然你的 lpr 要正確才行,如果有裝好 cups,下列命令就可以看到系統印表機狀態:
tom@glest:~/temp$ iceweasel http://localhost:631/admin



2010年8月26日 星期四

emacsclient font configurations

This text applies to version after Emacs 23.1
首先,我們可以把下列一行加入 ~/.bashrc
  alias ex='emacsclient -a "" -c "$@"'

解釋一下:
當我們使用 emacsclient 時,必須有一個 emacs server 啟動才可以用。
emacsclient 的參數有一個 -a "" 表示萬一 emacs server 沒有啟動,
就使用 `alternate editor' ,它可以是 vi, pico ... ,若是空字串 ("") ,表示 `那就叫一個 emacs server 起來好了'.
另外 參數 -c 表示 `create a new frame' 而不是用 server 的 frame.
至於後面要打開的檔案(可以一次指定開多個檔案來編輯),就用 bash 提供的 $@ 來代入即可。

第二,設定字型,因為 emacs server 可以在 X 之前就啟動了,因此,
很合理的,它不理會你指定在 X 環境下的字型。
現在的 X 環境下有兩種字體系統:核心字體系統與 Xft 字體系統。Xft 有許多優良的特性(向量,反鋸齒等),
所以 Emacs 23.1 開始支援 Xft as its font base. (see XftGnuEmacs).
只要在你的  ~/.Xresources 指定就好,例如,我們打算用 DejaVu Sans Mono 字型 :
    Emacs.FontBackend: xft
    Emacs.font: DejaVu Sans Mono-14

(謎:怎樣查出這個字型呢? M-x describe-font 然後給個 mono 讓它 match 出完整的字型敘述)

第三,設定 frame 的特性,我們希望打開 frame 時,是黑底白字,不要 tool bar, 不要 scroll bar ...
這些都與預設值不同,該怎麼設定呢?
emacs 的 default-frame-alist 裡面紀錄了 `新開一個 frame 所需的參數',設定這個就對了!
在你的 ~/.emacs 內這樣指定
(let ((frame '((left . 0)
               (top . 0)
               (width . 110)
               (height . 30)
               (tool-bar-lines . nil)
               (vertical-scroll-bars . nil)
               (background-color . "black")
               (foreground-color . "white")          
)))
  (setq default-frame-alist frame)
  (setq initial-frame-alist frame)

)

說明一下,[ GNU Emacs 手冊 ]查得到所有的 frame parameters。
第一次開啟的 frame(應該是 server frame)  參數會參考 `initial-frame-alist' ,往後開啟 frames(emacsclient frame)都會參考 `default-frame-alist' .

完工了!記得重新開啟 X 讓 .Xresources 生效啊啊~

2010年8月17日 星期二

lpr and cups troubleshooting

Bad situation encountered :
系統是 Debian/Testing.
透過 browser 瀏覽 http://localhost:631 可以透過 CUPS 管理印表機,目前我系統是安裝 CUPS 1.4.4。
使用其中的 Administration | Maintenance -> Print Self Test Page 可以順利印出測試頁面。
但是 emacs 裡面要列印時,就出問題了: 使用 print buffer 命令根本沒反應!

Troubleshooting :
因為 emacs 使用 `lpr' 指令作列印動作 --- 改用 `lpr' 指令試著列印一個文字檔 --- 也失效。
用 `lpq' 觀察 printing jobs 發現都在 spool 上,卻沒有送到 printer 。
觀察 debian 套件關係,原因是 cups-bsd-1.4.4-2 沒有裝,反倒是 lpr-2008.05 套件有裝上,這兩個是 conflict 的套件,因為都有提供 `lpr' 等指令。
但是前者提供 printing commands (i.e. `lpr') interactive with the CUPS. 必須裝這個套件而不是 `lpr-2008.05' 套件
這次裝錯套件的現象,可能是以前 upgrade 時沒有仔細看就同意用 lpr 套件來取代。
移除 `lpr-2008-05' 並裝上 `cups-bsd-1.4.4-2' ,重新啟動 cupsd 還不夠;可能是我還有 daemon 沒有重起,或是 debian 套件系統沒有正確的 post processing,就沒有去追究了。
試著重新開機, work !






2009年12月13日 星期日

Debian 升級 testing (sqeeze) 與 ATI X1450 的 driver 問題

Asus A8J 大約是兩三年前的華碩主流筆電之一,獨立顯卡採用  ATI X1450.
Debian Lenny 下有提供 ATI propietary driver (non-free) :
kernel driver(要 3D 加速,需要 kernel driver ) : fglrx-modules-2.6.26-* 等,driver source : fglrx-kernel-src
for openGL lib : fglrx-glx
根據這篇 [ arch linux ATI ] [ref 1] 知道,X1450 的 code name 為 (RV515, 即 r5xx  系列)

Debian 系統升級到  testing 後,kernel driver 套件變成 : fglrx-source , 且改為支援 r6xx-r7xx 而已,也就是說 ATI 官方 driver 不再支援 r5xx 系列,
但是這些不被支援的系列的 spec 已經  release 給 open source 社群。所以目前升級後的  xorg 7.4 裡面的  xserver-xorg-video-ati 套件,可以支援 r5xx 系列。
xorg.conf 已經不需要了,xorg 會自動偵測掛載  radeon driver。

glxgears 的數據為
1598 frames in 5.0 seconds = 319.450 FPS 
1613 frames in 5.0 seconds = 322.503 FPS  ( 本blog時間測)

6097 frames in 5.0 seconds = 1219.223 FPS 
6014 frames in 5.0 seconds = 1202.697 FPS  ( 2010年4月20測)

跟使用 ATI propietary ~1200 FPS 比較起來,稍稍等待 open source 社群是值得的,
時間會證明 open source community 提供的 code 效能,總會超越 propietary code 的,並且更穩定。
Technorati 標籤: , , ,

2009年11月18日 星期三

Emacs 捲動的設定

Emacs 內定的捲動方式為一次半頁,這樣看起來跳動很大,有些不習慣。修改 .emacs 加入下面設定,可以變成『自然捲』...
(setq scroll-margin 0 scroll-conservatively 10000 )

另外,想定義新的 macro 並且紀錄於 .emacs 以供下次使用,可以這樣作,
(以 scroll other window (up/down) one line 這個動作為例) :

C-x (      定義新的 macro
M 1 C-M-v   我們的新 command --- scroll other window down one line
C-x )     結束 macro 定義

給它取一個名字:
M-x name-last-kbd-macro [Enter]
打入自取名稱 ,例如 scroll-other-window-down-one-line [Enter]

打開 ~/.emacs 準備加入這個新定義:
M-x insert-kbd-macro
打入剛剛取的名稱  scroll-other-window-down-one-line [Enter] 就會出現
(fset 'scroll-other-window-down-one-line
   "\261\226")
然後定義一個 hotkey 例如 F11 給它:
(define-key global-map [f11] 'scroll-other-window-down-one-line)

以後按 F11 就會 scroll down other window.

為了對稱,做了一個 scroll other window up one line ,最後在 .emacs 裡長成這樣:

...
(fset 'scroll-other-window-up-one-line
   "\2551\226")
(define-key global-map [M-f11] 'scroll-other-window-up-one-line)
(fset 'scroll-other-window-down-one-line
   "\261\226")
(define-key global-map [f11] 'scroll-other-window-down-one-line)
...

Technorati 標籤:

2009年11月13日 星期五

eclipse + CDT for C++ Development

這篇說明 eclipse 的設定,為了怕設定的部份翻譯不好,乾脆用英文寫...

Since `cscope + ecb + emacs' is my favorite development tool, there is no need for "eclipse", while not all people get used to `emacs' conveniently. Here we introduce another good IDE for C/C++ developemnt --- Eclipse !!

1. From [ http://www.eclipse.org/downloads/ ] download `Eclipse IDE for Java EE...' or `Eclipse IDE for Java...' or `Eclipse IDE for C/C++...', I download the eclipse-jee-galileo-linux-gtk.tar.gz  , extract,  then add path (where you untar eclipse ) to ~/.bashrc such that when I type `eclipse' command so that it can be brought up (Yes, its green software).

2. Install the CDT plugin : (If you use `Eclipse IDE for C/C++' , please skip this step)
In eclipse menu, goto (Help | Install New Software ...) then type this html page:
http://download.eclipse.org/tools/cdt/releases/galileo
(note : CDT need > eclipse 3.5 or up )
then update. The CDT component will then be installed.

3. Create C++ project :
In eclipse menu, goto "File | New | Project...|C++":
   a. Fill "Project Name".
   b. Select Makefile Project | Empty Project.  <--- yes, choose `Empty Project' for the external Makefile case !!
   c. Select Linux GCC at the right side.
   d. Press the "Finish" button.
then you have created an empty project in eclipse.

4. Import external sources/Makefile to project:
Right click on the project name, select "import...":
choose "General | File System" , click "Next" button, then "browse" to your source path, (of,course, you can filter out unnecessary files ) then press "Finish".

5. Goto "Project | properties| C/C++ Build", in the right "Build Location" field, press the "workspace" button, and given your project path , for e.g. ${workspace_loc:/test/home/tom/external_open_source}. (I was fooling around here for 6 hours --- before I learn to press the "workspace" button)

Then press "OK", the project will be built. But in our `external_open_source' project, we need use `make opt' as the building command ---goto "Project |Proties" , in "C/C++ Build",
a. select the "Behavior" tab,
b. uncheck "Build on resource save(Auot build)",
c. modify "Build (Incremental build)" to "opt",
d. then press "OK" to finish.

Now, you should build the `external_open_source'  sucessfully, instead of the 'No rule to make target `opt' error message !

ps. In Debian Lenny, make sure to use

$update-alternatives --config java

to configure your default java to `java-6(5)-sun' instead of `java-gcj' , the Eclipse will NOT start with `java-gcj' as the default java environment:

  Selection    Alternative
-----------------------------------------------
              1    /usr/bin/gij-4.3
              2    /usr/lib/jvm/java-gcj/jre/bin/java
*+          3    /usr/lib/jvm/java-6-sun/jre/bin/java

Press enter to keep the default[*], or type selection number: 3
 
Technorati 標籤: ,

2009年9月14日 星期一

Suspend, Hibernate and Resume 的問題

這類問題因為 BIOS , H/W 每台機器不一樣,可能出問題的部份不一定相同,通常這樣的問題很難有系統的方式去了解原因。
但是這個 [HAL Sleep Quirks] 網站提供了一個偵測的 script ,幫助我們有系統的釐清原因。

以下紀錄以 Asus A8J 遇到的現象和解決的步驟:

安裝 Debian Lenny 後,從 Gnome 選單 |  關機 | 暫停 後,Resume 時會失敗,但是可以從遠端 ssh 回來,所以可能跟顯卡有關...
執行網站上所下載的 quirk-checker.sh ,建議把 iwl3945 無線網路模組先unload,等到 resume 後再 reload,所以 在 /etc/pm/config.d/unload_modules 加上這行:SUSPEND_MODULES="iwl3945"
但這應該不是原因,再進行一次 suspend,還是無法 resume.

研讀 pm-suspend 的參數說明,發現 --quirk-vbe-post 表示 resume 時可以用 bios 相同方式來 reset graphic device 所以試試看:
以 pm-suspend --quirk-post-vbe 來試驗,果然可以正常恢復...

現在修改 /usr/share/hal/fdi/information/10freedesktop 下的檔案.... 最有關的應該是 20-video-quirk-pm-asus.fdi :
由 lshal 指令得到,我們的機器 system.hardware.product=A8JP
找到這一段:
      <match key="system.hardware.product" prefix_outof="A6M;Z84F">
        <merge key="power_management.quirk.vbe_post" type="bool">true</merge>
      </match>

改為:
      <match key="system.hardware.product" prefix_outof="A6M;Z84F;A8JP">
        <merge key="power_management.quirk.vbe_post" type="bool">true</merge>
      </match>
     

如同紅色粗體這樣加入我們的 product ,表示我們要使用 --quirk-vbe-post 的參數即可
改完後,重新啟動 hal :
#> /etc/init.d/hal restart
現在透過 gnome-power-management 進行 suspend, hibernate 都可以正常 resume 回來了。真高興!
Technorati 標籤:


2009年8月4日 星期二

More on QEMU

兩年前在 [QEMU 安裝與試跑] 探討了模擬 ARM Versatile 系統。 原以為這樣就會使用 QEMU 了,最近兩天為了模擬 x86 不成功,只好重新拾起 [QEMU Documentation] 仔細再 K 一下,補足原本欠缺的觀念,以下紀錄的是該準備的 sources & images :

linux-2.6.28 由 [kernel archive] 下載解壓的,
linux-0.2.img.bz2 由 QEMU Documentation | [download] | 下載得到,
bzImage-2.6.28-test 由 linux-2.6.28 編好之後所得,
initrd.img-2.6.28-test.bz2 由 linux-2.6.28 編好安裝模組 (make modules_install) 後,利用 update-initramfs -c -k 2.6.28-test 所得到的
檔案系統 (bunzip2 -c initrd.img-2.6.28-test.bz2 | cpio -idm)

以下紀錄了幾次錯誤的啟動方式:
#> qemu -kernel bzImage-2.6.28-test
==>A disk image must be given for 'hda' when booting a Linux kernel
(if you really don't want it, use /dev/zero)
#> qemu -kernel bzImage-2.6.28-test -hda /dev/zero
==> booting from Hard Disk
==>failed : not a bootable disk
==> no bootable device
沒頭緒,翻翻線上手冊好了---
在 [QEMU Documentation] 3.8 節 Direct Linux Boot 提到:
`...It is very useful for fast Linux kernel testing.
The syntax is :
qemu -kernel arch/i386/boot/bzImage -hda root-2.4.20.img -append "root=/dev/hda" `

"...Use ‘-kernel’ to provide the Linux kernel image and ‘-append’ to give the kernel command line arguments. The ‘-initrd’ option can be used to provide an INITRD image.
When using the direct Linux boot, a disk image for the first hard disk ‘hda’ is required because its boot sector is used to launch the Linux kernel..."

所以我們得準備一個 disk image,也就是剛才下載的 linux-0.2.img,讓 QEMU 透過 disk image 的 boot sector 載入 kernel image,並且傳 kernel parameter "root=/dev/hda" ,告訴 kernel 說 root filesystem 在 disk image 上!

#>qemu -kernel bzImage-2.6.28-test  -hda linux-0.2.img -append "root=/dev/hda"

終於成功 ,顯示出的 kernel 為餵進去的 2.6.28-test.,注意 disk image 不能用壓縮的 bz2 or gz ,否則會發生 waiting for root filesystem...的現象...殘念!

結論:在模擬 x86 上,需要有 disk image (即使不使用 disk image 上的 kernel image 也一樣),跟模擬 ARM 有所不同。





2009年6月7日 星期日

Apt-get : NO_PUBKEY / GPG error

[原文出處]
有時改過 apt source list 後,會發生 GPG error  抱怨某個 key 找不到,把該 key 帶入下列指令就可以解決,背後原理還不知道,(待查)
gpg --keyserver pgpkeys.mit.edu --recv-key  010908312D230C5F
gpg -a --export 010908312D230C5F | sudo apt-key add -
其中,把範例中的 key 換成發生問題的 key 就可解決#Technorati 標籤: ,