Skip to content

Instantly share code, notes, and snippets.

View liamfoneill's full-sized avatar
🏠
Working from home

Liam F. O'Neill liamfoneill

🏠
Working from home
View GitHub Profile
@liamfoneill
liamfoneill / stripe-api-limiter-example.py
Last active March 27, 2024 13:28
The key aspects are: Initialize each user's rate limiter with different max requests and refill rates. Before making a request, check if there are available tokens If not, sleep based on refill time. Deduct a token for each request Refill tokens periodically based on refill rate. This allows allocating different capacity to different users while…
# USAGE EXAMPLES
# User 1 request
# curl -H "X-User-ID: user1" -d "..." http://localhost:5000/charge
# User 2 request
# curl -H "X-User-ID: user2" -d "..." http://localhost:5000/charge
from flask import Flask, request, jsonify
import stripe
@liamfoneill
liamfoneill / azure-pipelines-terraform.yaml
Created June 20, 2023 09:01
This is an example of a 'proper' Azure DevOps Pipeline for deploying Infrastructure with Terraform. It leverage Environments and publishes and consume the Terraform plan in separate stages. It also use the Service Connection credentials from Azure DevOps so we aren't duplicating Service Principals for no good reason.
trigger:
- main
pool:
vmImage: ubuntu-latest
stages:
- stage: build
jobs:

Keybase proof

I hereby claim:

  • I am liamfoneill on github.
  • I am liamfoneill (https://keybase.io/liamfoneill) on keybase.
  • I have a public key ASCcmm40KkC2y7x-jUHdVUKjFC0sbeFatj01gyi16WKcJQo

To claim this, I am signing this object:

@liamfoneill
liamfoneill / bootstrap.ps1
Created October 25, 2021 11:05
This is a file I use to bootstrap a new Windows installation with all of the applications and tools that I use. Ideally I would get everything from Winget but there are times when I need to get the apps from chocolately or Windows Store.
winget install code52.Carnac -s winget
winget install Github.GithubDesktop -s winget
winget install Postman.Postman -s winget
winget install Github.cli -s winget
winget install Microsoft.Powertoys -s winget
winget install Microsoft.AzureCLI -s winget
winget install Microsoft.VisualStudioCode -s winget
winget install Microsoft.VisualStudio.2022.Enterprise -s winget
winget install Microsoft.Bicep -s winget
winget install Microsoft.Teams -s winget
@liamfoneill
liamfoneill / management-groups.tf
Created March 28, 2021 19:05
Provisions the management structure of Azure Enteprise-Scale landing zones
variable "enterprise-scale-prefix" {
description = "Please enter a prefix which will be appended to your management group names for easy identification"
default = "building-azure"
}
resource "azurerm_management_group" "building_azure" {
name = var.enterprise-scale-prefix
}
resource "azurerm_management_group" "platform" {
@liamfoneill
liamfoneill / privatednszones.tf
Last active August 11, 2022 15:42
Creates Azure Private DNS Zones for all of the Azure PaaS Services that (currently) support Private Endpoints. NOTE: For some services, like AKS the DNS Zones need to be regionalised so you will need 1 zone for each region. I have included North and West Europe as examples. If you are using DNS Servers to resolve these records you will also need…
resource "azurerm_resource_group" "dnsprivatezones" {
name = "connectivity-dnsprivatezones-001"
location = "West Europe"
tags = {
"Usage" = "Azure Private DNS Zones for Private Endpoints"
}
}
resource "azurerm_private_dns_zone" "azureautomation" {
name = "privatelink.azure-automation.net"
resource_group_name = azurerm_resource_group.dnsprivatezones.name
###################
# Reset-AzOpsTenant #
###################
#Version: 02-08-2021
#Author: Liam F. O'Neill
#Email: lioneill@microsoft.com
#Contributor: Paul Grimley
<#
.SYNOPSIS