Skip to content

Instantly share code, notes, and snippets.

View michael-simons's full-sized avatar

Michael Simons michael-simons

View GitHub Profile
create table things(id int not null auto_increment, created_at date, user varchar(32), amount decimal(10,2), primary key(id));
insert into things(created_at, user, amount) values (date'2021-10-02', 'michael', 5);
insert into things(created_at, user, amount) values (date'2021-10-02', 'markus', 10);
insert into things(created_at, user, amount) values (date'2021-10-03', 'markus', 15);
insert into things(created_at, user, amount) values (date'2021-10-04', 'markus', 5);
// Correct
select avg(amount) from things;
// Same value but really hard to understand
${{ github.event.sender.login != 'dependabot[bot]' && (github.event_name != 'pull_request' || github.event.pull_request.head.repo.full_name == github.repository) }}
///usr/bin/env jbang "$0" "$@" ; exit $?
//JAVA 17
//DEPS com.tagtraum:obstmusic:0.9.2
import java.util.concurrent.Executors;
import java.util.concurrent.TimeUnit;
import com.tagtraum.macos.music.Application;
import com.tagtraum.macos.music.Epls;
package com.example.molecues;
import java.util.Collections;
import java.util.HashSet;
import java.util.Objects;
import java.util.Set;
import java.util.concurrent.atomic.AtomicLong;
import java.util.function.Supplier;
import org.springframework.boot.CommandLineRunner;
<build>
<plugins>
<plugin>
<groupId>org.apache.maven.plugins</groupId>
<artifactId>maven-compiler-plugin</artifactId>
<executions>
<execution>
<goals>
<goal>compile</goal>
</goals>
@michael-simons
michael-simons / Neo4jGraphqlJava.java
Last active September 15, 2022 12:23
Brings up a Neo4jGraphQL Java server.
///usr/bin/env jbang "$0" "$@" ; exit $?
//JAVA 16
//JAVAC_OPTIONS -source 16
//DEPS info.picocli:picocli:4.6.1
//DEPS io.javalin:javalin:3.13.9
//DEPS org.neo4j.driver:neo4j-java-driver:4.3.3
//DEPS org.neo4j:neo4j-graphql-java:1.3.0
//DEPS com.fasterxml.jackson.core:jackson-databind:2.10.5
//DEPS org.slf4j:slf4j-simple:1.7.31
package com.example.graphqlplain;
@michael-simons
michael-simons / module-info.java
Last active April 13, 2021 11:20
Who said it is hard to run Spring applications on modules?
module neo4jonmodules {
requires spring.beans;
requires spring.boot;
requires spring.boot.autoconfigure;
requires spring.data.neo4j;
// Well, the object mapper uses reflection, little surprising
opens com.example.cypherdsljava11test to spring.core;
// And yep, if we want to create beans from that package, it must be exported
///usr/bin/env jbang "$0" "$@" ; exit $?
import static java.lang.System.*;
public class fizzbuzz {
public static void main(String... args) {
for (int i = 1; i <= 100; i++) {
if (i % 3 == 0) out.print("Fizz");
if (i % 5 == 0) out.print("Buzz");
///usr/bin/env jbang "$0" "$@" ; exit $?
//JAVA 16
//JAVAC_OPTIONS -source 16
//DEPS info.picocli:picocli:4.2.0
//DEPS org.asciidoctor:asciidoctorj:2.4.2
//DEPS org.fusesource.jansi:jansi:2.1.1
import picocli.CommandLine;
import picocli.CommandLine.ExitCode;
import picocli.CommandLine.Option;
@michael-simons
michael-simons / MoviesController.java
Created December 18, 2020 11:39
A streaming controller providing tailable queries, result sets…
package com.example.demo.movies;
import reactor.core.publisher.Flux;
import reactor.core.publisher.Mono;
import java.time.Duration;
import java.time.LocalDateTime;
import java.util.concurrent.atomic.AtomicReference;
import org.springframework.data.domain.Sort;