adapted from: https://github.com/minkustree/socket-throttle/blob/master/socket-throttle.py
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
#!/bin/bash | |
last3lines=$(tail -n 3 $BASH_SOURCE) | |
echo "$last3lines" >> $BASH_SOURCE | |
echo "sleeping..."; sleep 1 |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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" | |