Skip to content

Instantly share code, notes, and snippets.

View SafeEval's full-sized avatar

Jack Sullivan SafeEval

View GitHub Profile
@SafeEval
SafeEval / guide.md
Created August 6, 2026 22:35 — forked from tom-ricci/guide.md
Configuring minimum release age across npm, pnpm, and yarn

Configuring minimum release age across npm, pnpm, yarn, and bun

Setting a minimum release age (a "cooldown") on dependencies is a cheap, high-leverage defense against supply-chain attacks. Most malicious package versions are detected and yanked within hours, so a 24-hour delay filters out the smash-and-grab incidents (axios 1.14.1, ua-parser-js, Solana web3.js, etc.).

All four major Node.js package managers now support this, but each one used a different name and a different unit. Here is what you need.

Minimum versions

Tool Setting Unit Introduced in
@SafeEval
SafeEval / guide.md
Created August 6, 2026 22:34 — forked from mcollina/guide.md
Configuring minimum release age across npm, pnpm, and yarn

Configuring minimum release age across npm, pnpm, and yarn

Setting a minimum release age (a "cooldown") on dependencies is a cheap, high-leverage defense against supply-chain attacks. Most malicious package versions are detected and yanked within hours, so a 24-hour delay filters out the smash-and-grab incidents (axios 1.14.1, ua-parser-js, Solana web3.js, etc.).

All three major Node.js package managers now support this, but each one used a different name and a different unit. Here is what you need.

Minimum versions

Tool Setting Unit Introduced in
@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"