Skip to content

Instantly share code, notes, and snippets.

View CR11CS's full-sized avatar
🐈

CRXFTAI3ALTTICS CR11CS

🐈
View GitHub Profile
@CR11CS
CR11CS / Terraform-Linux-SSH-KeyGen-Local.tf
Last active February 18, 2023 06:05
Terraform (Linux) file to provision an AWS EC2 instance and associated RSA key pair then exports .pem SSH key to local device and outputs instance public IP for quick reference. Automatically changes permissions on .pem file for use.
/*
Created by CR11CS
https://github.com/CR11CS
Generates an SSH keypair and stores SSH key to local folder, then outputs your server public IP for quick reference.
Linux Compatible version (using BASH)
*/
############################ Generic Terraform AWS EC2 Config
terraform {
@CR11CS
CR11CS / Terraform-Windows-SSH-KeyGen-Local.tf
Last active August 27, 2022 02:01
Terraform (Windows) file to provision an AWS EC2 instance and associated RSA key pair then exports .pem SSH key to local device and outputs instance public IP for quick reference.
/*
Created by CR11CS
https://github.com/CR11CS
Generates an SSH keypair and stores SSH key to local folder, then outputs your server public IP for quick reference.
Windows Compatible version (using PowerShell)
*/
############################ Generic Terraform AWS EC2 Config
terraform {
@CR11CS
CR11CS / configure-env-variables.py
Created August 27, 2022 01:59
Set Global Environment Variables for Windows / Linux
# Jankily configures environment variables at global scope for Windows or Linux but doesn't inherit to child process without extra steps
def set_environment_variables(access_key, secret_key):
"""Sets the required environment variables for Terraform to make API calls to AWS."""
if os.name == "posix":
with open(os.path.expanduser("~/.bashrc"), "a") as linux_environment_variables:
linux_environment_variables.write(f"export AWS_ACCESS_KEY_ID={access_key}")
linux_environment_variables.write(f"export AWS_SECRET_ACCESS_KEY={secret_key}")
if os.name == "nt":
windows_environment_variables = f'''Windows Registry Editor Version 5.00\n[HKEY_LOCAL_MACHINE\SYSTEM\CurrentControlSet\Control\Session Manager\Environment]\n"AWS_ACCESS_KEY_ID"="{access_key}"\n"AWS_SECRET_ACCESS_KEY"="{secret_key}"'''
@CR11CS
CR11CS / Gmail-API-SMS.py
Created April 1, 2023 22:31
This script is to send an email using the Gmail API (to an SMS gateway so you can send SMS to a cell phone) provided you have configured your Google developer project & settings.
from __future__ import print_function
import os.path
import base64
from google.auth.transport.requests import Request
from google.oauth2.credentials import Credentials
from google_auth_oauthlib.flow import InstalledAppFlow
from googleapiclient.discovery import build
from googleapiclient.errors import HttpError
@CR11CS
CR11CS / sed-mocking-text.sh
Created April 12, 2023 19:47
Uses sed to convert text to MocKInG tExT
sed -E 's/(\S)(\s*?)(\S)?/\U\1\2\L\3/g'
@CR11CS
CR11CS / gist:bec895c277ad439b7c5f8ff2c6f239ee
Last active July 14, 2023 01:47
Recreate Git directory structure and files as .md for import to Obsidian
import os
import shutil
def recreate_directory_structure(source_directory, target_directory):
for root, dirs, files in os.walk(source_directory):
for dir_name in dirs:
source_dir = os.path.join(root, dir_name)
target_dir = os.path.join(target_directory, os.path.relpath(source_dir, source_directory))
os.makedirs(target_dir, exist_ok=True)
for file_name in files: