Skip to content

Instantly share code, notes, and snippets.

View PatrickKalkman's full-sized avatar

Patrick Kalkman PatrickKalkman

View GitHub Profile
@Pipe({
name: 'duration',
pure: true
})
export class DurationPipe implements PipeTransform {
transform(value: any): any {
const { min, sec } = parseDuration(value);
return `${min}m${padTime(sec)}s`;
}
}
@PatrickKalkman
PatrickKalkman / dashboard.js
Created December 4, 2021 07:01
Enabling OnPush strategy on a component
@Component({
selector: 'app-dashboard',
templateUrl: './dashboard.component.html',
styleUrls: ['./dashboard.component.scss'],
changeDetection: ChangeDetectionStrategy.OnPush
})
@PatrickKalkman
PatrickKalkman / angular
Created November 28, 2021 14:22
Angular structure
- app
-- core
-- features
-- shared
-- styles
-- assets
@PatrickKalkman
PatrickKalkman / ckad-2.yaml
Created November 23, 2021 11:25
CKAD examples
apiVersion: v1
kind: Pod
metadata:
creationTimestamp: null
labels:
run: MyPod
name: MyPod
namespace: fire
spec:
containers:
@PatrickKalkman
PatrickKalkman / ckad-1.yaml
Created November 23, 2021 11:21
CKAD examples
apiVersion: v1
data:
database_host: 192.168.16.1
kind: ConfigMap
metadata:
creationTimestamp: null
name: MyConfigMap
namespace: fire
@PatrickKalkman
PatrickKalkman / program.cs
Created June 20, 2021 18:00
Default configuration using the CreateDefaultBuilder
public class Program
{
public static void Main(string[] args)
{
CreateHostBuilder(args).Build().Run();
}
public static IHostBuilder CreateHostBuilder(string[] args) =>
Host.CreateDefaultBuilder(args).ConfigureWebHostDefaults(webBuilder =>
{
@PatrickKalkman
PatrickKalkman / HealthController.cs
Created June 20, 2021 17:46
Adding logging to the health check controller
[ApiController]
[Route("[controller]")]
public class HealthCheckController : ControllerBase
{
private readonly ILogger<HealthCheckController> _logger;
public HealthCheckController(ILogger<HealthCheckController> logger)
{
_logger = logger;
}
@PatrickKalkman
PatrickKalkman / healthcheckcontroller.cs
Created June 20, 2021 16:15
Controller that receives the health check request
[ApiController]
[Route("[controller]")]
public class HealthCheckController : ControllerBase
{
private readonly ILogger<HealthCheckController> _logger;
public HealthCheckController(ILogger<HealthCheckController> logger)
{
_logger = logger;
}
@PatrickKalkman
PatrickKalkman / Dockerfile
Created June 20, 2021 16:09
A dockerfile that contains a health check
# We use the alpine as base image
FROM mcr.microsoft.com/dotnet/aspnet:5.0-alpine-amd64
# Perform the health check call via curl
HEALTHCHECK --interval=5s --timeout=3s CMD curl --fail http://localhost/healthcheck || exit 1
RUN apk --update --no-cache add curl
# Create a group and usermcr.microsoft.com/dotnet/runtime
RUN addgroup --gid 1000 -S app && adduser --uid 1000 -S app -G app
@PatrickKalkman
PatrickKalkman / program.cs
Created June 20, 2021 13:20
Handling SIGINT & SIGTERM
class Program
{
static async Task Main(string[] args)
{
AppDomain.CurrentDomain.ProcessExit += (_, _) =>
{
Console.WriteLine("Received SIGTERM");
};
Console.CancelKeyPress += (_, _) =>