Skip to content

Instantly share code, notes, and snippets.

View 01Vladimir10's full-sized avatar
🏠
Working from home

01Vladimir10

🏠
Working from home
View GitHub Profile
@01Vladimir10
01Vladimir10 / EfCoreExtensions.cs
Created December 23, 2024 16:33
Ef core extensions
using System.Collections;
using Dapper;
using Microsoft.EntityFrameworkCore;
using Microsoft.EntityFrameworkCore.ChangeTracking;
using MySqlConnector;
using System.Data;
using System.Diagnostics.CodeAnalysis;
using System.Linq.Expressions;
using System.Runtime.CompilerServices;
using Domain.Entities;
@01Vladimir10
01Vladimir10 / enumerable.ts
Created November 8, 2024 20:24
LinqTypescript
export type Comparer<T> = (a: T, b: T) => number
export class Enumerable<T> implements Iterable<T> {
protected readonly source: Iterable<T>
constructor(source: Iterable<T> | (() => Generator<T, void, undefined>)) {
this.source = typeof source == 'function' ? source() : source
}
static range(start: number, count: number, step: number = 1) {
return new Enumerable(function* () {
@01Vladimir10
01Vladimir10 / enumerable.ts
Created October 23, 2024 02:24
A basic implementation of linq in TS with zero dependencies.
export type Comparer<T> = (a: T, b: T) => number
export class Enumerable<T> implements Iterable<T> {
protected readonly source: Iterable<T>
constructor(source: Iterable<T> | (() => Generator<T, void, undefined>)) {
this.source = typeof source == 'function' ? source() : source
}
static from<T>(array: Iterable<T>) {
return new Enumerable(array)
@01Vladimir10
01Vladimir10 / HighlightedText.cs
Created August 19, 2023 06:50
Blazor safely highlight text in a string
using AdminPwaEditor.Web.Client.Components.Base;
using Microsoft.AspNetCore.Components;
using Microsoft.AspNetCore.Components.Rendering;
namespace AdminPwaEditor.Web.Client.Components.Controls;
public class HighlightedText : BaseComponent
{
[Parameter, EditorRequired] public string Text { get; set; } = "";
[Parameter] public string? Highlight { get; set; } = "";
@01Vladimir10
01Vladimir10 / JsonSnakeCaseNamingPolicy.cs
Created May 10, 2023 22:31
An implementation of JsonNamingPolicy for snake case, this is completly compatible with Json.NET
namespace ZuperApi.ZohoIntegration.Utils;
public class JsonSnakeCaseNamingPolicy : System.Text.Json.JsonNamingPolicy
{
public override string ConvertName(string name) => ToSeparatedCase(name, '_');
private enum SeparatedCaseState
{
Start,
Lower,