Skip to content

Instantly share code, notes, and snippets.

View yorzi's full-sized avatar
🏠
Working from home

Andy Wang yorzi

🏠
Working from home
  • Xi'an, China
  • 12:38 (UTC +08:00)
View GitHub Profile
@yorzi
yorzi / gist:769254
Created January 7, 2011 08:22 — forked from xdite/gist:758319
Ruby on Rails development Conventions

Rails 開發注意要點

About Ruby Syntax

  • 編輯器設定 soft tab (space=2),以 2 格空白符號做為程式內縮距離(不分語言)。
  • 函式如果只有一個參數,就不強制打()
  • 函式如果有二個以上的參數,通通都要有 ()
    • (避免發生奇怪的paser bug跟保持專案一致性)
  • 字串限定用雙引號包覆
  • 善用 "#{str1} #{str3} " 等字串改寫技巧取代不需要的字串加法。
@yorzi
yorzi / ruby-1.9-tips.rb
Created February 13, 2011 05:32 — forked from igrigorik/ruby-1.9-tips.rb
Ruby 1.9 Features and tips.
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!"
@yorzi
yorzi / gist:836679
Created February 21, 2011 05:11 — forked from xdite/gist:835829
MacBook 装机配置Rails的步骤

MacBook 裝機步驟

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

系統套件

  • Software Update
  • Install Xcode ( Mac OS X Install CD 那一塊的 >> 選擇安裝)
@yorzi
yorzi / write_deploy_log.rb
Created February 24, 2011 02:36 — forked from terrbear/write_deploy_log.rb
save the deploy log to server
alias :pputs :puts
def puts(str = "")
pputs(str)
$out << "#{str}"
end
STDOUT.instance_eval do
alias :pputs :puts
def puts(str = "")
pputs(str)
@yorzi
yorzi / branch-prompt.sh
Created March 17, 2011 13:33 — forked from thadd/branch-prompt.sh
Show your current git branch in a right-hand prompt in zsh
typeset -ga precmd_functions
precmd_functions+='update_git_branch_prompt'
update_git_branch_prompt() {
RPROMPT=$(git branch --no-color 2> /dev/null | sed -e '/^[^*]/d' -e 's/* \(.*\)/(\1)/')
}
@yorzi
yorzi / rspec-syntax-cheat-sheet.rb
Created May 9, 2011 11:49 — forked from dnagir/rspec-syntax-cheat-sheet.rb
RSpec 2 syntax cheat sheet by example
# RSpec 2.0 syntax Cheet Sheet by http://ApproachE.com
# defining spec within a module will automatically pick Player::MovieList as a 'subject' (see below)
module Player
describe MovieList, "with optional description" do
it "is pending example, so that you can write ones quickly"
it "is already working example that we want to suspend from failing temporarily" do
pending("working on another feature that temporarily breaks this one")
@yorzi
yorzi / rails_3_1_rc4_changes.md
Created June 24, 2011 02:08 — forked from ryanb/rails_3_1_rc4_changes.md
The Changelogs for Rails 3.1 Beta 1

Railties 3.1 RC4

  • The new rake task assets:clean removes precompiled assets. [fxn]

  • Application and plugin generation run bundle install unless --skip-gemfile or --skip-bundle. [fxn]

  • Fixed database tasks for jdbc* adapters #jruby [Rashmi Yadav]

  • Template generation for jdbcpostgresql #jruby [Vishnu Atrai]

@yorzi
yorzi / jquery.myplugin.coffee
Created July 1, 2011 14:42 — forked from jimeh/jquery.myplugin.coffee
Example jQuery plugin written in CoffeeScript, and the resulting compiled JavaScript file.
$.fn.extend
myplugin: (options) ->
self = $.fn.myplugin
opts = $.extend {}, self.default_options, options
$(this).each (i, el) ->
self.init el, opts
self.log el if opts.log
$.extend $.fn.myplugin,
default_options:
@yorzi
yorzi / sass.rb
Created August 3, 2011 02:32 — forked from denmarkin/sass.rb
Rails 3 initializer for Heroku/SASS setup
# see http://forrst.com/posts/Setting_up_SASS_on_Heroku-4dZ
# You can put this in config/initializers/sass.rb
# Setup directory in tmp/ to dump the generated css into
require "fileutils"
FileUtils.mkdir_p(Rails.root.join("tmp", "stylesheets", "generated"))
# Tell SASS to use the .sass files in public/stylesheets/sass and
# output the css to tmp/stylesheets/generated
@yorzi
yorzi / .bash_profile
Created August 31, 2011 01:01 — forked from bcardarella/.bash_profile
Git Autocompletion
source ~/.git-completion.sh
alias gco='git co'
alias gci='git ci'
alias grb='git rb'