Dependency Injection With Multiple Implementations Of The Same Interface

public void ConfigureServices(IServiceCollection services)
  services.AddTransient<Func<MathOperationType, IMathOperationRepository>>(serviceProvider => key =>
    switch (key)
      case MathOperationType.Add:
        return serviceProvider.GetService<AddOperationRepository>();
      case MathOperationType.Subtract:
        return serviceProvider.GetService<SubtractOperationRepository>();
      case MathOperationType.Multiply:
        return serviceProvider.GetService<MultiplyOperationRepository>();
      case MathOperationType.Divide:
        return serviceProvider.GetService<DivideOperationRepository>();
        throw new KeyNotFoundException();
  . . .

public class ValuesController : ControllerBase  
  private Func<MathOperationType, IMathOperationRepository> _mathRepositoryDelegate;  
  public ValuesController(Func<MathOperationType, IMathOperationRepository> mathRepositoryDelegate)  
    _mathRepositoryDelegate = mathRepositoryDelegate;  
  public ActionResult<OperationResult> Post([FromBody] OperationRequest opRequest)  
    IMathOperationRepository mathRepository = _mathRepositoryDelegate(opRequest.OperationType);  
    OperationResult opResult = mathRepository.PerformOperation(opRequest);  
    return new ObjectResult(opResult);  


Enable CORS in .NET Core Web API

// Startup.cs

public void ConfigureServices(IServiceCollection services)
        // ...
        // ...

public void Configure(IApplicationBuilder app, IApiVersionDescriptionProvider provider)
        // ...
        // ...

readonly string MyAllowSpecificOrigins = "_myAllowSpecificOrigins";
private void CorsConfig(IApplicationBuilder app)
private void CorsConfig(IServiceCollection services)
    services.AddCors(options =>
        builder =>

edit git commit details

git rebase -i 0abc12def // <- the commit before the one that needs edit
// use vi to change "pick" to "edit" on the commit(s) that need edits, then write/quit
git commit --amend --author="Christopher Snay <>"
// write/quit vi
git rebase --continue // <- repeat until all edited commits complete
git push -f

Angular setup

ng new projectname
cd projectname
sudo npm install --save @angular/material @angular/cdk @angular/animations
npm install hammerjs
ng generate component componentname
ng generate service servicename

Retrying (Retry(total=0, connect=None, read=None, redirect=None, status=None)) after connection broken by ‘SSLError(SSLError(1, u'[SSL: CERTIFICATE_VERIFY_FAILED] certificate verify failed (_ssl.c:726)’),)’: /simple/pylint/ >>>>>>>> Could not fetch URL There was a problem confirming the ssl certificate: HTTPSConnectionPool(host=’’, port=443): Max retries exceeded with url: /simple/setuptools/ (Caused by SSLError(SSLError(1, u'[SSL: CERTIFICATE_VERIFY_FAILED] certificate verify failed (_ssl.c:726)’),)) – skipping

// add the following flag to the pip command:

--trusted-host --trusted-host

// or wherever the error indicates a problem in

HTTPSConnectionPool(host='', port=443)

compare 2 files with Visual Studio

// open cmd
<<<path to Visual Studio\Common7\IDE>>>devenv /diff file1 file2

Or just create a batch file. Example:

@echo off
echo Drag and drop the first file onto this window. Then press [ENTER]
set /p file1=
echo Drag and drop the second file onto this window. Then press [ENTER]
set /p file2=
"C:\Program Files (x86)\Microsoft Visual Studio 11.0\Common7\IDE\devenv.exe" /diff %file1% %file2%