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
// Csproj: <PackageReference Include="Microsoft.Windows.CsWin32" Version="0.1.588-beta" PrivateAssets="all" /> | |
// NativeMethods.txt: GetLastInputInfo | |
using System; | |
using System.Threading; | |
using Windows.Win32; | |
using Windows.Win32.UI.KeyboardAndMouseInput; | |
public sealed class InactivityWatcher : IDisposable | |
{ |
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
MIT License | |
Copyright (c) 2021 Joseph Musser | |
Permission is hereby granted, free of charge, to any person obtaining a copy | |
of this software and associated documentation files (the "Software"), to deal | |
in the Software without restriction, including without limitation the rights | |
to use, copy, modify, merge, publish, distribute, sublicense, and/or sell | |
copies of the Software, and to permit persons to whom the Software is | |
furnished to do so, subject to the following conditions: |
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
using Microsoft.Win32.SafeHandles; | |
using System; | |
using System.ComponentModel; | |
using System.IO; | |
using System.Runtime.InteropServices; | |
internal static class AlternateDataStream | |
{ | |
/// <summary> | |
/// <para> |
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
using System; | |
using System.Threading; | |
using System.Threading.Tasks; | |
using System.Windows; | |
public static class GuaranteedCleanup | |
{ | |
private static readonly ManualResetEventSlim CleanupFinished = new(); | |
private static readonly CancellationTokenSource ShutdownStarted = new(); | |
private static int cleanupTaskCount; |
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
using System; | |
using System.Threading; | |
using System.Threading.Tasks; | |
/// <summary> | |
/// Guarantees that a <see cref="Func{T1, TResult}"/> will never be invoked more than once. | |
/// </summary> | |
public sealed class OneTimeTask<T1, TResult> | |
{ | |
private Func<T1, TResult>? resultFactory; |
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
using System; | |
using System.Diagnostics; | |
/// <summary> | |
/// Defers <see cref="decimal"/> division so that intermediate results such as 1/3 can later be combined with other | |
/// results such as multiplying by 3 to obtain a lossless final result of <c>1</c> rather than <c>0.99999…</c>. | |
/// </summary> | |
[DebuggerDisplay("{" + nameof(ToString) + "(),nq}")] | |
public readonly struct DecimalRational : IEquatable<DecimalRational>, IComparable<DecimalRational> | |
{ |
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
$youtubeDl = Join-Path $PSScriptRoot 'youtube-dl.exe' | |
$ffmpeg = Join-Path $PSScriptRoot 'ffmpeg.exe' | |
$ErrorActionPreference = 'Stop' | |
if (-not (Test-Path $youtubeDl)) { | |
Write-Host 'Downloading youtube-dl...' | |
Invoke-WebRequest 'https://youtube-dl.org/downloads/latest/youtube-dl.exe' -OutFile $youtubeDl | |
} |
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
using Microsoft.CodeAnalysis; | |
using Microsoft.CodeAnalysis.CSharp; | |
using Microsoft.CodeAnalysis.CSharp.Syntax; | |
using Microsoft.CodeAnalysis.Text; | |
using System; | |
using System.IO; | |
using System.IO.Enumeration; | |
using System.Linq; | |
var searchPath = Path.Join(Environment.GetFolderPath(Environment.SpecialFolder.UserProfile), @"Source\Repos"); |
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
using System.IO; | |
namespace Techsola.InstantReplay | |
{ | |
partial class GifWriter | |
{ | |
private struct GifImageDataChunker | |
{ | |
const byte MaxChunkLength = 255; |
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
using System; | |
using System.Linq; | |
using Microsoft.CodeAnalysis; | |
internal static class INamespaceOrTypeSymbolExtensions | |
{ | |
/// <summary> | |
/// Checks the full name of a type or namespace without incurring the expense of building a full name string. | |
/// </summary> | |
public static bool HasFullName(this INamespaceOrTypeSymbol symbol, params string[] segments) |