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

12/10/2007

Leopard,Terminal,Vim,and .... UTF-8

最近買了新的 MacBook ,Leopard 到目前感覺都還很不錯,尤其是大幅度改進的 Terminal.app 。不過,跟我預料的一樣,Terminal 的 UTF-8 問題依舊沒有設定好。所以花了點時間 survey ,順便把一直困擾我的 vim 中文問題一起解決。

Leopard 內建的 vim 是 version 7.0.234 ,GNU bash 是 3.2.17 ,這幾個版本支援 UTF-8 都沒有任何問題,所以其實只是設定檔的問題。

1. 修改 ~/.profile
加入
export LANG=zh_TW.UTF-8
2. ~/.vimrc
加入
if has("multi_byte")
set enc=utf-8
set fenc=utf-8
set termencoding=utf-8
set fileencodings=utf-8,ucs-bom,big5,latin1
else
echoerr "Sorry, this version of (g)vim was not compiled with multi_byte"
endif
不確定是否有沒有更好的設定方式,不過,我已經滿意了。

7/25/2007

[心得] RubyCocoa

轉自 ptt MacDev 板

作者 godfat (godfat 真常) 看板 MacDev
標題 [心得] RubyCocoa
時間 Tue Jul 24 21:40:20 2007
──────────────────

嫌 objective-c 太難用嗎?還在等 obj-c 2.0 嗎?先試試 RubyCocoa 吧 XD
http://rubycocoa.sourceforge.net/

[quote]
It lets you write full-stack Cocoa applications in Ruby. It is also possible to write a Cocoa application that mixes Ruby and Objective-C code.
[/quote]

how to install?
有灌 macports 的話:(當然,xcode 是一定要灌的)
sudo port install ruby
sudo port install rb-rubygems(非必要,但建議)
sudo port install rb-cocoa

文件放在:
/Developer/Documentation/RubyCocoa

範例放在:(相當豐富)
/Developer/Examples/RubyCocoa

我這裡有一個簡化的 hello world, 可以小瞥一下:

require 'osx/cocoa'
include OSX

app = NSApplication.sharedApplication

hello = NSWindow.alloc.initWithContentRect_styleMask_backing_defer [200.0, 300.0, 100.0, 100.0], 15, 2, 0
hello.setTitle 'Hello'

btn = NSButton.alloc.initWithFrame [10.0, 10.0, 80.0, 80.0]
hello.contentView.addSubview btn
btn.setTitle 'Hello World!'
btn.setAction 'stop:'
btn.setBezelStyle 4

hello.display
hello.orderFrontRegardless

app.run

另外可以順便請教一下,如何讓視窗在按下 X 時關閉而不是隱藏嗎?我沒寫過 obj-c(XD), 昨天文件翻來翻去找不到要怎麼做



另一方面,如果只是要做 GUI 而不需要 call mac 的 api 的話,個人強力推薦 QtRuby

sudo port install qt4-mac(這個會 build 很久)
sudo port install cmake

QtRuby 沒有這麼方便的安裝法,要到
http://rubyforge.org/projects/korundum/
抓 qt4-qtruby, 然後進到目錄下:

cmake .
make
sudo make install

於是就可以正常使用 QtRuby 了,hello world 如下:

require 'qt'
include Qt
app = Application.new ARGV
hello = PushButton.new "Hello World!"
hello.resize 100, 30
hello.show
app.exec



Qt 是什麼?
http://trolltech.com/products/qt
是我用過最棒的 GUI toolkit, 使用 C++ 語言。可用 GPL 授權或用商業授權(很貴),二擇一(這是 Qt 唯一被批評的點)

Ruby 是什麼?
http://ruby-lang.org/
是我用過最方便的 programming language, 使用 Ruby license(很自由)歡迎來 ptt Ruby 板參觀 :p



Mac OS 10.5 將搭載 Ruby 1.8.6 + Rails 1.2.3, 想試試 Rails 寫網站嗎?
sudo gem install rails
不需要等 10.5 就可以輕鬆試驗了 XD
http://rubyonrails.org/

==

發完神經了,有傷眼請見諒 XD

--
#!/usr/bin/ruby          [露比] /Programming (Kn|N)ight/            看板《Ruby》
# if a dog nailed extra legs that http://www.ptt.cc/bbs/Ruby/index.html
# walks like an octopus, and Welcome ~Ruby@ptt~
# talks like an octopus, then ◢█◣ http://www.ruby-lang.org/
# we are happy to treat it as █ http://www.ruby-doc.org/
# if it were an octopus. ◥ ◤ http://www.rubyforge.org/
--
※ 發信站: 批踢踢實業坊(ptt.cc)
◆ From: 220.135.28.18

10/22/2006

37 signal + MAC

Apple 在他的網站上面發表了一篇 Video , 由37 Signal的Jason Fried和David Heinemeier Hasson 講解 Apple ,Ruby,Ruby on Rails 之間的關係,以及如何彼此互助。眾所皆知,37 Signal 每個人都是使用 MAC 的,TextMate 這個在 MAC 上強大的編輯器也因為 Ruby on Rails 的 15 minute 系列才被大家所知道,所以由他們推薦 MAC 也相當的有說服力。

我也是用 MAC 的,我自己覺得 MAC 很多方面都相當適合網頁程式設計師。像是BSD Like 的 Darwin OS,Command Line 的介面,內建許多知名 Language(包括Ruby),也內建 SQLite,對於程式設計師來說,MAC相當有吸引力歐。