Skip to content

Instantly share code, notes, and snippets.

View MichalBrylka's full-sized avatar

Michał Bryłka MichalBrylka

View GitHub Profile
@MichalBrylka
MichalBrylka / PagerResult.java
Last active February 26, 2026 19:30
PagerResult
import java.net.URI;
import java.util.List;
import java.util.Map;
import java.util.Objects;
public record PagedResult<T>(
List<T> content,
int pageNumber, // 1-based
int pageSize,
long totalElements,
@MichalBrylka
MichalBrylka / TimestampRange.java
Created February 26, 2026 17:25
TimestampRange
package org.nemesis;
import jakarta.servlet.http.HttpServlet;
import jakarta.servlet.http.HttpServletRequest;
import jakarta.servlet.http.HttpServletResponse;
import org.eclipse.jetty.server.Server;
import org.eclipse.jetty.servlet.ServletContextHandler;
import org.eclipse.jetty.servlet.ServletHolder;
import java.sql.*;
import java.time.LocalDateTime;
import java.time.LocalDate;
import java.util.UUID;
public class Booking {
public String id;
public String guestName;
public String roomNumber;
public LocalDate checkIn;
public LocalDate checkOut;
import java.lang.reflect.*;
import java.util.*;
public class DefaultObjectGenerator {
public <T> T create(Class<T> clazz) {
try {
// Base cases: primitive, string, enum
if (isSimpleType(clazz)) return getPrimitive(clazz);
if (clazz.isEnum()) return clazz.cast(createEnumValue(clazz));
@MichalBrylka
MichalBrylka / FormattableNumber.java
Last active June 3, 2025 15:48
Formattable number for Excel
package conditionalFormattingExcel;
import org.jetbrains.annotations.NotNull;
public sealed interface FormattableNumber permits FormattableNumber.Currency, FormattableNumber.Fixed, FormattableNumber.Percentage {
double rawNumber();
static Fixed ofFixed(double value) {
return new Fixed(value);
}
@MichalBrylka
MichalBrylka / EvalEx_CustomFunction.java
Last active March 10, 2025 07:56
Add custom function to EvalEx
package evaluation;
import com.ezylang.evalex.EvaluationException;
import com.ezylang.evalex.Expression;
import com.ezylang.evalex.config.ExpressionConfiguration;
import com.ezylang.evalex.data.EvaluationValue;
import com.ezylang.evalex.functions.AbstractFunction;
import com.ezylang.evalex.functions.FunctionParameter;
import com.ezylang.evalex.parser.Token;
import lombok.extern.slf4j.Slf4j;
@MichalBrylka
MichalBrylka / Encode-Hex.ps1
Last active January 31, 2025 14:28
Encode Hex
<#
.SYNOPSIS
This script provides three modes of operation:
1. Converts a given string to its hexadecimal representation.
2. Decodes a given hexadecimal string back to its original UTF-8 representation.
3. Renames files in a given directory by encoding the part of the filename before the first '.' or '_'.
.PARAMETER InputString
A string that will be converted to hexadecimal encoding.
@MichalBrylka
MichalBrylka / Process.ps1
Created January 15, 2025 13:28
Process.ps1
$process = Get-Process | Where-Object { $_.MainWindowTitle -like "*xxx*" }
if ($process) {
# Get the executable file path
$exePath = Get-CimInstance -ClassName Win32_Process -Filter "ProcessId = $($process.Id)" | Select-Object -ExpandProperty ExecutablePath
Write-Output "Executable Path: $exePath"
} else {
Write-Output "No process found with the specified window title."
}
@MichalBrylka
MichalBrylka / JsonAnyGetter_CustomSerdes.java
Last active January 12, 2025 18:02
JsonAnyGetter_CustomSerdes
package org.example2;
import com.fasterxml.jackson.core.*;
import com.fasterxml.jackson.databind.*;
import com.fasterxml.jackson.databind.annotation.JsonDeserialize;
import java.io.IOException;
import java.util.*;
import java.util.stream.Collectors;
@MichalBrylka
MichalBrylka / Checker.js
Last active December 17, 2024 21:08
UnicodeCodePointsChecker
function findCodePointsLikeAtoZ() {
const targetLetters = "ABCDEFGHIJKLMNOPQRSTUVWXYZ";
const normalizationResults = {};
// Initialize the dictionary for each letter
for (const letter of targetLetters) {
normalizationResults[letter] = [];
}
// Iterate over all Unicode code points