I hereby claim:
- I am bryanrite on github.
- I am bryanrite (https://keybase.io/bryanrite) on keybase.
- I have a public key whose fingerprint is B30B 6C25 8639 D831 DD61 3D57 ACE2 A309 51FA B65E
To claim this, I am signing this object:
# You have forked a project but someone has submitted a nice looking pull-request | |
# to the upstream project that you want for your fork. | |
# Setup upstream repo | |
git remote add upstream https://github.com/whatever/repo.git | |
# Get the desired pull-request from upstream | |
git fetch upstream pull/<PR-ID>/head:pr-<PR-ID> | |
# Rebase pull-request on your master |
I hereby claim:
To claim this, I am signing this object:
Originally taken from: Braintree Article and expanded on by me.
# Add this to config/environments/development.rb | |
# Limit your development log file to 5 MB | |
config.logger = Logger.new(config.paths["log"].first, 1, 5242880) # 5 megabytes |
# config/routes.rb | |
resources :documents do | |
scope module: 'documents' do | |
resources :versions do | |
post :restore, on: :member | |
end | |
resource :lock | |
end | |
end |
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.
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.