Skip to content

Instantly share code, notes, and snippets.

View SimonPStevens's full-sized avatar

Simon P Stevens SimonPStevens

View GitHub Profile

Keybase proof

I hereby claim:

  • I am SimonPStevens on github.
  • I am simonpstevens (https://keybase.io/simonpstevens) on keybase.
  • I have a public key whose fingerprint is D70C DE6A 9EB7 6721 5CE5 34D7 A493 E691 EFD0 2F8A

To claim this, I am signing this object:

0x59D8C884971d58cb4845CC5c16dB77efEE5103A9
0x59D8C884971d58cb4845CC5c16dB77efEE5103A9
@SimonPStevens
SimonPStevens / RunOnceEnumerableExtensions.cs
Created July 8, 2017 21:13
An enumerable extension that can be used to ensure an IEnumerable<T> is only evaulated once.
namespace System.Collections.Generic
{
public static class RunOnceEnumerableExtensions
{
public static IRunOnceEnumerable<T> OnlyRunOnce<T>(this IEnumerable<T> source)
{
return new RunOnceEnumerable<T>(source);
}
public interface IRunOnceEnumerable<T> : IEnumerable<T>
@SimonPStevens
SimonPStevens / ForEachUntil.cs
Created June 21, 2017 20:38
A little for each helper to do for each loops either to the end or until a condition is met.
public static class ForEachHelper
{
public static void ForEachUntil<T>(IEnumerable<T> enumerable, Func<T, bool> until, Action<T> loopInner)
{
var enumerator = enumerable.GetEnumerator();
while (enumerator.MoveNext() && !until(enumerator.Current))
{
loopInner(enumerator.Current);
}
}
@SimonPStevens
SimonPStevens / .gitconfig
Last active March 8, 2021 21:48
Git Config
[core]
autocrlf = false
pager = less
[push]
default = tracking
[branch]
autosetupmerge = true
[color]
diff = auto
ui = auto