Skip to content

Instantly share code, notes, and snippets.

# Here are some JVM args that are extremely useful in production when things go wrong
-XX:+G1SummarizeRSetStats
-XX:G1SummarizeRSetStatsPeriod=10
-XX:+PrintAdaptiveSizePolicy
-XX:+PrintJNIGCStalls
-XX:+PrintReferenceGC
-XX:+PrintGCCause
-XX:+PrintGCDateStamps
-XX:+PrintGCTimeStamps
-XX:+PrintGCDetails
@findepi
findepi / Directions for creating PEM files
Created September 26, 2018 20:06 — forked from dain/Directions for creating PEM files
Create Java KeyStore from standard PEM encoded private key and certificate chain files
# To regenerate the test key and certificates
# Generate an RSA private key and convert it to PKCS8 wraped in PEM
openssl genrsa 2048 | openssl pkcs8 -topk8 -inform pem -outform pem -nocrypt -out rsa.key
# Generate a certificate signing request with the private key
openssl req -new -key rsa.key -out rsa.csr
# Sign request with private key
openssl x509 -req -days 10000 -in rsa.csr -signkey rsa.key -out rsa.crt
@findepi
findepi / client-certificate-authentication.md
Created October 29, 2018 11:50 — forked from jankronquist/client-certificate-authentication.md
Java certificate authentication for both server and client using shared trusted CA.

Certificates

CA and trust keystore

keytool -genkeypair -keyalg RSA -keysize 2048 -validity 365 -alias ca -dname "CN=ca,O=HMS,S=SE" -keystore ca.jks -storepass password
keytool -exportcert -rfc -alias ca -keystore ca.jks -storepass password > ca.pem
cat ca.pem | keytool -importcert -alias ca -noprompt -keystore trust.jks -storepass password

server cert

  1. Intellij Preferences > Live Templates > group other
  2. Add a new one with
    • abbreviation rnn
    • Description requireNonNull
    • Template text java.util.Objects.requireNonNull($var$, "$var$ is null")
    • Applicable contexts: Java > Expression
    • check use static imports if possible
  • Edit variables button and there add var variable with variableOfType("Object") expression
@findepi
findepi / maven-release.md
Last active January 4, 2023 14:06
Standard maven release process
mvn clean release:clean && mvn release:prepare
# `env GPG_TTY=$(tty)` may help with some sort of GPG problems
mvn release:perform

full build, like mvn install

# See knownSparkVersions in gradle.properties for current list Spark versions
./gradlew -DsparkVersions=2.4,3.0,3.1,3.2,3.3 -x test -x integrationTest build publishToMavenLocal

# ... or pull the list automatically
./gradlew -DsparkVersions=$(sed -n 's/^systemProp.knownSparkVersions=//p' gradle.properties) \
    -x test -x integrationTest build publishToMavenLocal
@findepi
findepi / Dockerfile
Last active March 14, 2024 10:04
Retrieved GitHub secrets securely
# store as docky/Dockerfile to match references in the other script
FROM ubuntu:latest
RUN true && \
export DEBIAN_FRONTEND=noninteractive && \
apt-get update && \
apt-get install -y openssl && \
apt-get clean && \
echo OK