Skip to content

Instantly share code, notes, and snippets.

WSL 2 Cisco AnyConnect Networking Workaround

Overview

WSL 2 uses a Hyper-V Virtual Network adapter. Network connectivity works without any issue when a VPN is not in use. However when a Cisco AnyConnect VPN session is established Firewall Rules and Routes are added which breaks connectivity within the WSL 2 VM. This issue is tracked WSL/issues/4277

Below outline steps to automatically configure the Interface metric on VPN connect and update DNS settings (/etc/resolv.conf) on connect/disconnect.

Manual Configuration

Set Interface Metrics

Motivation

Integrate JMH (Java Microbenchmarking Harness) with Spring (Boot) and make developing and running benchmarks as easy and convinent as writing tests.

Idea

Wrap the necessary JMH boilerplate code within JUnit to benefit from all the existing test infrastructure Spring (Boot) provides. It should be as easy and convinent to write benchmarks as it is to write tests.

TL;DR;

@dimio
dimio / HOWTO.md
Created March 3, 2021 18:53 — forked from Toparvion/HOWTO.md
JUnit test for conditional Spring Boot bean registration (@ConditionalOnProperty)

Problem

Suppose you have two classes that should be registered with Spring context exclusively, e.g. only one of the beans must exist in the context at any time based on some boolean property value. Of course you can do it by adding explicit if condition into your @Configuration class. But if the classes have no common interface it may be quite cumbersome. As an alternative you can use @ConditionalOnProperty annotation on your classes, e.g.:

@Service
@ConditionalOnProperty(name = "use-left-service", havingValue = "true", matchIfMissing = false)
public class LeftService
@dimio
dimio / js_common_notes.md
Last active April 16, 2020 18:49
JS tips & tricks

Sort object by keys/values

let unsortedObject = {
  c: "ccc",
  f: "123",
  b: "bb",
  a: "0",
};

// a[0], b[0] - by key, a[1], b[1] - by value
@dimio
dimio / image_manipulation.md
Last active December 5, 2020 20:24
Shell tips & tricks

Подготовка изображений к публикации (imagemagick)

Преобразование с минимумом визуальных искажений на выходе, позволяет уменьшить размер изображений перед публикацией или отправкой в гос. органы. mogrify умеет обрабатывать коллекцию файлов, но не всегда работает корректно и не всегда установлен, вариант с xargs и convert более универсальный (также, он позволяет использовать требуемое число потоков)

mogrify -path ./res/ \
-filter Triangle -define filter:support=2 \
-unsharp 0.25x0.08+8.3+0.045 -dither None -posterize 136 -quality 80 \