Skip to content

Instantly share code, notes, and snippets.

View schiemon's full-sized avatar

Szymon Habrainski schiemon

View GitHub Profile
@schiemon
schiemon / AbstractRetryingClient.java
Last active September 1, 2025 08:51
Armeria - Retrying/Hedging Refactor Design - V2
/*
* Copyright 2017 LINE Corporation
*
* LINE Corporation licenses this file to you 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:
*
* https://www.apache.org/licenses/LICENSE-2.0
*
* Unless required by applicable law or agreed to in writing, software
13:54:36.202 [main] DEBUG i.n.u.i.l.InternalLoggerFactory - Using SLF4J as the default logging framework
13:54:36.214 [main] DEBUG i.n.util.internal.PlatformDependent0 - -Dio.netty.noUnsafe: true
13:54:36.214 [main] DEBUG i.n.util.internal.PlatformDependent0 - sun.misc.Unsafe: unavailable (io.netty.noUnsafe)
13:54:36.214 [main] DEBUG i.n.util.internal.PlatformDependent0 - Java version: 21
13:54:36.214 [main] DEBUG i.n.util.internal.PlatformDependent0 - java.nio.DirectByteBuffer.<init>(long, {int,long}): unavailable
13:54:36.215 [main] DEBUG i.n.util.internal.PlatformDependent - maxDirectMemory: 805306368 bytes (maybe)
13:54:36.216 [main] DEBUG i.n.util.internal.PlatformDependent - -Dio.netty.tmpdir: /var/folders/27/35dp_qr520d9ff2lr528z6380000gn/T (java.io.tmpdir)
13:54:36.216 [main] DEBUG i.n.util.internal.PlatformDependent - -Dio.netty.bitMode: 64 (sun.arch.data.model)
13:54:36.216 [main] DEBUG i.n.util.internal.PlatformDependent - Platform: MacOS
13:54:36.216 [main] DEBUG i.n.util.internal.PlatformDependen
package com.linecorp.armeria.testing.junit5.server.mock;
import io.netty.buffer.ByteBufAllocator;
import io.netty.handler.ssl.OpenSsl;
import io.netty.handler.ssl.SslContext;
import io.netty.handler.ssl.SslContextBuilder;
import io.netty.handler.ssl.util.SelfSignedCertificate;
import io.netty.util.ReferenceCountUtil;
import org.junit.jupiter.api.Test;
@schiemon
schiemon / CancelledRequestsInterceptor.java
Created January 8, 2025 19:39
Armeria Race Condition `onMessage`/ `onCancel` Reproducer
// example/armeria/grpc/CancelledRequestsInterceptor.java
package example.armeria.grpc;
import java.util.List;
import org.slf4j.Logger;
import org.slf4j.LoggerFactory;
import io.grpc.ForwardingServerCallListener.SimpleForwardingServerCallListener;
@schiemon
schiemon / AppTest.java
Created November 27, 2024 15:44
Jackson `Optional` handling
package org.example;
import com.fasterxml.jackson.annotation.JsonAutoDetect;
import com.fasterxml.jackson.annotation.JsonInclude;
import com.fasterxml.jackson.annotation.PropertyAccessor;
import com.fasterxml.jackson.core.JsonProcessingException;
import com.fasterxml.jackson.databind.ObjectMapper;
import com.fasterxml.jackson.databind.SerializationFeature;
import com.fasterxml.jackson.datatype.jdk8.Jdk8Module;
import com.fasterxml.jackson.datatype.joda.JodaModule;
{
"configurations": [
{
"name": "MergeSort (Debug)",
"type": "cppdbg",
"request": "launch",
"program": "${workspaceFolder}/merge-sort.exe",
"runtimeExecutable": "${workspaceRoot}/info.sh",
"args": [
"${input:number_elements}",
import { NextApiRequest, NextApiResponse } from "next";
import { withApiAuthRequired } from "@auth0/nextjs-auth0";
import nc from "next-connect";
// Secured api endpoint.
// Possible synergy between next-connect and withApiAuthRequired from nextjs-auth0.
const handler = withApiAuthRequired(
nc<NextApiRequest, NextApiResponse>()
.get(
@schiemon
schiemon / edf.py
Last active April 13, 2021 18:47
Empirische Verteilungsfunktion mit matplotlib
import matplotlib.pyplot as plt
import numpy as np
from collections import Counter
from matplotlib.widgets import Slider
from functools import partial
(fig, ax) = plt.subplots(1, 1)
def gen(n):
ax.clear()
@schiemon
schiemon / deadlock.rs
Created February 23, 2021 12:56
Provoking a deadlock in Rust
fn make_deadlock() {
let a = Arc::new(Mutex::new(1u32));
let aa = Arc::clone(&a);
let b = Arc::new(Mutex::new(1u32));
let bb = Arc::clone(&b);
let t_a = spawn(move || loop {
do_locking("A".to_string(), "a".to_string(), &*a, "b".to_string(), &*b);
});