Skip to content

Instantly share code, notes, and snippets.

@rainly
rainly / gist:758425
Created December 29, 2010 11:10 — forked from xdite/gist:758319

Rails 開發注意要點

About Ruby Syntax

  • 編輯器設定 soft tab (space=2),以 2 格空白符號做為程式內縮距離(不分語言)。
  • 函式如果只有一個參數,就不強制打()
  • 函式如果有二個以上的參數,通通都要有 ()
    • (避免發生奇怪的paser bug跟保持專案一致性)
  • 字串限定用雙引號包覆
  • 善用 "#{str1} #{str3} " 等字串改寫技巧取代不需要的字串加法。
#This will load the current command into the editor defined in the variable VISUAL
# ctrl+x then ctrl+e
export VISUAL=vim
export EDITOR=vim
export VIM_APP_DIR="~/App/Bin"
export PATH="~/Local/bin:$PATH"
#Auto dir correction for cd
shopt -s cdspell
#!/usr/bin/env ruby
require 'fileutils'
require 'tmpdir'
Gems = %w(factory_girl rspec-core capybara remarkable remarkable_activerecord)
output_dir = Dir.pwd
Dir.mktmpdir do |tmpdir|

Rails Dev Stack on Snow Leopard

(from a scratch install). Kinda, I imported my user home (~) from a Time Machine backup.

Homebrew

sudo mkdir /usr/local
sudo chown -R `whoami` /usr/local
curl -L http://github.com/mxcl/homebrew/tarball/master | tar xz --strip 1 -C /usr/local

MacBook 裝機步驟

警告: 請絕對不要跳著裝!

系統套件

  • Software Update
  • Install Xcode ( Mac OS X Install CD 那一塊的 >> 選擇安裝)
~$ ARCHFLAGS='-arch i386 -arch x86_64'
~$ rvm install ree --debug --enable-shared=yes
~$ wget http://sourceforge.net/projects/rubycocoa/files/RubyCocoa/1.0.0/RubyCocoa-1.0.0.tar.gz/download
~$ tar xzf RubyCocoa-1.0.0.tar.gz && rm RubyCocoa-1.0.0.tar.gz && cd RubyCocoa-1.0.0
~/RubyCocoa-1.0.0$ ruby install.rb config --build-universal=yes
~/RubyCocoa-1.0.0$ ruby install.rb setup
~/RubyCocoa-1.0.0$ sudo ruby install.rb install
大道至简:软件工程实践者的思想(点评版) http://www.china-pub.com/196277
MySQL核心内幕 http://www.china-pub.com/196166
软件调试实战(软件调试权威指南) http://www.china-pub.com/193196
修改代碼的藝術 http://www.china-pub.com/36363
高效程序员的45个习惯:敏捷开发修炼之道 http://www.china-pub.com/196313
设计网事--互联网产品设计实践 http://www.china-pub.com/193212
程序员修炼之道--从小工到专家(十周年纪念版) http://www.china-pub.com/47975
实战Nginx:取代Apache的高性能Web服务器 http://youa.baidu.com/item/5ae4a036c13655e3b86ae1c4
《高性能MySQL(第二版)》 http://youa.baidu.com/item/f536a31fdbae8221965dd7ae
@rainly
rainly / .emacs
Created March 17, 2011 09:58 — forked from lidaobing/.emacs
(custom-set-variables
;; custom-set-variables was added by Custom.
;; If you edit it by hand, you could mess it up, so be careful.
;; Your init file should contain only one such instance.
;; If there is more than one, they won't work right.
'(TeX-PDF-mode t)
'(auto-compression-mode t nil (jka-compr))
'(browse-url-browser-function (quote browse-url-firefox))
'(c-offsets-alist (quote ((arglist-intro . +) (namespace-open . 0) (namespace-close . 0) (innamespace . 0))))
'(case-fold-search t)
JAVA_OPTS="${JAVA_OPTS} -Xms1024m -Xmx2048m -XX:MaxPermSize=256m -server"; export JAVA_OPTS;
irb(main):001:0> a = Object.new
=> #<Object:0x7ff7a6ff6388>
irb(main):002:0> a.object_id #获取对象ID
=> 70350817702340
irb(main):003:0> a.class #获取对象类型
=> Object
irb(main):004:0> Integer.superclass #获取父类
=> Numeric
irb(main):006:0> Numeric.superclass #...
=> Object