Skip to content

Instantly share code, notes, and snippets.

@rkfg
Created September 12, 2014 05:03
Show Gist options
  • Save rkfg/e9db0e228be190444094 to your computer and use it in GitHub Desktop.
Save rkfg/e9db0e228be190444094 to your computer and use it in GitHub Desktop.
#!/bin/sh
TEACOUNT=8
TEADIV=
if [ -n "$1" ]
then
TEADIV="_$1"
fi
HASH=$(echo -n "teatime_$(date +%d-%m-%Y)$TEADIV" | sha256sum | sed 's/\([0-9a-f]*\) .*/\1/' | tr '[:lower:]' '[:upper:]')
TEANUMBER=$(echo "ibase=16; scale=0; $HASH % $TEACOUNT" | bc)
echo "HASH=$HASH\nTea count=$TEACOUNT\nTea number=$TEANUMBER"
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment