- 編輯器設定 soft tab (space=2),以 2 格空白符號做為程式內縮距離(不分語言)。
- 函式如果只有一個參數,就不強制打()
- 函式如果有二個以上的參數,通通都要有 ()
- (避免發生奇怪的paser bug跟保持專案一致性)
- 字串限定用雙引號包覆
- 善用 "#{str1} #{str3} " 等字串改寫技巧取代不需要的字串加法。
This file contains 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
<%= render_table(@products, | |
[ | |
["ID", lambda { |p| p.id }], | |
["名稱", lambda { |p| p.name }], | |
["動作", lambda { |p| | |
link_to("Show", admin_product_path(p)) + ' | ' + | |
link_to("Edit", edit_admin_product_path(p)) + ' | ' + | |
link_to("Delete", admin_product_path(p), :confirm => "Are you sure?", :method => :delete )}] | |
], | |
:class_name => "table" |
This file contains 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
<%= render_table(@games, | |
[ | |
["ID", lambda { |p| p.id }], | |
["遊戲名稱", lambda { |p| p.name }], | |
["標籤", lambda { |p| p.tag_list.join(" | ") }], | |
["動作", lambda { |p| | |
if current_user | |
add_to_favorites_status_bar(p) + ' | ' + | |
link_to("Show", game_path(p)) + ' | ' + | |
link_to("Edit", edit_game_path(p)) + ' | ' + |
This file contains 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
<%= render_table(@games, | |
[ | |
["ID", lambda { |p| p.id }], | |
["遊戲名稱", lambda { |p| p.name }], | |
["標籤", lambda { |p| p.tag_list.join(" | ") }], | |
["動作", lambda { |p| | |
add_to_favorites_status_bar(p) + ' | ' + | |
unless current_user | |
link_to("Show", game_path(p)) + ' | ' + | |
end |
This file contains 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
<%= render_table(@games, | |
[ | |
["ID", lambda { |p| p.id }], | |
["遊戲名稱", lambda { |p| p.name }], | |
["標籤", lambda { |p| p.tag_list.join(" | ") }], | |
["動作", lambda { |p| index_table(p)}] | |
], | |
:class_name => "table") | |
%> |
This file contains 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
wget http://hackmysql.com/scripts/mysqlsla | |
chmod +x mysqlsla-2.03 | |
sudo ./mysqlsla-2.03 /var/log/mysql/mysql-slow.log | |
# 預設會列出 top 10 的 slow quires | |
# 可以帶參數 --top 13 修改列出的項目數量 | |
# 通常網路上都說從 top 1, 2, 3 的 slow quires 去修 | |
# 是對增進效能最有幫助的! |
This file contains 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
[ -f ~/.git-bash-completion.sh ] && . ~/.git-bash-completion.sh | |
[[ -s "$HOME/.rvm/scripts/rvm" ]] && . "$HOME/.rvm/scripts/rvm" # This loads RVM into a shell session. | |
[[ -s /Users/jcrt/.rvm/scripts/rvm ]] && source /Users/jcrt/.rvm/scripts/rvm | |
function git_branch { | |
ref=$(git symbolic-ref HEAD 2> /dev/null) || return; | |
echo "("${ref#refs/heads/}") "; | |
} |
This file contains 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
#!/usr/bin/env ruby | |
# http://dis.4chan.org/read/prog/1295544154 | |
# Example: ./sleep_sort.rb 5 1 4 2 3 | |
def sleep_then_puts | |
puts sleep(ARGV.shift.to_i) | |
end | |
threads = [] | |
while !ARGV.empty? do |
This file contains 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
http://animatable.com/demos/madmanimation/ | |
http://www.mozillademos.org/demos/planetarium/demo.html | |
http://www.chrysaora.com/ | |
http://mozillademos.org/demos/remixingreality/demo.html | |
http://playbiolab.com | |
http://chrome.angrybirds.com | |
http://helloracer.com/webgl/ | |
http://videos.mozilla.org/serv/blizzard/audio-slideshow/ | |
http://paulrouget.com/TheSanbox | |
http://hacks.mozilla.org/2011/08/speak-js-text-to-speech-on-the-web/ |
This file contains 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
group :assets do | |
gem 'sass-rails', '~> 3.1.0' | |
gem 'coffee-rails', '~> 3.1.0' | |
gem 'uglifier' | |
gem 'compass', '~> 0.12.alpha' | |
end |
OlderNewer