mirror of
https://gitea.blesmrt.net/mikaela/scripts.git
synced 2025-08-04 21:27:21 +02:00
Compare commits
21 Commits
6f970a2b1a
...
bf1c36b03b
Author | SHA1 | Date | |
---|---|---|---|
bf1c36b03b | |||
25e521f4ad | |||
14dcc4d45a | |||
c4994e9fc3 | |||
854561af3d | |||
4782f57712 | |||
cc88636642 | |||
1293347e38 | |||
99288e471a | |||
d574359cd2 | |||
5a1812ab92 | |||
b577f8c1e3 | |||
f58f7dee5d | |||
18159a86f8 | |||
701b2f031e | |||
78b38e9e62 | |||
a445377236 | |||
93dac934fe | |||
34cfb4b3bb | |||
8017ae480a | |||
c7c527d4c7 |
4
.gitmodules
vendored
4
.gitmodules
vendored
@ -8,5 +8,5 @@
|
|||||||
branch = master
|
branch = master
|
||||||
[submodule "submodules/shell-things"]
|
[submodule "submodules/shell-things"]
|
||||||
path = submodules/shell-things
|
path = submodules/shell-things
|
||||||
url = https://gitea.blesmrt.net/Mikaela/shell-things.git
|
url = https://codeberg.org/Aminda/shell-things.git
|
||||||
branch = master
|
branch = cxefa
|
||||||
|
2
.pre-commit-config.yaml
vendored
2
.pre-commit-config.yaml
vendored
@ -10,8 +10,6 @@ ci:
|
|||||||
|
|
||||||
default_language_version:
|
default_language_version:
|
||||||
node: "lts"
|
node: "lts"
|
||||||
# Remember .python-version and pyproject.toml !
|
|
||||||
python: "3.13"
|
|
||||||
ruby: ".ruby-version"
|
ruby: ".ruby-version"
|
||||||
|
|
||||||
repos:
|
repos:
|
||||||
|
@ -1 +0,0 @@
|
|||||||
system
|
|
@ -8,7 +8,10 @@
|
|||||||
|
|
||||||
set -x
|
set -x
|
||||||
|
|
||||||
# TODO: if adb is not installed or in $PATH, exit?
|
if ! hash adb 2> /dev/null; then
|
||||||
|
echo "Error: adb not found in $PATH" 1>&2
|
||||||
|
exit 1
|
||||||
|
fi
|
||||||
|
|
||||||
# Remember,
|
# Remember,
|
||||||
echo "In case of trouble check Android System Settings, Connected devices, USB mode. It should be data transfer for adb USB debugging to take effect."
|
echo "In case of trouble check Android System Settings, Connected devices, USB mode. It should be data transfer for adb USB debugging to take effect."
|
||||||
@ -42,16 +45,21 @@ adb "$@" shell pm grant com.github.cvzi.darkmodewallpaper android.permission.REA
|
|||||||
(adb "$@" shell pm uninstall com.google.android.safetycore &)
|
(adb "$@" shell pm uninstall com.google.android.safetycore &)
|
||||||
#(adb "$@" shell pm disable com.google.android.safetycore &)
|
#(adb "$@" shell pm disable com.google.android.safetycore &)
|
||||||
|
|
||||||
# Should tell whether the DoH3 module exists
|
# Enable DNS-over-TLS
|
||||||
(adb "$@" shell pm list package | grep com.android.resolv &)
|
(adb "$@" shell settings put global private_dns_mode hostname &)
|
||||||
|
# If dns.google or cloudflare-dns.com, it will be updated to DoH3
|
||||||
# If 1, DoH3 is supported. How about trying to make it 1?
|
#(adb "$@" shell settings put global private_dns_specifier dns.google &)
|
||||||
(adb "$@" shell cmd device_config get netd_native doh &)
|
# TODO: Revisit this after DNS4EU launch. Regardless of potential issues,
|
||||||
|
# I am tempted by non-commercial ad filtering DNS.
|
||||||
|
(adb "$@" shell settings put global private_dns_specifier dns.adguard-dns.com &)
|
||||||
|
# I thought maybe setting the above to DoH3 and this would together allow
|
||||||
|
# arbitary DoH3 server, but no
|
||||||
(adb "$@" shell cmd device_config put netd_native doh 1 &)
|
(adb "$@" shell cmd device_config put netd_native doh 1 &)
|
||||||
|
|
||||||
# Wait a bit and then reboot the device
|
# Wait a bit and then reboot the device
|
||||||
sleep 5
|
sleep 5
|
||||||
#adb "$@" reboot
|
#adb "$@" reboot
|
||||||
|
|
||||||
printf "Performance issues? adb shell top -b | head\n"
|
printf "Consider: adb $@ shell settings put global private_dns_specifier dns.adguard-dns.com\n"
|
||||||
|
printf "Performance issues? adb $@ shell top -b | head\n"
|
||||||
set +x
|
set +x
|
||||||
|
@ -80,6 +80,12 @@ else
|
|||||||
printf "Either linuxbrew is not installed or running as root, skipping linuxbrew...\n"
|
printf "Either linuxbrew is not installed or running as root, skipping linuxbrew...\n"
|
||||||
fi
|
fi
|
||||||
|
|
||||||
|
if hash pipx 2> /dev/null; then
|
||||||
|
if [[ $(id -u) != 0 ]]; then
|
||||||
|
pipx upgrade-all
|
||||||
|
fi
|
||||||
|
fi
|
||||||
|
|
||||||
if hash rpmconf 2> /dev/null; then
|
if hash rpmconf 2> /dev/null; then
|
||||||
# Tests if there are rpmsave/rpmnew files, hopefully is non-interactive
|
# Tests if there are rpmsave/rpmnew files, hopefully is non-interactive
|
||||||
rpmconf -a -t
|
rpmconf -a -t
|
||||||
@ -150,17 +156,5 @@ if [ -f /root/fixgrub.bash ]; then
|
|||||||
. /root/fixgrub.bash
|
. /root/fixgrub.bash
|
||||||
fi
|
fi
|
||||||
|
|
||||||
# Lumina & Sedric have been having kernel update issues, let's see if this
|
|
||||||
# script could detect and suggest action for that.
|
|
||||||
# if [ -f /root/fix-kernel-install.bash ]; then
|
|
||||||
# . /root/fix-kernel-install.bash
|
|
||||||
# fi
|
|
||||||
# TODO: This seems to have been entirely on wrong track. Remove it?
|
|
||||||
#if hash kernel-install 2> /dev/null; then
|
|
||||||
# sleep 3
|
|
||||||
# kernel-install add-all -v
|
|
||||||
# sleep 5
|
|
||||||
#fi
|
|
||||||
|
|
||||||
# Hide commands being executed again
|
# Hide commands being executed again
|
||||||
set +x
|
set +x
|
||||||
|
@ -1,41 +0,0 @@
|
|||||||
#!/usr/bin/env bash
|
|
||||||
|
|
||||||
#set -x
|
|
||||||
|
|
||||||
export LC_ALL=en_DK.UTF-8
|
|
||||||
|
|
||||||
# Check for existence of /etc/machine-id/
|
|
||||||
if [ -f /etc/machine-id ]; then
|
|
||||||
|
|
||||||
# How about we just store the machine-id instead of fetching it
|
|
||||||
# constantly?
|
|
||||||
MACHINEID="$(cat /etc/machine-id)"
|
|
||||||
#echo "Our machine-id is $MACHINEID"
|
|
||||||
|
|
||||||
# Check for existence of the /boot/<machine-id> directory
|
|
||||||
if [ -d /boot/efi/"$MACHINEID" ]; then
|
|
||||||
|
|
||||||
# Store the latest installed kernel to $EXPECTEDKERNEL
|
|
||||||
EXPECTEDKERNEL="$(find /lib/modules -maxdepth 1 -printf '%P\n' | sort | tail -n -1)"
|
|
||||||
|
|
||||||
# And actual kernel in the boot/efi directory
|
|
||||||
ACTUALKERNEL="$(find /boot/efi/"$MACHINEID"/ -maxdepth 1 -printf '%P\n' | sort | tail -n -1)"
|
|
||||||
|
|
||||||
# Are they the same? Everything OK!
|
|
||||||
if [ "$EXPECTEDKERNEL" == "$ACTUALKERNEL" ]; then
|
|
||||||
echo "The kernel situation seems OK."
|
|
||||||
|
|
||||||
else
|
|
||||||
printf "\nWARNING! Kernels mismatch! Suggested actions:\n"
|
|
||||||
printf "\tsudo mkdir /boot/%b/%b\n" "$MACHINEID" "$EXPECTEDKERNEL"
|
|
||||||
printf "\tsudo kernel-install -v add %b /lib/modules/%b/vmlinuz\n" "$EXPECTEDKERNEL" "$EXPECTEDKERNEL"
|
|
||||||
#printf "\tsudo dnf reinstall kernel-core-%b -y\n" "$EXPECTEDKERNEL"
|
|
||||||
printf "Please note that Lumina and Sedric have moved to UKI.\n"
|
|
||||||
fi
|
|
||||||
fi
|
|
||||||
fi
|
|
||||||
|
|
||||||
echo "New kernel? Just in case, try sudo kernel-install -v add $(uname -r) # although using the actual new kernel version"
|
|
||||||
echo "Alternatively sudo kernel-install -v add-all"
|
|
||||||
|
|
||||||
#set +x
|
|
89
bash/snap-browsers.bash
Executable file
89
bash/snap-browsers.bash
Executable file
@ -0,0 +1,89 @@
|
|||||||
|
#!/usr/bin/env bash
|
||||||
|
set -x
|
||||||
|
# I am not a fan of Snap in general due to issues such as one allowed
|
||||||
|
# repository allowed at a time, closed source server, issues when running
|
||||||
|
# without a desktop environment, but with web browsers it beats flatpak for
|
||||||
|
# respecting browser policies, thus this script which is kind of
|
||||||
|
# snap-workarounds.bash
|
||||||
|
|
||||||
|
# WARNING: No KDE Desktop Integration for snap users. And obviously this
|
||||||
|
# script isn't going to install snap duplicates of browsers that are already
|
||||||
|
# installed, Ubuntu users are trusted to know firefox/chromium are wrappers
|
||||||
|
# for snaps.
|
||||||
|
|
||||||
|
# If snap isn't installed, exit
|
||||||
|
if ! hash snap 2> /dev/null; then
|
||||||
|
echo "This script is useless without snap installed."
|
||||||
|
exit 1
|
||||||
|
fi
|
||||||
|
|
||||||
|
# Require root or exit
|
||||||
|
if [ "$(id -u)" != "0" ]; then
|
||||||
|
echo "This script requires root." 1>&2
|
||||||
|
exit 1
|
||||||
|
fi
|
||||||
|
|
||||||
|
# Ensure classic snap support is enabled
|
||||||
|
if [ ! -d "/snap" ]; then
|
||||||
|
ln -nsv /var/lib/snapd/snap /snap
|
||||||
|
fi
|
||||||
|
|
||||||
|
# Init policy directories or quit if the script isn't available
|
||||||
|
if [ -f "../submodules/shell-things/etc/init-browser-policies.bash" ]; then
|
||||||
|
# TODO: That script has comments that might be more at home here!
|
||||||
|
../submodules/shell-things/etc/init-browser-policies.bash
|
||||||
|
else
|
||||||
|
echo "Missing submodule shell-things, initializing submodules"
|
||||||
|
git submodule update --init
|
||||||
|
echo "Please run the script again!"
|
||||||
|
exit 1
|
||||||
|
fi
|
||||||
|
|
||||||
|
# If Firefox is already installed, switch to the ESR channel for distrust
|
||||||
|
# towards Mozilla and search engine policy support. Otherwise install Firefox
|
||||||
|
# This is officially supported/published by Mozilla.
|
||||||
|
if [[ ! -f "/usr/bin/firefox" ]] && [[ ! -f "/usr/bin/firefox-esr" ]]; then
|
||||||
|
if [ -f "/snap/bin/firefox" ]; then
|
||||||
|
snap refresh firefox --channel=esr/stable
|
||||||
|
else
|
||||||
|
snap install firefox --channel=esr/stable
|
||||||
|
fi
|
||||||
|
else
|
||||||
|
echo "If on Ubuntu: sudo snap refresh firefox --channel=esr/stable"
|
||||||
|
fi
|
||||||
|
|
||||||
|
# Difficult to test Chromium policies without Chromium. And for testing edge is fine.
|
||||||
|
# Published/supported by Canonical.
|
||||||
|
if [[ ! -f "/usr/bin/chromium" ]] && [[ ! -f "/usr/bin/chromium-browser" ]]; then
|
||||||
|
if [ -f "/snap/bin/chromium" ]; then
|
||||||
|
snap refresh chromium --channel=edge
|
||||||
|
else
|
||||||
|
snap install chromium --edge
|
||||||
|
fi
|
||||||
|
else
|
||||||
|
echo "If on Ubuntu: sudo snap refresh chromium --channel=edge"
|
||||||
|
fi
|
||||||
|
|
||||||
|
# European/Norwegian freeware browser that I prefer to keep installed as an option.
|
||||||
|
# Official snap.
|
||||||
|
if [[ ! -f "/usr/bin/vivaldi" ]] && [[ ! -f "/usr/bin/vivaldi-snapshot" ]]; then
|
||||||
|
if [ -f "/snap/bin/vivaldi.vivaldi-stable" ]; then
|
||||||
|
snap refresh vivaldi
|
||||||
|
else
|
||||||
|
snap install vivaldi
|
||||||
|
fi
|
||||||
|
fi
|
||||||
|
|
||||||
|
# TODO: Revisit when they change CEO.
|
||||||
|
# - 2008: https://en.wikipedia.org/wiki/Brendan_Eich#Appointment_to_CEO_and_resignation
|
||||||
|
# - 2025: https://news.ycombinator.com/item?id=43251203
|
||||||
|
#
|
||||||
|
#if [[ ! -f "/usr/bin/brave-browser-stable" ]] && [[ ! -f "/usr/bin/brave-browser-beta" ]] && [[ ! -f "/usr/bin/brave-browser-nightly" ]]; then
|
||||||
|
# if [ -f "/snap/bin/brave" ]; then
|
||||||
|
# snap refresh brave
|
||||||
|
# else
|
||||||
|
# snap install brave
|
||||||
|
# fi
|
||||||
|
#fi
|
||||||
|
|
||||||
|
set +x
|
@ -1,9 +1,12 @@
|
|||||||
#!/usr/bin/env bash
|
#!/usr/bin/env bash
|
||||||
|
|
||||||
set -x
|
set -x
|
||||||
|
|
||||||
if [[ -d "$HOME/.config/BraveSoftware/Brave-Browser-Nightly" && -d "$HOME/.cache/BraveSoftware/Brave-Browser-Nightly" ]]; then
|
if [[ -d "$HOME/.config/BraveSoftware/Brave-Browser-Nightly" && -d "$HOME/.cache/BraveSoftware/Brave-Browser-Nightly" ]]; then
|
||||||
/usr/bin/brave-browser-nightly --ozone-platform=wayland --disk-cache-dir='/dev/null' --enable-features=WaylandWindowDecorations "$@"
|
/usr/bin/brave-browser-nightly --ozone-platform=wayland --disk-cache-dir='/dev/null' --enable-features=WaylandWindowDecorations "$@"
|
||||||
else
|
elif [ -f /usr/bin/brave-browser-stable ]; then
|
||||||
/usr/bin/brave-browser-stable --ozone-platform=wayland --disk-cache-dir='/dev/null' --enable-features=WaylandWindowDecorations "$@"
|
/usr/bin/brave-browser-stable --ozone-platform=wayland --disk-cache-dir='/dev/null' --enable-features=WaylandWindowDecorations "$@"
|
||||||
|
elif [ -f /snap/bin/brave ]; then
|
||||||
|
snap run brave --ozone-platform=wayland --disk-cache-dir='/dev/null' --enable "$@"
|
||||||
fi
|
fi
|
||||||
|
|
||||||
set +x
|
set +x
|
||||||
|
@ -1,4 +1,8 @@
|
|||||||
#!/usr/bin/env bash
|
#!/usr/bin/env bash
|
||||||
set -x
|
set -x
|
||||||
|
if [ -f /usr/bin/chromium-browser ]; then
|
||||||
/usr/bin/chromium-browser --ozone-platform=wayland --disk-cache-dir='/dev/null' --enable-features=WaylandWindowDecorations "$@"
|
/usr/bin/chromium-browser --ozone-platform=wayland --disk-cache-dir='/dev/null' --enable-features=WaylandWindowDecorations "$@"
|
||||||
|
else
|
||||||
|
snap run chromium --ozone-platform=wayland --disk-cache-dir='/dev/null' --enable "$@"
|
||||||
|
fi
|
||||||
set +x
|
set +x
|
||||||
|
@ -4,5 +4,9 @@
|
|||||||
|
|
||||||
set -x
|
set -x
|
||||||
# --start-in-tray - would be nice, but then I cannot open it from there, thus --use-tray-icon
|
# --start-in-tray - would be nice, but then I cannot open it from there, thus --use-tray-icon
|
||||||
flatpak run org.signal.Signal --use-tray-icon --ozone-platform=wayland --enable-features=WaylandWindowDecorations "$@"
|
(flatpak run org.signal.Signal --use-tray-icon --ozone-platform=wayland --enable-features=WaylandWindowDecorations "$@" &)
|
||||||
|
if [ -f /snap/bin/signal-desktop ]; then
|
||||||
|
#snap set signal-desktop tray-icon=true
|
||||||
|
(snap run signal-desktop --use-tray-icon --ozone-platform=wayland --enable-features=WaylandWindowDecorations "$@" &)
|
||||||
|
fi
|
||||||
set +x
|
set +x
|
||||||
|
@ -2,7 +2,9 @@
|
|||||||
set -x
|
set -x
|
||||||
if [[ -d "$HOME/.config/vivaldi-snapshot" && -d "$HOME/.cache/vivaldi-snapshot" ]]; then
|
if [[ -d "$HOME/.config/vivaldi-snapshot" && -d "$HOME/.cache/vivaldi-snapshot" ]]; then
|
||||||
/usr/bin/vivaldi-snapshot --ozone-platform=wayland --disk-cache-dir='/dev/null' --enable-features=WaylandWindowDecorations "$@"
|
/usr/bin/vivaldi-snapshot --ozone-platform=wayland --disk-cache-dir='/dev/null' --enable-features=WaylandWindowDecorations "$@"
|
||||||
else
|
elif [ -f /usr/bin/vivaldi ]; then
|
||||||
/usr/bin/vivaldi --ozone-platform=wayland --disk-cache-dir='/dev/null' --enable-features=WaylandWindowDecorations "$@"
|
/usr/bin/vivaldi --ozone-platform=wayland --disk-cache-dir='/dev/null' --enable-features=WaylandWindowDecorations "$@"
|
||||||
|
elif [ -f /snap/bin/vivaldi.vivaldi-stable ]; then
|
||||||
|
snap run vivaldi.vivaldi-stable --ozone-platform=wayland --disk-cache-dir='/dev/null' --enable "$@"
|
||||||
fi
|
fi
|
||||||
set +x
|
set +x
|
||||||
|
@ -1,13 +1,14 @@
|
|||||||
{
|
{
|
||||||
"devDependencies": {
|
"devDependencies": {
|
||||||
"@aminda/global-prettier-config": "2025.10.0",
|
"@aminda/global-prettier-config": "2025.13.0",
|
||||||
"@prettier/plugin-ruby": "4.0.4",
|
"@prettier/plugin-ruby": "4.0.4",
|
||||||
"@prettier/plugin-xml": "3.4.1",
|
"@prettier/plugin-xml": "3.4.1",
|
||||||
|
"corepack": "latest",
|
||||||
"prettier": "3.5.3",
|
"prettier": "3.5.3",
|
||||||
"prettier-plugin-nginx": "1.0.3",
|
"prettier-plugin-nginx": "1.0.3",
|
||||||
"prettier-plugin-sh": "0.15.0",
|
"prettier-plugin-sh": "0.15.0",
|
||||||
"prettier-plugin-toml": "2.0.2"
|
"prettier-plugin-toml": "2.0.2"
|
||||||
},
|
},
|
||||||
"packageManager": "pnpm@10.6.0+sha512.df0136e797db0cfa7ec1084e77f3bdf81bacbae9066832fbf95cba4c2140ad05e64f316cde51ce3f99ea00a91ffc702d6aedd3c0f450f895e3e7c052fe573cd8",
|
"packageManager": "pnpm@10.6.5+sha512.cdf928fca20832cd59ec53826492b7dc25dc524d4370b6b4adbf65803d32efaa6c1c88147c0ae4e8d579a6c9eec715757b50d4fa35eea179d868eada4ed043af",
|
||||||
"prettier": "@aminda/global-prettier-config"
|
"prettier": "@aminda/global-prettier-config"
|
||||||
}
|
}
|
||||||
|
24
pnpm-lock.yaml
generated
vendored
24
pnpm-lock.yaml
generated
vendored
@ -8,14 +8,17 @@ importers:
|
|||||||
.:
|
.:
|
||||||
devDependencies:
|
devDependencies:
|
||||||
"@aminda/global-prettier-config":
|
"@aminda/global-prettier-config":
|
||||||
specifier: 2025.10.0
|
specifier: 2025.13.0
|
||||||
version: 2025.10.0
|
version: 2025.13.0
|
||||||
"@prettier/plugin-ruby":
|
"@prettier/plugin-ruby":
|
||||||
specifier: 4.0.4
|
specifier: 4.0.4
|
||||||
version: 4.0.4(prettier@3.5.3)
|
version: 4.0.4(prettier@3.5.3)
|
||||||
"@prettier/plugin-xml":
|
"@prettier/plugin-xml":
|
||||||
specifier: 3.4.1
|
specifier: 3.4.1
|
||||||
version: 3.4.1(prettier@3.5.3)
|
version: 3.4.1(prettier@3.5.3)
|
||||||
|
corepack:
|
||||||
|
specifier: latest
|
||||||
|
version: 0.32.0
|
||||||
prettier:
|
prettier:
|
||||||
specifier: 3.5.3
|
specifier: 3.5.3
|
||||||
version: 3.5.3
|
version: 3.5.3
|
||||||
@ -30,10 +33,10 @@ importers:
|
|||||||
version: 2.0.2(prettier@3.5.3)
|
version: 2.0.2(prettier@3.5.3)
|
||||||
|
|
||||||
packages:
|
packages:
|
||||||
"@aminda/global-prettier-config@2025.10.0":
|
"@aminda/global-prettier-config@2025.13.0":
|
||||||
resolution:
|
resolution:
|
||||||
{
|
{
|
||||||
integrity: sha512-7M2TWWTZDU6rU0AkcNeFSILuvh8lT3Mr0TAl/ZVctYWgWuzOzyRVZySwStl4o3Oj2QMCEEEky5wzJO8540rq1Q==,
|
integrity: sha512-1yRmlX7lrBu41eu7dcAF17fTYdbnTYp6o1zRKGUVku6ddz9rp0cjCw4QK1oNrUq7KU0GAAlxQtDfw0WlOzJw+A==,
|
||||||
}
|
}
|
||||||
|
|
||||||
"@prettier/plugin-ruby@4.0.4":
|
"@prettier/plugin-ruby@4.0.4":
|
||||||
@ -76,6 +79,14 @@ packages:
|
|||||||
integrity: sha512-wy3mC1x4ye+O+QkEinVJkPf5u2vsrDIYW9G7ZuwFl6v/Yu0LwUuT2POsb+NUWApebyxfkQq6+yDfRExbnI5rcw==,
|
integrity: sha512-wy3mC1x4ye+O+QkEinVJkPf5u2vsrDIYW9G7ZuwFl6v/Yu0LwUuT2POsb+NUWApebyxfkQq6+yDfRExbnI5rcw==,
|
||||||
}
|
}
|
||||||
|
|
||||||
|
corepack@0.32.0:
|
||||||
|
resolution:
|
||||||
|
{
|
||||||
|
integrity: sha512-KhahVUFy7xL8OTty/ToY646hXMQhih8rnvUkA9/qnk/u4QUF2+SbQneX/zZnDxG1NiABFm5ojZCWnIv93oyhhQ==,
|
||||||
|
}
|
||||||
|
engines: { node: ^18.17.1 || ^20.10.0 || >=22.11.0 }
|
||||||
|
hasBin: true
|
||||||
|
|
||||||
mvdan-sh@0.10.1:
|
mvdan-sh@0.10.1:
|
||||||
resolution:
|
resolution:
|
||||||
{
|
{
|
||||||
@ -134,10 +145,11 @@ packages:
|
|||||||
}
|
}
|
||||||
|
|
||||||
snapshots:
|
snapshots:
|
||||||
"@aminda/global-prettier-config@2025.10.0":
|
"@aminda/global-prettier-config@2025.13.0":
|
||||||
dependencies:
|
dependencies:
|
||||||
"@prettier/plugin-ruby": 4.0.4(prettier@3.5.3)
|
"@prettier/plugin-ruby": 4.0.4(prettier@3.5.3)
|
||||||
"@prettier/plugin-xml": 3.4.1(prettier@3.5.3)
|
"@prettier/plugin-xml": 3.4.1(prettier@3.5.3)
|
||||||
|
corepack: 0.32.0
|
||||||
prettier: 3.5.3
|
prettier: 3.5.3
|
||||||
prettier-plugin-nginx: 1.0.3
|
prettier-plugin-nginx: 1.0.3
|
||||||
prettier-plugin-sh: 0.15.0(prettier@3.5.3)
|
prettier-plugin-sh: 0.15.0(prettier@3.5.3)
|
||||||
@ -166,6 +178,8 @@ snapshots:
|
|||||||
dependencies:
|
dependencies:
|
||||||
regexp-to-ast: 0.5.0
|
regexp-to-ast: 0.5.0
|
||||||
|
|
||||||
|
corepack@0.32.0: {}
|
||||||
|
|
||||||
mvdan-sh@0.10.1: {}
|
mvdan-sh@0.10.1: {}
|
||||||
|
|
||||||
prettier-plugin-nginx@1.0.3: {}
|
prettier-plugin-nginx@1.0.3: {}
|
||||||
|
42
python/weeknumbers.py
Executable file
42
python/weeknumbers.py
Executable file
@ -0,0 +1,42 @@
|
|||||||
|
#!/usr/bin/env python3
|
||||||
|
"""
|
||||||
|
A family member wanted to know what dates are on weeks 26 and 31 and instead of
|
||||||
|
the answer received this script. I thought I would try to improve it for fun,
|
||||||
|
since it doesn't pass pylint or anything.
|
||||||
|
"""
|
||||||
|
import datetime
|
||||||
|
|
||||||
|
# Current year
|
||||||
|
# TODO: ask the user or if no answer, assume the actual current year?
|
||||||
|
CURRENT_YEAR = 2025
|
||||||
|
|
||||||
|
|
||||||
|
# TODO: ask for the week
|
||||||
|
# Calculate dates for weeks 26-31
|
||||||
|
def get_dates_for_week(week_number, year):
|
||||||
|
"""
|
||||||
|
This function gets the dates for the week in question.
|
||||||
|
"""
|
||||||
|
# Find the first day of the year
|
||||||
|
first_day_of_year = datetime.date(year, 1, 1)
|
||||||
|
|
||||||
|
# Find the first day of the desired week (ISO format week numbering)
|
||||||
|
start_of_week = first_day_of_year + datetime.timedelta(
|
||||||
|
weeks=week_number - 1
|
||||||
|
)
|
||||||
|
|
||||||
|
# Return the start and end date of the week
|
||||||
|
start_of_week = start_of_week - datetime.timedelta(
|
||||||
|
days=start_of_week.weekday()
|
||||||
|
) # Adjust to Monday
|
||||||
|
end_of_week = start_of_week + datetime.timedelta(days=6) # Sunday
|
||||||
|
|
||||||
|
return (start_of_week, end_of_week)
|
||||||
|
|
||||||
|
|
||||||
|
# TODO: ansewr in a more human format
|
||||||
|
# Get the dates for weeks 26-31
|
||||||
|
weeks = {
|
||||||
|
week: get_dates_for_week(week, CURRENT_YEAR) for week in range(26, 32)
|
||||||
|
}
|
||||||
|
print(weeks)
|
@ -1 +1 @@
|
|||||||
Subproject commit 47d6a0b0cc0e241149303547e7819ef34ea91502
|
Subproject commit bc3750b65f76149edd6c7fc673c8ef3f0b8e20f6
|
@ -1 +1 @@
|
|||||||
Subproject commit 9cdd99fdb18bd01dd4fc1a5d5320a981bb207698
|
Subproject commit a6bba46ab55b195363248ffff9b22228db11609a
|
Loading…
x
Reference in New Issue
Block a user