Skip to content

Instantly share code, notes, and snippets.

Avatar
💭
🤨

Brice Dutheil bric3

💭
🤨
View GitHub Profile
@bric3
bric3 / jdk-mission-control-snapshot.rb
Created Nov 30, 2020
Brew formula for JDK Mission Control 8 SNAPSHOT
View jdk-mission-control-snapshot.rb
# 1. brew cask create jdk-mission-control
# 2. brew edit jdk-mission-control-snapshot
# 3. Then paste this content
cask 'jdk-mission-control-snapshot' do
version :latest
sha256 :no_check
url do
# was 'https://ci.adoptopenjdk.net/view/JMC/job/jmc-build/job/master/lastSuccessfulBuild/artifact/target/products/org.openjdk.jmc-macosx.cocoa.x86_64.tar.gz'
'https://ci.adoptopenjdk.net/view/JMC/job/jmc-build/job/master/lastSuccessfulBuild/artifact/target/products/org.openjdk.jmc-8.0.0-SNAPSHOT-macosx.cocoa.x86_64.tar.gz'
@bric3
bric3 / pod-analysis.json
Last active Nov 10, 2020
Kubernetes JVM pod analysis using Micrometer, Istio, and Kube state metrics
View pod-analysis.json
{
"annotations": {
"list": [
{
"builtIn": 1,
"datasource": "-- Grafana --",
"enable": true,
"hide": true,
"iconColor": "rgba(0, 211, 255, 1)",
"limit": 100,
@bric3
bric3 / libsodium.gradle
Last active Nov 4, 2020
Gradle script that downloads prebuilt libsodium for macOS or Linux
View libsodium.gradle
apply plugin: 'de.undercouch.download'
OperatingSystem os = org.gradle.nativeplatform.platform.internal.DefaultNativePlatform.currentOperatingSystem;
if(os.isLinux()) {
ext {
debFileName = "libsodium-dev_1.0.17-1_amd64.deb"
debSha256 = "f72e5b1e3a716154c284d98969bb698701daa30b02d755a78d10d460c582d48b"
}
@bric3
bric3 / docker-tag-groups.sh
Last active Oct 16, 2020
Group all docker tags by image
View docker-tag-groups.sh
#!/usr/bin/env bash
set -euo pipefail
#set -o xtrace
image=${1};
wanted_tag=${2:-""};
max_pages=10;
grouped_tags_tmp=$(mktemp);
@bric3
bric3 / CryptoHackerUsageTest.java
Last active Sep 17, 2020
Pre-JKD8u151 that allows to modify the AES key length
View CryptoHackerUsageTest.java
import org.junit.Test;
import javax.crypto.BadPaddingException;
import javax.crypto.Cipher;
import javax.crypto.IllegalBlockSizeException;
import javax.crypto.NoSuchPaddingException;
import javax.crypto.spec.IvParameterSpec;
import javax.crypto.spec.SecretKeySpec;
import java.security.InvalidAlgorithmParameterException;
import java.security.InvalidKeyException;
@bric3
bric3 / PrivateConstructors.java
Created Aug 27, 2020
Uses MethodHandle to access private package
View PrivateConstructors.java
public abstract class PrivateConstructors {
// public class CustomIterable<V> implements Iterable<V> {
// CustomIterable() {}
// }
@SuppressWarnings("unchecked")
private static <I extends T, T> I newInstanceOf(Class<T> clazz) throws Throwable {
MethodHandles.Lookup lookup = MethodHandles.privateLookupIn(clazz, MethodHandles.lookup());
MethodHandle methodHandle = lookup.findConstructor(clazz, MethodType.methodType(void.class));
@bric3
bric3 / identiies-only-with-teleport.adoc
Created Jul 29, 2020
IdentitiesOnly with teleport configuration
View identiies-only-with-teleport.adoc

If you use IdentitiesOnly yes in your SSH config, because you want to limit the key info you send to random SSH servers, it may not work for some teleport+ssh services like for git.domain.com One alternative is to have:

Host git.domain.com
    ProxyCommand ssh -A -p 3023 %r@teleport.domain.com -s proxy:%h:22
    IdentitiesOnly no
@bric3
bric3 / hacking_jvm_logging.java
Last active Jul 28, 2020
misappropriate Jfr to log your own logs with unified logging, limited to some tag set though
View hacking_jvm_logging.java
import java.lang.invoke.MethodHandles;
import java.lang.invoke.MethodType;
import java.util.Arrays;
import java.util.Set;
public class hacking_jvm_logging {
/**
* Logging Level
*
* public enum LogLevel {
@bric3
bric3 / TriggerGcLogsProgrammatically.java
Last active Jul 24, 2020
Trigger GC logs programmatically
View TriggerGcLogsProgrammatically.java
import javax.management.InstanceNotFoundException;
import javax.management.IntrospectionException;
import javax.management.MBeanException;
import javax.management.MBeanInfo;
import javax.management.MalformedObjectNameException;
import javax.management.ObjectName;
import javax.management.ReflectionException;
import java.lang.management.ManagementFactory;
public class TriggerGcLogsProgrammatically {
View OnDemandJsonPrettyPrintingFilter.java
import com.fasterxml.jackson.core.JsonGenerator;
import com.fasterxml.jackson.databind.ObjectWriter;
import com.fasterxml.jackson.jaxrs.cfg.EndpointConfigBase;
import com.fasterxml.jackson.jaxrs.cfg.ObjectWriterInjector;
import com.fasterxml.jackson.jaxrs.cfg.ObjectWriterModifier;
import javax.ws.rs.container.ContainerRequestContext;
import javax.ws.rs.container.ContainerResponseContext;
import javax.ws.rs.container.ContainerResponseFilter;
import javax.ws.rs.core.MultivaluedMap;
You can’t perform that action at this time.