Skip to content

Instantly share code, notes, and snippets.

View fbricon's full-sized avatar
🖖

Fred Bricon fbricon

🖖
View GitHub Profile
@fbricon
fbricon / qmdns.java
Last active September 11, 2024 08:58
Automatically register a Quarkus app with a custom hostname.local via mDNS
//usr/bin/env jbang "$0" "$@" ; exit $?
//DEPS io.quarkus.platform:quarkus-bom:3.14.2@pom
//DEPS io.quarkus:quarkus-rest
//DEPS org.jmdns:jmdns:3.5.12
//COMPILE_OPTIONS -parameters
//RUNTIME_OPTIONS -Djava.util.logging.manager=org.jboss.logmanager.LogManager -Dmdns.host=awesome
import java.io.IOException;
import java.net.InetAddress;
@fbricon
fbricon / HelloTensorFlow.java
Last active November 29, 2022 15:31
Java TensorFlow example using JBang. Based on https://www.tensorflow.org/jvm/install. Doesn't run on Mac M1 (https://github.com/tensorflow/java/issues/252)
///usr/bin/env jbang "$0" "$@" ; exit $?
//DEPS org.tensorflow:tensorflow-core-platform:0.4.2
//JAVA 11+
import org.tensorflow.ConcreteFunction;
import org.tensorflow.Signature;
import org.tensorflow.Tensor;
import org.tensorflow.TensorFlow;
import org.tensorflow.op.Ops;
import org.tensorflow.op.core.Placeholder;
import org.tensorflow.op.math.Add;
@fbricon
fbricon / lol.java
Last active November 24, 2022 11:17
JFiglet + Lolcat with JBang
///usr/bin/env jbang "$0" "$@" ; exit $?
//DEPS com.github.jamesnetherton:lolcat4j:0.4.0
//DEPS com.github.lalyos:jfiglet:0.0.9
//JAVA 11+
import java.io.IOException;
import com.github.jamesnetherton.lolcat4j.Lol;
import com.github.lalyos.jfiglet.FigletFont;
public class lol {
@fbricon
fbricon / repoflattener.java
Last active May 16, 2024 14:31
Flatten a p2 repo with JBang
///usr/bin/env jbang "$0" "$@" ; exit $?
/**
* Copyright 2022 Fred Bricon
*
* 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
*
@fbricon
fbricon / sayvnw
Created December 4, 2021 22:36
sayvn
#!/usr/bin/env sh
# License: Apache 2.0
# Description: Sayvn is a Wrapper for the Maven Wrapper that notifies you via the OSX say command whether a task failed or succeeded.
# Sayvn is a port of Sam Edwards' Saydle wrapper for Gradle
# Orginal Saydle Source: https://github.com/handstandsam/saydle/
# Version: 1.0.0-alpha01
# Customizations
success_phrase="Success"
failed_phrase="Failed"
@fbricon
fbricon / kafkaproducer.java
Created March 15, 2021 11:16
Produce Long messages to local Kafka cluster
///usr/bin/env jbang "$0" "$@" ; exit $?
//DEPS info.picocli:picocli:4.5.0
//DEPS org.apache.kafka:kafka-clients:LATEST
import picocli.CommandLine;
import picocli.CommandLine.Command;
import java.util.Properties;
import java.util.Random;
import java.util.concurrent.ExecutionException;
import org.apache.kafka.clients.producer.KafkaProducer;
//usr/bin/env jbang "$0" "$@" ; exit $?
//DEPS info.picocli:picocli:4.2.0
//DEPS org.eclipse.jgit:org.eclipse.jgit:5.8.1.202007141445-r
import org.eclipse.jgit.api.ListBranchCommand;
import org.eclipse.jgit.api.errors.GitAPIException;
import org.eclipse.jgit.lib.Ref;
import org.eclipse.jgit.lib.Repository;
import org.eclipse.jgit.revwalk.RevCommit;
@fbricon
fbricon / lastweek.java
Created July 21, 2020 14:21
List all commits that happened last week on a set of repos
//usr/bin/env jbang "$0" "$@" ; exit $?
//JAVAC_OPTIONS -Xlint:unchecked
//DEPS com.google.code.gson:gson:2.8.6
import java.io.InputStream;
import java.io.InputStreamReader;
import java.io.Reader;
import java.net.URL;
import java.net.URLConnection;
import java.time.Duration;
import java.time.Instant;
@fbricon
fbricon / GenerateChangelog.java
Last active August 31, 2020 17:08
Generate changelogs
//usr/bin/env jbang "$0" "$@" ; exit $?
//DEPS com.google.code.gson:gson:2.8.6
import java.io.InputStream;
import java.io.InputStreamReader;
import java.io.Reader;
import java.net.URL;
import java.net.URLConnection;
import java.util.ArrayList;
import java.util.LinkedHashMap;
@fbricon
fbricon / failing.pom.xml
Created January 18, 2019 21:35
Maven resolution puzzler
<project xmlns="http://maven.apache.org/POM/4.0.0"
xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
xsi:schemaLocation="http://maven.apache.org/POM/4.0.0 http://maven.apache.org/xsd/maven-4.0.0.xsd">
<modelVersion>4.0.0</modelVersion>
<groupId>foo.bar</groupId>
<artifactId>test</artifactId>
<version>0.0.1-SNAPSHOT</version>
<dependencies>
<!-- Maven build fails because :
Missing artifact org.eclipse.xtend:org.eclipse.xtend.lib:jar:2.17.0.M1