Skip to content

Instantly share code, notes, and snippets.

View Koriit's full-sized avatar

Aleksander Stelmaczonek Koriit

View GitHub Profile
@Koriit
Koriit / install-toolbox.sh
Created July 11, 2022 18:53 — forked from greeflas/install-toolbox.sh
JetBrains Toolbox installation script for Ubuntu - https://www.jetbrains.com/toolbox/app/
#!/bin/bash
set -e
if [ -d ~/.local/share/JetBrains/Toolbox ]; then
echo "JetBrains Toolbox is already installed!"
exit 0
fi
echo "Start installation..."
/*
Credits:
https://productforums.google.com/forum/#!topic/docs/w4MXeqJaefU
http://webapps.stackexchange.com/questions/23861/header-numbering-in-google-docs
Instructions to use:
In a Google Doc
@Koriit
Koriit / OffsetDateTimeMatcher.java
Last active May 7, 2022 18:45
Hamcrest matcher for OffsetDateTime
import org.hamcrest.Description;
import org.hamcrest.TypeSafeMatcher;
import java.time.OffsetDateTime;
import java.time.format.DateTimeParseException;
import static java.time.format.DateTimeFormatter.ISO_OFFSET_DATE_TIME;
/**
* Matcher to validate date-time strings. Can also be used as equals matcher for offset date-time.
From https://nipafx.dev/junit-5-architecture-jupiter#api-lifecycle
Internal: Must not be used by any external code. Might be removed without prior notice.
Deprecated: Should no longer be used, might disappear in the next minor release.
Experimental: Intended for new, experimental features where the publisher of the API is looking for feedback. Use with caution. Might be promoted to Maintained or Stable in the future, but might also be removed without prior notice.
Maintained: Intended for features that will not be changed in a backwards-incompatible way for at least the next minor release of the current major version. If scheduled for removal, such a feature will be demoted to Deprecated first.
Stable: Intended for features that will not be changed in a backwards-incompatible way in the current major version.
Java
https://github.com/apiguardian-team/apiguardian
CA
openssl genrsa -aes256 -out rootCA.key 4096
openssl req -x509 -new -nodes -key rootCA.key -sha256 -days 3650 -out rootCA.crt
truststore.jks
keytool -keystore truststore.jks -alias rootca -import -file rootCA.crt
openssl signing
openssl genrsa -aes256 -out server.key 2048
openssl req -new -key server.key -out server.csr
git filter-branch -f --env-filter "GIT_AUTHOR_NAME='To Name'; GIT_AUTHOR_EMAIL='to@email.com'; GIT_COMMITTER_NAME='To Name'; GIT_COMMITTER_EMAIL='to@email.com';" HEAD;
@Koriit
Koriit / significant_round.kt
Created January 26, 2020 19:49
Round decimal to n significant places
infix fun Double.roundToSig(places: Int): Double {
val order = log10(this).roundToInt() + 1
val shift = 10.0.pow(places - order)
return round(this * shift) / shift
}
fun testRoundToSig() {
assert(12.9.roundToSig(2).toString() == "13.0")
#!/bin/sh
# Close container on SIGTERM
# It's a bit hacky but here is the thing
onSIGTERM(){
# Now pass SIGTERM to application
kill -15 $applicationPid
# And wait for it to gracefully close
wait $applicationPid
# Now we can close this script and also the running container since this script would be run with PID 1
if(!doc['tags.keyword'].empty && doc['tags.keyword'].contains("parallel_gc")) {
return doc['duration'].value * 1000
}
@Koriit
Koriit / to_camel_case.jq
Created February 8, 2019 13:47
To camel case function for JQ
def to_camel_case: . | ascii_downcase | split("_") | .[0:1] as $first | .[1:] | map(.[1:] as $rest | .[0:1] | ascii_upcase | . + $rest) | $first + . | join("");