Skip to content

Instantly share code, notes, and snippets.

@eliottrobson
eliottrobson / View+PositionSticky.swift
Created March 22, 2024 22:26
SwiftUI Sticky Header
//
// View+PositionSticky.swift
// App
//
// Created by Eliott Robson on 22/03/2024.
//
import SwiftUI
extension View {
@eliottrobson
eliottrobson / ISpecification.cs
Created March 10, 2021 11:40
Specification Expression Replacer
public interface ISpecification<T> where T : class
{
Expression<Func<T, bool>> Predicate { get; }
bool IsSatisfiedBy(T entity);
}
@eliottrobson
eliottrobson / BooleanExpressionReducer.cs
Last active November 12, 2021 16:44
Boolean Expression Reducer
/// <summary>
/// Reduces boolean expressions to improve performance with generated queries.
/// <example>
/// For example:
/// <code>
/// Expression<Func<User, FollowingData>> projection = u => new FollowingData
/// {
/// UserId = u.Id,
/// FollowersCount = u.Followers.Count,
/// IsFollowing = currentUserId.HasValue && u.Following.Any(f => f.UserId == currentUserId.Value)