Skip to content

Instantly share code, notes, and snippets.

View michael-simons's full-sized avatar

Michael Simons michael-simons

View GitHub Profile
@michael-simons
michael-simons / Application.kt
Last active February 18, 2024 10:55
Minimal Kotlin/Gradle Example for Neo4j OGM
package so
import org.neo4j.ogm.annotation.GeneratedValue
import org.neo4j.ogm.annotation.Id
import org.neo4j.ogm.annotation.NodeEntity
import org.neo4j.ogm.annotation.Relationship
import org.neo4j.ogm.config.Configuration
import org.neo4j.ogm.session.SessionFactory
@NodeEntity
package ac.simons.neo4j.examples;
import java.io.IOException;
import java.nio.file.Files;
import java.util.List;
import java.util.Map;
import org.neo4j.configuration.connectors.BoltConnector;
import org.neo4j.configuration.helpers.SocketAddress;
import org.neo4j.dbms.api.DatabaseManagementServiceBuilder;
@michael-simons
michael-simons / Movie.java
Created October 25, 2023 08:00
An example how to run integration tests as GraalVM native image.
package demo;
import java.util.Map;
import java.util.stream.Collectors;
import org.neo4j.driver.Driver;
public record Movie(String id, String title) {
public static final class Repository {
Moved to https://github.com/michael-simons/pv
//usr/bin/env jbang "$0" "$@" ; exit $?
//JAVA 17
//DEPS org.neo4j.driver:neo4j-java-driver:5.7.0
//DEPS com.fasterxml.jackson.core:jackson-databind:2.14.1
package ac.simons;
import java.io.IOException;
import java.nio.file.Files;
import java.nio.file.Path;
import java.nio.file.Paths;
@michael-simons
michael-simons / Server.java
Created October 12, 2020 09:38 — forked from nigjo/Server.java
A simple, insecure One-File-Java-Server to serve static pages. Main purpose is to have a simple server to locally test some github pages.
/*
* Copyright 2020 Jens "Nigjo" Hofschröer.
*
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
* You may obtain a copy of the License at
*
* http://www.apache.org/licenses/LICENSE-2.0
*
* Unless required by applicable law or agreed to in writing, software
sqlite3 :memory: \
'.mode csv' \
'.import "|curl -s https://gist.githubusercontent.com/zhonglism/f146a9423e2c975de8d03c26451f841e/raw/f79e190df4225caed58bf360d8e20a9fa872b4ac/vgsales.csv" hlp' \
"
WITH vgsales AS (
SELECT name, cast(global_sales as number) * 1000000 AS sales, cast(year as number) AS year FROM hlp WHERE year != 'N/A'
),
per_year AS (
SELECT year, name, sales, dense_rank() OVER (PARTITION BY year ORDER BY sales DESC) AS rnk FROM vgsales
)
@michael-simons
michael-simons / RecordMapperProviderImpl.java
Last active January 22, 2023 00:04
A RecordMapperProvider implementation that resolves jOOQ RecordMappers from a Spring Application Context.
import java.util.Map;
import org.jooq.Record;
import org.jooq.RecordMapper;
import org.jooq.RecordMapperProvider;
import org.jooq.RecordType;
import org.jooq.impl.DefaultRecordMapper;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.cache.annotation.Cacheable;
import org.springframework.core.ResolvableType;
@michael-simons
michael-simons / format_java.java
Created December 23, 2022 13:14
Formats Java source files with Google Formats.
//usr/bin/env jbang "$0" "$@" ; exit $?
//JAVA 17+
//DEPS com.google.googlejavaformat:google-java-format:1.15.0
//RUNTIME_OPTIONS --add-exports jdk.compiler/com.sun.tools.javac.api=ALL-UNNAMED
//RUNTIME_OPTIONS --add-exports jdk.compiler/com.sun.tools.javac.file=ALL-UNNAMED
//RUNTIME_OPTIONS --add-exports jdk.compiler/com.sun.tools.javac.parser=ALL-UNNAMED
//RUNTIME_OPTIONS --add-exports jdk.compiler/com.sun.tools.javac.tree=ALL-UNNAMED
//RUNTIME_OPTIONS --add-exports jdk.compiler/com.sun.tools.javac.util=ALL-UNNAMED
import com.google.googlejavaformat.java.Main;
@michael-simons
michael-simons / build.gradle
Created August 22, 2019 06:02
Update Jackson's BOM in Spring Boot with Gradle
plugins {
id 'org.springframework.boot' version '2.1.7.RELEASE'
id 'io.spring.dependency-management' version '1.0.8.RELEASE'
id 'java'
}
group = 'com.example'
version = '0.0.1-SNAPSHOT'
sourceCompatibility = '1.8'