Skip to content

Instantly share code, notes, and snippets.

View vladfaust's full-sized avatar
🕉️
एकक्षण

Vlad Faust vladfaust

🕉️
एकक्षण
View GitHub Profile
@vladfaust
vladfaust / build_sqlite3_lib.md
Created August 18, 2020 17:31 — forked from zeljic/build_sqlite3_lib.md
Build SQLite3 .lib file on windows

How to build SQLite3 .lib file on Windows 10

  1. Download source from source (https://www.sqlite.org/download.html)

    For example: source https://www.sqlite.org/2020/sqlite-amalgamation-3310100.zip

  2. Download binary from binary

    For example: binary https://www.sqlite.org/2020/sqlite-dll-win64-x64-3310100.zip

  3. Extract both archives to the same directory

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.

@vladfaust
vladfaust / gist:cc51b26c8ef545017bdb
Last active January 15, 2016 19:38 — forked from bibstha/gist:49540af53fa0ec5ab869
Deploy to dokku from codeship.com

After migrating from heroku to dokku, we had to also chance codeship so we deploy to dokku. I followed the following steps to successfully deploy to dokku.

  1. Save the public key of the codeship project. It is found in Project Settings > General Settings.
  2. Copy the public key to a file /tmp/codeship_projectname.pub.
  3. Make sure when pasting, all the contents are in a single line and not multiple lines.
  4. Add the public key to dokku using the following command in console. Reference.
cat /tmp/codeship_projectname.pub | ssh root@yourdokkuinstance "sudo sshcommand acl-add dokku [description]"