Skip to content

Instantly share code, notes, and snippets.

View thomashartm's full-sized avatar

Thomas Hartmann thomashartm

  • Netcentric
  • Germany
View GitHub Profile
@thomashartm
thomashartm / buildx-docker-colima.md
Last active September 11, 2025 08:21
Set up buildx with Colima and Docker Engine on MacOS

Set up buildx with Colima and Docker Engine on MacOS

This guide configures Colima’s Docker context to use Buildx as the default builder

Requirements

  • macOS 12+ (Apple Silicon or Intel)
  • Colima installed via Homebrew
  • Docker CLI
  • Docker Buildx

Installation

@thomashartm
thomashartm / android-to-mac.md
Created September 6, 2025 10:21
Recovering all files from an old Android Phone to macOS using ADB

📱 Extracting Files from an Old Android Phone to macOS using ADB

Connecting an approximately 10-year-old Android phone (likely Android 4–6) to a MacBook is tricky, because Google has barely maintained the official Android File Transfer (AFT) app for years and older devices often only support MTP (Media Transfer Protocol).

This guide explains how to copy all accessible files from an older Android device to a Mac using ADB (Android Debug Bridge).
It works even if your device is 10+ years old, as long as you can enable USB debugging.

1. Prepare the Android Device

@thomashartm
thomashartm / clone-terragrunt-stack.sh
Created June 16, 2025 15:27
Clones a terragrunt and or a terraform stack to support the case where we need to clone stacks for different environments in terragrunt. Removes the state directories.
#!/bin/bash
# Check if the correct number of arguments is provided
if [ "$#" -ne 2 ]; then
echo "Usage: $0 <source_directory> <target_directory>"
exit 1
fi
SOURCE_DIR=$1
TARGET_DIR=$2
@thomashartm
thomashartm / create-env.sh
Last active June 20, 2024 12:55
Output environment variables based on AWS SSM params and write .env files. This might be helpful when relying on centrally managed environments variables for local development or CICD
#!/bin/bash
set -e
# Enable -x only for debug purposes
#set -x
# Retrieves a JSON parameter from SSM and output them as key/values
# ./create-env.sh -p <system manager param name>
# Write the output to .env.local
# ./create-env.sh -p <system manager param name> > .env.local
@thomashartm
thomashartm / remove-terragrunt-state.sh
Last active June 19, 2024 08:47
Removes a terragrunt state for a group of resources that contain the provided argument
#!/bin/bash
# usage:
# ./remove-terragrunt-state module.s3_bucket ../../../
TOKEN=$1
SOURCE=$2
terragrunt state rm $(terragrunt state list --terragrunt-source ../../../ | grep $TOKEN) --terragrunt-source $SOURCE
@thomashartm
thomashartm / test-with-false-jwt-claims.py
Last active January 12, 2023 14:04
Testing script for sending manipulated parameters to an OpenIdConnect Endpoint.
import requests
import json
# Konfiguration
client_id = "your_client_id"
client_secret = "your_client_secret"
issuer = "https://your_issuer.com"
redirect_uri = "https://your_redirect_uri.com"
# Anmelde-Anfrage
@thomashartm
thomashartm / aws-sam-colima.md
Last active September 2, 2025 11:00
Enable AWS SAM local to run without Docker Desktop but Colima + Docker Daemon on MacOs

AWS SAM local commands without Docker Desktop

AWS SAM local commands check for the existance of DOCKER_HOST. If the variable is not present, it will fail with the following error message

Error: Running AWS SAM projects locally requires Docker. Have you got it installed and running?

Replace it with Colima

Point DOCKER_HOST to unix socket of the Docker Daemon.

@thomashartm
thomashartm / set-aws-env.sh
Created August 19, 2021 13:30
Manage different AWS settings and export them if necessary
#!/bin/bash
####################################
# Prepares dev environment settings
# call:
# set-aws-env <environment>
# or for help:
# set-aws-env
#
# How to use and expected file system structure:
@thomashartm
thomashartm / set-aws-env.sh
Last active June 7, 2021 10:08
Switch between different AWS credentials which are isolated in separate folders e.g. to support isolated credentials files for different customers or projects.
#!/bin/bash
####################################
# Prepares dev environment settings
# call:
# set-dev-env <environment>
# or for help:
# set-dev-env
#
# How to use and expected file system structure:
@thomashartm
thomashartm / awsprofile.sh
Last active May 26, 2023 02:51
Easy AWS profile switch via bash script.
#!/bin/bash
#
# 1. Place this script somewhere in your path:
# touch /Users/username/path-to-your-scripts-directory/awsprofile.sh
# 2. Save this script and make it executable
# chmod +x /Users/username/path-to-your-scripts-directory/awsprofile.sh
# 3. Add the directory to your bash profile
# export PATH="/path-to-your-scripts-directory:$PATH"
# 4. Source your bash profile
# awsprofile.sh