Skip to content

Instantly share code, notes, and snippets.

View bmangold's full-sized avatar

Brandon Mangold bmangold

  • San Francisco, CA
View GitHub Profile

How we incorporate next and cloudfront (2018-04-21)

Feel free to contact me at robert.balicki@gmail.com or tweet at me @statisticsftw

This is a rough outline of how we utilize next.js and S3/Cloudfront. Hope it helps!

It assumes some knowledge of AWS.

Goals

@brikis98
brikis98 / main.tf
Last active March 14, 2023 23:43
A hacky way to create a dynamic list of maps in Terraform
# The goal: create a list of maps of subnet mappings so we don't have to statically hard-code them in aws_lb
# https://www.terraform.io/docs/providers/aws/r/lb.html#subnet_mapping
locals {
# These represent dynamic data we fetch from somewhere, such as subnet IDs and EIPs from a VPC module
subnet_ids = ["subnet-1", "subnet-2", "subnet-3"]
eips = ["eip-1", "eip-2", "eip-3"]
}
# Here's the hack! The null_resource has a map called triggers that we can set to arbitrary values.
# We can also use count to create a list of null_resources. By accessing the triggers map inside of
@checco
checco / rw_ro_access.sql
Last active March 22, 2024 08:32 — forked from oinopion/read-access.sql
How to create a read only user in AWS RDS PostgreSQL and a user with superuser privileges on AWS RDS PostgreSQL
--
-- Read only
--
-- Create a group
CREATE ROLE postgres_ro_group;
-- Grant access to existing tables
GRANT USAGE ON SCHEMA public TO postgres_ro_group;
GRANT SELECT ON ALL TABLES IN SCHEMA public TO postgres_ro_group;
@csawyerYumaed
csawyerYumaed / nomad-check.py
Created October 17, 2016 16:22
after running a nomad job, check, verify and if failed, roll-back to previous build.
#!/usr/bin/env python
"""
As part of my jenkins build-pipeline, I'm having jenkins build and then deploy my services directly into nomad.
my build and deploy in jenkins looks like this:
docker build -t pdfservice:$BUILD_NUMBER .
docker tag pdfservice:$BUILD_NUMBER registry.service.consul:5000/pdfservice:$BUILD_NUMBER
docker push registry.service.consul:5000/pdfservice:$BUILD_NUMBER
docker build -t pdfservice:latest .
docker tag pdfservice:latest registry.service.consul:5000/pdfservice:latest
docker push registry.service.consul:5000/pdfservice:latest
@gboeing
gboeing / pypi.md
Last active June 17, 2022 16:11
How to organize and distribution a package on pypi

To distribute a package on pypi

Directory structure

/project/
    /package/
        __init__.py
        module.py
 setup.py
@vcastellm
vcastellm / ecs-run
Last active April 15, 2024 17:55
Run task and wait for result in AWS ECS
#!/usr/bin/env bash
set -e
function usage() {
set -e
cat <<EOM
##### ecs-run #####
Simple script for running tasks on Amazon Elastic Container Service
One of the following is required:
Required arguments:
@Ninir
Ninir / aws-api-gw-lambda-post-root-resource.md
Created August 4, 2016 16:37
Create an AWS API Gateway with a POST method on the root resource targetting a given Lambda

Description

This helps creating an AWS API GW with a POST method on the root resource (i.e /) targetting a given Lambda.

The current Terraform documentation is exposing a Mock integration. Thus, a few options are missing when wanting to expose a Lambda integration instead.

There are a few things to know:

1. Add the integration HTTP Method

First of all, you will need to add the integration_http_method alongside the http_method, as in:

@rgreenjr
rgreenjr / postgres_queries_and_commands.sql
Last active June 20, 2024 14:04
Useful PostgreSQL Queries and Commands
-- show running queries (pre 9.2)
SELECT procpid, age(clock_timestamp(), query_start), usename, current_query
FROM pg_stat_activity
WHERE current_query != '<IDLE>' AND current_query NOT ILIKE '%pg_stat_activity%'
ORDER BY query_start desc;
-- show running queries (9.2)
SELECT pid, age(clock_timestamp(), query_start), usename, query
FROM pg_stat_activity
WHERE query != '<IDLE>' AND query NOT ILIKE '%pg_stat_activity%'