Skip to content

Instantly share code, notes, and snippets.

View WillGibson's full-sized avatar

Will Gibson WillGibson

View GitHub Profile
@WillGibson
WillGibson / dict-of-dicts-any-name-allowed.py
Created January 23, 2025 16:07
Schema.json_schema() does not return properties for a dict of dicts where first level key can be any string
import json
from schema import Schema, Literal
schema = Schema(
{
Literal("application", description="The name of your application. Letters, numbers, hyphens and underscores are allowed."): str,
"dict-of-dicts-only-specific-names-allowed": {
"specific-name-1": {
"property-1": str,
@WillGibson
WillGibson / trufflehog-ignore-doesn't-work-in-some-cases
Created November 14, 2024 07:38
For "# trufflehog:ignore doesn't work in some cases" issue
➜ trufflehog filesystem . --no-verification --fail --trace
2024-11-14T07:36:39Z info-2 trufflehog trufflehog 3.83.6
🐷🔑🐷 TruffleHog. Unearth your secrets. 🐷🔑🐷
2024-11-14T07:36:39Z info-4 trufflehog default engine options set
2024-11-14T07:36:39Z info-4 trufflehog engine initialized
2024-11-14T07:36:39Z info-4 trufflehog setting up aho-corasick core
2024-11-14T07:36:39Z info-4 trufflehog set up aho-corasick core
2024-11-14T07:36:39Z info-2 trufflehog starting scanner workers {"count": 8}
2024-11-14T07:36:39Z info-2 trufflehog starting detector workers {"count": 64}
#!/bin/bash
# Usage...
# ./migrate-ecr-images.sh <aws_account_id> <region> <source_repository> <destination_repository>
# E.g...
# ./migrate-ecr-images.sh 1234567890 eu-west-2 group/this group/that
awsAccountId="$1"
region="$2"
sourceRepository="$3"
#!/bin/bash
# I had a situation where a config upgrader tool added empty lines to the end of thousands of files, which made for an insane pull request diff (in Bitbucket).
# This is what I used to append those empty lines separately and get that into my main branch so that the diff is more manageable for my colleagues...
# cd into the parent directory, paste this into your terminal, hit enter...
find . -type f -name '*.*' -print0 | while IFS= read -r -d '' file; do
echo "$file"
echo "" >> "$file"
@WillGibson
WillGibson / explodeJSONToFiles.js
Created January 18, 2021 12:38
Explode first level properties in a JSON object to separate files
/*
Maybe someone already solved this in a library, but I wasn't finding it,
so I wrote this.
In the same directory as this file, put your JSON object in temp.json
and create an empty directory called temp, then run...
node explodeJSONToFiles.js
...and do whatever you need to do with the files.