修改Rails默认生成的Gemfile的source

由于大陆的"`特殊情况`",rails默认生成的Gemfile的源 https://rubygems.org很慢甚至被重置,所以适应国情,要修改下Rails默认生成的Gemfile文件。 如何做呢? 很简单,切换到Rails的默认模板路径下,修改Gemfile文件的source: 1.cd $rvm_path/gems/ruby-1.9.3-p194@rails32/gems/railties-3.2.5/lib/rails/generators/rails/app/templates/ 2.修改Gemfile文件,替换https://rubygems.org为http://ruby.taobao.org Over~~ 分

Strings

s = "hello" s.concat(" world") #the same as << s.insert(5, " there") #s[5] = " there" s.slice(0,5) #the same as s[0,5] s.slice!(5,6) #same as s[5,6] = "" s.eql?("hello world") #true #the length of string s = "hello" s.length #5 s.bytesize #5 中文为每字3byte,ASCII为1byte s.size # 5 s.empty? #false "".empty? #true s = "hello" s.index('l') #2 s.index(?l) #2 s.index(/l+/) #2 s.index('l',3) #the first position after position 3 of l s.index('Ruby') #nil s.rindex('l') #3 s.rindex('l',2) #2 index of rightmost l at or before position 2 s.start_with? "hell" #true s.end_with? "bells" #false s.include?('ll') #true s.include?(?H) #false s =~ /[aeiou]{2}/ #nil s.match(/[aeiou]/) {|m| m.to_s} #e return first "this is it".split #this is it "hello".split('l') #['he','','o'] "1, 2,3".split(/,\s*/) #1,2,3 "banana".partition("an") #["b", "an", "ana"] "banana".rpartition("an") #["ban", "an", "a"] "a123b".partition(/\d+/) #["a", "123", "b"] s = "hello" s.sub('l', 'L') #replace the first l to L s.gsub("l", "L") #replace all the l to L s.sub!(/(.)(.)/, '\2\1') #swap first character s.sub!(/(.)(.)/, '\\2\\1') #"ehllo" Double backslashes for double quotes "hello world".gsub(/\b./) { |match| match.upcase } #Hello World s = "hello" s.upcase #HELLO s.downcase #hello s.capitalize #Hello s.swapcase #HELLO s.casecmp("HELLO") #0 case