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 DistinctSubject<T> : SubjectBase<T> | |
{ | |
// based on https://github.com/dotnet/reactive/blob/main/Rx.NET/Source/src/System.Reactive/Subjects/BehaviorSubject.cs | |
// also: https://stackoverflow.com/q/69239022/1768303 | |
// TODO: unit tests | |
private object _lock = new(); | |
private T _value; | |
private readonly EqualityComparer<T> _comparer; |
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://stackoverflow.com/q/69207420/1768303 | |
#nullable enable | |
using System; | |
using System.Diagnostics; | |
using System.Linq; | |
using Microsoft.Extensions.DependencyInjection; | |
namespace App | |
{ | |
static class Program |
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.Collections.Generic; | |
using System.Diagnostics; | |
using System.Linq; | |
using System.Reactive.Linq; | |
using System.Threading.Tasks; | |
static async IAsyncEnumerable<int> Produce() | |
{ | |
for (int i = 0; i < 10; i++) |
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
<Project Sdk="Microsoft.NET.Sdk"> | |
<PropertyGroup> | |
<TargetFramework>net5.0-windows</TargetFramework> | |
<OutputType>Exe</OutputType> | |
<DisableWinExeOutputInference>true</DisableWinExeOutputInference> | |
<UseWPF>true</UseWPF> | |
<UsingMicrosoftNETSdkWeb>true</UsingMicrosoftNETSdkWeb> | |
<StartupObject>WebView2AppKeys.Program</StartupObject> |
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
@echo off | |
set folders=bin obj .vs | |
echo This will delete all [%folders%] folders recursively and cannot be undone. | |
choice /t 10 /d n /c yn /m "Press Y to continue, N to stop" | |
if %errorLevel% neq 1 goto :EOF | |
for /d /r . %%D in (%folders%) do if exist "%%~fD\" (echo %%D && rd "%%~fD" /s /q) |
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
@echo off | |
set folders=node_modules | |
echo This will delete all [%folders%] folders recursively and cannot be undone. | |
choice /t 10 /d n /c yn /m "Press Y to continue, N to stop" | |
if %errorLevel% neq 1 goto :EOF | |
for /d /r . %%D in (%folders%) do if exist "%%~fD\" (echo %%D && rd "%%~fD" /s /q) |
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
import kotlinx.coroutines.* | |
suspend fun suspendableDelay(ms: Long): Long { | |
delay(ms); | |
return ms; | |
} | |
fun regularDelay(ms: Long): Deferred<Long> { | |
val d = CompletableDeferred<Long>() | |
GlobalScope.async { delay(ms); d.complete(ms) } |
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://try.dot.net/?bufferId=trydotnet.cs&fromGist=717d378bc9f14db1ed30d0e2e67b0534 | |
// async/await doesn't work on try.dot.net, an open issue since Oct 2019: | |
// https://github.com/dotnet/try/issues/527 | |
using System; | |
using System.Threading.Tasks; | |
public class Program | |
{ | |
public static async Task Main() | |
{ | |
Console.WriteLine("Hello..."); |
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
Add an option to use the existing Xorg session with | |
chrome-remote-desktop. | |
The original idea of the patch: https://superuser.com/a/850359 | |
--- a/chrome-remote-desktop 2021-04-05 11:53:16.537908500 +0000 | |
+++ b/chrome-remote-desktop 2021-04-05 12:04:52.768536483 +0000 | |
@@ -107,6 +107,8 @@ | |
X_LOCK_FILE_TEMPLATE = "/tmp/.X%d-lock" | |
FIRST_X_DISPLAY_NUMBER = 20 |
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
if (!EventTarget.prototype.addDisposableEventListener) { | |
EventTarget.prototype.addDisposableEventListener = function(type, listener, options) { | |
this.addEventListener(type, listener, options); | |
return () => this.removeEventListener(type, listener); | |
} | |
} | |
const dispose = document.body.addDisposableEventListener( | |
'click', () => console.log('clicked!')); | |
try { |