Skip to content

Instantly share code, notes, and snippets.

View jonathanhle's full-sized avatar

Jonathan Le jonathanhle

View GitHub Profile
@jonathanhle
jonathanhle / gist:d3fa1b2257970a5a11a3c25702ef6c5c
Last active October 29, 2023 02:22
Simplified Python OOP Basics

Simplified Python OOP Basics

  1. Class: A blueprint for creating objects (specific instances) with certain properties and methods. It's like a template for building objects.

    class Car:
        pass
  2. Object: An instance of a class. It's like building a car using the Car blueprint.

@jonathanhle
jonathanhle / GoogleAuthenticationCurl.sh
Created March 16, 2023 13:54 — forked from LindaLawton/GoogleAuthenticationCurl.sh
Curl bash script for getting a Google Oauth2 Access token
# Tutorial https://www.daimto.com/how-to-get-a-google-access-token-with-curl/
# YouTube video https://youtu.be/hBC_tVJIx5w
# Client id from Google Developer console
# Client Secret from Google Developer console
# Scope this is a space seprated list of the scopes of access you are requesting.
# Authorization link. Place this in a browser and copy the code that is returned after you accept the scopes.
https://accounts.google.com/o/oauth2/auth?client_id=[Application Client Id]&redirect_uri=http://127.0.0.1&scope=[Scopes]&response_type=code
# Exchange Authorization code for an access token and a refresh token.
# sh -c "$(curl -fsSL https://gist.githubusercontent.com/gjgd/5a08da85a98bf147294f331461e44d1f/raw/a63bf0f4169a8ab651adfa0a56e676e6bc465876/setup-github-action-runner.sh)"
# Update instance
sudo apt update -y
sudo apt upgrade -y
# Install latest version of git
sudo add-apt-repository ppa:git-core/ppa -y
sudo apt-get update
sudo apt-get install git -y
import asyncio
from typing import Coroutine, List, Sequence
def _limit_concurrency(
coroutines: Sequence[Coroutine], concurrency: int
) -> List[Coroutine]:
"""Decorate coroutines to limit concurrency.
Enforces a limit on the number of coroutines that can run concurrently in higher
@jonathanhle
jonathanhle / AndyHunt.me
Created October 24, 2022 18:50
Terraform Variable Validation
From https://andyhunt.me/til/2021/03/04/you-can-fully-validate-a-complex-input-object-in-terraform/
You can fully validate a complex input object in Terraform
Posted: Thursday 04 March 2021 @ 12:12:55
Terraform allows you to define your inputs as arbitrarily complex objects and lists of objects. For example, consider the following:
variable "instances" {
type = list(object({
name = string
@jonathanhle
jonathanhle / Security_Tools_for_AWS.MD
Created September 15, 2022 21:26 — forked from markofu/Security_Tools_for_AWS.MD
Security Tools for AWS

Security Tools for AWS

I often get asked which tools are good to use for securing your AWS infrastructure so I figured I'd write a short listof some useful Security Tools for the AWS Cloud Infrastructure.

This list is not intended be something completely exhaustive, more so provide a good launching pad for someone as they dig into AWS and want to make it secure from the start.

Open Source

This section focuses on tools and services provided by the community and released as open-source.

@jonathanhle
jonathanhle / main.tf
Created September 12, 2022 23:07 — forked from rodrigodiez/main.tf
Terraform code to configure ALB listener rules with OIDC authentication with one app per route
variable "aws_lb_listener_arn" {
description = "ARN of the ALB listener to include rules into"
type = "string"
}
variable "okta_auth_server_base_url" {
description = "Base URL of Okta's authorization server"
type = "string"
}
@jonathanhle
jonathanhle / System Design.md
Created September 11, 2022 18:51 — forked from vasanthk/System Design.md
System Design Cheatsheet

System Design Cheatsheet

Picking the right architecture = Picking the right battles + Managing trade-offs

Basic Steps

  1. Clarify and agree on the scope of the system
  • User cases (description of sequences of events that, taken together, lead to a system doing something useful)
    • Who is going to use it?
    • How are they going to use it?
@jonathanhle
jonathanhle / generate-aws-sso-config
Created September 8, 2022 21:37
generate-aws-sso-config
# install https://pypa.github.io/pipx/
pipx install git+https://github.com/jonathanhle/aws-sso-config-generator#subdirectory=src
generate-aws-sso-config --start-url https://SSO_SITE.awsapps.com/start --output json --region us-east-1 --sso-region us-east-1
eval $(aws-sso-creds --profile SecurityProd-Administrator export)
@jonathanhle
jonathanhle / How to Record Screen With Internal Audio on Mac
Created September 8, 2022 18:24
How to Record Screen With Internal Audio on Mac
https://appletoolbox.com/record-screen-internal-audio-mac/#Download_and_Install_BlackHole