Skip to content

Instantly share code, notes, and snippets.

View SafeEval's full-sized avatar

Jack Sullivan SafeEval

View GitHub Profile
@SafeEval
SafeEval / ecs-exec-check.sh
Created May 30, 2025 20:56
ECS Exec Shell — Shelling into an AWS Fargate container
#!/bin/bash
# Set CLUSTER_NAME and SERVICE_NAME env vars.
# Get the container task ID.
TASK_ID=$(aws ecs list-tasks \
--cluster "$CLUSTER_NAME" \
--desired-status RUNNING \
--output text \
--query 'taskArns[0]' | awk -F/ '{print $NF}')
@SafeEval
SafeEval / enrich_ips.txt
Last active May 20, 2025 23:08
Enrich a list of IP addresses
import requests
import csv
import sys
import time
# Optional: Replace with your ipinfo.io token (or use free tier)
IPINFO_TOKEN = "" # e.g., "123abc456def"
HEADERS = {
"Authorization": f"Bearer {IPINFO_TOKEN}"
@SafeEval
SafeEval / agent.py
Created March 31, 2025 02:38
Hello DSPy — A simple "hello world" style DSPy script
import dspy
from typing import Dict
class PortlandOracle(dspy.Signature):
"""Answer questions about Portland restaurants."""
question: str = dspy.InputField()
answer: str = dspy.OutputField()
def forward(self, question):
@SafeEval
SafeEval / scrypt-example.ts
Last active February 6, 2025 23:26
Example of using Scrypt hashing in TypeScript.
import { randomBytes as csprngRandomBytes, scrypt, timingSafeEqual } from 'crypto';
import { promisify } from 'util';
const scryptAsync = promisify(scrypt);
/**
* Hashes a string using the scrypt algorithm.
*
* @param value - The value to hash.
* @returns A promise that resolves to the hashed value in the format `base64(salt):base64(derivedKey)`.
@SafeEval
SafeEval / argon2-demo.ts
Last active February 6, 2025 06:02
TypeScript demo of argon2 for string hashing and verification
import { hash, verify, Options, Algorithm } from '@node-rs/argon2';
/**
* Hashes a string using the Argon2id algorithm.
* Argon2 is a memory-hard function that requires a large amount of memory to compute.
* The 'id' variant mixes resistance against both GPU cracking and side-channel attacks.
* A generated salt value adds resistance against pre-computed rainbow table attacks.
* The configuration options are included in argon2 hashes to simplify verification.
*
* @param value - The value to hash.
@SafeEval
SafeEval / gen-otp-sha256.sh
Last active September 20, 2024 02:07
Generate the sha256 hashes of all six digit OTPs in 970 seconds (16 minutes, 69 MB)
#!/bin/bash
OUTFILE="otp-hashes.csv"
function gen_hash() {
otp=$1;
hash=$(echo -n $otp | sha256sum | awk '{print $1}');
echo "$otp,$hash" >> $OUTFILE;
}
@SafeEval
SafeEval / get-tfc-profile
Created August 27, 2024 20:49
Show the HCP Terraform (Terraform Cloud) profile information for a user with a given token
#!/bin/bash
curl \
--header "Authorization: Bearer $TFC_TOKEN" \
--header "Content-Type: application/vnd.api+json" \
"https://app.terraform.io/api/v2/account/details"
@SafeEval
SafeEval / update-tfc-workspace-vcs-config.sh
Created August 14, 2024 04:02
Update a set of TFC workspace VCS configs to use a Github App
#!/bin/bash
# Connect a TFC workspace to a Github VCS provider using the TFC API.
INFILE_WORKSPACES="tfc-workspace-name-list.txt"
function check_env() {
var_name="$1"
var_value="$2"
@SafeEval
SafeEval / tfc-workspace-vcs-config.sh
Created August 14, 2024 00:48
List out the VCS configs for all TFC workspaces in the organization
#!/bin/bash
# Script to pull details on all TFC workspaces and then focus on VCS configs.
# Note: jq is used to parse JSON, you need to install it if not already available
# Variables - Replace with your actual values
if [ -z $TFC_API_TOKEN ]; then
echo "Missing TFC_API_TOKEN environment variable";
exit 1;
fi
@SafeEval
SafeEval / list-rds-force-ssl.sh
Created August 12, 2024 16:25
List `rds.force_ssl` RDS DB Parameter Group values for all DBs in the account. Dump results to CSV.
#!/bin/bash
# List `rds.force_ssl` RDS DB Parameter Group values for all DBs in the account.
# Dump the results to CSV.
OUTFILE="rds-force-ssl.$(date +%s).csv"
# Get all RDS parameter group names
parameter_groups=$(aws rds describe-db-parameter-groups --query "DBParameterGroups[].DBParameterGroupName" --output text)