rails validates_presence_of

validates_presence_of
在对应属性值为false的时候,rails会认为是空,不能通过验证。
rails版本:2.3.5

mysql 删除字段

alter table `user` drop column dep;

硬恢复(删除最后的改动,commit信息和代码)

git-reset –hard HEAD~1

安慰人也是学问

安慰人也是学问

rails memcache config

config.gem "cached_model"
require 'memcache'
memcache_options = {
:c_threshold => 10_000,
:compression => true,
:debug =>false,
:namespace => 'my_rails_app',
:readonly => false,
:urlencode =>false
}
 
CACHE = MemCache.new memcache_options
CACHE.servers = ['localhost:11211', 'localhost:11212']

git log查找某一个author的提交

git log --author=<pattern>

Passing parameters to a shared example group

shared_examples_for "a measurable object" do |measurement, measurement_methods|
  measurement_methods.each do |measurement_method|
    it "should return #{measurement} from ##{measurement_method}" do
      subject.send(measurement_method).should == measurement
    end
  end
end

wc命令

wc命令用来打印文件的文本行数、单词数、字节数等(print the number of newlines, words, and bytes in files)

格式:wc -l

打印指定文件的文本行数。(l=小写L)

参数:-c, –bytes
打印字节数(print the byte counts)

参数:-m, –chars
打印字符数(print the character counts)

参数:-l, –lines
打印行数(print the newline counts)

参数:-w, –words
打印单词数(print the word counts)

memcached 启动参数

启动参数
-p memcached监听的TCP端口
-l 监听的ip地址
-d 以daemon方式运行,将程序放入后台
-u memcached的运行用户
-P memcached的pid文件路径
-m memcached可以使用的最大内存数量
-c memcached同时可以接受的最大的连接数

如果你希望以socket方式来访问memcached,那么在启动的时候就必须去掉 -l和-p参数,并加上-s参数:

Aliasing “it_should_behave_like” to “it_has_behavior”

RSpec.configure do |c|
  c.alias_it_should_behave_like_to :it_has_behavior, 'has behavior:'
end
 
shared_examples_for 'sortability' do
  it 'responds to <=>' do
    sortable.should respond_to(:<=>)
  end
end
 
describe String do
  it_has_behavior 'sortability' do
    let(:sortable) { 'sample string' }
  end
end
Powered by WordPress | Find Wireless Deals at BestInCellPhones.com. | Thanks to iCellPhoneDeals.com Free Cell Phones, Find Highest CD Rates and Incinerador De Grasa Revisión