Skip to content

Latest commit

 

History

History
212 lines (162 loc) · 6.47 KB

Hints&Tricks.md

File metadata and controls

212 lines (162 loc) · 6.47 KB

Hints and tricks

Generating Certificates

openssl req -new -newkey rsa:4096 -nodes -keyout yourfinance.key -out yourfinance.csr
openssl x509 -req -sha256 -days 365 -in yourfinance.csr -signkey yourfinance.key -out yourfinance.pem

NodeJS Update NPM Update

npm audit fix
npm install npm@latest -g
npm update -g
npm install npm@latest -g
npm update -g
npm install -g npm-check-updates
ncu -u
npm update
npm update --legacy-peer-deps
yarn install

Node JS installation via NVM

curl -o- https://raw.githubusercontent.com/nvm-sh/nvm/v0.39.0/install.sh | bash
export NVM_DIR="$HOME/.nvm"
[ -s "$NVM_DIR/nvm.sh" ] && \. "$NVM_DIR/nvm.sh" c
nvm install 16.13.0

HOME is your home directory. This may change according to the system you are running this script in.

Java installation via SDKMAN!

  • Install java versions with SDKMan for MAC-OS and Linux based systems
curl -s "https://get.sdkman.io" | bash
source "$HOME/.sdkman/bin/sdkman-init.sh"
sdk install java 8.0.242.hs-adpt
sdk install java 11.0.6.hs-adpt
sdk install java 12.0.2.hs-adpt
sdk install java 13.0.2.hs-adpt
sdk install java 14.0.0.hs-adpt
sdk install java 16.0.1.hs-adpt
sdk install java 17-open
sdk install java 19.0.2-open
sdk install java 20.0.1-open

Java installation via APT

apt-get -y update
apt-get -y upgrade
apt -y install apt-transport-https ca-certificates wget dirmngr gnupg software-properties-common
wget -qO - https://adoptopenjdk.jfrog.io/adoptopenjdk/api/gpg/key/public | apt-key add -
add-apt-repository --yes https://adoptopenjdk.jfrog.io/adoptopenjdk/deb/
apt -y update
sudo apt -y install openjdk-11-jdk
sudo apt install openjdk-13-jdk
sudo apt -y install adoptopenjdk-8-hotspot
sudo apt -y autoremove

Aliases to switch version

General aliases

  • .bashrc file to get GitPrompt, SDKMAN and some handy aliases in a Windows environment with MinGW or just in a MAC-OS environment.
alias jdk8="sdk use java 8.0.242.hs-adpt"
alias jdk11="sdk use java 11.0.6.hs-adpt"
alias jdk12="sdk use java 12.0.2.hs-adpt"
alias jdk13="sdk use java 13.0.2.hs-adpt"
alias jdk14="sdk use java 14.0.0.hs-adpt"
alias jdk16="sdk use java 16.0.1.hs-adpt"
alias jdk17="sdk use java 17-open"
alias jdk19="sdk use java 19.0.2-open"
alias node16='export NVM_DIR="$HOME/.nvm" && [ -s "$NVM_DIR/nvm.sh" ] && \. "$NVM_DIR/nvm.sh" c && nvm install 16.13.0 && nvm use 16.13.0'
alias m2enable="mv ~/.m2/settings.backup ~/.m2/settings.xml"
alias m2disable="mv ~/.m2/settings.xml ~/.m2/settings.backup"
if [ -f "/root/.bash-git-prompt/gitprompt.sh" ]; then
    GIT_PROMPT_ONLY_IN_REPO=1
    source /root/.bash-git-prompt/gitprompt.sh
fi

alias java8="export JAVA_HOME=/usr/lib/jvm/adoptopenjdk-8-hotspot-amd64 && update-java-alternatives -s adoptopenjdk-8-hotspot-amd64"
alias java11="export JAVA_HOME=/usr/lib/jvm/java-1.11.0-openjdk-amd64 && update-java-alternatives -s java-1.11.0-openjdk-amd64"
alias java12="echo \"Java 12 is not available. Setting up 13\" && export JAVA_HOME=/usr/lib/jvm/java-13-oracle && update-java-alternatives -s java-13-oracle"
alias java13="export JAVA_HOME=/usr/lib/jvm/java-13-oracle && update-java-alternatives -s java-13-oracle"
alias m2disable="rm ~/.m2/settings.xml"
alias m2enable="cp /your_repo_folder/settings.xml ~/.m2/"

Git tag change

git tag new-tag old-tag
git tag -d old-tag
git push origin :refs/tags/old-tag
git push --tags
git pull --prune --tags

Setting up OpenShift alt text

  • Open an account

  • Setup OKD (Original Community Distribution of Kubernetes)

Install Minishift

brew cask install minishift
brew cask install --force minishift
minishift addons install --defaults
minishift addons enable admin-user
minishift start --vm-driver=virtualbox
brew install openshift-cli
oc adm policy --as system:admin add-cluster-role-to-user cluster-admin developer
minishift console
oc create rolebinding default-view --clusterrole=view --serviceaccount=mancalaje:default --namespace=mancalaje

Git tag datetime listing

git for-each-ref --format="%(refname:short) | %(creatordate)" "refs/tags/*"
curl -L "http://coolsite.com" | pbcopy

Upgrade YARN

curl --compressed -o- -L https://yarnpkg.com/install.sh | bash

Remove Docker-machine

NOTE: This process will remove old docker-machine installations. User Docker-Desktop instead.

brew uninstall docker-machine-driver-vmware
brew uninstall --force docker-machine
docker system prune -a

Git History Email Change

git filter-branch --env-filter '
WRONG_EMAIL="<old-mail>"
NEW_NAME="Joao Esperancinha"
NEW_EMAIL="<new-mail>

if [ "$GIT_COMMITTER_EMAIL" = "$WRONG_EMAIL" ]
then
    export GIT_COMMITTER_NAME="$NEW_NAME"
    export GIT_COMMITTER_EMAIL="$NEW_EMAIL"
fi
if [ "$GIT_AUTHOR_EMAIL" = "$WRONG_EMAIL" ]
then
    export GIT_AUTHOR_NAME="$NEW_NAME"
    export GIT_AUTHOR_EMAIL="$NEW_EMAIL"
fi
' --tag-name-filter cat -- --branches --tags

Maven

mvn io.spring.javaformat:spring-javaformat-maven-plugin:0.0.27:apply

Find something in files

grep -R --include="*.xml" "springdoc" .

References