Skip to content

Instantly share code, notes, and snippets.

@cartercanedy
cartercanedy / Result.cs
Last active March 7, 2024 22:26
C# Result<TOk, TErr> type
using System;
// makes sure that all references passed to this api are valid
// imho calls yielding nulls should actually yield err/exception if using this interface
#nullable enable
namespace Result;
/// <summary>
/// Covariant interface for <see cref="Result{TOk, TErr}"/> that assists in consumer variable binding.
@cartercanedy
cartercanedy / .prompt_fmt.sh
Last active March 9, 2024 19:14
bash prompt
GREEN=""
RED=""
NO_COLOR=""
BLUE=""
if [ "$color_prompt" = yes ]; then
GREEN='\033[01;32m'
RED='\033[01;31m'
NO_COLOR='\033[00m'
BLUE='\033[34m'
@cartercanedy
cartercanedy / query.py
Last active November 1, 2023 21:58
Pure Python sequence query functions using Python 3.12+ generic type syntax
from typing import (
Sequence,
Iterable,
Callable
)
type Predicate[ T ] = Callable[ [ T ] , bool ]
type Converter[ TIn , TOut ] = Callable[ [ TIn ] , TOut ]
class QueryException( Exception ):