Skip to content

Instantly share code, notes, and snippets.

View agentgt's full-sized avatar

Adam Gent agentgt

View GitHub Profile
@agentgt
agentgt / debugoptions
Created March 11, 2024 15:24
Debug printing of annotation processing in Eclipse
org.eclipse.jdt.apt.core/debug=true
@agentgt
agentgt / eclipse_null_bugs.md
Last active August 18, 2023 20:15
Eclipse null analysis issues

Eclipse does not allow generic parameters on record attributes to be passed on to accessor methods.

public record Blah(List<String> strings) {}

public static void process(List<String> s) {}

var blah = new Blah(List.of("hello"));

process(blah.strings()); // null warning here because it does not know that strings is List&lt;@NonNull String&gt;
@agentgt
agentgt / Config.java
Last active February 12, 2023 15:18
Config.java
public interface Config extends Iterable<PropertyString> {
/*
* Required methods to implement
*/
public Config withPrefix(String prefix);
public Stream<PropertyString> stream();
@agentgt
agentgt / gist:97db11fadafed1579564b630138fc769
Created March 12, 2020 13:38
Using evolve for branching
hg init
echo Upstream1 > main.txt
hg add main.txt
hg commit -m "Master1"
hg branch -q feature
@agentgt
agentgt / ColumnPrism.java
Created May 14, 2019 14:57
Example of Hickory generating a prism for JPA column
import java.util.ArrayList;
import java.util.List;
import java.util.Map;
import javax.lang.model.element.AnnotationMirror;
import javax.lang.model.element.Element;
import javax.lang.model.element.VariableElement;
import javax.lang.model.element.AnnotationValue;
import javax.lang.model.type.TypeMirror;
import net.java.dev.hickory.prism.internal.*;
import java.util.HashMap;
@agentgt
agentgt / LoggerService.java
Last active March 17, 2017 15:49
A wrapper SLF4j to avoid default static initialization
package com.snaphop.slf4j;
import java.util.ServiceLoader;
import org.slf4j.ILoggerFactory;
import org.slf4j.Logger;
import org.slf4j.helpers.NOPLoggerFactory;
public interface LoggerService {
/*
* EXAMPLE USAGE. NOT TESTED THOUGH.
*/
public class Example {
public static void example() {
//do a double lock synchronization block if you are setting a singleton
PomManifest pm = null;
try {
@agentgt
agentgt / CustomJooqGeneratorStrategy.java
Created August 31, 2016 16:13
A Jooq generator that puts POJO in a public package and records in a private package
package com.snaphop.jooq;
import org.jooq.util.DefaultGeneratorStrategy;
import org.jooq.util.Definition;
public class CustomJooqGeneratorStrategy extends DefaultGeneratorStrategy {
@Override
public String getJavaClassName(Definition definition, Mode mode) {
/*
#!/usr/bin/env groovy
import groovy.xml.MarkupBuilder
def xml = new XmlSlurper().parse(new File(args[0]));
def sw = new StringWriter()
def b = new MarkupBuilder(sw)
def i = 0;
b.dependencyManagement() {
dependencies() {
@agentgt
agentgt / routine.rst
Last active March 17, 2017 16:50
Routine.rst

Adam's Lifting Routine

Overview, Theory, Philosophy

This routine is focused on efficiency, convenience, simple/affordable equipment, and general fitness with a slight lean towards bodybuilding. It is a long term routine and not something that "shocks" the system.