Skip to content

Instantly share code, notes, and snippets.

View dcagnetta's full-sized avatar

Dillan Cagnetta dcagnetta

View GitHub Profile
@dcagnetta
dcagnetta / azure-pipelines-api.yml
Created July 17, 2023 07:57
Docker extract files from container
- task: Docker@2
displayName: 'Build Api image'
inputs:
containerRegistry: '$(dockerRegistry)'
repository: '$(dockerHub)/$(imageName)'
Dockerfile: '$(workingDirectory)/Dockerfile-Api'
tags: |
$(tag)
latest
addPipelineData: false
@dcagnetta
dcagnetta / gist:d50e12bf6a06ef12ade0ea8dafb3cf26
Created September 14, 2022 13:23
Angular Async Validation
this.form = this.formBuilder.group({
code: ['',
[Validators.required, Validators.pattern('^[A-Za-z0-9]{4}')],
this.asyncCodeValidator.validate(),
]
});
@Injectable({ providedIn: 'root' })
export class AsyncCodeValidatorService {
@dcagnetta
dcagnetta / Directory.Build.props
Created August 16, 2022 13:34
Directory.Build Files
<Project>
<PropertyGroup>
<TargetFramework>netcoreapp3.1</TargetFramework>
</PropertyGroup>
<PropertyGroup Label="Settings">
<!--produce an assembly whose byte-for-byte output is identical across compilations for identical inputs.-->
<Deterministic>true</Deterministic>
<DebugSymbols>true</DebugSymbols>
<!--Emit debugging information into the .dll-->
@dcagnetta
dcagnetta / Program.cs
Last active August 15, 2022 08:15
C# – How to supply IOptions
read configuration settings before initializing a Host in ASP .NET Core?
https://stackoverflow.com/questions/58530942/how-to-read-configuration-settings-before-initializing-a-host-in-asp-net-core#_=_
@dcagnetta
dcagnetta / app.component.html
Created May 24, 2022 09:09
Control Value Accessor
<button (click)="updateValue(+value - 1)">-</button>
<input [ngModel]="value"
(ngModelChange)="updateValue($event)"
type="string">
<button (click)="updateValue(+value + 1)">+</button>
<PropertyGroup Label="Settings">
<!--produce an assembly whose byte-for-byte output is identical across compilations for identical inputs.-->
<Deterministic>true</Deterministic>
<DebugSymbols>true</DebugSymbols>
<!--Emit debugging information into the .dll-->
<DebugType>embedded</DebugType>
<MinVerSkip Condition="'$(Configuration)' == 'Debug'">true</MinVerSkip>
<MinVerVerbosity>detailed</MinVerVerbosity>
<IsPackable>false</IsPackable>
</PropertyGroup>
@dcagnetta
dcagnetta / DbRepository.cs
Created March 27, 2022 12:43
IDisposable Pattern
public class DbRepository : IDisposable
{
public IDbConnection Connection { get; set; }
private bool _disposedValue;
protected virtual void Dispose(bool disposing)
{
if (!_disposedValue)
{
if (disposing)
@dcagnetta
dcagnetta / GetUninitializedObject.cs
Created February 11, 2022 08:41
Create new instance without the constructor
var someclass = (SomeClass) FormatterServices.GetUninitializedObject(typeof(SomeClass));
@dcagnetta
dcagnetta / TracerProvicerExtensions.cs
Created February 4, 2022 08:18
C# Configuration Extensions example
namespace OpenTelemetry.Trace
{
/// <summary>
/// Extension methods to simplify registering of dependency instrumentation.
/// </summary>
public static class TracerProviderBuilderExtensions
{
/// <summary>
/// Enables Microsoft.EntityFrameworkCore instrumentation.
/// </summary>
@dcagnetta
dcagnetta / some-service.providers.ts
Last active April 13, 2021 00:35
ANGULAR STREAMLINE PROVIDERS
// token to access a stream with the organisation information we need
// this is what we inject e.g. @Inject(ORG_INFO) readonly orgInfo$: Observable<string>
export const ORG_INFO = new InjectionToken<Observable<string>>(
'Organisation name information'
);
// This is what we add to `providers` array in module or component
export const ORGANISATION_PROVIDERS: Provider[] = [
{
provide: ORG_INFO,