From 6e3961d28bc8a89c18068cbc988abaee9598a3d0 Mon Sep 17 00:00:00 2001 From: NVolcz Date: Thu, 19 Sep 2024 00:24:22 +0200 Subject: [PATCH] fixes --- config/bashrc | 10 +- config/bics-plugins/analysis.bash | 142 ++++++++++++++++++++++++++ config/config/Code/User/settings.json | 5 +- config/config/dconf/user.txt | 27 +++-- config/config/git/config | 40 +++++--- hacks.md | 5 +- installs/firefox-addons.sh | 7 ++ installs/gcm.sh | 46 +++++++++ installs/terraform.sh | 6 -- installs/vscode.sh | 11 -- iwlwifi.md | 25 +++++ power-management.txt | 22 ++++ 12 files changed, 300 insertions(+), 46 deletions(-) create mode 100644 config/bics-plugins/analysis.bash create mode 100644 installs/gcm.sh delete mode 100755 installs/terraform.sh create mode 100644 iwlwifi.md diff --git a/config/bashrc b/config/bashrc index 4bcd675..577112b 100755 --- a/config/bashrc +++ b/config/bashrc @@ -148,7 +148,7 @@ alias l='ls' alias docker='podman' # Found https://www.reddit.com/r/programming/comments/3evbbk/how_to_write_a_git_commit_message/ctiuwwz -alias whatthecommit='git commit -m "$(curl -s whatthecommit.com/index.txt)"' +alias whatthecommit='git commit -m "$(curl -s https://www.whatthecommit.com/index.txt)"' # Found at: https://stackoverflow.com/questions/33150176/get-subnet-mask-in-linux-using-bash/33150670#33150670 alias whichnetwork="ip -o -f inet addr show | awk '/scope global/ {print \$4}'" @@ -194,6 +194,8 @@ highlight() { set -o vi export EDITOR='vim' +export PAGER='less' + # Nice when doing pomodoro. Sleeps specified number of minutes. pomo() { sleep "$((60*$1))" @@ -262,3 +264,9 @@ export LANG='en_GB.UTF-8' # Borrowed from: https://anarc.at/blog/2020-03-02-moving-dconf-entries-to-git/ export DCONF_PROFILE=$HOME/.config/dconf/profile + +export KIND_EXPERIMENTAL_PROVIDER=podman +eval "$(mise activate bash)" + +export CDPATH=".:~:~/git:~/git/controla" + diff --git a/config/bics-plugins/analysis.bash b/config/bics-plugins/analysis.bash new file mode 100644 index 0000000..53dcc43 --- /dev/null +++ b/config/bics-plugins/analysis.bash @@ -0,0 +1,142 @@ +# analysis +# +# Various tools for text extraction, representation, and analysis +# +# Author: Dave Eddy +# Credits: Brendan Gregg http://www.brendangregg.com/ +# License: MIT +# Date: 3/2/2013 + +# Calculate the average of input numbers +# +# $ cat data +# 100 +# 100 +# 0 +# $ avg < data +# 66.666 +avg() { + local f=${1:-1} + awk -F "${2:- }" "length(\$$f) { i+=1; sum+=\$$f; } END { print sum/i }" +} + +# Add commas to a given inputs numbers +# +# $ echo '100000 / 100000000' | commas +# 100,000 / 100,000,000 +commas() { + sed -e :a -e 's/\(.*[0-9]\)\([0-9]\{3\}\)/\1,\2/;ta' +} + +# Grab a field from given input +# Adapted from http://www.brendangregg.com/Shell/field +# +# $ echo -e ' three different\tcolumns ' | field 2 +# different +field() { + awk -F "${2:- }" "{ print \$${1:-1} }" +} + +# Poor mans frequency count +# +# $ cat data +# a +# b +# c +# c +# $ cat data | freq +# 1 a +# 1 b +# 2 c +freq() { + sort | uniq -c | sort -n +} + +# Print gaps in numbers (inclusively) +# http://stackoverflow.com/questions/15867557/finding-gaps-sequential-numbers +# +# $ cat data +# 1 +# 2 +# 3 +# 6 +# 10 +# $ cat data +# 4-5 +# 7-9 +gaps() { + awk '$1 != (p+1) { print p+1 "-" $1-1 } { p = $1 }' +} + +# Figure out the max number of given input +# +# $ cat data +# 1 +# 2 +# 3 +# $ max < data +# 3 +max() { + local f=${1:-1} + awk -F "${2:- }" " + length(\$$f) { + if (max == \"\" || \$$f > max) + max = \$$f + } + END { print max; }" +} + +# Figure out the min number of given input +# +# $ cat data +# 1 +# 2 +# 3 +# $ min < data +# 1 +min() { + local f=${1:-1} + awk -F "${2:- }" " + length(\$$f) { + if (min == \"\" || \$$f < min) + min = \$$f + } + END { print min; }" +} + +# Print a summary for input data +# show average, sum, min and max +summarize() { + local f=${1:-1} + awk -F "${2:- }" " + length(\$$f) { + if (max == \"\") + max = min = \$$f; + i += 1; + sum += \$$f; + if (\$$f > max) + max = \$$f + if (\$$f < min) + min = \$$f + } + END { + print \"lines\\t\", i; + print \"min\\t\", min; + print \"max\\t\", max; + print \"sum\\t\", sum; + print \"avg\\t\", sum/i; + }" +} + +# Total a given field using awk +# Taken from http://www.brendangregg.com/Shell/total +# +# $ cat data +# 1 +# 2 +# 4 +# $ cat data | total +# 7 +total() { + awk -F "${2:- }" "{ s += \$${1:-1} } END { print s }" +} diff --git a/config/config/Code/User/settings.json b/config/config/Code/User/settings.json index 90d0266..bcc89e2 100644 --- a/config/config/Code/User/settings.json +++ b/config/config/Code/User/settings.json @@ -9,9 +9,12 @@ "cSpell.language": "en-GB,sv-SE", "redhat.telemetry.enabled": true, "cSpell.userWords": [ + "Controla", "Springflod", "Venor" ], "diffEditor.diffAlgorithm": "advanced", - "explorer.autoReveal": true + "explorer.autoReveal": true, + "security.workspace.trust.untrustedFiles": "open", + "cSpell.enabled": false } \ No newline at end of file diff --git a/config/config/dconf/user.txt b/config/config/dconf/user.txt index a458d55..cdc728d 100644 --- a/config/config/dconf/user.txt +++ b/config/config/dconf/user.txt @@ -1,5 +1,10 @@ -[org/freedesktop/ibus/general] -hotkey=[''] +# See schemas at: https://github.com/GNOME/gsettings-desktop-schemas/tree/master/schemas +# The value inside the brackets are the path of the schema + +# It seems that symlinked keyfiles are automatically converted to files +# by copying the symlink destination. This causes edits in this file not be +# written to the dconf file. + [org/gnome/desktop/wm/keybindings] switch-group=[''] @@ -15,24 +20,18 @@ clock-format='24h' clock-show-date=true clock-show-seconds=false -[org.gnome.desktop.peripherals.touchpad] +[org/gnome/desktop/peripherals/touchpad] natural-scroll=false -[org.gnome.shell.extensions.dash-to-dock] -autohide=true +[org/gnome/shell/extensions/dash-to-dock] +dock-fixed=false -[org.gnome.settings-daemon.plugins.color] +[org/gnome/settings-daemon/plugins/color] night-light-enabled=true -[org.freedesktop.ibus.panel.emoji] -hotkey=[''] - -[org.gnome.desktop.calendar] +[org/gnome/desktop/calendar] show-weekdate=true -[org.gnome.nautilus.preferences] +[org/gnome/nautilus/preferences] default-sort-order = 'type' -[org.gnome.desktop.peripherals.touchpad] -natural-scroll=false - diff --git a/config/config/git/config b/config/config/git/config index 64c5358..93fa9de 100755 --- a/config/config/git/config +++ b/config/config/git/config @@ -1,15 +1,17 @@ [user] - name = NVolcz - email = niklas.volcz@gmail.com + name = NVolcz + email = niklas.volcz@gmail.com [alias] - lg = log --graph --abbrev-commit --decorate --date=relative --format=format:'%C(bold blue)%h%C(reset) - %C(white)%s%C(reset) %C(dim white)- %an%C(reset)%C(auto)%d%C(reset)' --all + lg = log --graph --abbrev-commit --decorate --date=relative --format=format:'%C(bold blue)%h%C(reset) - %C(white)%s%C(reset) %C(dim white)- %an%C(reset)%C(auto)%d%C(reset)' --all aliases = config --get-regexp alias autoamend = commit --amend -CHEAD diffs = diff --staged wdiff = diff --word-diff root = rev-parse --show-toplevel reset-origin = !"git branch -f \"$1\" \"origin/$1\" #" + whoami = "!echo \"$(git config user.name) ($(git config user.email))\"" + please = push --force-with-lease [merge] conflictstyle = diff3 @@ -33,16 +35,30 @@ date = iso [filter "lfs"] - required = true - clean = git-lfs clean -- %f - smudge = git-lfs smudge -- %f - process = git-lfs filter-process + required = true + clean = git-lfs clean -- %f + smudge = git-lfs smudge -- %f + process = git-lfs filter-process [color "branch"] - current = yellow reverse - local = yellow - remote = green + current = yellow reverse + local = yellow + remote = green + [fetch] - prune = true + prune = true + [init] - defaultBranch = main + defaultBranch = main + +[includeIf "gitdir:~/git/controla/"] + path = ~/git/controla/.gitconfig + +[includeIf "gitdir:~/git/springflod/"] + path = ~/git/springflod/.gitconfig +[credential] + helper = + helper = /usr/local/bin/git-credential-manager + credentialStore = secretservice +[credential "https://dev.azure.com"] + useHttpPath = true diff --git a/hacks.md b/hacks.md index 90ff609..1df0ae8 100644 --- a/hacks.md +++ b/hacks.md @@ -32,9 +32,12 @@ time_total: %{time_total}s\n Command: `curl -w "@curl-format.txt" -o /dev/null -s "http://wordpress.com/"` -## Fix end-of-line in Git repository +## Fix missing newline EOF in Git repository ```git ls-tree --full-tree -r --name-only HEAD | head -n 3 | tee /dev/tty | xargs -I{} sed -i -e '$a\' {}``` +From [Stackoverflow](https://stackoverflow.com/a/57770973): +```for f in $(git grep --cached -Il ''); do tail -c1 $f | read -r _ || echo >> $f; done``` + ## Download apt package and dependencies Useful for installing a package on a computer without network. Borrowed from: https://stackoverflow.com/a/27469489 diff --git a/installs/firefox-addons.sh b/installs/firefox-addons.sh index f816b2d..319ea24 100755 --- a/installs/firefox-addons.sh +++ b/installs/firefox-addons.sh @@ -21,3 +21,10 @@ firefox "https://addons.mozilla.org/firefox/downloads/file/3539390/" # TODO: Find a way to install other Firefox configurations: # Disable "mute tab"-button - browser.tabs.showAudioPlayingIcon false # Disable firefox password manager - sigon.rememberSignons false + + +# Firefox settings: +# privacy.trackingprotection.enabled - true +# https://wiki.archlinux.org/title/Firefox#Hardware_video_acceleration + +# signon.rememberSignons;false - Disable Firefox password manager. \ No newline at end of file diff --git a/installs/gcm.sh b/installs/gcm.sh new file mode 100644 index 0000000..1c490ea --- /dev/null +++ b/installs/gcm.sh @@ -0,0 +1,46 @@ +#!/usr/bin/env bash +set -euo pipefail + +cleanup() { + echo "Cleaning up..." + rm -f "$DEB_FILE" +} +trap cleanup EXIT + +ASSETS_URL="$(curl -s https://api.github.com/repos/git-ecosystem/git-credential-manager/releases/latest | jq -r '.assets_url')" + +DOWNLOAD_URL="$(curl -s "$ASSETS_URL" | jq -r '.[] | select(.name | test("^gcm-linux_amd64.*\\.deb$")) | .browser_download_url')" + +if [[ -z "$DOWNLOAD_URL" ]]; then + echo "Failed to find the .deb package download URL" + exit 1 +fi + +TEMP_DIR="/tmp" +DEB_FILE="$TEMP_DIR/$(basename "$DOWNLOAD_URL")" + +curl -s -Lo "$DEB_FILE" "$DOWNLOAD_URL" + +sudo apt install "$DEB_FILE" + +# Should I verify the signature? +# https://github.com/git-ecosystem/git-credential-manager/blob/release/docs/linux-validate-gpg.md#debian-package + +# +# Code below is for isntalling gcm with dotnot. It is the preferred +# way according to the documentation but this currently forces the use of +# dotnot 7.0 which is EOL. +# + +## Should I used the scripted installation instead? +## https://learn.microsoft.com/en-us/dotnet/core/install/linux-scripted-manual#scripted-install +# +## Since dotnet 7 is required for GCM, we need to install the dotnet backports library: +#sudo add-apt-repository -y ppa:dotnet/backports +## https://learn.microsoft.com/en-us/dotnet/core/install/linux-ubuntu#supported-distributions +## https://github.com/git-ecosystem/git-credential-manager/issues/1702 +# +#sudo apt install -y dotnet-sdk-7.0 +# +#dotnet tool install -g git-credential-manager +#git-credential-manager configure diff --git a/installs/terraform.sh b/installs/terraform.sh deleted file mode 100755 index cb39422..0000000 --- a/installs/terraform.sh +++ /dev/null @@ -1,6 +0,0 @@ -#!/usr/bin/env bash -set -euo pipefail - -wget -O- https://apt.releases.hashicorp.com/gpg | sudo gpg --dearmor -o /usr/share/keyrings/hashicorp-archive-keyring.gpg -echo "deb [signed-by=/usr/share/keyrings/hashicorp-archive-keyring.gpg] https://apt.releases.hashicorp.com $(lsb_release -cs) main" | sudo tee /etc/apt/sources.list.d/hashicorp.list -sudo apt update && sudo apt install terraform diff --git a/installs/vscode.sh b/installs/vscode.sh index e90765a..b7f3938 100755 --- a/installs/vscode.sh +++ b/installs/vscode.sh @@ -14,21 +14,10 @@ code --install-extension eamodio.gitlens # This plugin does no longer work with podman: https://github.com/microsoft/vscode-docker/issues/3766 code --install-extension ms-azuretools.vscode-docker -code --install-extension ms-vscode.makefile-tools # TODO: Replace if there ever is a plugin that integrates to the official test API. # See: https://github.com/hbenl/vscode-mocha-test-adapter/issues/184 code --install-extension hbenl.vscode-mocha-test-adapter -# Prefer ronnidc.nunjucks over eseom.nunjucks-template for now. -# They seem very similar but ronnidc seems: -# - More active on Github -# - more lightweight (it is basically only TextMate syntax files packaged as a vscode extension) -# On the other hand: -# - TextMate, is it really a good way to implement syntax highlighting? -# - It is only a single dependency. -# - ronnidc does currently not have a license (See issues #33) -code --install-extension ronnidc.nunjucks - code --install-extension dbaeumer.vscode-eslint code --install-extension streetsidesoftware.code-spell-checker diff --git a/iwlwifi.md b/iwlwifi.md new file mode 100644 index 0000000..c56ee3a --- /dev/null +++ b/iwlwifi.md @@ -0,0 +1,25 @@ + +It is possible to configure iwlwifi by adding options to `/etc/modprobe.d/iwlwifi.conf`. + +I have seen people suggest to try and evaluate these options: +``` +options iwlwifi 11n_disable=1 +options iwlwifi 11n_disable=8 +``` + +Don't forget to remove iwlmvm when reloading: +``` +sudo modprobe -r iwlmvm +sudo modprobe -r iwlwifi +sudo modprobe iwlwifi +``` + +`sudo modinfo iwlwifi` for showing params (and other stuff). + +for checking the running hardware: +``` +lspci | grep -i network +sudo lshw -C network +``` + +https://forum.manjaro.org/t/wifi-network-speed-intel-wireless-7265-driver-iwlwifi/154472/6 \ No newline at end of file diff --git a/power-management.txt b/power-management.txt index 05ff187..034cc9f 100644 --- a/power-management.txt +++ b/power-management.txt @@ -43,6 +43,28 @@ According to [ArchWiki](https://wiki.archlinux.org/title/Solid_state_drive) ALPM - [Ubuntu](https://wiki.ubuntu.com/Kernel/PowerManagement/PowerSavingTweaks) +# CPU frequency scaling + +https://wiki.archlinux.org/title/CPU_frequency_scaling + +`schedutil` was used on my UX303. This is because of the cpu scaling driver being set to `intel_cpufreq`. +```cat /sys/devices/system/cpu/cpu*/cpufreq/scaling_driver``` + +It seems reasonable to asume that the hardware backed intel pstate scaling would do a better job. + +How to change it to pstate: https://askubuntu.com/a/1184512 + +Benchmarks: https://www.phoronix.com/review/linux50-pstate-cpufreq/6 + +Some people seem to really dislike [shedutil](https://www.phoronix.com/forums/forum/software/general-linux-open-source/1486834-experimental-schedutil-patches-yield-30-boost-to-web-browser-benchmark-on-linux?p=1486848#post1486848). +Some people seem to reallt dislike [intel pstate](https://www.phoronix.com/forums/forum/hardware/processors-memory/1173150-initial-benchmarks-of-schedutil-performance-on-linux-5-7-show-room-still-for-improvement?p=1214010#post1214010). + +https://www.phoronix.com/review/xeon-linux57-schedutil/7 +https://www.phoronix.com/review/amd-linux511-perfgov/2 + +I think I found [the reason](https://www.reddit.com/r/linux/comments/ihdozd/linux_kernel_58_defaults_to_passive_mode_for/) but I am not sure if it is valid: +https://www.phoronix.com/news/P-State-Passive-Def-For-No-HWP + # TODO - [Investigate hiberation](https://wiki.archlinux.org/title/Power_management/Suspend_and_hibernate)