Skip to content

Instantly share code, notes, and snippets.

View errrzarrr's full-sized avatar
💭

Roberto errrzarrr

💭
  • Dominican Republic
  • 23:12 (UTC -03:00)
View GitHub Profile

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.

@wojteklu
wojteklu / clean_code.md
Last active May 8, 2025 10:02
Summary of 'Clean code' by Robert C. Martin

Code is clean if it can be understood easily – by everyone on the team. Clean code can be read and enhanced by a developer other than its original author. With understandability comes readability, changeability, extensibility and maintainability.


General rules

  1. Follow standard conventions.
  2. Keep it simple stupid. Simpler is always better. Reduce complexity as much as possible.
  3. Boy scout rule. Leave the campground cleaner than you found it.
  4. Always find root cause. Always look for the root cause of a problem.

Design rules

@octocat
octocat / .gitignore
Created February 27, 2014 19:38
Some common .gitignore configurations
# Compiled source #
###################
*.com
*.class
*.dll
*.exe
*.o
*.so
# Packages #
@gotjosh
gotjosh / gist:8105782
Last active April 8, 2017 04:59
Pixel Perfect Tree's - Full Stack Developer

Pixel Perfect Tree - Full Stack Developer.

Hi there!

We’ve cleared out our desks to make space for a new member at Pixel Perfect Tree. We're a company that's 100% self bootstrap, we had an amazing year and continue to grow on a steady pace.

Our quest searching for a passionate and savvy full-stack developer has just begun.

The lucky developer will have the responsibility of defending our company’s honour fighting imaginary dragons and ogres along our skilled knights from the Order of the Pixel in our Santo Domingo office (however, if you are a wizard and prefer to fight from afar, remote work is a possibility for the right candidate). You'll be expected to not only to write code but also provide your insight on projects and technologies used.

@pksunkara
pksunkara / config
Last active May 6, 2025 17:23
Sample of git config file (Example .gitconfig) (Place them in $XDG_CONFIG_HOME/git)
[user]
name = Pavan Kumar Sunkara
email = [email protected]
username = pksunkara
[init]
defaultBranch = master
[core]
editor = nvim
whitespace = fix,-indent-with-non-tab,trailing-space,cr-at-eol
pager = delta