Skip to content

Commit

Permalink
fixes
Browse files Browse the repository at this point in the history
  • Loading branch information
NVolcz committed Sep 18, 2024
1 parent a7b5da7 commit 6e3961d
Show file tree
Hide file tree
Showing 12 changed files with 300 additions and 46 deletions.
10 changes: 9 additions & 1 deletion config/bashrc
Original file line number Diff line number Diff line change
Expand Up @@ -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}'"
Expand Down Expand Up @@ -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))"
Expand Down Expand Up @@ -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"

142 changes: 142 additions & 0 deletions config/bics-plugins/analysis.bash
Original file line number Diff line number Diff line change
@@ -0,0 +1,142 @@
# analysis
#
# Various tools for text extraction, representation, and analysis
#
# Author: Dave Eddy <[email protected]>
# 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 }"
}
5 changes: 4 additions & 1 deletion config/config/Code/User/settings.json
Original file line number Diff line number Diff line change
Expand Up @@ -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
}
27 changes: 13 additions & 14 deletions config/config/dconf/user.txt
Original file line number Diff line number Diff line change
@@ -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=['']
Expand All @@ -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

40 changes: 28 additions & 12 deletions config/config/git/config
Original file line number Diff line number Diff line change
@@ -1,15 +1,17 @@
[user]
name = NVolcz
email = [email protected]
name = NVolcz
email = [email protected]

[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
Expand All @@ -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
5 changes: 4 additions & 1 deletion hacks.md
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down
7 changes: 7 additions & 0 deletions installs/firefox-addons.sh
Original file line number Diff line number Diff line change
Expand Up @@ -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.
46 changes: 46 additions & 0 deletions installs/gcm.sh
Original file line number Diff line number Diff line change
@@ -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
6 changes: 0 additions & 6 deletions installs/terraform.sh

This file was deleted.

11 changes: 0 additions & 11 deletions installs/vscode.sh
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down
Loading

0 comments on commit 6e3961d

Please sign in to comment.