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 / sync_ftp_to_s3.md
Last active September 28, 2024 07:20
syncing ftp to s3 one-time really fast.

Original idea from Transfer files from an FTP server to S3 by "Hack N Cheese".

I moved roughly a terrabyte in less than an hour. Granted, I couldn't take advantage of lftp's --parallel=30 switch due to my ftp source limiting me to one connection at a time, but use-pget-n=N did seem to help out.

  • Get a fast Ubuntu 14.4 EC2 box on Amazon for temporary usage (I went with m1.xlarge) so data tranfers aren't limited by your local bandwidth at least. I also attached a fat 2TB EBS volume and symlinked it to /bigdisk, and made sure the EBS volume was deleted after I terminated this EC2 box. I hope lftp 2.6.4 is available as a stable package by the next time I attempt this.
  • Build lftp 2.6.4+ (Not easy to compile, so read the INSTALL file and plow through all your missing dependencies - you'll also need to re-run `sudo ./configure && su
@mikeatlas
mikeatlas / console-log-format-timestamps.js
Created September 8, 2016 20:11
Overrides the console.log (specifically this is for node.js) with an ISO timestamp prefix and still handles string interpolation formats.
function showDate(){
var date = new Date(), str = date.toISOString();
return str;
}
function formatArgs(args){
return util.format.apply(util.format, Array.prototype.slice.call(args));
}
var origLog = console.log;
console.log = function() {
var strDate = " [ " + showDate() + " ] ";
@mikeatlas
mikeatlas / .golang-example-gitlab-ci.yml
Last active February 2, 2024 08:08
Example Go GitLab CI setup (no root/sudo required)
# See docs/examples
# http://doc.gitlab.com/ce/ci/quick_start/README.html
# http://doc.gitlab.com/ce/ci/yaml/README.html
# GitLab CI template for Go tests. Note this installs
# a new working copy of Go in a non-standard path such
# that sudo/root is not needed for the install stage.
# note that this particular install-environment stage
# is overly verbose in order to debug anything tricky
@mikeatlas
mikeatlas / readme.md
Created March 21, 2018 22:10
maxfiles ulimit on macos
@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 / postgres_array.go
Created February 28, 2018 17:00 — forked from adharris/postgres_array.go
PostgreSQL demo of Array types using Golang
package main
import (
"database/sql"
"errors"
"fmt"
_ "github.com/bmizerany/pq"
"os"
"regexp"
"strings"
@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 / 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,