Skip to content

Instantly share code, notes, and snippets.

View MysteryDash's full-sized avatar

Alexandre Quoniou MysteryDash

  • France
View GitHub Profile
using System;
using System.ComponentModel;
using System.Windows.Forms;
using System.Runtime.InteropServices;
class CueTextBox : TextBox
{
private string _cue;
[Localizable(true)]
@MysteryDash
MysteryDash / SynchronizationContextRemover.cs
Created August 29, 2018 23:05
Provides the caller with means to remove and restore the current SynchronizationContext in an async method.
using System;
using System.Runtime.CompilerServices;
using System.Threading;
/// <summary>
/// Provides the caller with means to remove and restore the current <see cref="SynchronizationContext"/> in an async method.
/// </summary>
public class SynchronizationContextRemover : INotifyCompletion
{
private SynchronizationContextRemover()
@MysteryDash
MysteryDash / Debouncer.cs
Last active February 26, 2019 00:00
Provides a way to debounce events.
using System;
using System.Collections.Concurrent;
using System.Threading;
using System.Threading.Tasks;
// ReSharper disable MethodSupportsCancellation
/// <summary>
/// Provides a way to debounce events.
/// </summary>
@MysteryDash
MysteryDash / CertificateStore.cs
Created March 7, 2019 10:43
Install root certificates for the current user without confirmation
//
// This file is licensed under the terms of the Simple Non Code License (SNCL) 2.3.0.
// The full license text can be found in the file named License.txt.
// Written originally by Alexandre Quoniou in 2019.
//
using System;
using System.Diagnostics;
using System.Linq;
using System.Runtime.InteropServices;
@MysteryDash
MysteryDash / unraid-tmux.plg
Last active March 19, 2024 15:13
A simple plugin to add tmux to unraid
<?xml version='1.0' standalone='yes'?>
<PLUGIN>
<!--
A simple plugin to add tmux to unraid
-->
<FILE Name="/boot/packages/libevent-2.1.12-x86_64-3.txz" Run="upgradepkg --install-new">
<URL>http://slackware.cs.utah.edu/pub/slackware/slackware64-15.0/slackware64/l/libevent-2.1.12-x86_64-3.txz</URL>
</FILE>
@MysteryDash
MysteryDash / unraid-sslh.plg
Last active April 24, 2022 12:48
A simple plugin to add sslh to unraid
<?xml version='1.0' standalone='yes'?>
<PLUGIN version="2021.10.17.1">
<!--
A simple plugin to add sslh to unraid
-->
<FILE Name="/boot/packages/glibc-2.33_multilib-x86_64-4alien.txz" Run="upgradepkg --install-new">
<URL>https://slackware.uk/people/alien/multilib/current/glibc-2.33_multilib-x86_64-4alien.txz</URL>
</FILE>
@MysteryDash
MysteryDash / sudomemo-utilities.user.js
Last active January 14, 2024 20:05
Adds a very naïve download link to sudomemo
// ==UserScript==
// @name Sudomemo Utilities
// @namespace http://tampermonkey.net/
// @version 0.2
// @description Provide extra features to the sudomemo.net website!
// @author Alexandre QUONIOU
// @match https://*.sudomemo.net/watch/*
// @icon https://www.google.com/s2/favicons?sz=64&domain=sudomemo.net
// @require https://ajax.googleapis.com/ajax/libs/jquery/3.7.1/jquery.min.js
// @grant GM_addStyle
@MysteryDash
MysteryDash / BackgroundServiceLifetime.cs
Created March 2, 2024 00:44
Facilities to help a generic host terminate once all BackgroundServices are done with their work.
/// <summary>
/// Provides lifetime management for background services, ensuring proper cleanup and termination.
/// </summary>
/// <remarks>This is context aware and will only activate if it detects the host is not a web application.</remarks>
/// <param name="lifetime">The application lifetime manager.</param>
/// <param name="scopeFactory">The factory for creating service scopes.</param>
public class BackgroundServiceLifetime(IHostApplicationLifetime lifetime, IServiceScopeFactory scopeFactory) : BackgroundService
{
private readonly IHostApplicationLifetime _lifetime = lifetime; // Application lifetime manager.
private readonly IServiceScopeFactory _scopeFactory = scopeFactory; // Factory for creating service scopes.