Skip to content

Instantly share code, notes, and snippets.

View michael-simons's full-sized avatar

Michael Simons michael-simons

View GitHub Profile
///usr/bin/env jbang "$0" "$@" ; exit $?
//JAVA 17
//DEPS info.picocli:picocli:4.6.3
package df;
import picocli.CommandLine;
import picocli.CommandLine.Model.CommandSpec;
import picocli.CommandLine.Option;
import picocli.CommandLine.ParameterException;
import picocli.CommandLine.Spec;
WITH duplicate_checksums AS (
SELECT MD5 FROM file_duplicates_develop.files
GROUP BY MD5 HAVING COUNT(*) > 1
)
SELECT * FROM file_duplicates_develop.files
WHERE MD5 = duplicate_checksums.MD5
ORDER BY -Size, MD5;

Howto serialize and deserialize cyclomatic references in Java objects with Jacksons to and from JSON

@michael-simons
michael-simons / README.md
Created March 23, 2022 11:37
Filtering contents of fileB.json with information from fileA.json
@michael-simons
michael-simons / import_tgf_recursive.java
Created March 20, 2022 19:24
Create a bunch of Trivial Graph Format (tgf) files from Maven and import them into Neo4j.
///usr/bin/env jbang "$0" "$@" ; exit $?
//JAVA 17
//DEPS info.picocli:picocli:4.6.3
//DEPS org.neo4j.driver:neo4j-java-driver:4.4.5
import picocli.CommandLine;
import picocli.CommandLine.Command;
import picocli.CommandLine.Option;
import picocli.CommandLine.Parameters;
@michael-simons
michael-simons / Peng.java
Created January 1, 2022 20:12
Add text with emojis to an image
import java.awt.Color;
import java.awt.Font;
import java.io.File;
import java.io.IOException;
import javax.imageio.ImageIO;
public class Peng {
public static void main(String... a) throws IOException {
@michael-simons
michael-simons / jfr-agent.xml
Created December 21, 2021 09:23
JFR Agent description to emit events when queries are executed via Neo4j Java Driver
<?xml version="1.0" encoding="UTF-8"?>
<jfragent>
<config>
<classprefix>__JFREvent</classprefix>
<allowtostring>true</allowtostring>
<allowconverter>true</allowconverter>
</config>
<events>
<event id="bolt.TemplatedQueryRun">
<label>Templated queries</label>
///usr/bin/env jbang "$0" "$@" ; exit $?
//DEPS org.jsoup:jsoup:1.14.3
//JAVA_OPTIONS -ea
import org.jsoup.parser.Parser;
public class f {
public static void main(String...a) {
var s1 = "🚀 Features";
var s2 = "\uD83D\uDE80 Features";
@michael-simons
michael-simons / Application.java
Last active November 25, 2021 16:42
A better Date Proxy to expose java.util.Date or java.time.Instant into GraalVMs JS embedding.
///usr/bin/env jbang "$0" "$@" ; exit $?
//JAVA 17
//DEPS org.graalvm.sdk:graal-sdk:21.3.0
//DEPS org.assertj:assertj-core:3.21.0
// Only needed when running on vanilla JVM
//DEPS org.graalvm.js:js:21.3.0
package example;
import static org.assertj.core.api.Assertions.assertThat;
@michael-simons
michael-simons / ExtResourcesConfig.java
Created November 8, 2021 10:15
Configure additional, dynamic paths to be delivered as static content by Spring Boot in addition to the default static content.
package com.example.demo;
import java.util.List;
import java.util.logging.Level;
import java.util.logging.Logger;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.boot.context.properties.ConfigurationProperties;
import org.springframework.boot.context.properties.EnableConfigurationProperties;
import org.springframework.context.annotation.Bean;