Compare commits

..

No commits in common. "466f93e0732ccee421238fe584770df612fae131" and "b8aef151f2f78565cf3ebe74682ac536b5b65721" have entirely different histories.

3 changed files with 46 additions and 54 deletions

View File

@ -1,21 +0,0 @@
#!/bin/bash
cidr2mask() {
local i mask=""
local full_octets=$(($1 / 8))
local partial_octet=$(($1 % 8))
for ((i = 0; i < 4; i += 1)); do
if [ $i -lt $full_octets ]; then
mask+=255
elif [ $i -eq $full_octets ]; then
mask+=$((256 - 2 ** (8 - partial_octet)))
else
mask+=0
fi
test $i -lt 3 && mask+=.
done
echo $mask
}
cidr2mask "$@"

View File

@ -1,20 +0,0 @@
#!/bin/bash
mask2cidr() {
local mask=$1
# In RFC 4632 netmasks there's no "255." after a non-255 byte in the mask
local left_stripped_mask=${mask##*255.}
local len_mask=${#mask}
local len_left_stripped_mask=${#left_stripped_mask}
local conversion_table=0^^^128^192^224^240^248^252^254^
local number_of_bits_stripped=$(((len_mask - len_left_stripped_mask) * 2))
local signifacant_octet=${left_stripped_mask%%.*}
local right_stripped_conversion_table=${conversion_table%%$signifacant_octet*}
local len_right_stripped_conversion_table=${#right_stripped_conversion_table}
local number_of_bits_from_conversion_table=$((len_right_stripped_conversion_table / 4))
echo $((number_of_bits_stripped + number_of_bits_from_conversion_table))
}
mask2cidr "$@"

59
.zshrc
View File

@ -16,6 +16,43 @@ gbranch() {
echo -e "$(git branch "$@")" echo -e "$(git branch "$@")"
} }
mask2cidr() {
local mask=$1
# In RFC 4632 netmasks there's no "255." after a non-255 byte in the mask
local left_stripped_mask=${mask##*255.}
local len_mask=${#mask}
local len_left_stripped_mask=${#left_stripped_mask}
local conversion_table=0^^^128^192^224^240^248^252^254^
local number_of_bits_stripped=$((($len_mask - $len_left_stripped_mask) * 2))
local signifacant_octet=${left_stripped_mask%%.*}
local right_stripped_conversion_table=${conversion_table%%$signifacant_octet*}
local len_right_stripped_conversion_table=${#right_stripped_conversion_table}
local number_of_bits_from_conversion_table=$((len_right_stripped_conversion_table / 4))
echo $(($number_of_bits_stripped + $number_of_bits_from_conversion_table))
}
cidr2mask() {
local i mask=""
local full_octets=$(($1 / 8))
local partial_octet=$(($1 % 8))
for ((i = 0; i < 4; i += 1)); do
if [ $i -lt $full_octets ]; then
mask+=255
elif [ $i -eq $full_octets ]; then
mask+=$((256 - 2 ** (8 - $partial_octet)))
else
mask+=0
fi
test $i -lt 3 && mask+=.
done
echo $mask
}
[ -f /etc/gentoo-release ] && export ZSH="/usr/share/zsh/site-contrib/oh-my-zsh" [ -f /etc/gentoo-release ] && export ZSH="/usr/share/zsh/site-contrib/oh-my-zsh"
[ -f /etc/centos-release ] && export ZSH="$HOME/.oh-my-zsh" [ -f /etc/centos-release ] && export ZSH="$HOME/.oh-my-zsh"
[ -f /etc/debian_version ] && export ZSH="$HOME/.oh-my-zsh" [ -f /etc/debian_version ] && export ZSH="$HOME/.oh-my-zsh"
@ -93,12 +130,10 @@ fi
alias ansible-lint-work='GIT_SSH_COMMAND="ssh -i ~/.ssh/work/id_rsa" ansible-lint' alias ansible-lint-work='GIT_SSH_COMMAND="ssh -i ~/.ssh/work/id_rsa" ansible-lint'
alias ansible-galaxy-work='GIT_SSH_COMMAND="ssh -i ~/.ssh/work/id_rsa" ansible-galaxy' alias ansible-galaxy-work='GIT_SSH_COMMAND="ssh -i ~/.ssh/work/id_rsa" ansible-galaxy'
alias ssh-work="ssh -i ~/.ssh/work/id_rsa" alias ssh-work="ssh -i ~/.ssh/work/id_rsa"
alias gwork='GIT_SSH_COMMAND="ssh -i ~/.ssh/work/id_rsa" git'
alias rsyncwork="rsync -h --progress -e 'ssh -i ~/.ssh/work/id_rsa'" alias rsyncwork="rsync -h --progress -e 'ssh -i ~/.ssh/work/id_rsa'"
alias git-work='GIT_SSH_COMMAND="ssh -i ~/.ssh/work/id_rsa" git'
alias gwork=git-work
alias gitwork=gwork
alias gcommitw="git commit --author='Marcin Woźniak <marcin.wozniak@wundermanthompson.com>'" alias gcommitw="git commit --author='Marcin Woźniak <marcin.wozniak@wundermanthompson.com>'"
alias git-commit-work=gcommitw alias gitwork=gwork
alias gitcommitwork=gcommitw alias gitcommitwork=gcommitw
alias gitworkcommit=gcommitw alias gitworkcommit=gcommitw
@ -175,6 +210,9 @@ if [[ "$(uname)" == "Darwin" ]]; then
sort | sort |
tail -n1) tail -n1)
export PATH=$PATH:/opt/homebrew/Cellar/tfenv/$TFENVVERSION/versions/$TFVERSION/ export PATH=$PATH:/opt/homebrew/Cellar/tfenv/$TFENVVERSION/versions/$TFVERSION/
# Project
alias meraki="cd $HOME/git/ansible_collections/cisco/meraki/"
fi fi
# Setting the right editor # Setting the right editor
@ -208,8 +246,7 @@ alias myip="curl ipinfo.io/ip"
alias changefont="figlet" alias changefont="figlet"
# Git # Git
alias git-exclude="git update-index --assume-unchanged" alias gexclude="git update-index --assume-unchanged"
alias gexclude=git-exclude
alias gmaster="git checkout master; git checkout main" alias gmaster="git checkout master; git checkout main"
alias gmain="git checkout master; git checkout main" alias gmain="git checkout master; git checkout main"
alias gcommit="git commit --author='Marcin Woźniak <y0rune@aol.com>' -s" alias gcommit="git commit --author='Marcin Woźniak <y0rune@aol.com>' -s"
@ -222,19 +259,15 @@ alias gch="git checkout"
alias gst="git status -s" alias gst="git status -s"
alias gdiff="git --no-pager diff" alias gdiff="git --no-pager diff"
alias glog="git log --color --graph --pretty=format:'%Cred%h%Creset -%C(yellow)%d%Creset %s %Cgreen(%cr) %C(bold blue)<%an - %ae>%Creset' --abbrev-commit --branches" alias glog="git log --color --graph --pretty=format:'%Cred%h%Creset -%C(yellow)%d%Creset %s %Cgreen(%cr) %C(bold blue)<%an - %ae>%Creset' --abbrev-commit --branches"
alias git-show="git --no-pager show --color --pretty=format:%b" alias gshow="git --no-pager show --color --pretty=format:%b"
alias gshow=git-show alias gd=gshow
alias gd=git-show alias guntrackfile="git update-index --assume-unchanged"
alias git-untrack-file="git update-index --assume-unchanged"
alias guntrackfile=git-untrack-file
# Others # Others
alias channel-check='sudo iwlist wlan0 scan | egrep -i "essid|frequency"' alias channel-check='sudo iwlist wlan0 scan | egrep -i "essid|frequency"'
alias newswork="newsboat --url=$HOME/.config/newsboat/urlswork" alias newswork="newsboat --url=$HOME/.config/newsboat/urlswork"
alias aria2c="aria2c --seed-time=0 --disable-ipv6 --max-upload-limit=1k" alias aria2c="aria2c --seed-time=0 --disable-ipv6 --max-upload-limit=1k"
alias irc="ssh mikrus -t 'screen -r'" alias irc="ssh mikrus -t 'screen -r'"
# GoLang
alias go-mod="go mod edit -go $(go version | grep -oE 'go[0-9]*\.[0-9]*\.[0-9]*' | sed 's/go//g'); go get -u; go mod verify; go get -x -v; go mod verify; go mod tidy" alias go-mod="go mod edit -go $(go version | grep -oE 'go[0-9]*\.[0-9]*\.[0-9]*' | sed 's/go//g'); go get -u; go mod verify; go get -x -v; go mod verify; go mod tidy"
# Resolve problem with - zsh: no matches found # Resolve problem with - zsh: no matches found