Skip to content

Instantly share code, notes, and snippets.

Go banana!

Peter Mescalchin magnetikonline

Go banana!
View GitHub Profile
magnetikonline /
Last active Aug 18, 2021
Rudimentary JavaScript object deep copy.

Rudimentary JavaScript object deep copy

Function to perform a deep copy of an object - rudimentary in that it will only handle the following types:

  • Primitives
  • Array
  • Object

Basically can perform the following, but also copy undefined:

magnetikonline /
Created Jul 13, 2021
Python threaded workers using ThreadPoolExecutor().

Python threaded workers using ThreadPoolExecutor()

A pattern for using concurrent.futures.ThreadPoolExecutor() to execute a series of "worker" functions in parallel, processing a queue of assigned "work".

How it works:

  • worker_init() creates:
    • Queues for "work" and "results".
    • A threading.Event() to denote "no more work in queue".
    • A futures.ThreadPoolExecutor().
magnetikonline /
Last active Jul 9, 2021
Cleanup legacy GitHub Actions workflow runs.

Cleanup legacy GitHub Actions workflow runs

Python utility to delete in bulk all GitHub Actions runs for a given workflow, either current or legacy/since removed. The GitHub UI currently allows removal of individual workflow runs, but this becomes tedious with a bulk of previous runs.


Create a Personal access token with workflow scope:


magnetikonline /
Last active May 28, 2021
Quick example for using the GitHub Container (Docker) registry.

Quick example for using the GitHub Container registry

Human user access

Create a new Personal access token with the following permissions:

magnetikonline /
Created Apr 27, 2021
Enable GitHub Dependabot for Golang based repositories.

Dependabot for Golang based repositories

Minimal YAML configuration for enabling Dependabot within a Golang based repository.

Place dependabot.yml at .github/dependabot.yml in your project and you should be good to go.


magnetikonline / workflow.yaml
Last active Apr 27, 2021
Simple flow for passing artefacts between GitHub Actions workflow jobs.
View workflow.yaml
name: Workflow
- main
runs-on: ubuntu-latest
magnetikonline /
Created Mar 4, 2021
Remove an existing AWS CloudFormation stack, but retain the managed resources.

Delete CloudFormation stack - retaining resources

How to remove an existing CloudFormation stack, but retain the managed resources.

First step - we need the stack within a state of DELETE_FAILED, this can be achieve by attempting stack delete with a user that only has IAM rights to cloudformation:*. Create a new temporary IAM user with the following inline policy:

	"Version": "2012-10-17",
	"Statement": [
magnetikonline /
Last active Jan 19, 2021
Remove AWS network interfaces from given security group ID.

Remove AWS network interfaces from security group ID

Script has been handy to clean up security groups which have been used with VPC honed AWS Lambda functions and maintain an ENI association.

Why this is a problem:

  • New Lambda is created within the given VPC subnets and security group.
  • During deployment, AWS creates ENIs assigned to the security group and placed into the instructed subnets.
  • Next, change is made to Lambda involving new security group association. AWS now creates new ENIs - as ENI reuse between Lambdas is only for the same security group/subnet combination.
  • Finally, user wishes to clean up legacy security group - but can't as existing ENIs still use security group.
magnetikonline /
Last active Jan 17, 2021
List AWS Lambda@Edge log groups across regions.

List AWS Lambda@Edge log groups across regions

AWS Lambda@Edge functions, which run under CloudFront at multiple edge locations require associated Lambda functions to exist within each AWS region.

By design, this means CloudWatch Logs produced by Lambda@Edge functions will exist across these regions.

This Bash script will query for all log groups associated to Lambda@Edge functions for each enabled region of the current AWS account to hopefully help determine where logs are going/exist.

magnetikonline /
Created Jan 11, 2021
Delete all AWS S3 bucket versioned objects and delete markers.

Delete all S3 versioned objects and delete markers

Quick and dirty Bash script to iterate an S3 bucket and remove all object versions and delete markers.

Probably only usable on buckets with a few hundred version objects maximum, otherwise it might be more efficient and time effective to use a lifecycle rule to age out and remove objects in bulk.