Another fun thing to put on the micro journal: making a dice.
Because why not? A dice could be handy in many situations. Back when I took my master degree, I was the oldest among my classmates (I mean, I am 6-16 years older from them), they are cool and friendly, but if there was a group assignment, who would want to be a group with an old lady who doesn't know the latest trend on tik tok? I believe my classmates are kind, they wouldn't leave me behind, but just in case... I always bring a dice to made it looks like a fair decision, odd number means you get to be in group with this old lady.
And it is not only for my own situation, back then I also work as a teaching assistant, and there were times when the students had to present their work but nobody wants to be the first. So that's the time to roll a dice. Somehow a random decision by the dice or roulette seems more fair than pointing a finger.
So of course, I ask my friend, Gemini AI to make a dice for my micro journal
here's the script:
#!/bin/bash
# --- PREPARATION ---
clear
echo "🎲 THE MAGIC DICE IS SHAKING..."
echo ""
# --- THE ROLL ANIMATION ---
# Rapidly cycle through numbers to simulate rolling motion
for i in {1..10}; do
temp_roll=$(( ( RANDOM % 6 ) + 1 ))
# -n prevents new line, \r moves cursor back to start of line
echo -ne " Rolling... [ $temp_roll ]\r"
sleep 0.1
done
# --- THE FINAL RESULT ---
# Pick the actual final number (1-6)
final_roll=$(( ( RANDOM % 6 ) + 1 ))
echo -e " Rolling... [ $final_roll ]" # Lock it in
echo ""
echo " The die hits the table!"
echo ""
# --- DRAW THE FACE ---
echo -e "\033[1;36m" # Set color to Cyan
case $final_roll in
1)
cat << "EOF"
_______
| |
| o |
| |
-------
EOF
;;
2)
cat << "EOF"
_______
| o |
| |
| o |
-------
EOF
;;
3)
cat << "EOF"
_______
| o |
| o |
| o |
-------
EOF
;;
4)
cat << "EOF"
_______
| o o |
| |
| o o |
-------
EOF
;;
5)
cat << "EOF"
_______
| o o |
| o |
| o o |
-------
EOF
;;
6)
cat << "EOF"
_______
| o o |
| o o |
| o o |
-------
EOF
;;
esac
echo -e "\033[0m" # Reset color
echo ""
echo -e " ✨ YOUR MAGIC NUMBER IS: \033[1;33m$final_roll\033[0m ✨"
echo ""
I didn't change anything from the script, as you can see, the Gemini AI is a little bit witty, it adds some conversation there and I kinda like it. Just like usual, save it to .sh file, do that chmod +x thing and open the .sh file.

No comments:
Post a Comment