Skip to content

Instantly share code, notes, and snippets.

import boto3
import email
from email.mime.text import MIMEText
from email.mime.multipart import MIMEMultipart
from botocore.exceptions import ClientError
import logging
from email.utils import parseaddr, formataddr
import hashlib
# Configure logging.
@charlesrc019
charlesrc019 / server_sync_route53_via_api.ps1
Created December 12, 2024 23:30
server_sync_route53_via_api.ps1
# Fetch the public IPv4 address from the metadata service.
$ipUrl = "http://checkip.amazonaws.com/"
$publicIp = Invoke-RestMethod -Uri $ipUrl
if (-not $publicIp) {
Write-Error "Failed to retrieve the public IP address."
exit 1
}
Write-Output "Public IP Address: $publicIp"
#$publicIp = "2.2.2.2"
@charlesrc019
charlesrc019 / web_manage_aws_services_easy.py
Created November 13, 2024 22:34
web_manage_aws_services_easy.py
import json
import boto3
def lambda_handler(event, context):
msg = None
try:
data = json.loads(event['body'].lower())
@charlesrc019
charlesrc019 / math_convert_datestamp_to_epoch.py
Created November 11, 2024 15:30
math_convert_datestamp_to_epoch.py
import time
import calendar
def dattim_to_epoch(dattim, fmt='%Y%m%d%H%M'):
return int(calendar.timegm(time.strptime(str(dattim), fmt)))
@charlesrc019
charlesrc019 / math_convert_epoch_to_datestamp.py
Created November 11, 2024 15:29
math_convert_epoch_to_datestamp.py
import datetime
def epoch_to_dattim(epoch_time, fmt='%Y%m%d%H%M%S'):
return int(datetime.datetime.utcfromtimestamp(int(epoch_time)).strftime(fmt))
@charlesrc019
charlesrc019 / endpoint_rename_to_numbers.sh
Created November 8, 2024 02:26
endpoint_rename_to_numbers.sh
#!/bin/zsh
# Check if directory argument is provided
if [ -z "$1" ]; then
echo "Usage: $0 /path/to/directory"
exit 1
fi
# Set the directory
directory="$1"
@charlesrc019
charlesrc019 / web_store_variables.php
Created November 8, 2024 02:25
web_store_variables.php
<?php
// Initialize global parameters.
$SQL_USERNAME = "";
$SQL_PASSWORD = "";
$SQL_DATABASE = "";
$conn = NULL;
// Function. Display an JSON message.
function jsonMessage ($msg='Generic error.', $success=FALSE) {
@charlesrc019
charlesrc019 / web_track_device_ips.php
Created November 8, 2024 02:24
web_track_device_ips.php
<?php
$SQL_DATABASE = "";
$SQL_USERNAME = "";
$SQL_PASSWORD = "";
// Function. Display an JSON message.
function jsonMessage ($MessageDetails='Generic error.', $IsSuccess=FALSE) {
// Return message.
@charlesrc019
charlesrc019 / web_automate_byu_ytime.php
Last active November 8, 2024 02:23
web_automate_byu_ytime.php
<?php
/*
/ BYU Y-TIME TRIGGER FOR IFTTT (UNOFFICIAL)
/ Author: Charles Christensen
/ Edited: April 3, 2019
/
/ Required Dependencies:
/ - IFTTT
/ - PHP Webserver
@charlesrc019
charlesrc019 / server_sync_route53_dns.ps1
Last active November 13, 2024 22:33
server_sync_route53_dns.ps1
Start-Sleep -Seconds 60 # allow windows to spin-up
Import-Module -name AWSPowerShell
# Define your parameters
$hostedZoneId = "ZZZZZ" # The ID of your hosted zone in Route 53.
$recordName = "subdomain.url.co" # The A record you want to update (e.g., "subdomain.example.com.")
$awsRegion = "us-west-2" # The AWS region (if using Route 53 in a specific region)
# Fetch the public IPv4 address from the metadata service.