Skip to content

Instantly share code, notes, and snippets.

@mrgarymartin
mrgarymartin / config_manager.py
Created November 1, 2023 19:51
In this example, the ConfigManager class is responsible for managing the application configuration. It checks if the AZURE_ENVIRONMENT environment variable is set to determine if the application is running in Azure. If it is, it initializes the Azure App Configuration client and fetches configuration settings from there. If not, it loads environ…
import os
from dotenv import load_dotenv
from azure.appconfiguration import AzureAppConfigurationClient, ConfigurationSetting
class ConfigManager:
def __init__(self):
# Load environment variables from .env file for local development
load_dotenv()
# Check if running in Azure environment
@mrgarymartin
mrgarymartin / readme.md
Created October 17, 2023 14:09
Create a permanent Powershell Alias Profile

Make the document user profile

cd $env:USERPROFILE\Documents
md WindowsPowerShell -ErrorAction SilentlyContinue
New-Item -Path $Profile -Type File

Using a function the contents of Microsoft.PowerShell_profile.ps1 can be:

@mrgarymartin
mrgarymartin / genmoveterraformstates.sh
Created July 10, 2023 16:19
This script will capture current terraform states then output a ps1 script to run and import them
# Extract the identifying URLs using terraform plan
terraform plan | grep "Refreshing state" > terraform-current-states.txt
# Extract the states we know from the configuration
terraform state list > terraform-state-list.txt
# Subscription strings
OLD_SUBSCRIPTION=00000000-0000-0000-0000-000000000000
NEW_SUBSCRIPTION=11111111-1111-1111-1111-111111111111
# Resource group strings (other name)
OLD_RG='Rg-appname-TST'
name: Build and Push Docker Image
on:
push:
branches:
- main
env:
ECR_REGISTRY: <your ECR registry URL>
ECR_REPOSITORY: <your ECR repository name>
@mrgarymartin
mrgarymartin / deploy-rollback.yml
Created April 7, 2023 16:06
Github action with rollback.
name: Deploy
on:
push:
branches:
- main
jobs:
deploy:
runs-on: ubuntu-latest
@mrgarymartin
mrgarymartin / company-form.component.ts
Last active January 2, 2023 20:06
File Upload Service
import { FileUpload } from './../../../models/file-upload';
import { FileUploadService } from './../../../services/file-upload.service';
import { Component, OnInit } from '@angular/core';
@Component({
selector: 'app-company-form',
templateUrl: './company-form.component.html',
styleUrls: ['./company-form.component.scss']
})
export class CompanyFormComponent implements OnInit {
@mrgarymartin
mrgarymartin / pushFileToStorage.ts
Created January 2, 2023 18:33
Angular Fire Upload tasks
pushFileToStorage(fileUpload: FileUpload) {
const filePath = `${this.basePath}/${fileUpload.file.name}`;
const storageRef = ref(this.storage, filePath);
const uploadTask = uploadBytesResumable(storageRef, fileUpload.file);
uploadTask.on('state_changed',
(snapshot) => {
// Observe state change events such as progress, pause, and resume
// Get task progress, including the number of bytes uploaded and the total number of bytes to be uploaded
@mrgarymartin
mrgarymartin / StreamLabsCloudbot.md
Created December 14, 2020 22:46
Streamlabs Cloudbot Commands updated 12/2020

====== Streamlabs Cloudbot 2020 Updated======

***This is a updated doc for Cloudbot. Supported by Tunerzedge.

Streamlabs Chatbot (SLCB), formerly known as AnkhBot, is a self-hosted bot solution developed by [https://twitter.com/ankhheart|AnkhHeart] for Twitch streamers with a number of unique features, as well as now officially integrates with [https://www.streamlabs.com/|Streamlabs] and its exclusive services. Not to mention the software and all of its features are completely free.

There's numerous resources for learning how to utilize the bot to its fullest potential, but this documentation is an attempt at an all in one, quick and simple source for getting started and beyond. It's also important to note that a lot of these commands use an external API, coded and provided by the user [https://decapi.me/|Decicus] that would otherwise be impossible to do with the bot alone.


@mrgarymartin
mrgarymartin / cleanup-docker.sh
Last active December 9, 2020 17:37
This script installs automated docker cleanup via "docker image prune"
#!/bin/sh
# This script installs automated docker cleanup via "docker image prune"
# onto systemd-based systems.
# It requires that docker is installed properly
# source: https://techoverflow.net/2019/10/03/how-to-automatically-cleanup-prune-docker-images-daily/
cat >/etc/systemd/system/PruneDocker.service <<EOF
[Unit]
Description=PruneDocker
@mrgarymartin
mrgarymartin / firewall.sh
Created February 23, 2018 20:35
Updated version to whitelist all cloudflare ips in firewalld
#!/usr/bin/env bash
#https://techstat.net/automatic-whitelist-cloudflare-ips-firewalld-bash-script-via-cron-job/
SERVER_IP=xxx.xxx.xxx.xxx
for i in $(curl "https://www.cloudflare.com/ips-v4"); do sudo firewall-cmd --permanent --zone=public --add-rich-rule 'rule family="ipv4" source address="'$i'" port port=80 protocol=tcp accept'; done
for i in $(curl "https://www.cloudflare.com/ips-v4"); do sudo firewall-cmd --permanent --zone=public --add-rich-rule 'rule family="ipv4" source address="'$i'" port port=443 protocol=tcp accept'; done
for i in $(curl "https://www.cloudflare.com/ips-v6"); do sudo firewall-cmd --permanent --zone=public --add-rich-rule 'rule family="ipv6" source address="'$i'" port port=80 protocol=tcp accept'; done
for i in $(curl "https://www.cloudflare.com/ips-v6"); do sudo firewall-cmd --permanent --zone=public --add-rich-rule 'rule family="ipv6" source address="'$i'" port port=443 protocol=tcp accept'; done