Skip to content

Instantly share code, notes, and snippets.

@amoffat
amoffat / forever.sh
Created April 26, 2022 23:32
The way that this script runs forever should scare you
#!/bin/bash
last3lines=$(tail -n 3 $BASH_SOURCE)
echo "$last3lines" >> $BASH_SOURCE
echo "sleeping..."; sleep 1
from math import ceil, log
def calc_file_path(some_id, base, max_size):
""" calculates a log-based file path using a specific base and a maximum
size. the resulting path has logN(max_size) components. useful for s3
paths or file system paths:
calc_file_path(49500, 50, 4000000)
=> "0-80000/48000-49600/49472-49504/49500-49501"