202412301735586432 HAPPY NEW YEAR
This commit is contained in:
parent
9789a3db29
commit
65240b8408
10 changed files with 29481 additions and 25 deletions
71
global/scripts/functions.sh
Normal file
71
global/scripts/functions.sh
Normal file
|
@ -0,0 +1,71 @@
|
|||
declare -A weather_emoji
|
||||
|
||||
weather_emoji[01d]=🌞
|
||||
weather_emoji[02d]=🌥
|
||||
weather_emoji[03d]=☁
|
||||
weather_emoji[04d]=☁
|
||||
weather_emoji[09d]=🌧
|
||||
weather_emoji[10d]=🌦
|
||||
weather_emoji[11d]=⛈
|
||||
weather_emoji[13d]=❄
|
||||
weather_emoji[50d]=🌫
|
||||
weather_emoji[01n]=🌑
|
||||
weather_emoji[02n]=🌑
|
||||
weather_emoji[03n]=☁
|
||||
weather_emoji[04n]=☁☁
|
||||
weather_emoji[09n]=🌧
|
||||
weather_emoji[10n]=☔
|
||||
weather_emoji[11n]=⛈
|
||||
weather_emoji[13n]=❄
|
||||
weather_emoji[50n]=🌫
|
||||
|
||||
function set_text_color() {
|
||||
tput setaf "$1"
|
||||
}
|
||||
|
||||
function set_bold_text() {
|
||||
tput bold
|
||||
}
|
||||
|
||||
function reset_text_format() {
|
||||
tput sgr0
|
||||
}
|
||||
|
||||
function die() {
|
||||
set_text_color 1
|
||||
echo "Script failed: $1, exiting..."
|
||||
reset_text_format
|
||||
exit 1
|
||||
}
|
||||
|
||||
function round() {
|
||||
echo $(echo "$1" | awk '{print ($1 > int($1)) ? int($1)+1 : int($1)}')
|
||||
}
|
||||
|
||||
function check_tools() {
|
||||
tools="$1"
|
||||
for tool in "${tools[@]}"; do
|
||||
if [ ! -x "$(command -v "$tool")" ]; then
|
||||
die "$tool is not installed"
|
||||
fi
|
||||
done
|
||||
}
|
||||
|
||||
function calculate_timezone() {
|
||||
offset_hours=$(("${1:?}" / 3600))
|
||||
sign="+"
|
||||
if ((offset_hours < 0)); then
|
||||
sign="-"
|
||||
offset_hours=$((-"$offset_hours"))
|
||||
fi
|
||||
echo "${offset_hours:?}"
|
||||
}
|
||||
|
||||
function generate_random_string() {
|
||||
length="${1:-10}"
|
||||
echo $(cat /dev/urandom | tr -dc 'a-zA-Z09' | head -c "$length")
|
||||
}
|
||||
|
||||
function checksumm() {
|
||||
echo $(sha256sum "${1:?}" | awk '{print $1}')
|
||||
}
|
Loading…
Add table
Add a link
Reference in a new issue