Skip to content

Instantly share code, notes, and snippets.

View MichalBrylka's full-sized avatar

Michał Bryłka MichalBrylka

View GitHub Profile
@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
@MichalBrylka
MichalBrylka / Program.cs
Created November 17, 2024 14:28
Guid.CreateVersion7
using System.Runtime.InteropServices;
var now = DateTimeOffset.UtcNow;
TryGenerate(() => Guid.NewGuid(), " v4");
TryGenerate(() => Guid.CreateVersion7(now), " v7");
TryGenerate(() => CreateVersion7(now), "MBv7");
TryGenerate(() => Ulid.NewUlid(now).ToGuid(), "Ulid");
static void TryGenerate(Func<Guid> generator, string name)
// See https://aka.ms/new-console-template for more information
using FluentResults;
//1. simple
Console.WriteLine(Divide(5, 0));
//2. fluent
var fluent = Result.Fail("error message 1")
.WithError("error message 2")
@MichalBrylka
MichalBrylka / Program.cs
Created February 5, 2024 11:09
Result public
// See https://aka.ms/new-console-template for more information
using ConsoleApp1;
var nameEntities = new[] { "", null, "Dawid", "Kacper", "Wojciech", "Michał M", "Michał B", "Rafał", "Anna", "Floris" }
.Select(CreateUser).ToList();
var index = 0;
foreach (var ne in nameEntities)
{
if (ne.TryGetValue(out var u)) Console.WriteLine($"{index++}. User created: {u}");
@MichalBrylka
MichalBrylka / InterceptorsLogging.cs
Created November 27, 2023 13:59
Interceptor for logging
using System.Runtime.CompilerServices;
namespace Net8.Features;
[Order(9)]
internal class InterceptorsLogging : IShowable
{
public void Show()
{
var todo = new TodoApi();
@MichalBrylka
MichalBrylka / LogCallBenchmarks.cs
Created February 22, 2023 13:21
TestLoggerCallsPerf
using System;
using BenchmarkDotNet.Attributes;
using Serilog;
namespace TestLoggerCallsPerf;
/*Console
| Method | Mean | Error | StdDev | Ratio | RatioSD | Allocated | Alloc Ratio |
|----------- |---------:|--------:|---------:|------:|--------:|----------:|------------:|
| ParamsArgs | 477.0 ms | 8.56 ms | 8.01 ms | 1.00 | 0.00 | 3.75 MB | 1.00 |