Skip to content

Instantly share code, notes, and snippets.

View mrichman's full-sized avatar

Mark Richman mrichman

View GitHub Profile
mrichman / cognito.yaml
Created August 12, 2023 02:04 — forked from singledigit/cognito.yaml
Create a Cognito Authentication Backend via CloudFormation
AWSTemplateFormatVersion: '2010-09-09'
Description: Cognito Stack
Type: String
Description: Unique Auth Name for Cognito Resources
# Creates a role that allows Cognito to send SNS messages
mrichman /
Created May 28, 2021 18:49
Resize EC2 volume
# Specify the desired volume size in GiB as a command-line argument. If not specified, default to 20 GiB.
# Get the ID of the environment host Amazon EC2 instance.
# Get the ID of the Amazon EBS volume associated with the instance.
VOLUMEID=$(aws ec2 describe-instances \
mrichman /
Created March 31, 2021 11:07 — forked from sivasamysubramaniam/
A workaround to get all data loaded into AWS RDS MySQL. When a read replica is restored from a snapshot, the replica won't wait for all the data to be transferred from Amazon Simple Storage Service (Amazon S3) to the Amazon Elastic Block Store (Amazon EBS) volume that's associated with the replica DB instance. The replica DB instance is availabl…
echo '' > $0.queue
databases=$(mysql -h $host -u $user -p$password -e "show databases" -sN | grep -v information_schema | grep -v mysql | grep -v sys)
for database in $databases; do
for table in $(mysql -h $host -u $user -p"$password" -N -B -e "show tables from \`$database\`"); do
mrichman / main.go
Last active July 19, 2020 12:32
Invoking AWS SDK using WaitGroup of configurable size
// Run N workers in a WaitGroup until they complete
package main
import (
mrichman / Cloud9_bootstrap.yaml
Created July 8, 2020 19:05 — forked from richardhboyd/Cloud9_bootstrap.yaml
StepFunction that bootstraps a Cloud9 environment
AWSTemplateFormatVersion: "2010-09-09"
Transform: AWS::Serverless-2016-10-31
Description: "Region-specific assets S3 bucket name (e.g. ee-assets-prod-us-east-1)"
Type: String
Default: "cf-templates-1xnac3rwgtxo7-us-west-2"
Description: "Size of EBS Volume (in GB)"
Type: Number
mrichman / HelloWorld.vue
Last active January 16, 2023 13:11
Cognito Hosted UI + Vue.js
<b-row align-h="center">
<div v-if="!signedIn">
<b-button variant="success" @click="signIn">Sign in with Cognito</b-button>
<div v-if="signedIn">
<h4>Welcome, {{ username }}!</h4>
<b-button variant="danger" @click="signOut">Sign out</b-button>
mrichman / table.js
Created January 30, 2020 11:41
Sort any HTML table by clicking a header
const getCellValue = (tr, idx) => tr.children[idx].innerText || tr.children[idx].textContent;
const comparer = (idx, asc) => (a, b) => ((v1, v2) =>
v1 !== '' && v2 !== '' && !isNaN(v1) && !isNaN(v2) ? v1 - v2 : v1.toString().localeCompare(v2)
)(getCellValue(asc ? a : b, idx), getCellValue(asc ? b : a, idx));
// do the work...
document.querySelectorAll('th').forEach(th => th.addEventListener('click', (() => {
const table = th.closest('table');
.sort(comparer(Array.from(th.parentNode.children).indexOf(th), this.asc = !this.asc))
.forEach(tr => table.appendChild(tr) );
mrichman /
Created October 25, 2019 11:55
Simple HTTPS Server in Python
#!/usr/bin/env python3
generate server.pem:
openssl req -new -x509 -keyout server.pem -out server.pem -days 365 -nodes
from http.server import HTTPServer, SimpleHTTPRequestHandler
import ssl
mrichman /
Created April 11, 2019 18:14
Blog Post: Scheduling DynamoDB Backups with Lambda, Python, and Boto3
import datetime
import boto3
dynamo = boto3.client('dynamodb')
def lambda_handler(event, context):