Pular para o conteúdo principal

Snippets Intro

· Leitura de um minuto

In this section, I'll be sharing code snippets that I use as templates for solving future problems.
Previously, this content was on my Wordpress until May 10th, 2024. I'm moving it here, but there might be some formatting issues due to the transfer. These will be addressed promptly!

Note: To make this movement, I used this tool: https://github.com/lonekorean/wordpress-export-to-markdown

Publishing a jar to private maven repository

· Leitura de um minuto

Example 1- Publishing to AWS

  1. setup maven settings xml file
<settings>
<servers>
<server>
<id>codeartifact</id>
<username>aws</username>
<password>${env.CODEARTIFACT_AUTH_TOKEN}</password>
</server>
</servers>
</settings>
  1. publish with mvn
mvn deploy:deploy-file -DgroupId=commons-cli          \
-DartifactId=commons-cli \
-Dversion=1.4 \
-Dfile=./commons-cli-1.4.jar \
-Dpackaging=jar \
-DrepositoryId=codeartifact \
-Durl=https://my_domain-111122223333.d.codeartifact.region.amazonaws.com/maven/repo-name/

References

  1. https://docs.aws.amazon.com/codeartifact/latest/ug/maven-mvn.html#publishing-third-party-artifacts

Fixing DNS Erros in WSL

· Leitura de um minuto

Create a %USERPROFILE%\.wslconfig file with the following contents:

[experimental]
autoMemoryReclaim=gradual
networkingMode=mirrored
dnsTunneling=true
firewall=true
autoProxy=true

Reference

  1. https://askubuntu.com/a/1512056

Fixing pacman corrupted signature (PGP) when executing an update

· Leitura de um minuto

When an error like following occurs...

File /var/cache/pacman/pkg/rhash-1.4.4-1-x86_64.pkg.tar.zst is corrupted (invalid or corrupted package (PGP signature)).

Just execute the following command

sudo pacman -S archlinux-keyring

Fixing python based applications SSL Errors

· Leitura de um minuto

When running python based apps in ArchLinux which returns errors like following:

http: error: SSLError: HTTPSConnectionPool(host='api.ipify.org', port=443): Max retries exceeded with url: /?format=json (Caused by SSLError(SSLCertVerificationError(1, '[SSL: CERTIFICATE_VERIFY_FAILED] certificate verify failed: unable to get local issuer certificate (_ssl.c:1000)'))) while doing a GET request to URL: https://api.ipify.org/?format=json

Just run...

yay -S python-pip-system-certs --noconfirm

Generating temporary credentials with cloud shell

· Leitura de um minuto
# install jq
sudo yum install jq -y# curl paste the result /tmp/credentials (raw credential json)
curl -H "Authorization: $AWS_CONTAINER_AUTHORIZATION_TOKEN" $AWS_CONTAINER_CREDENTIALS_FULL_URI 2>/dev/null > /tmp/credentials# parse the result json
ACCESS_KEY=`cat /tmp/credentials| jq -r .AccessKeyId`
SECRET_KEY=`cat /tmp/credentials| jq -r .SecretAccessKey`
SESSION_TOKEN=`cat /tmp/credentials| jq -r .Token`# show the result with "export" style
echo -ne "\nThis is ${ROLE_NAME} temporary credential.\nPaste them in your shell! \n\nexport AWS_ACCESS_KEY_ID=${ACCESS_KEY};\nexport AWS_SECRET_ACCESS_KEY=${SECRET_KEY};\nexport AWS_SESSION_TOKEN=${SESSION_TOKEN};\n\n"

Removing dangling namespace from Kubernetes (Status: Terminating)

· Leitura de um minuto

Credits are not mine. Please follow this post in StackOverflow: https://stackoverflow.com/a/53661717

Author: https://stackoverflow.com/users/86967/brent-bradburn

requirements:

  • kubectl
  • jq
(
NAMESPACE=my-dangling-ns
kubectl proxy &
kubectl get namespace $NAMESPACE -o json |jq '.spec = {"finalizers":[]}' >temp.json
curl -k -H "Content-Type: application/json" -X PUT --data-binary @temp.json 127.0.0.1:8001/api/v1/namespaces/$NAMESPACE/finalize
)