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
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 / 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 / .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")
@skwashd
skwashd / enable-github-security-tooling.py
Created August 26, 2019 16:24
Bulk enable dependabot and security alerts on github repos
#!/usr/bin/env python3
import json
import os
import requests
token = os.environ.get("GITHUB_TOKEN")
org = os.environ.get("GITHUB_ORG")
@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 / README.md
Created May 28, 2018 09:50
Remove all external collaborators from GitHub

This script removes all external collaborators in a GitHub organisation. Collaborators look like a good idea when you have a small organisation and you don't want to start managing a lot of teams. Once your organisation grows collaborators are a nightmare to manage. There is little or no context about why they have access, they're often missed when auditing user access and they get forgotten about.

Setup

  • Run pip install requests to install the one and only dependency
  • Configure the GITHUB_ORG and GITHUB_TOKEN environment variables

Running

Run the script like so python3 ./remove-collaborators.py. The output should look like this:

@skwashd
skwashd / README.md
Created January 16, 2018 02:42
Purge GitHub Invites

Purge GitHub Invites

Large organisations invite new users to GitHub all the time. Some times the user never accepts the invite. GitHub invites never expire. Long after the user has been forgotten they can still accept the invite. This is a potential security issue.

Back in September 2015 I asked GitHub to expose invite information via their API. In December 2016 GitHub launched their new Organization Memberships APIs, which included an endpoint for pending invitations. The initial implementation lacked information of when the invite was sent. GitHub added this property after I asked for it.

I created a script that uses this new API that checks for any invites which have been pending more than a week. If they exist they're pruged. I hope someone else finds this usef

@skwashd
skwashd / cf-tls12-only.sh
Created October 31, 2017 16:20
Disable old versions of TLS for all domains on Cloudflare
#!/bin/sh
# Enable modern TLS only mode for all sites on Cloudflare (max 50)
#
# Written by Dave Hall <skwashd@gmail.com>
# CC-0 License applies - https://creativecommons.org/publicdomain/zero/1.0/
BASE_URI="https://api.cloudflare.com/client/v4"
if [[ -z "${AUTH_EMAIL}" ]]; then