Skip to content

Instantly share code, notes, and snippets.

View duanenewman's full-sized avatar

Duane Newman duanenewman

View GitHub Profile
@duanenewman
duanenewman / LinqPad.cs
Created February 19, 2019 17:17
Concurrent Reads and Locked Writes with In-Memory Objects
static Random rnd = new Random();
void Main()
{
NoLocking();
UsingReadUpdateLocker();
UsingInstanceReadUpdateLocker();
@duanenewman
duanenewman / StopwatchTaskExtension.linq
Created December 4, 2018 20:56
Timing Task execution as an extension method
<Query Kind="Program">
<Namespace>System</Namespace>
<Namespace>System.Collections.Generic</Namespace>
<Namespace>System.Text</Namespace>
<Namespace>System.Threading.Tasks</Namespace>
</Query>
void Main()
{
@duanenewman
duanenewman / BoxStarterScript.ps1
Last active January 25, 2018 18:54
New Dev Machine Boxstarter Script
# START http://boxstarter.org/package/nr/url?https://gist.githubusercontent.com/duanenewman/1a71fae24da1e64df14113c9de8f2ade/raw/d2837a391dc24e186262ff1f505911ced6066e51/BoxStarterScript.ps1
#
# Boxstarter options
$Boxstarter.RebootOk=$true # Allow reboots?
$Boxstarter.NoPassword=$false # Is this a machine with no login password?
$Boxstarter.AutoLogin=$true # Save my password securely and auto-login after a reboot
#### .NET 3.5 ####
@duanenewman
duanenewman / gist:c84086e30ab7955322fe
Created July 17, 2015 15:07
TakePreviousAndNext for IEnumerable<T>
/// <summary>
/// Searches a sequence for an element and returns the elements before and after the matched element.
/// </summary>
/// <typeparam name="T">The type of the elements of source.</typeparam>
/// <param name="source">The sequence to search</param>
/// <param name="predicate">A function to test each element for a condition.</param>
/// <returns>Returns the elements before and after the element that satisfies a specified condition.</returns>
/// <exception cref="System.ArgumentNullException">source or predicate is null</exception>
/// <exception cref="System.InvalidOperationException">No element satisfies the condition in predicate.-or-The source sequence is empty.</exception>
public static Tuple<T, T> TakePreviousAndNext<T>(this IEnumerable<T> source, Func<T, bool> predicate)

Keybase proof

I hereby claim:

  • I am duanenewman on github.
  • I am duanenewman (https://keybase.io/duanenewman) on keybase.
  • I have a public key whose fingerprint is 1B5C 62C8 81C9 CC6A D7AC A4EF 39DC 89B2 FF7C FAF9

To claim this, I am signing this object: