Skip to content

Instantly share code, notes, and snippets.

View alexfoxgill's full-sized avatar

Alex Fox Gill alexfoxgill

View GitHub Profile
@alexfoxgill
alexfoxgill / day1.rs
Created December 1, 2022 09:02
AoC 2022 Day 1: Rust
use std::fs;
fn load_vec(path: &str) -> Vec<String> {
fs::read_to_string(path)
.expect("Could not read file")
.split('\n')
.map(|x| String::from(x))
.collect()
}
@alexfoxgill
alexfoxgill / FizzBuzzWoof.fs
Last active March 3, 2016 12:13
Small F# script demonstrating extensible FizzBuzz implementation
let combine fs x y = Seq.fold (fun acc f -> acc || f x y) false fs
let matcher f (n, msg) i =
if f n i then
Some msg
else
None
module Option =
let combine op a b =
@alexfoxgill
alexfoxgill / gist:f4d122781e75b4b5dac2
Last active August 29, 2015 14:22
Runtime context dependent proxy switcher proposal for Simple Injector
container.RegisterRuntimeProxy<ITestGuard>(context =>
new TestGuardSwitcher(() =>
context.Ancestors().Any(x => x.ImplementationType == typeof(TestController))
? new NullTestGuard()
: new OtherTestGuard());
class TestGuardSwitcher : ITestGuard
{
public TestGuardSwitcher(Func<ITestGuard> switcher)
{
@alexfoxgill
alexfoxgill / AutoPropertyDataAttribute.cs
Last active March 7, 2022 15:53
Combine xUnit's PropertyData with AutoFixture
public class AutoPropertyDataAttribute : DataAttribute
{
private readonly string _propertyName;
private readonly Func<IFixture> _createFixture;
public AutoPropertyDataAttribute(string propertyName)
: this(propertyName, () => new Fixture())
{ }
protected AutoPropertyDataAttribute(string propertyName, Func<IFixture> createFixture)