Skip to content

Instantly share code, notes, and snippets.

View skwashd's full-sized avatar
👨‍💻
planning, coding, reviewing

Dave Hall skwashd

👨‍💻
planning, coding, reviewing
View GitHub Profile
@skwashd
skwashd / README.md
Last active January 13, 2025 16:30
Import Data from JSON File to Aurora PostgreSQL

Import Data from JSON File to Aurora PostgreSQL

This script loads data from a PostreSQL JSON dump file into an Aurora PostgreSQL database using the RDS Data API.

Update the values in the COLUMN_TYPES dictionary to match your schema. Map your column data types to the supported field types. You can cast a string to a custom type by appending :type to the field type.

Run Script

To run the script you need boto3 installed. Then run the script like so:

@skwashd
skwashd / README.md
Created November 3, 2024 09:06
Archive Replayed EventBridge Events

EventBridge Event Replay Module

Amazon EventBridge Archive ignores replayed events. The archive rule is a managed rule and so there is no way to remove this restriction. This limitation can be frustrating when standing up a new bus.

This Terraform module configures an AWS Step Functions Express workflow that handles replayed events from an EventBridge bus. Events with a replay-name property are sent directly to the workflow and reinjected into the same bus with the replay marker removed.

Flow

  1. EventBridge rule captures events with replay-name property
  2. Events are routed directly to a Step Function
@skwashd
skwashd / README.md
Last active September 6, 2024 10:20
Copy AWS SSM Parameter Store Path

This Python (3.6+) script is for migrating Amazon AWS System Manager (SSM) Parameter Store keys from one path to another.

Quick Start

To install the script do the following:

  • Configure your AWS credentials
  • Grab the code from this gist
  • Make it executable (chmod +x /path/to/copy-ssm-ps-path.py)
  • pip install boto3 (if you don't have it installed already)
@skwashd
skwashd / pre-commit
Last active February 28, 2024 11:11
Git pre-commit hook that blocks commits for files that contain swear words.
#!/bin/bash -e
#
# Git pre-commit hook that blocks commits for files that contain swear words.
#
# Created by Dave Hall - http://davehall.com.au
# Distributed under the terms of the WTFPL - http://www.wtfpl.net/
#
# Please don't use this fucking script, it is shit!
#
@skwashd
skwashd / bricklink.py
Created February 24, 2024 09:52
Script for turning a list of LEGO entityIDs into a BrickLink wishlist
@skwashd
skwashd / autoscroll.js
Created November 12, 2023 04:03
Safari doesn't support the behaviour property when calling window.scroll. This prevents smooth scrolling. Copy and paste this code into your JS console to get smooth scrolling. Great for screen capture videos.
const footerHeight = 800;
let pos = 0,
pageHeight = document.body.offsetHeight,
winHeight = window.innerHeight,
maxPos = pageHeight - winHeight - footerHeight;
function scrollWin() {
if (pos >= maxPos) {
console.log(`We're done at ${pos}`);
@skwashd
skwashd / .gitignore_global
Last active August 23, 2022 08:55
Global .gitignore configuration for PHP and Python developers
# Save this file as ~/.gitignore_global
# Add the following entry to ~/.gitconfig
#
# [core]
# excludesfile = /Users/dave/.gitignore_global
#
# Compiled source #
###################
*.class
@skwashd
skwashd / README.md
Last active January 15, 2022 15:29
Auto starting minecraft server in a docker container on Ubuntu 16.04

The better way to do this

During a twitter conversation with itzg, he suggested that I use [docker's built in --restart="unless-stopped" runtime flag] (https://gist.github.com/itzg/36e59186f6195a445f1f1fa2b0087ea9). That worked a treat and means I don't need to maintain an extra service.

My old way of doing it

This is only retained for historic record. Don't follow these steps.

If you want to run a minecraft server in a docker container on Ubuntu 16.04 and have it automatically start at boot, follow these steps:

@skwashd
skwashd / .gitconfig
Created October 3, 2021 04:31
My gitconfig
[user]
name = Dave Hall
email = skwashd@example.com
signingkey = GPG-KEY-FINGERPRINT # follow these instructions to setup https://andrewmatveychuk.com/how-to-sign-you-commits-with-gpg-git-and-yubikey/
[core]
editor = vim # no debate
excludesfile = ~/.gitignore_global # Generated using https://www.gitignore.io/api/diff,patch,go,vim,macos,python,pycharm,webstorm,archives,phpstorm,drupal,node
[commit]
@skwashd
skwashd / configure-dependabot.py
Created August 27, 2019 03:50
Batch create dependabot config.yml file in github repos
#!/usr/bin/env python3
import base64
import os
import requests
token = os.environ.get("GITHUB_TOKEN")
org = os.environ.get("GITHUB_ORG")