Skip to content

Instantly share code, notes, and snippets.

  • Narcissistic Personality Disorder (NPD) – Narcissists may gaslight to maintain their self-image, deflect blame, or manipulate others into serving their needs.
  • Antisocial Personality Disorder (ASPD) – People with ASPD may use gaslighting as part of a broader pattern of manipulation or exploitation.
  • Insecurity and Low Self-Esteem – Some gaslighters might not have a diagnosable disorder but may manipulate others out of fear, insecurity, or poor emotional regulation.
  • Learned Behavior – People who grow up in environments where manipulation was common may adopt gaslighting as a tool, even without understanding the harm they're causing.

Not Always Clinical: It’s important to note that not everyone who gaslights has a mental illness. Some people engage in gaslighting knowingly and deliberately as a form of abuse, while others might do it subconsciously without realizing the impact.

If you're dealing with gaslighting, whether from a partner, family member, friend, or coworker, it's worth taking seriously—reg

@mike-seger
mike-seger / fault-tolerance-libs.md
Last active March 17, 2025 17:57
What are the key differences between Resilience4j and dev.failsafe?

Resilience4j and dev.failsafe (Failsafe) are both fault-tolerance libraries for Java, but they have key differences in their architecture, feature set, and intended use cases. 1. Design and Philosophy

  • Resilience4j : Built specifically for resilience in microservices, inspired by Netflix Hystrix. It provides various fault-tolerance mechanisms as independent modules.

  • Failsafe : A more lightweight and flexible general-purpose retry/fault-tolerance library with a functional and fluent API.

2. Features Comparison

Feature Resilience4j Failsafe
@mike-seger
mike-seger / RestAssured SSLSocketFactory.kt
Last active March 14, 2025 18:03
RestAssured SSLSocketFactory
import io.restassured.RestAssured
import io.restassured.config.SSLConfig
import javax.net.ssl.SSLSocketFactory
import javax.net.ssl.TrustManagerFactory
import javax.net.ssl.SSLContext
import java.security.KeyStore
fun createSSLSocketFactory(): SSLSocketFactory {
val trustManagerFactory = TrustManagerFactory.getInstance(TrustManagerFactory.getDefaultAlgorithm())
trustManagerFactory.init(null as KeyStore?)

recipees

Method 1: Using sed

sed -i ':a;/^\n*$/{N;ba};/\n/{:b;/\n$/!{N;bb};s/^\n*//;s/\n*$//}' filename

Method 2: Using awk

awk '{if (NF || !blank) {print; blank=0} else if (!blank) {blank=1}}' filename > temp && mv temp filename

Method 3: Using perl

perl -i -0777 -pe 's/^\n+|\n+$//g' filename

import io.swagger.v3.oas.models.Paths
import io.swagger.v3.oas.models.OpenAPI
import org.springdoc.core.customizers.OpenApiCustomiser
import org.springframework.context.annotation.Bean
import org.springframework.context.annotation.Configuration
import java.util.TreeMap
@Configuration
class OpenApiConfig {
@mike-seger
mike-seger / merge-odd-even.md
Created December 15, 2024 19:43
Merge odd and even lines into a tab delimited file
awk 'NR % 2 == 1' input.txt > odd_lines.txt
awk 'NR % 2 == 0' input.txt > even_lines.txt
paste -d '\t' odd_lines.txt even_lines.txt
@mike-seger
mike-seger / ws-series.md
Last active December 15, 2024 07:07
WS Series controlled LED use cases

WS Series controlled LED use cases

Model Voltage Features Use Case
WS2811 12V External IC Budget-friendly, long runs
WS2812B 5V Integrated IC, compact General-purpose, most popular
WS2813 5V Backup data line High reliability
WS2815 12V Low current, long strips Large installations
WS2801 5V SPI control Older systems or simple timing
WS2821 5V High-speed Faster animations

You:

in Spring i can do tests @WithMockUser and a list of roles is there a way to achieve the same with parameterized tests looping through an actual list of roles instead of a single test with the combination of roles?

ChatGPT:

Yes, you can achieve this with parameterized tests by dynamically setting up each test with a single role from a list of roles. However, @WithMockUser doesn’t directly support parameterized roles out of the box. Instead, you can use @ParameterizedTest and programmatically create a mock user with each role in the list.Here’s how you can do it by leveraging SecurityContextHolder to manually set up the authentication for each test:

@mike-seger
mike-seger / ControllerTests.kt
Last active November 3, 2024 14:11
Parameterized controller tests
import org.junit.jupiter.api.Assertions.assertEquals
import org.junit.jupiter.api.DisplayName
import org.junit.jupiter.api.MethodSource
import org.junit.jupiter.params.ParameterizedTest
import org.junit.jupiter.params.provider.Arguments
import org.springframework.beans.factory.annotation.Autowired
import org.springframework.boot.test.autoconfigure.web.servlet.AutoConfigureMockMvc
import org.springframework.boot.test.context.SpringBootTest
import org.springframework.http.HttpStatus
import org.springframework.http.MediaType

You:

i have a spring security enabled test application currently configured with a single test user in application.yaml: spring: security.user: name: user password: pw

the goal is to modify this setup to allow 2 distinct users (user1, user2) basic auth access through a SecurityFilterChain, permitting user1 access to a resource antMatchers("/dir1/") and user2 access to a resource antMatchers("/dir2/")