Compare commits
9 Commits
4174b3f7e3
...
main
| Author | SHA1 | Date | |
|---|---|---|---|
|
|
cb67db2a78 | ||
|
|
71cf1ec44c | ||
|
|
ed19ae5c0d | ||
|
|
c4d9e053ee | ||
|
|
8d88743624 | ||
|
|
2cdab60efb | ||
|
|
c761fe5d93 | ||
|
|
4342f0a5f8 | ||
|
|
be7e5da172 |
@@ -72,6 +72,7 @@ vpn
|
|||||||
.config/Nextcloud/
|
.config/Nextcloud/
|
||||||
nextcloud-test.*/
|
nextcloud-test.*/
|
||||||
.VirtualBox/
|
.VirtualBox/
|
||||||
|
VirtualBox/
|
||||||
DMS/
|
DMS/
|
||||||
tmp
|
tmp
|
||||||
.zoom/
|
.zoom/
|
||||||
|
|||||||
@@ -1,5 +1,5 @@
|
|||||||
function g_basename {
|
function g_basename {
|
||||||
g_basename_result="${1##*/}"
|
g_basename_result=${1##*/}
|
||||||
g_basename_result="${g_basename_result:-/}"
|
g_basename_result=${g_basename_result:-/}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|||||||
@@ -27,7 +27,7 @@ function g_calc {
|
|||||||
read -u ${g_fd_bc_out} g_calc_result
|
read -u ${g_fd_bc_out} g_calc_result
|
||||||
|
|
||||||
# check if there is a output
|
# check if there is a output
|
||||||
if [ -z $g_calc_result ]
|
if [ -z "$g_calc_result" ]
|
||||||
then
|
then
|
||||||
echo "${FUNCNAME} $@" 1>&2
|
echo "${FUNCNAME} $@" 1>&2
|
||||||
unset g_calc_result
|
unset g_calc_result
|
||||||
@@ -48,7 +48,7 @@ function g_calc {
|
|||||||
[[ $g_calc_result == *"." ]] && g_calc_result=${g_calc_result%?}
|
[[ $g_calc_result == *"." ]] && g_calc_result=${g_calc_result%?}
|
||||||
|
|
||||||
# check output
|
# check output
|
||||||
if ! g_num_valid_number $g_calc_result
|
if ! g_num_valid_number "$g_calc_result"
|
||||||
then
|
then
|
||||||
echo "${FUNCNAME} $@" 1>&2
|
echo "${FUNCNAME} $@" 1>&2
|
||||||
unset g_calc_result
|
unset g_calc_result
|
||||||
|
|||||||
@@ -11,20 +11,16 @@ function g_median {
|
|||||||
local g_num_elements=${#g_sorted_numbers[@]}
|
local g_num_elements=${#g_sorted_numbers[@]}
|
||||||
|
|
||||||
# calculate the middle
|
# calculate the middle
|
||||||
local g_middle=$((g_num_elements/2))
|
local g_middle=$(($g_num_elements/2))
|
||||||
|
|
||||||
local g_median
|
|
||||||
# even/odd number
|
# even/odd number
|
||||||
if ((g_num_elements % 2 == 1))
|
if (($g_num_elements % 2 == 1))
|
||||||
then
|
then
|
||||||
# odd number
|
# odd number
|
||||||
echo "g_middle=$g_middle"
|
g_median_result="${g_sorted_numbers[$g_middle]}"
|
||||||
g_median=${g_sorted_numbers[g_middle]}
|
|
||||||
else
|
else
|
||||||
# even number
|
# even number
|
||||||
g_calc "(${g_sorted_numbers[g_middle - 1]} + ${g_sorted_numbers[g_middle]}) / 2"
|
g_calc "(${g_sorted_numbers[$g_middle - 1]} + ${g_sorted_numbers[$g_middle]}) / 2"
|
||||||
g_median=$g_calc_result
|
g_median_result="$g_calc_result"
|
||||||
fi
|
fi
|
||||||
|
|
||||||
g_median_result=$g_median
|
|
||||||
}
|
}
|
||||||
|
|||||||
11
gaboshlib/g_num_exponential2normal_file.sh
Normal file
11
gaboshlib/g_num_exponential2normal_file.sh
Normal file
@@ -0,0 +1,11 @@
|
|||||||
|
function g_num_exponential2normal_file {
|
||||||
|
# changes expionential numbers in normal notation in given file
|
||||||
|
local g_file=$1
|
||||||
|
local g_substitution g_exnum
|
||||||
|
for g_exnum in $(egrep -o -i "[0-9]+\.[0-9]+e[\+\-][0-9]+" "$g_file" | sort -u)
|
||||||
|
do
|
||||||
|
g_num_exponential2normal $g_exnum && g_substitution="${g_substitution}s/${g_exnum}/${g_num_exponential2normal_result}/g;"
|
||||||
|
done
|
||||||
|
sed -i "${g_substitution}" "$g_file" && return 0
|
||||||
|
}
|
||||||
|
|
||||||
@@ -48,6 +48,11 @@ function g_read_csv {
|
|||||||
g_csv_headline_array+=("${g_headline_item//[^a-zA-Z0-9_]/}")
|
g_csv_headline_array+=("${g_headline_item//[^a-zA-Z0-9_]/}")
|
||||||
done
|
done
|
||||||
|
|
||||||
|
g_basename $g_csvfile
|
||||||
|
local g_csvfile_base=${g_basename_result/\.history*.csv/}
|
||||||
|
g_csvfile_base=${g_csvfile_base//[^a-zA-Z0-9_]/}
|
||||||
|
g_csvfile_base=${g_csvfile_base//ECONOMY*/}
|
||||||
|
|
||||||
# read last lines if defined or complete csv file
|
# read last lines if defined or complete csv file
|
||||||
if [ -n "$g_last_lines" ]
|
if [ -n "$g_last_lines" ]
|
||||||
then
|
then
|
||||||
@@ -55,14 +60,15 @@ function g_read_csv {
|
|||||||
g_csvfile="${g_tmp}/g_csv_tmp.csv"
|
g_csvfile="${g_tmp}/g_csv_tmp.csv"
|
||||||
fi
|
fi
|
||||||
|
|
||||||
|
|
||||||
# read csv file to array
|
# read csv file to array
|
||||||
g_array "$g_csvfile" g_csv_array_ref
|
g_array "$g_csvfile" g_csv_array_ref
|
||||||
g_csv_array=("${g_csv_array_ref[@]}")
|
g_csv_array=("${g_csv_array_ref[@]}")
|
||||||
|
|
||||||
# go reverse through array
|
# create associative arrays forward and reverse and superarray v/vr
|
||||||
declare -Ag v_csv_array_associative
|
declare -Ag v_csv_array_associative
|
||||||
declare -Ag v_csv_array_associative_reverse
|
declare -Ag v_csv_array_associative_reverse
|
||||||
|
declare -Ag v
|
||||||
|
declare -Ag vr
|
||||||
l=0
|
l=0
|
||||||
for (( r=${#g_csv_array[@]}-1 ; r>=0 ; r-- ))
|
for (( r=${#g_csv_array[@]}-1 ; r>=0 ; r-- ))
|
||||||
do
|
do
|
||||||
@@ -76,6 +82,14 @@ function g_read_csv {
|
|||||||
[ "$l" = 0 ] && declare -g v_${g_headline_item}="${g_csv_line_array[i]}"
|
[ "$l" = 0 ] && declare -g v_${g_headline_item}="${g_csv_line_array[i]}"
|
||||||
v_csv_array_associative[${g_headline_item}_${r}]="${g_csv_line_array[i]}"
|
v_csv_array_associative[${g_headline_item}_${r}]="${g_csv_line_array[i]}"
|
||||||
v_csv_array_associative_reverse[${g_headline_item}_${l}]="${g_csv_line_array[i]}"
|
v_csv_array_associative_reverse[${g_headline_item}_${l}]="${g_csv_line_array[i]}"
|
||||||
|
if [ -z "${g_csvfile_base}" ]
|
||||||
|
then
|
||||||
|
v[${g_headline_item}_${r}]=${g_csv_line_array[i]}
|
||||||
|
vr[${g_headline_item}_${l}]=${g_csv_line_array[i]}
|
||||||
|
else
|
||||||
|
v[${g_csvfile_base}_${g_headline_item}_${r}]=${g_csv_line_array[i]}
|
||||||
|
vr[${g_csvfile_base}_${g_headline_item}_${l}]=${g_csv_line_array[i]}
|
||||||
|
fi
|
||||||
((i++))
|
((i++))
|
||||||
done
|
done
|
||||||
((l++))
|
((l++))
|
||||||
|
|||||||
@@ -1,3 +1,7 @@
|
|||||||
function g_wget {
|
function g_wget {
|
||||||
wget -T 10 -t 2 -U "Mozilla/5.0 (Windows NT 10.0; Win64; x64) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/92.0.4515.159 Safari/537.36" $@
|
wget -T 10 -t 2 \
|
||||||
|
--header="User-Agent: Mozilla/5.0 (Windows NT 10.0; Win64; x64) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/109.0.0.0 Safari/537.36" \
|
||||||
|
--header="Content-Type: application/json" \
|
||||||
|
--header="Accept-Language: en-US,en," \
|
||||||
|
$@
|
||||||
}
|
}
|
||||||
|
|||||||
Reference in New Issue
Block a user