Skip to content

Instantly share code, notes, and snippets.

View appie2go's full-sized avatar

Albert Starreveld appie2go

View GitHub Profile
@appie2go
appie2go / create-and-run-proxy.sh
Last active August 1, 2024 17:33
create-and-run-angular-spa+proxy
# ---------------------------------------------------------------------------
# Prerequisites:
# - .NET 8 SDK @ https://dotnet.microsoft.com/en-us/download/dotnet/8.0
# - NodeJS @ https://nodejs.org/en/download/package-manager
# - Angular 18 CLI @ https://angular.dev/tools/cli/setup-local
# ---------------------------------------------------------------------------
# Download and install the template pack first
dotnet new install OidcProxy.Net.Templates
@appie2go
appie2go / create-and-run-proxy.sh
Last active August 1, 2024 17:31
run oidcproxy
# ---------------------------------------------------------------------------
# Prerequisites:
# - .NET 8 SDK @ https://dotnet.microsoft.com/en-us/download/dotnet/8.0
# ---------------------------------------------------------------------------
# Download and install the template pack first
dotnet new install OidcProxy.Net.Templates
# Scaffold the proxy
dotnet new OidcProxy.Net --backend "https://api.myapp.com"
@appie2go
appie2go / StoredProcedureTest.cs
Created February 17, 2023 21:02
StoredProcedureTest.cs
using System;
using System.Collections.Generic;
using System.Threading.Tasks;
using DotNet.Testcontainers.Builders;
using DotNet.Testcontainers.Containers;
using FluentAssertions;
using Foo.Data;
using Foo.Data.QueryHandlers;
using Microsoft.EntityFrameworkCore;
var connectionString = "Server=127.0.0.1;Database=test;User Id=sa;Password=nunajabeezwax;TrustServerCertificate=True";
var options = new DbContextOptionsBuilder<BookContext>()
.UseSqlServer(connectionString)
.Options;
using var context = new BookContext(options);
context.Database.MigrateAsync();
@appie2go
appie2go / unittest.cs
Created February 17, 2023 18:44
unittest.cs
using System;
using System.Threading.Tasks;
namespace Foo.Tests;
public class MyUnitTestWithTestContainers : IAsyncLifetime
{
public async Task InitializeAsync()
{
// This is your async setup. You can start your testcontainer here.
@appie2go
appie2go / startcontainer.cs
Last active February 17, 2023 18:30
startcontainer.cs
var dockerContainer = new ContainerBuilder()
.WithName(Guid.NewGuid().ToString("D"))
.WithImage("mcr.microsoft.com/mssql/server:2022-latest")
.WithPortBinding(1433, 1433)
.WithEnvironment(new Dictionary<string, string>()
{
{ "ACCEPT_EULA", "Y" },
{ "MSSQL_SA_PASSWORD", "nunnajabeezwax" }
})
.Build();
@appie2go
appie2go / CustomVision.cs
Created February 13, 2023 15:35
CustomVision.cs
using Microsoft.Azure.CognitiveServices.Vision.CustomVision.Prediction;
namespace CS;
public class ImageClassifier
{
private readonly string _endpoint;
private readonly string _key;
public ImageClassifier(string endpoint, string key)
@appie2go
appie2go / ImageClassification.cs
Created February 13, 2023 15:09
ImageClassification.cs
using Microsoft.Azure.CognitiveServices.Vision.ComputerVision;
using Microsoft.Azure.CognitiveServices.Vision.ComputerVision.Models;
namespace Foo;
public class ImageClassifier
{
private readonly string _endpoint;
private readonly string _key;
public class DriveCustomerToTrainStationFailedHandler : IHandleMessages<DriveCustomerToTrainStationFailed>
{
public IBus _messageBus;
public IMap<DriveCustomerToTrainStationFailed, ArrangeAlternativeTransport> _arrangeAlternativeTransportMapper;
public IMap<DriveCustomerToTrainStationFailed, UpdateCabRideQueryModel> _updateCabRideQueryModelMapper;
public DriveCustomerToTrainStationFailedHandler(IBus messageBus,
IMap<DriveCustomerToTrainStationFailed, ArrangeAlternativeTransport> arrangeAlternativeTransport,
IMap<DriveCustomerToTrainStationFailed, UpdateCabRideQueryModel> updateCabRideQueryModel)
{
public async Task Handle(DriveCustomerToTrainStation command)
{
var location = _commandMapper.MapLocation(command.Location);
var customerId = _commandMapper.MapCustomerId(command.CustomerId);
try
{
var cabRide = await _cabRideService.BringCustomerToTheTrainStation(customerId);
DroveCustomerToTrainStation @event = _commandMapper.MapSuccessEvent(cabRide);
await _messageBus.Publish(@event);