干掉经常发现的东西

Posted

tags:

篇首语:本文由小常识网(cha138.com)小编为大家整理,主要介绍了干掉经常发现的东西相关的知识,希望对你有一定的参考价值。

  1. # Always be on the lookout for duplicated code. If you find yourself doing
  2. # asset.incomings.find(:all, :limit => 10) in multiple places, then perhaps you need to
  3. # pull that into a method of its own. Given the use of the magic number "10", it might
  4. # not be a bad idea to do so anyway.
  5.  
  6. class Asset < ActiveRecord::Base
  7. has_many :incomings do
  8. def recent(count=10)
  9. find(:all, :limit => count)
  10. end
  11. end
  12. end
  13.  
  14. # Then, you just have to do @asset.incomings.recent to get the first 10 items.

以上是关于干掉经常发现的东西的主要内容,如果未能解决你的问题,请参考以下文章

ChatGPT想干掉开发人员,做梦去吧

干掉 "ZooKeeper",阿里为什么不用 ZK 做服务发现?

记一个程序oom的排查过程

我的博客怎么被发现呢?

干掉僵尸进程

thinkphp5 文件清理列表