Skip to content

Instantly share code, notes, and snippets.

View coleca's full-sized avatar

Cole Calistra coleca

View GitHub Profile
@0xdabbad00
0xdabbad00 / AWSExposedCredentialPolicy_DO_NOT_REMOVE
Created April 10, 2020 18:34
Copy of AWSExposedCredentialPolicy_DO_NOT_REMOVE sent to me by someone
{
"Version": "2012-10-17",
"Statement": [
{
"Effect": "Deny",
"Action": [
"iam:UpdateAccessKey",
"ec2:RequestSpotInstances",
"organizations:InviteAccountToOrganization",
"lightsail:DownloadDefaultKeyPair",
@tuannvm
tuannvm / 0.12.tf
Last active December 3, 2022 18:50
#terraform #hashicorp #cheatsheet #0.12
#### first class expresssion
variable "ami" {}
resource "aws_instance" "example" {
ami = var.ami
}
#### list & map
resource "aws_instance" "example" {
vpc_security_group_ids = var.security_group_id != "" ? [var.security_group_id] : []
}
@mgoodness
mgoodness / helm-rbac.md
Last active October 30, 2021 17:04
Helm RBAC setup for K8s v1.6+ (tested on minikube)
kubectl -n kube-system create sa tiller
kubectl create clusterrolebinding tiller --clusterrole cluster-admin --serviceaccount=kube-system:tiller
helm init --service-account tiller

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.

@mgoodness
mgoodness / k8s-svc-annotations.md
Last active September 7, 2024 16:25
AWS ELB-related annotations for Kubernetes Services (as of v1.12.0)
  • service.beta.kubernetes.io/aws-load-balancer-access-log-emit-interval (in minutes)
  • service.beta.kubernetes.io/aws-load-balancer-access-log-enabled (true|false)
  • service.beta.kubernetes.io/aws-load-balancer-access-log-s3-bucket-name
  • service.beta.kubernetes.io/aws-load-balancer-access-log-s3-bucket-prefix
  • service.beta.kubernetes.io/aws-load-balancer-additional-resource-tags (comma-separated list of key=value)
  • service.beta.kubernetes.io/aws-load-balancer-backend-protocol (http|https|ssl|tcp)
  • service.beta.kubernetes.io/aws-load-balancer-connection-draining-enabled (true|false)
@leonardofed
leonardofed / README.md
Last active September 12, 2024 07:52
A curated list of AWS resources to prepare for the AWS Certifications


A curated list of AWS resources to prepare for the AWS Certifications

A curated list of awesome AWS resources you need to prepare for the all 5 AWS Certifications. This gist will include: open source repos, blogs & blogposts, ebooks, PDF, whitepapers, video courses, free lecture, slides, sample test and many other resources.


#!/bin/bash
if [ "$(id -u)" = "0" ]; then
echo
echo "Do not run as root. Run as your user"
exit 2
fi
usage() { echo "Usage: $0 -t <time needed> <salt-feature-branch>" 1>&2; exit 1; }
@wallyqs
wallyqs / Docker Compose + NATS example
Last active February 18, 2024 22:27
NATS Docker blog post/HTTP Server
FROM golang:1.6.2
COPY . /go
RUN go get github.com/nats-io/nats
RUN go build api-server.go
EXPOSE 8080
ENTRYPOINT ["/go/api-server"]
@mikemackintosh
mikemackintosh / git-pre-commit-replace-tabs.sh
Last active May 31, 2016 15:33
R.I.G.B.Y. - Tabs v Spaces
#!/usr/bin/env ruby
files_modified = `git diff-index --cached --name-only HEAD`.split(/\n/)
# expand_tabs from Stack Overflow
# -> http://stackoverflow.com/a/8900610/1431239
# This algorithm by Brian Candler (B.Candler@pobox.com) found on the
# org.ruby-lang.ruby-talk mailing list
# http://markmail.org/message/avdjw34ahxi447qk
# Date: 2003-5-31 13:35:09
# Subject: Re: expandtabs
@josue
josue / xdebugger.sh
Last active May 12, 2016 13:24
xdebugger - Execute php file and outputs xdebug trace and script logs to file for further analyzing.
#/bin/bash
check_xdebug_installed () {
INSTALLED=`php -m | grep xdebug`
if [ "$INSTALLED" = "" ]; then
echo "PHP extention 'xdebug' must be installed."
exit 1
fi
}