Skip to content

Instantly share code, notes, and snippets.

View OndraZizka's full-sized avatar
🫖

Ondrej Zizka OndraZizka

🫖
View GitHub Profile
@OndraZizka
OndraZizka / maven-latest-plugins.pom.xml
Created April 17, 2025 21:29
Maven latest plugins - basic set for pluginManagement
<pluginManagement>
<plugins>
<!-- Last updated 2025-04-17 -->
<plugin><groupId>org.jetbrains.kotlin</groupId><artifactId>kotlin-maven-plugin</artifactId><version>${kotlin.version}</version></plugin>
<plugin><groupId>io.fabric8</groupId><artifactId>docker-maven-plugin</artifactId><version>0.46.0</version></plugin>
<plugin><groupId>io.quarkus.platform</groupId><artifactId>quarkus-maven-plugin</artifactId><version>${quarkus.platform.version}</version><extensions>true</extensions></plugin>
<plugin><artifactId>maven-enforcer-plugin</artifactId><version>3.5.0</version></plugin>
<plugin><artifactId>maven-clean-plugin</artifactId><version>3.4.1</version></plugin>
<plugin><artifactId>maven-dependency-plugin</artifactId><version>3.8.1</version></plugin>
<plugin><artifactId>maven-compiler-plugin</artifactId><version>3.14.0</version></plugin>
@OndraZizka
OndraZizka / Maven-super-short-intro.md
Last active April 16, 2025 09:16
Maven super-short intro.

Maven super-short intro.

Note

Maven is declarative, not procedural. By default it is in XML, but you can write it in other languages.* We will use YAML.

 

Tip

Maven works on a principle of a “tree of trees” of build configuration overlaid over each other, which then create an effective tree - so called POM (project object model).

@OndraZizka
OndraZizka / Flyway-docker-image-usage.txt
Created April 10, 2025 00:51
Flyway Docker image usage
[flyway/flyway:latest] "flyway": Start container 980e2f7f4081
: Usage
: flyway [options] [command]
: flyway help [command]
:
: By default, the configuration will be read from conf/flyway.conf.
: Options passed from the command-line override the configuration.
:
: Commands
: help Print this usage info and exit
@OndraZizka
OndraZizka / Steam-proton-setting.md
Created April 9, 2025 18:20
Steam - custom setting for games to work on Linux
PROTON_USE_WINED3D=1 %command%
@OndraZizka
OndraZizka / StackBasedContext.kt
Created October 10, 2023 21:44
A Stack-based Processing Context for Kotlin
class StackBasedContext(
val nestingStack: Deque<NestingLevel> = ArrayDeque(),
val problems: MutableList<Pair<String, List<NestingLevel>>> = mutableListOf(),
) {
override fun toString() = nestingStack.ifEmpty { listOf("(root)") }.joinToString("/")
fun addProblem(msg: String) { problems.add(msg to nestingStack.descendingIterator().asSequence().toList()) }
fun pushLevel(dataParam: KParameter): PopOnClose { nestingStack.push(NestingLevel(dataParam)); return PopOnClose() }
fun pushLevel(collectionIndex: Int): PopOnClose { nestingStack.push(NestingLevel(collectionIndex = collectionIndex)); return PopOnClose() }
@OndraZizka
OndraZizka / ResourceUtils.kt
Created September 1, 2023 21:45
Kotlin - utilities for loading resources from the classpath.
import java.io.FileNotFoundException
import java.io.InputStream
import java.nio.file.Path
object ResourceUtils {
fun getCallingClassName(): String? {
var testUtilsSpotted = false;
for (stackItem in Thread.currentThread().stackTrace) {
if (stackItem.className == ResourceUtils::class.java.name) {
@OndraZizka
OndraZizka / startup.md
Created April 15, 2023 21:54 — forked from dsyer/startup.md
Notes on Spring Boot startup performance

Anatomy of Spring Boot Start Up Timing

When a Spring Boot app starts up with default (INFO) logging, there are some noticeable gaps (pauses). It's worth focusing on the gaps when looking for efficiency savings because of the amount of time they take, and because no-one bothered to log anything, so the chances are the app is doing something repetitive. We can tweak the logging levels to try and fill in the gaps and find out what is going on in there.

Basic empty web app with actuators has three such gaps:

0                                                                        1410ms
|------|---------------------------|-----|------|---------|--------|--------|
       |           578             |     |144(5)|         | 133(6) |
@OndraZizka
OndraZizka / fetchAllGitRepos.sh
Last active April 18, 2023 19:07
Fetch all Git repos in subdirectories
#!/bin/bash
## Run this in a directory to fetch all Git repos within it.
find -name .git | sed 's#.git##' | sort | xargs -t -n1 -I % git -C % fetch --all
## CRON job: You can also put this into `crontab -e` in order to keep all repos up-to-date automatically:
# # m h DoM mth DoW command
# */5 * * * * find /home/ondra/work -name .git | sed 's#.git##' | sort | xargs -t -n1 -I % git -C % fetch --all --tags --force
@OndraZizka
OndraZizka / enumCliOptionParsing.kt
Created November 27, 2022 00:23
Kotlin: Parsing CLI options easily using ENUMs
private inline fun <reified T : OptionEnum> tryParseEnumOption(enumArgumentDefault: T, arg: String): T? {
val optionIntro = "--${enumArgumentDefault.optionName}"
if (!arg.startsWith(optionIntro))
return null
if (arg == optionIntro || arg == optionIntro + "=" + enumArgumentDefault.optionValue)
return enumArgumentDefault
val valueStr = arg.substringAfter(optionIntro).removePrefix("=")
@OndraZizka
OndraZizka / Slf4jLazy.kt
Last active February 22, 2024 11:28
Kotlin SLF4J log message lazy evaluation based on log level
/*
Lazy evaluation of the messages sent to Slf4j.
Usage:
log.trace { "State dump: " + expensiveLongSerialisation(state) }
See also https://jira.qos.ch/browse/SLF4J-371
*/
import org.slf4j.Logger
import org.slf4j.LoggerFactory
import kotlin.reflect.KClass