Skip to content

Instantly share code, notes, and snippets.

@stephankoelle
stephankoelle / pom.markdown
Last active June 17, 2025 09:38
Enhance Maven Build Quality: Auto Version Updates, License Validation, CVE Checks & Formatting

Add this to your maven build plugin:

  • Check to have only permissive OSS licenses
  • Check for CVEs: ./mvnw clean org.sonatype.ossindex.maven:ossindex-maven-plugin:audit
  • Update dependency version: ./mvnw versions:update-properties; ./mvnw versions:use-latest-versions
  • Install the pre-commit hook to automtically run: ./mvnw spotless:apply
<plugin>
	<groupId>org.honton.chas</groupId>
@stephankoelle
stephankoelle / snippet.txt
Created June 17, 2025 09:39
scan for leaked secrets / credentials in git using just a container
docker run -v $(pwd):/path ghcr.io/gitleaks/gitleaks:latest dir /path -r /path/report.json
@stephankoelle
stephankoelle / snippet.markdown
Last active August 9, 2025 12:27
Bootstrap quarkus app (with jabbaw & mvnw) from almost nothing
@stephankoelle
stephankoelle / extract.markdown
Created June 17, 2025 09:42
Perl One-Liner to Extract Data Using a Regular Expression

Extract top 1000 slowest requests for a access log file

cat /opt/epoq/wildfly/standalone/log/accesslog | grep -a getRec | perl -nle 'print "$1 $_" if m/ D(.*?) /;' | sort -n | tail -n 1000

This command is designed to:

Filter log entries related to getRec requests.
Extract specific numerical or timestamp-like data following the D character.

@stephankoelle
stephankoelle / intersect.sh
Created June 17, 2025 09:42
Find the sessionId (sessionId intersection) that visited a list of productIds
#!/bin/bash
set -e
file=/opt/epoq/wildfly/standalone/log/access*
for pid in 40683780 406837806 732586891 732586894 732586900 ; do
echo $file
cat $file | grep -a $pid | perl -nle 'print $1 if /sessionId=(.*?)&/;' > /tmp/mop/$pid.data
done
# List of files
@stephankoelle
stephankoelle / H2ServerStarter.java
Created June 17, 2025 09:43
Start h2 server in a quarkus app, to connect also from a SQL tool (for example intellij) to the dev database
import io.quarkus.runtime.ShutdownEvent;
import io.quarkus.runtime.StartupEvent;
import jakarta.inject.Inject;
import org.h2.tools.Server;
import jakarta.enterprise.context.ApplicationScoped;
import jakarta.enterprise.event.Observes;
import org.jboss.logging.Logger;
import java.sql.SQLException;
@stephankoelle
stephankoelle / Dockerfile
Created June 17, 2025 09:44
Build docker container with bitbucket pipelines & upload to private ecr repository
# Use Maven 3.9.X with Eclipse Temurin JDK 21 as the base image
#FROM docker.io/library/maven:3.9.9-eclipse-temurin-21
FROM public.ecr.aws/docker/library/maven:3.9.9-eclipse-temurin-21
# Set working directory
WORKDIR /app
# Environment variables (replace with actual values or set dynamically in pipeline)
ARG bitbucketpipelines_bootstrap
ARG bamboo_id_rsa
@stephankoelle
stephankoelle / manage_fleetlock.service
Created June 17, 2025 09:45
run fleetlock server only when someone can handle emergencies
#~/.config/systemd/user/manage_fleetlock.service
#journalctl --user -t manage_fleetlock
[Unit]
Description=Manage fleetlock service based on public holidays and work hours
[Service]
Type=oneshot
ExecStart=/usr/local/bin/manage_fleetlock.sh
@stephankoelle
stephankoelle / snippet.markdown
Created June 17, 2025 09:46
minimal caddy file with podlet & quadlet

caddyfile

Define both domains and obtain certificates

www.abc.com, abc.com {
    # Redirect www to the bare domain
    @www {
        host www.abc.com
    }
    redir @www https://abc.com{uri}
@stephankoelle
stephankoelle / snippet.yaml
Created June 17, 2025 09:47
Terraform for Hetzner Cloud Fedora CoreOS
# Alter:
# hcloud_server_type
# ssh_public_key_file
# ssh_private_key_file
# versions.tf
terraform {
required_providers {
hcloud = {