Skip to content

Instantly share code, notes, and snippets.

View nmagee's full-sized avatar

Neal Magee nmagee

View GitHub Profile
@nmagee
nmagee / destination-trigger.yaml
Created September 16, 2022 13:39
A template snippet for GitHub action that is triggered by a source deployment. This updates a K8S deployment for handling by ArgoCD
name: Remote Dispatch Action
on: [ repository_dispatch, workflow_dispatch ]
jobs:
update-version:
runs-on: ubuntu-latest
steps:
- uses: actions/checkout@v2
- name: Event Information
@nmagee
nmagee / source-trigger.yaml
Last active September 16, 2022 13:41
A template snippet for GitHub action that triggers a K8S deployment via ArgoCD
name: Container Build CICD
on:
push:
branches:
- 'main'
env:
REGISTRY: ghcr.io
IMAGE_NAME: org/container-name
@nmagee
nmagee / delete_ebs_snapshots.py
Last active February 16, 2022 17:54
Delete older EBS snapshots using `boto3`
#!/usr/bin/env python
##### THIS IS A DESTRUCTIVE SCRIPT - USE WITH CAUTION OR SET DryRun=True
import datetime
import sys
import boto3
# Set these two variables before running:
AWSTemplateFormatVersion: '2010-09-09'
Description: 'Simple CloudFront distribution with an S3 origin'
Parameters:
S3BucketName:
Type: String
Description: The name for the S3 bucket - must be unique across all of AWS
AllowedPattern: '^[a-z0-9]{5,40}$'
Resources:
@nmagee
nmagee / Dockerfile
Last active April 5, 2021 18:37
Hello World Flask API for Lightsail
FROM python:3
ADD helloworld.py /
RUN pip install flask
RUN pip install flask_restful
EXPOSE 80
CMD [ "python", "./helloworld.py"]
@nmagee
nmagee / assignment.py
Created March 1, 2021 21:22
FastAPI stack for assignment
#!/usr/bin/env python3
import os
import requests
from fastapi import FastAPI
from typing import Optional
from pydantic import BaseModel
app = FastAPI()
@nmagee
nmagee / convert-to-json.sh
Last active March 21, 2022 22:22
Converts CSV into JSON
#!/bin/bash
jq --slurp --raw-input --raw-output \
'split("\n") | .[1:] | map(split(",")) |
map({"id": .[0],
"fname": .[1],
"lname": .[2],
"email": .[3],
"ipv4": .[5]})' \
mock_data.csv > mock_data.json
#!/bin/bash
set -e
## --------------------------------------------------------------
## OKAY - but simple
## The script has a proper shebang line and has been
## chmod to 755 so it can be executed.
@nmagee
nmagee / detabify.py
Created February 18, 2021 19:37
Convert TSV to CSV using re.sub
#!/usr/bin/env python3
import io
import re
def convert(file_name):
# Open csv file
file_name="new_mock_data"
csv = io.open(file_name + ".csv", mode="w", encoding="utf-8")
@nmagee
nmagee / python-orchestrator.py
Created February 18, 2021 19:24
How to call a bash command from within python3
#!/usr/bin/env python3
# How to run a bash command from within a python3 script.
## -----------------------------------------------------------
## BAD
## This solution looks good but is a bad practice. as os.system
## and os.spawn are older and being replaced. This may not work