Working Remotely (via SSH) Rocks! from Kent Chen @ Speaker Deck
Apple, Mac OS X, Linux, Embedded System, Vim Rocks, Blogger Hack ... VIVOTEK nOOb
| [+/-] |
[Slide] Working Remotely (via SSH) Rocks! / 偽遠距工作之在家加班寫程式超爽der(誤) |
| [+/-] |
[Apple / Mac OS X] How To Ignore a Software Update / 如何略過軟體更新項目 |
Mac OS X的軟體更新跟Windows update一樣很貼心?!... 一整包都送給你,但你跟我一樣,有同樣的困擾,有時候某些項目、功能你根本用不到,不想浪費空間去升級那些,看底下的圖,我想你就知道該怎麼做了。發個文做個記錄...
STEP 1:
| [+/-] |
[Apple / Mac OS X] Administrator privileges gone / root權限不見啦 |
身為菜鳥Apple User的我,在入手iMac 20"之後,就開始 Mac OS X 大玩特玩一番,毫無忌憚地裝了一堆有的沒的軟體,從Leopard (Mac OS X 10.5.x) 一路無痛升至 Snow Leopard (Mac OS X 10.6.5, 64-bit,如下圖),很多軟體也因為相容性的問題,迫使我得再抓別套功能性相同的的取代軟體,或是升級解決。並且也參考了網路上一些Optimization、Performance Tuning的教學或是利用了一些軟體,如OnyX,將整個作業系統,改東改西徹底惡搞一番了。



| [+/-] |
[Apple / Mac OS X] Time Machine Tips (and Bugs?) / 蘋果時光機 |

