@zen nice :)
#6 楼 @nouse 是的,完全可以。又提供了一种解法,棒棒的!
Git cherry-pick is great when you know which commits you want (and you know their corresponding hashes) -- it's hard to beat the simplicity it provides.
But what about the situation where you don't know what commits you want? Thankfully git has you covered there as well! We can use interactive rebasing for this -- it's the best way to review a series of commits you're about to rebase.
第一步: 第二步: 第三步:
def report
'Memory ' + `ps ax -o pid,rss | grep -E "^[[:space:]]*#{$$}"`
.strip.split.map(&:to_i)[1].to_s + 'KB'
end
d1 = report
big_var = " " * 10_000_000
d2 = report
big_var = nil
d3 = report
ObjectSpace.garbage_collect
sleep 1
d4 = report
?> d1
=> "Memory 40900KB"
>> d2
=> "Memory 40908KB"
>> d3
=> "Memory 40908KB"
>> d4
=> "Memory 40908KB"
s1 = report
big_var = 1_000_000.times.map(&:to_s)
s2 = report
big_var = nil
s3 = report
ObjectSpace.garbage_collect
sleep 1
s4 = report
>> s1
=> "Memory 10020KB"
>> s2
=> "Memory 149492KB"
>> s3
=> "Memory 149512KB"
>> s4
=> "Memory 139896KB"
>>
ruby 2.1.1p76 (2014-02-24 revision 45161) [x86_64-darwin12] && OSX
效果和上面出入略大呢?怎么破?
@ery 👍
@ery 是的,非常 nice 呢,简直可以称为利器
@simlegate 恩,不同的异常处理确实不一样。 @zamia 文章翻译的挺好的,由于版本更替,物是人非,能想到的也就是在旧版本中 nil 存在 id 方法。感谢带来这么精彩的文章。 @u1430993106 看得挺细的。👍
@zamia 再补充个问题
为了保证一个子事务的 rollback 被父事务知晓,必须手动在子事务中添加 :require_new => true ,照这样的理解 子事务里面的会回滚,同时父事务中的也会被回滚?
貌似不是这个样子的
抛出 Exception
时
抛出 ActiveRecord::Rollback
时
不使用嵌套的例子
@zamia 第一个问题
david = User.find_by_name("david")
david.id
nil 对象也有一个 id 方法
那这个是怎么回事呢?不太明白。
第二个问题
触发事务回滚 第一个例子中,结束标签 少个 d
@xxqfamous thx
@tianlitao 由于一月份项目太多,无瑕顾及。临时停掉了网站
If you want the best the world has to offer, offer it your best!