Skip to content

Instantly share code, notes, and snippets.

View tierra's full-sized avatar

Bryan Petty tierra

View GitHub Profile
@goodwill
goodwill / cloud-sql-proxy.service
Last active December 15, 2023 06:37
Example Systemd file for starting cloud sql proxy at system start
[Install]
WantedBy=multi-user.target
[Unit]
Description=Google Cloud Compute Engine SQL Proxy
Requires=networking.service
After=networking.service
[Service]
Type=simple

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.

@grahamb
grahamb / sfucanvas.md
Last active August 16, 2021 17:54
SFU's Canvas LMS infrastructure and ugprade

🎓 Canvas at SFU

Simon Fraser University is a mid-sized comprehensive university with three campuses in the Greater Vancouver area of British Columbia, Canada. We are a trimester school, with a Fall, Spring and Summer term. We have approximately 25,000 undergraduate FTEs.

SFU chose Canvas as its new LMS during a selection process in 2011/2012. We went into production in 2012. As of this writing, our enrollment counts in Canvas are:

  • Students: 25250
  • Teachers: 1070
  • TAs: 865
@Eeemil
Eeemil / _config.yml
Last active July 10, 2022 16:40
Jekyll - adding edit on GitHub button to your site
# Site settings
title: Emil Marklund's blog of digital magics
email: eeemil@acc.umu.se
description: >
A blog on programming, GNU Linux/Unix and other things I might find interesting.
I like to learn and teach and writing about what I learn is a great way to do both.
This blog is running Jekyll
baseurl: "" # the subpath of your site, e.g. /blog/
url: "http://eeemil.se" # the base hostname & protocol for your site
twitter_username: eeemil_
@JustAboutJeff
JustAboutJeff / molasses_spice_cookies.md
Created December 17, 2014 17:51
Molasses Spice Cookie Recipe

Molasses Spice Cookies

With freshly ground spices

These wintry cookies get overlooked for being too traditional. But when you're craving a gingery treat, they're softer and chewier than their spicy crisp gingersnap cousins.

* Preheat Oven to 325° F

* Makes 4 Dozen Cookies

@stereoscott
stereoscott / copy_attachments.rb
Created April 6, 2014 21:56
Paperclip Copy Attachments
module Paperclip
module CopyAttachments
def copy_attachments_from(source_obj, source_bucket = nil, destination_bucket = nil)
self.class.attachment_definitions.keys.each do |attachment_name|
source_attachment = source_obj.send(attachment_name)
next if source_attachment.blank?
destination_attachment = self.send(attachment_name)
connection = destination_attachment.send(:connection)
@malarkey
malarkey / Contract Killer 3.md
Last active April 16, 2024 21:44
The latest version of my ‘killer contract’ for web designers and developers

When times get tough and people get nasty, you’ll need more than a killer smile. You’ll need a killer contract.

Used by 1000s of designers and developers Clarify what’s expected on both sides Helps build great relationships between you and your clients Plain and simple, no legal jargon Customisable to suit your business Used on countless web projects since 2008

…………………………