This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
// somewhere early in App.xaml.cs | |
AppDomain.CurrentDomain.UnhandledException += (s, e) => | |
LogUnhandledException((Exception) e.ExceptionObject, "AppDomain.CurrentDomain.UnhandledException"); | |
DispatcherUnhandledException += (s, e) => | |
LogUnhandledException(e.Exception, "Application.Current.DispatcherUnhandledException"); | |
TaskScheduler.UnobservedTaskException += (s, e) => | |
LogUnhandledException(e.Exception, "TaskScheduler.UnobservedTaskException"); |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
public class ConcurrentList<T> : IList<T>, IDisposable | |
{ | |
private ReaderWriterLockSlim _lock = new ReaderWriterLockSlim(LockRecursionPolicy.SupportsRecursion); | |
private int _count = 0; | |
public int Count | |
{ | |
get | |
{ | |
_lock.EnterReadLock(); |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
public static class SftpExtensions | |
{ | |
/// <remarks> | |
/// unfortunately the ssh library doesn't expose a modern async api | |
/// that supports cancellation via CancellationToken | |
/// so we have to wrap the APM pattern with a TaskCompletionSource | |
/// </remarks> | |
public static Task UploadFileAsync(this SftpClient sftpClient, Stream input, string path, bool canOverride, Action<ulong> uploadCallback = null, CancellationToken cancellationToken = default(CancellationToken)) | |
{ | |
var tcs = new TaskCompletionSource<SftpUploadAsyncResult>(); |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
internal static IEnumerable<string> ReadLines(this string s) | |
{ | |
string line; | |
using (var sr = new StringReader(s)) | |
while ((line = sr.ReadLine()) != null) | |
yield return line; | |
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
<script> | |
// loop over all "up-down" elements | |
for(let ud of document.querySelectorAll('span[id$=ud]')) | |
{ | |
// reflect that it is already expanded | |
ud.className = 'arrow-up'; | |
// derive the expandable element's id | |
let id = ud.id.substring(0, ud.id.length - 2); |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
public static class JaroWinklerDistance | |
{ | |
/* The Winkler modification will not be applied unless the | |
* percent match was at or above the mWeightThreshold percent | |
* without the modification. | |
* Winkler's paper used a default value of 0.7 | |
*/ | |
private const double WeightThreshold = 0.7; | |
/* Size of the prefix to be concidered by the Winkler modification. |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
var ch = Channel.CreateUnbounded<int>(); | |
var producer = Task.Run(() => | |
{ | |
for (int i = 0; i < 500_000; i++) | |
ch.Writer.WriteAsync(i); | |
ch.Writer.Complete(); | |
}); |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
### Keybase proof | |
I hereby claim: | |
* I am ronnieoverby on github. | |
* I am ronnieoverby (https://keybase.io/ronnieoverby) on keybase. | |
* I have a public key ASCXPI6o5jpbNT7RowJ7h_vBeGh0pzcksHwfhqWFQNVxUgo | |
To claim this, I am signing this object: |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
https://docs.microsoft.com/en-us/dotnet/visual-basic/programming-guide/language-features/data-types/value-types-and-reference-types | |
https://jonskeet.uk/csharp/references.html | |
http://www.albahari.com/valuevsreftypes.aspx |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
https://docs.microsoft.com/en-us/dotnet/visual-basic/programming-guide/language-features/data-types/value-types-and-reference-types | |
https://jonskeet.uk/csharp/references.html | |
http://www.albahari.com/valuevsreftypes.aspx |
NewerOlder