Step 1: SetFile -a V "/Volumes/Time_Machine_drive_name"
Step 2: killall Finder
(若要放棄隱藏: SetFile -a v "/Volumes/Time_Machine_drive_name").秘技: 透過AFP、Samba來當作Time Machine -> Store Time Machine backups on an AFP NAS
重點就在於這一行: defaults write com.apple.systempreferences TMShowUnsupportedNetworkVolumes 1| [+/-] |
[Mac/Snow Leopard] launchctl - Mac OS X load/unload daemons or agents command |
一般在Unix/Linux上,我們會透過 service 這指令來控制(啟用/停用)某些系統服務,在WIndows上也可以透過,"控制台->管理->服務及應用程式" 或 msconfig來達到同等效用。在我的雪豹被我養得愈來愈肥的情況下,該是停掉一些無三小路用的service的時候了。
詳細指令操作,請找男人: man launchctl
.Disable / Unload oooxxx:sudo launchctl unload -w /System/Library/LaunchAgents/com.apple.oooxxx.plist.Enable / Load oooxxx:sudo launchctl load -w /System/Library/LaunchDaemons/com.apple.oooxxx.plist.所有Daemons及Agents的擺放目錄如下:man launchctl
~/Library/LaunchAgents Per-user agents provided by the user.
/Library/LaunchAgents Per-user agents provided by the administrator.
/Library/LaunchDaemons System wide daemons provided by the administrator.
/System/Library/LaunchAgents Mac OS X Per-user agents.
/System/Library/LaunchDaemons Mac OS X System wide daemons.References:
How To FULLY Disable Spotlight in Leopard
(iPhone) 优化3.0服务,重启内存54M+电量及发热改善明显(大幅优化)
| [+/-] |
[Mac/Snow Leopard] build GDB v7.0 from source |
之前在Leopard (Mac OS X 10.5.X)的時候,都是靠Macports在討生活的,大部份我常用的ports都還Maintain的不錯,但到了Snow Leopard (Mac OS X 10.6.X) 的年代,發現許多ports都被發的bug都一直掛著沒人維護,小弟只好自力救濟了。像是著名的GDB神器,在console底下,只要下個 port search gdb ,就會出現這麼樣一個東西:gdb @6.8 (devel) 6.8版,還蠻新的嘛。接著再下 sudo port install gdb ,就會出現底下不堪入目的畫面
GDB: The GNU Project Debugger---> Computing dependencies for gdb 哪泥......macports裡頭竟然連gdb的檔案都沒放了,不再是萬能的了,此時只好靠萬能的”source code”以及"gcc"了,心想只要有心,沒有porting不過來呀...科科,就是這"灌C"的威力。先來抓個最新版的weekly build的GDB來嚐鮮一下
---> Verifying checksum(s) for gdb
Error: Target org.macports.checksum returned: Could not open file: /opt/local/var/macports/distfiles/gdb/gdb-6.8.tar.bz2
Error: Status 1 encountered during processing.wget ftp://sourceware.org/pub/gdb/snapshots/current/gdb-weekly-7.0.50.20091110.tar.bz2 接著, bunzip2 gdb-*.tar.bz2 解開這壓縮檔。重點戲來了,configure一下,藍色字是key point,記得加,這是在Snow Leopard上編gdb成功的關鍵: $ ./configure --disable-werror --build=x86_64-apple-darwin10 --prefix=/Users/kent/usr 這個時候build成功了,很開心的跑 gdb ./hello ,我想應該會出現
$ make && make installGNU gdb (GDB) 7.0.50.20091110 心想,搓屎…怎麼會這樣,找不到debug symbol..囧rz。(後來發現,好像每次都會出現,但還是可以正常使用,先不管…堪用),再接著執行
Copyright (C) 2009 Free Software Foundation, Inc.
License GPLv3+: GNU GPL version 3 or later
This is free software: you are free to change and redistribute it.
There is NO WARRANTY, to the extent permitted by law. Type "show copying"
and "show warranty" for details.
This GDB was configured as "x86_64-apple-darwin10".
For bug reporting instructions, please see:
Reading symbols from /Users/kent/RD1-2/practice/GDB/gdb-samples/hello...(no debugging symbols found)...done.
(gdb) (gdb) b main 後來求助於Google,似乎是權限的關係,假使你當初就用root權限安裝的話,就沒這問題了。若你和我一樣喜歡安裝在個人目錄下(有代--prefix=/Users/xxx/參數),記得將gdb作個權限相關設定
Breakpoint 1 at 0x100000f0c: file hello.c, line 6.
(gdb) run
Starting program: /Users/kent/RD1-2/practice/GDB/gdb-samples/hello
Unable to find Mach task port for process-id 80958: (os/kern) failure (0x5).
(please check gdb is codesigned - see taskgated(8))
(gdb) $ sudo chgrp procmod /yourpath/gdb
$ sudo chmod g+s /yourpath/gdb
前一篇有個網友提到的擾人的"^M"符號的問題,果然從gdb v6.3.5升到gdb v7.0之後就迎刃而解了,照慣例,抓張圖吧。
| [+/-] |
[VimGdb = vim + gdb] build vim from source with vimgdb patch |
我想對於vim和gdb的搭配,最完美的組合莫過於vimgdb這個patch了。前一陣子在苦腦怎麼樣的環境會讓我操作gdb這個神器最順手呢?! 讓我能夠remote debugging在ARM開發板上的程式得心應手呢 ^^ ?! 先來張snapshot吧!
Clewn(for gVim) / vimGdb(for Vim) 官網:
http://clewn.sourceforge.net/index.html1. tar xjf vim-7.2.tar.bz2
2. tar xzf vimgdb72-1.14.tar.gz
3. patch -d vim72 --backup -p0 < vimgdb/vim72.diff
4. cd vim72
#重點是configure時,記得加上--enable-gdb這個參數
5. ./configure --enable-cscope --enable-gdb --enable-multibyte --disable-gui --enable-gui=no --without-x --disable-gpm --disable-nls --with-tlib=ncurses --enable-pythoninterp --prefix=/home/kent/usr/
6. make && make install===============================================
NOTE: In Ubuntu 8.10 and later versions, -D_FORTIFY_SOURCE=2
is set by default, and is activated when -O is set to 2 or higher.
This enables additional compile-time and run-time checks for several
libc functions. To disable, specify either -U_FORTIFY_SOURCE or
-D_FORTIFY_SOURCE=0.
===============================================
The difference between -D_FORTIFY_SOURCE=1 and -D_FORTIFY_SOURCE=2
is e.g. for
struct S { struct T { char buf[5]; int x; } t; char buf[20]; } var;
With -D_FORTIFY_SOURCE=1,
strcpy (&var.t.buf[1], "abcdefg");
is not considered an overflow (object is whole VAR), while
with -D_FORTIFY_SOURCE=2
strcpy (&var.t.buf[1], "abcdefg");
will be considered a buffer overflow.
============================================./configure --enable-multibyte --enable-cscope --disable-gui --enable-gdb --prefix=/Users/kent/usr/ CFLAGS="-O3 -D_FORTIFY_SOURCE=1"| [+/-] |
[Mac] MacPorts on Snow Leopard (Mac OS X 10.6.1) |
port installed > myports.txt
sudo port clean installed
sudo port -f uninstall installed
sudo port install portname +variant1 +variant2 ...
◎GNU Core Utilities:
coreutils
findutils
gawk
grep
gsed
bash
(安裝方式: sudo port install coreutils +with_default_names)
----------------------------------------------------------
◎順便記錄一下個人常用的:
bash-completion
cflow
ctags
cscope
htop
irssi
lesspipe
git-core
subversion
vim
colordiff
cowsay
wget
| [+/-] |
[Linux/Vim] Vim session manager |
在使用Vim的時候,時常會在不同的Project或是Module之間切來切去,在修改某個Module時,有時變動比較大,不是短時間就可以修改完的,亦或是偶爾會有些Interrupt,必須馬上停止目前的工作,切換到另一個project去...切很大、切不用錢...囧rz,通常一個module一改就得開好幾個檔案,這時想到若能有相關的Tool來達到這應用不知該有多好,心想強大的VIM肯定有類似的plugin可用。
於是乎馬上求助於Google大神,尋找輔助工具,一開始找到了vim內建的mksession,的確可以達到我想要的,但並不是那麼的好用,有些小細節要再tune一下,心想 Vim Scripts 站肯定有許多好心的強者包裝好更方便的plugin了,因此就找到了底下這個好玩意.Description: Vim provides a ':mksession' command to save the current editing session. This plug-in helps to work with Vim sessions by keeping them in the dedicated location and by providing commands to list all sessions, open session, open last session, close session, save session and show last session. From a list of sessions you can open session, delete session, edit session and edit extra session script. Please note that session name can contain spaces and does not have to have a .vim extension. 它幾乎具備了所有我想要的功能了,但美中不足的是,這plugin並沒有考慮到"set autochdir"這個option(這是項好東西呀,我已被寵懷了,不行沒有它呀),這個option會導致透過Vim session manager所產生的檔案的路徑有點錯亂(即使是原生的mksession也有這問題),相關的討論串在此,看來也不少人遇到這問題。將那個workaround solution加進sessionman.vim之後... Perfect! 推薦給有需要的人…
.Link: sessionman.vim : Vim session manager
| [+/-] |
[Mac] Keyfixer 0.4 for Firefox and Thunderbird |
這真是個好東西呀,原本在Mac OS X版本的Firefox的key binding和Windows的有點差異,像是Home/End按鈕在Mac上是無效的,必預按⌘+left(Home)以及⌘+right(End),個人覺得有點難按,不太習慣,後來Google了一下,發現這位仁兄跟我有同樣的困擾,於是手癢生出了這個patch,相關下載資訊如下Description: Patches the key bindings for Mac OS X users of Firefox and Thunderbird to match the key bindings of Windows.
Download: https://addons.mozilla.org/en-US/firefox/addon/9796
| [+/-] |
[Mac] Apache web sharing bug - 為何"網頁共享"會失效 |
這幾天心血來潮,想說將我的Max OS X的Apache (Http server - httpd)跑起來玩看看,畢竟在Mac OS X很多事只要簡單的設定一下就OK了,如下:
但這次踢到鐵板了,在連到最上層的網頁根目錄 (http://localhost/) 是OK的,代表apache有成功run起來,但在針對個人帳戶這邊,也就是 http://localhost/~username/,怎麼連就是會出現 403 Forbidden. 真是見鬼了,只好求助於Google大神,後來發現,若啟動了"網頁共享"服務的話,在針對個人用戶方面,Mac OS X應該在此目錄下
You don't have permission to access /~username/ on this server./private/etc/apache2/users/新增一個和你的username相關的username.conf設定檔,但卻發現此檔案卻不存在於此,因此請自行新增一個吧,內容如下:<Directory "/Users/username/Sites/">之後記得重新啟動apache使生效
Options Indexes MultiViews
AllowOverride None
Order allow,deny
Allow from all
</Directory>sudo apachectl restart
[Best viewed in non-IE browser & This Font]
©2006 Template ReDesign by Kaie | Template Design: Blogger Templates by GeckoandFly.
Original design by Michael Heilemann