Skip to content

Instantly share code, notes, and snippets.

@YimianDai
YimianDai / Submit-PR.md
Last active March 14, 2024 06:28
向开源项目提交 Pull Request

步骤

Part 1 - Local Repo Config

  1. 先 Fork 感兴趣项目,即 dmlc/gluon-cv
  2. Clone 到本地,git clone git@github.com:YimianDai/gluon-cv.git
  3. 添加源项目 dmlc/gluon-cv 作为 upstream 源,git remote add upstream https://github.com/dmlc/gluon-cv.git
  4. 禁止直接向 upstream 源 push,因为我们不是 dmlc 的人,没有 push 的权限,要提交代码必须通过 Pull Request,git remote set-url --push upstream no_push
  5. 创建并切换到本地的新分支 fixMixSoftmaxCrossEntropyLossgit checkout -b fixMixSoftmaxCrossEntropyLoss

Scaling your API with rate limiters

The following are examples of the four types rate limiters discussed in the accompanying blog post. In the examples below I've used pseudocode-like Ruby, so if you're unfamiliar with Ruby you should be able to easily translate this approach to other languages. Complete examples in Ruby are also provided later in this gist.

In most cases you'll want all these examples to be classes, but I've used simple functions here to keep the code samples brief.

Request rate limiter

This uses a basic token bucket algorithm and relies on the fact that Redis scripts execute atomically. No other operations can run between fetching the count and writing the new count.