Snippets for http://fagner.co/2016/01/02/Defining-cross-cutting-concerns-using-the-MediatR-library/
param($installPath, $toolsPath, $package, $project) | |
$projectFullName = $project.FullName | |
Write-Host "Copying Docs folder to the root of the solution: $projectFullName" | |
$fileInfo = new-object -typename System.IO.FileInfo -ArgumentList $projectFullName | |
$projectDirectory = $fileInfo.DirectoryName | |
$sourceDirectory = "$installPath\docs" | |
Write-Host $sourceDirectory |
public IServiceProvider ConfigureServices(IServiceCollection services) | |
{ | |
// domainAssembly contains all IRequest<>, IRequestHandler<>, INotification, INotificationHandler<> implementations | |
var domainAssembly = typeof(RegulationEmailNotificationHandler).Assembly; | |
services.AddMediatR(domainAssembly); | |
// ContainerBuilder is from Autofac | |
var builder = new ContainerBuilder(); | |
let query = "daniel"; | |
let filter = { | |
logic: "or", | |
filters:[ | |
{ field: "FirstName", operator: "contains", value: query }, | |
{ field: "LastName", operator: "contains", value: query }, | |
{ field: "Email", operator: "contains", value: query }, | |
] | |
} |
; Full script for making an NSIS installation package for .NET programs, | |
; Allows installing and uninstalling programs on Windows environment, and unlike the package system | |
; integrated with Visual Studio, this one does not suck. | |
;To use this script: | |
; 1. Download NSIS (http://nsis.sourceforge.net/Download) and install | |
; 2. Save this script to your project and edit it to include files you want - and display text you want | |
; 3. Add something like the following into your post-build script (maybe only for Release configuration) | |
; "$(DevEnvDir)..\..\..\NSIS\makensis.exe" "$(ProjectDir)Setup\setup.nsi" | |
; 4. Build your project. |
internal class DockerMsSqlServerDatabase : IAsyncDisposable | |
{ | |
private const string Password = "!Passw0rd"; | |
private const string Image = "mcr.microsoft.com/mssql/server"; | |
private const string Tag = "2019-GA-ubuntu-16.04"; | |
private static IContainer _sqlServerContainer; | |
private SemaphoreSlim semaphore = new(1, 1); | |
private readonly string DatabaseName; |
module StateMachine = | |
type State<'Event> = | |
| Next of ('Event -> State<'Event>) | |
| Stop | |
let feed state event = | |
match state with | |
| Stop -> failwith "Terminal state reached" | |
| Next handler -> event |> handler |
On my RetroPie machine I wanted a hardware volume knob — the games I play use a handful of emulators, and there's no unified software interface for controlling the volume. The speakers I got for my cabinet are great, but don't have their own hardware volume knob. So with a bunch of googling and trial and error, I figured out what I need to pull this off: a rotary encoder and a daemon that listens for the signals it sends.
A rotary encoder is like the standard potentiometer (i.e., analog volume knob) we all know, except (a) you can keep turning it in either direction for as long as you want, and thus (b) it talks to the RPi differently than a potentiometer would.
I picked up this one from Adafruit, but there are plenty others available. This rotary encoder also lets you push the knob in and treats that like a button press, so I figured that would be useful for toggling mute on and off.