- 編輯器設定 soft tab (space=2),以 2 格空白符號做為程式內縮距離(不分語言)。
- 函式如果只有一個參數,就不強制打()
- 函式如果有二個以上的參數,通通都要有 ()
- (避免發生奇怪的paser bug跟保持專案一致性)
- 字串限定用雙引號包覆
- 善用 "#{str1} #{str3} " 等字串改寫技巧取代不需要的字串加法。
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
def tip(msg); puts; puts msg; puts "-"*100; end | |
# | |
# 30 Ruby 1.9 Tips, Tricks & Features: | |
# http://www.igvita.com/2011/02/03/new-ruby-19-features-tips-tricks/ | |
# | |
tip "Upgrading to Ruby 1.9 is simple: rvm install 1.9.2 && rvm --default 1.9.2" | |
tip "Ruby 1.9 supports named captures in regular expressions!" |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
#!/bin/sh | |
# | |
# redis - this script starts and stops the redis-server daemon | |
# | |
# chkconfig: - 85 15 | |
# description: Redis is a persistent key-value database | |
# processname: redis-server | |
# config: /etc/redis/redis.conf | |
# config: /etc/sysconfig/redis | |
# pidfile: /var/run/redis.pid |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
rails new test -d mysql -Tm https://gist.github.com/956645.txt |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
source 'http://rubygems.org' | |
gem 'rails', '3.1.0.beta1' | |
# Bundle edge Rails instead: | |
# gem 'rails', :git => 'git://github.com/rails/rails.git' | |
# Asset template engines | |
gem 'sass' | |
gem 'coffee-script' |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
# remove files | |
run "rm README" | |
run "rm public/index.html" | |
run "rm app/assets/images/rails.png" | |
run "cp config/database.yml config/database.yml.example" | |
# install gems | |
run "rm Gemfile" | |
run "curl -L https://gist.github.com/956650.txt > Gemfile" |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
# remove files | |
run "rm README" | |
run "rm public/index.html" | |
run "rm public/images/rails.png" | |
run "cp config/database.yml config/database.yml.example" | |
# install gems | |
run "rm Gemfile" | |
run "curl -L https://github.com/Psli/rails3-app-template/raw/master/Gemfile > Gemfile" |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
<!-- layout file --> | |
<% if current_user %> | |
Welcome <%= current_user.username %>. Not you? <%= link_to "Log out", logout_path %> | |
<% else %> | |
<%= link_to "Sign up", signup_path %> or <%= link_to "log in", login_path %>. | |
<% end %> |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
comet(Req) -> | |
Body = Req:recv_body(), | |
io:format("~nBody: ~p~n", [Body]), | |
Socket = Req:get(socket), | |
inet:setopts(Socket, [{active, once}]), | |
Response = connection:handle_json(Body), | |
inet:setopts(Socket, [{active, false}]), | |
io:format("~nSending Response: ~s~n", [Response]), | |
Req:ok({"application/json", [], Response}). |
NewerOlder