Skip to content

Instantly share code, notes, and snippets.

@SaundersB
SaundersB / sample-dms.ts
Created December 27, 2023 13:41
Sample Database Migration Service AWS CDK Stack
import * as cdk from 'aws-cdk-lib/core';
import * as ecr from 'aws-cdk-lib/aws-ecr';
import { StackProps } from 'aws-cdk-lib';
import { Construct } from 'constructs';
import * as iam from 'aws-cdk-lib/aws-iam';
import * as dms from 'aws-cdk-lib/aws-dms';
import * as ec2 from 'aws-cdk-lib/aws-ec2';
export class Stack extends cdk.Stack {
constructor(scope: Construct, id: string, props?: StackProps) {
@SaundersB
SaundersB / gist:20057ac380b7084d24972180f3b018ad
Created August 16, 2023 04:06
NextJS middleware.page.ts
import { NextRequest, NextResponse } from 'next/server';
export function middleware(request: NextRequest): Response | NextResponse {
const host = request.headers.get('host');
if (!host) {
// Handle the situation where the host header is not present.
console.error('Host header not found.');
return NextResponse.next();
}
alias release_notes='git log --since="1 week ago" --pretty=format:"%cd %s" --date=format:"%Y-%m-%d" --no-merges > ~/commits.txt'
@SaundersB
SaundersB / index.js
Created February 26, 2023 15:31
Delete AWS EC2 Snapshots Older Than Six Months Lambda
const AWS = require('aws-sdk');
AWS.config.update({ region: 'us-west-2' });
exports.handler = async (event, context, callback) => {
const sixMonthsAgo = new Date(Date.now() - 6 * 30 * 24 * 60 * 60 * 1000);
const conditionDate = sixMonthsAgo.toISOString();
const ownerIds = ["REPLACE_ME"];
let nextToken;
@SaundersB
SaundersB / index.ts
Created December 14, 2021 00:11
CDK Microservice using the same Application Load Balancer v1
import { Construct } from '@aws-cdk/core';
import * as cdk from '@aws-cdk/core';
import * as ec2 from '@aws-cdk/aws-ec2';
import * as ecs from '@aws-cdk/aws-ecs';
import * as ecr from '@aws-cdk/aws-ecr';
import * as elasticloadbalancing from '@aws-cdk/aws-elasticloadbalancingv2';
import { CfnOutput, Duration, RemovalPolicy } from '@aws-cdk/core';
const capitalize = (s: string) => {
return s.charAt(0).toUpperCase() + s.slice(1);
@SaundersB
SaundersB / shell.sh
Created August 24, 2021 00:02
Openconnect to Cisco Router without AnyConnect
sudo openconnect vpnurl.com --certificate ~/certificates/certificate.pfx
@SaundersB
SaundersB / gist:574e35b23d732243f3fe0ca6afb56beb
Last active May 10, 2021 16:42
Create Sync Up Meeting Notes Script
#!/bin/bash
YEAR=$(date +"%Y");
MONTH=$(date +"%B");
MONDAY=$(date -v-monday +"%m-%d")
FRIDAY=$(date -v+friday +"%m-%d")
THIS_WEEK_PATH="${YEAR}/${MONTH}";
THIS_WEEK_FILE_NAME="${MONDAY}_${FRIDAY}";
@SaundersB
SaundersB / install.sh
Created December 24, 2020 22:59
Install Plex Media Server for Ubuntu 20.04
wget https://downloads.plex.tv/plex-media-server-new/1.21.1.3830-6c22540d5/debian/plexmediaserver_1.21.1.3830-6c22540d5_amd64.deb
sudo dpkg -i plexmediaserver_1.21.1.3830-6c22540d5_amd64.deb
sudo systemctl status plexmediaserver.service
sudo systemctl enable plexmediaserver.service