Skip to content

Instantly share code, notes, and snippets.

@sgrimm
sgrimm / Test.kt
Last active December 8, 2023 16:46
Two attempts to use IntelliJ's AI assistant to write a test case
// Attempt 1: Just the function name as the prompt. Totally wrong approach, plus neither of
// the reportStore methods exists, plus reportStore is a dependency anyway, not
// the class under test.
//
// fun `deletes unsubmitted project-level reports when project is deleted`() {
// val projectReports = reportStore.findReportsByProjectId(projectId)
// projectReports.forEach { report ->
// if (!report.isSubmitted) {
// reportStore.deleteReport(report.reportId)
// }
@sgrimm
sgrimm / JobRunrJsonMapper.kt
Created May 12, 2022 07:49
Quick-and-dirty proof of concept for overriding JobRunr JSON mapper visibility settings
package com.example
import com.fasterxml.jackson.databind.ObjectMapper
import com.fasterxml.jackson.databind.introspect.AnnotatedField
import com.fasterxml.jackson.databind.introspect.AnnotatedMember
import com.fasterxml.jackson.databind.introspect.AnnotatedMethod
import com.fasterxml.jackson.databind.introspect.VisibilityChecker
import java.lang.reflect.Field
import java.lang.reflect.Member
import java.lang.reflect.Method
@sgrimm
sgrimm / trim-branches.sh
Created October 13, 2021 18:53
Script to remove local PR branches after the PRs have been squash merged
#!/bin/bash
#
# Removes local branches whose contents have already been merged into main.
#
set -eo pipefail
say() {
echo ===
echo === "$@"
echo ===
@sgrimm
sgrimm / GapAwareTrackingTokenConverter.kt
Last active December 20, 2019 15:25
Compact-format XStream converters for Axon 4 tracking tokens
package com.thesegovia.payment.serial
import com.thoughtworks.xstream.converters.Converter
import com.thoughtworks.xstream.converters.MarshallingContext
import com.thoughtworks.xstream.converters.UnmarshallingContext
import com.thoughtworks.xstream.io.HierarchicalStreamReader
import com.thoughtworks.xstream.io.HierarchicalStreamWriter
import org.axonframework.eventhandling.GapAwareTrackingToken
/**