Skip to content

Instantly share code, notes, and snippets.

@mikeatlas
mikeatlas / find_new_nest_js_endpoints.py
Last active March 19, 2025 15:25
Finds all newly created API endpoints going back to a specific date across a list of git repositories containing NestJS web services and prints out a report. This script was generated with a few iterations of prompts to ChatGPT o1 model.
import os
import re
import subprocess
import sys
# Regex to parse the diff hunk header, e.g. "@@ -12,5 +12,6 @@"
HUNK_HEADER_RE = re.compile(r'@@ -(\d+),?(\d+)? \+(\d+),?(\d+)? @@')
# Regex to find @ApiOperation(...) inside a line
API_OPERATION_RE = re.compile(r'@ApiOperation\s*\(\s*(.*)\s*\)')
@mikeatlas
mikeatlas / delete_old_ecr_images.sh
Created December 12, 2024 21:40
Script to batch delete old ECR images. Mostly written by ChatGPT
#!/bin/bash
# Repository name
REPO_NAME="my-repo-name"
# Get the date 2 years ago in UTC format
TWO_YEARS_AGO=$(date -v-2y -u +"%Y-%m-%dT%H:%M:%SZ")
# Retrieve and filter images older than 2 years
IMAGES_TO_DELETE=$(aws ecr describe-images \
@mikeatlas
mikeatlas / userscript.js
Created September 5, 2023 20:05
Tampermonkey userscript: AWS SSO - Close 'Get Credentials' Modal
// ==UserScript==
// @name AWS SSO - Close 'Get Credentials' Modal
// @namespace awsapps.com
// @version 1.0
// @description Allow escape key to close modal
// @author Mike Atlas
// @match https://*.awsapps.com/start*
// @icon https://www.google.com/s2/favicons?sz=64&domain=awsapps.com
// ==/UserScript==
@mikeatlas
mikeatlas / closeCredentialsModalAWSSSO.js
Created May 2, 2023 19:04
Tampermonkey script for the AWS SSO login page. Allows keyboard escape key to close the "Get Credentials" modal.
// ==UserScript==
// @name AWS SSO - Close 'Get Credentials' Modal
// @namespace awsapps.com
// @version 1.0
// @description Allow escape key to close modal
// @author Mike Atlas
// @match https://*.awsapps.com/start*
// @icon https://www.google.com/s2/favicons?sz=64&domain=awsapps.com
// ==/UserScript==
@mikeatlas
mikeatlas / ecs-task.tf
Created April 3, 2023 21:00
terraform template for applying a task
resource "aws_ecs_task_definition" "user_code_task_def" {
family = local.user_code_family
container_definitions = jsonencode([
{
"name" : "${local.user_code_family}",
"image" : "${local.ecr_repo_image_path}:${local.latest_user_code_tag}",
"portMappings" : [
{
"hostPort" : 8001,
"protocol" : "tcp",
@mikeatlas
mikeatlas / example task definition for user code dagster.json
Last active April 3, 2023 21:19
pardon some of the mix of underscores and dashes, they may not be consistent... redacting internal values quickly
{
"taskDefinitionArn": "arn:aws:ecs:us-east-1:0123456789:task-definition/user_code:155",
"containerDefinitions": [
{
"name": "user-code-task",
"image": "0123456789.dkr.ecr.us-east-1.amazonaws.com/user_code:build-v1.124",
"cpu": 0,
"portMappings": [
{
"containerPort": 8001,
@mikeatlas
mikeatlas / Dockerfile
Last active March 24, 2023 15:47
"user code" / biz logic service for Dagster. All jobs/graphs/ops/etc live in the user_code directory
FROM python:3.10-slim-bullseye as dagster
RUN apt-get update && apt-get upgrade -yqq
ENV DAGSTER_HOME=/opt/dagster/dagster_home
RUN mkdir -p $DAGSTER_HOME/user_code
WORKDIR $DAGSTER_HOME
COPY dagster.yaml workspace.yaml $DAGSTER_HOME/
@mikeatlas
mikeatlas / split-csv.md
Last active April 1, 2022 20:31
some bash shell timesaver for splitting up csv
function split-csv() { 
  fn=${1:0:-4}; 
  fe=${1: -4}; 
  split -d -n $2 ${fn}${fe} ${fn}__part_; 
  for f in ${fn}__part*; do mv $f ${f}${fe}; done; 
};

Usage:

@mikeatlas
mikeatlas / fix-libv8-mac.txt
Created October 20, 2020 15:02 — forked from fernandoaleman/fix-libv8-mac.txt
Fixing libv8 and therubyracer on Mac
brew tap homebrew/versions
brew install v8-319
gem install libv8 -v '3.16.14.19' -- --with-system-v8
gem install therubyracer -- --with-v8-dir=/usr/local/opt/v8-319
bundle install
@mikeatlas
mikeatlas / README.md
Created February 24, 2020 22:15 — forked from mosra/README.md
Git pre-push hook to confirm pushing to master

Git pre-push hook

Checks if the remote branch is master, then asks a confirmation. Based on https://gist.github.com/ColCh/9d48693276aac50cac37a9fce23f9bda, but modified to check the remote name instead of local, making it work also for the really dangerous accidents like below:

git push -f origin e09b7418a310114f6aaf495f969c3859095a99af:master

Further info: https://dev.ghost.org/prevent-master-push/, https://coderwall.com/p/jp7d5q/create-a-global-git-commit-hook, https://git-scm.com/docs/githooks#_pre_push, https://stackoverflow.com/questions/22585091/git-hooks-pre-push-script-does-not-receive-input-via-stdin