Skip to content

Instantly share code, notes, and snippets.

View slaughtr's full-sized avatar

Dallas slaughtr

  • PNW
View GitHub Profile
@slaughtr
slaughtr / gist:17564d9f4aac7f3b20dc1b604e155aff
Created April 11, 2024 17:44
Kagi CSS to be more like the old theme and remove those underlines in links
:root {
--custom-bg-color: #090c10;
--search-result-gap: 20px;
--search-result-gap-mobile: 10px;
--app-bg: var(--custom-bg-color);
--search-result-title: #fff;
--primary-visited: #aaa;
/*! --quick-search-bg: #000; */
@slaughtr
slaughtr / find-action-in-workflows.js
Created March 19, 2024 20:18
Find if a specific action is present in the workflows of all repos in an org. Outputs CSV for review. Not perfect, Github API doesn't like some things.
const { Octokit } = require("@octokit/rest");
const createCsvWriter = require('csv-writer').createObjectCsvWriter;
// Initialize Octokit with your GitHub token from environment variable
const octokit = new Octokit({ auth: process.env.GITHUB_TOKEN });
// CSV setup
const csvWriter = createCsvWriter({
path: 'compliance_check_result.csv',
header: [
@slaughtr
slaughtr / prcache
Created March 15, 2024 21:45
prcache
# Another ChatGPT win, I only had to make one change
# This just builds a JSON-based cache (in your home dir, update the cacheFile if you don't like that) based on a git branch name, commit message, and pull request body
# Using those, it will create a new branch, add a commit, and (using the gh CLI) create a PR with the cached body
# This allows for however many cached values you need
# Pretty much only useful for large-scale small-change PR rollouts, like small GHA updates etc
prcache() {
cacheFile="$HOME/.git_pr_cache.json"
# Initialize the cache file with an empty array if it doesn't exist
@slaughtr
slaughtr / mupen
Created March 15, 2024 21:42
mupen
# Thanks chat gippity!
# This zsh function simplifies jumping around many repos. And single repos, too
# It attempts to checkout the current dir's git repo main branch, fetch and pull, and open the directory in VS Code
# If there are unstaged changes in the current branch, it shows a diff and asks y/n if you want to discard those changes
# If yes, it continues as normal (checkout main, fetch, pull, VSC). If no, it aborts
# Why "mupen"? It's some amalgamation of main, pull, and open :shrug:
# Define the function
mupen() {
# Attempt to checkout the main branch. If there are no changes, this will succeed.
@slaughtr
slaughtr / docker_config_var_mac.md
Created January 4, 2022 01:29
Docker for Mac - use DOCKER_CONFIG var

Docker for Mac does not respect the DOCKER_CONFIG var - docker/for-mac#2635

However, using launchctl you can get the desktop app to use a different .docker location.

  • Create a plist file, I use environment.plist as I use this workaround for other apps.
  • Insert the following into the plist file:
<?xml version="1.0" encoding="UTF-8"?>
<!DOCTYPE plist PUBLIC "-//Apple//DTD PLIST 1.0//EN" "http://www.apple.com/DTDs/PropertyList-1.0.dtd">
@slaughtr
slaughtr / pre-commit-terraform.md
Last active January 5, 2022 07:14
pre-commit terraform
repos:
  - repo: https://github.com/antonbabenko/pre-commit-terraform
    rev: v1.55.0 # verify this is latest version
    hooks:
      - id: terraform_fmt
      - id: terraform_docs
  - repo: https://github.com/pre-commit/pre-commit-hooks
    rev: v2.4.0 # Use the ref you want to point at - check for updates
 hooks:

Keybase proof

I hereby claim:

  • I am slaughtr on github.
  • I am slaughtr (https://keybase.io/slaughtr) on keybase.
  • I have a public key ASC6lKQTnHAr3roSDE5Slqdcdv0i8bNH7JfXLFYHGbiGxQo

To claim this, I am signing this object:

@slaughtr
slaughtr / apacheRedirectCheck.js
Last active October 20, 2021 21:52
Check RewriteRules - find redirect chains, status codes, final URLs
// USAGE: node apacheRedirectCheck.js /path/to/file.conf.in https://yourdomain.example
const lineReader = require('line-by-line')
const util = require('util');
const exec = util.promisify(require('child_process').exec);
// get our file
const [ ,, fileName, host ] = process.argv
const lr = new lineReader(fileName)
const results = { success: [], regex: [], failure: []}
// Linereader boilerplate
lr.on('error', console.error)
@slaughtr
slaughtr / listAllBucketObjectsNoPrefixes.js
Created February 28, 2020 20:43
List all objects in S3 bucket (without prefixes)
const getAllObjects = async s3Params => {
const AWS = require('aws-sdk');
const S3 = new AWS.S3();
let results = [];
let gotAllObjs = false;
// Loop until we get all keys - This does NOT do any retries or backoff.
while (!gotAllObjs) {
if (!s3Params.ContinuationToken || s3Params.ContinuationToken !== 'DONE') {
const s3listres = await S3.listObjectsV2(s3Params).promise();
// assign ContinuationToken to data.NextContinuationToken