Skip to content

Instantly share code, notes, and snippets.

View LayZeeDK's full-sized avatar
🇩🇰
Denmark

Lars Gyrup Brink Nielsen LayZeeDK

🇩🇰
Denmark
View GitHub Profile
@LayZeeDK
LayZeeDK / _typescript-utility-types.md
Last active August 26, 2024 20:28
TypeScript utility types

TypeScript utility types

License (MIT)

Copyright 2024 Lars Gyrup Brink Nielsen

Permission is hereby granted, free of charge, to any person obtaining a copy of this software and associated documentation files (the "Software"), to deal in the Software without restriction, including without limitation the rights to use, copy, modify, merge, publish, distribute, sublicense, and/or sell copies of the Software, and to permit persons to whom the Software is furnished to do so, subject to the following conditions:

The above copyright notice and this permission notice shall be included in all copies or substantial portions of the Software.

THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT

@LayZeeDK
LayZeeDK / data-access-allowed-dependencies.md
Last active June 26, 2022 19:54
Nx library types: Allowed dependencies
%%{init: {'theme': 'base', 'themeVariables': { 'primaryColor': '#bad6db', 'primaryBorderColor': '#01a9c1', 'primaryTextColor': '#051f34', 'lineColor': '#051f34' }}}%%
graph TD
  data-access --> data-access
  data-access --> util
  data-access --> test-util
@LayZeeDK
LayZeeDK / nx-shared-domain-objects.md
Last active January 25, 2023 08:50
Dependency flow when sharing domain objects in an Nx workspac.e
graph TD;
  feature-->domain
  feature-->dataAccess[data-access]
  dataAccess-->domain
  feature-->ui
  ui-->domain
@LayZeeDK
LayZeeDK / direct-standalone-dependencies.md
Last active June 10, 2022 08:01
Indirect dependencies between components declared by NgModules. Standalone Angular components are easier to understand for both developers and compilers. "imports" means import statements in these diagrams.
  graph TD;
      A[ParentComponent]--imports-->B[ChildComponent];
@LayZeeDK
LayZeeDK / content-child.md
Last active September 16, 2023 21:35
Strict framework-injected properties in Angular components
flowchart TD
    A[ContentChild] --> B;
    B{Is static?} -- No --> C;
    B -- Yes --> D;
    C[Make the query<br>type optional] --> E(Access in<br>ngAfterContentInit<br>or later);
    D(Add assertion<br>in ngOnInit or<br>ngOnChanges) --> F;
    F[Add ! to<br>the query type] --> G(Access in<br>ngOnInit<br>or later)
@LayZeeDK
LayZeeDK / existing resource group with a few changes
Last active April 11, 2022 21:30
az deployment sub what-if
PS> az deployment sub what-if --location westeurope --template-file ./bicep/main.bicep
Note: The result may contain false positive predictions (noise).
You can help us improve the accuracy of the result by opening an issue here: https://aka.ms/WhatIfIssues
Resource and property changes are indicated with these symbols:
+ Create oviders/Microsoft
~ Modify
= Nochange
The deployment will update the following scopes
@LayZeeDK
LayZeeDK / mermaid-flowchart.md
Last active March 2, 2022 21:12
Mermaid Gist
flowchart TD
    A[Deploy to production] --> B{Is it Friday?};
    B -- Yes --> C[Do not deploy!];
    B -- No --> D[Run deploy.sh to deploy!]
    C ----> E[Enjoy your weekend!];
    D ----> E[Enjoy your weekend!];
@LayZeeDK
LayZeeDK / angular-member-ordering.md
Last active February 2, 2026 16:46
Ordering of Angular component class members.

Ordering of Angular component class members

Use the following order of groups to organize Angular components:

  1. Injected dependencies.
  2. Private properties.
  3. Data binding properties.
  4. View and content properties.
  5. UI properties.
  6. Component API properties.
  7. Constructor.
  8. Lifecycle hooks.
@LayZeeDK
LayZeeDK / breadcrumb.integration.spec.ts
Created February 11, 2021 21:06
Tane Piper: Auxiliary route test
import { HttpClientTestingModule } from '@angular/common/http/testing';
import { Component, Injectable, Input, OnDestroy } from '@angular/core';
import { ComponentFixture, TestBed, waitForAsync } from '@angular/core/testing';
import { By } from '@angular/platform-browser';
import { ActivatedRouteSnapshot, NavigationEnd, Route, Router } from '@angular/router';
import { RouterTestingModule } from '@angular/router/testing';
import { Subject } from 'rxjs';
import { filter, map, takeUntil, tap } from 'rxjs/operators';
interface Breadcrumb {
@LayZeeDK
LayZeeDK / my-log-driver\my-log-driver-config.token.ts
Last active March 13, 2021 17:46
Generate Lumberjack log driver with no custom options.
import { inject, InjectionToken } from '@angular/core';
import { LumberjackLogDriverConfig, lumberjackLogDriverConfigToken } from '@ngworker/lumberjack';
export const myLogDriverConfigToken = new InjectionToken<LumberjackLogDriverConfig>('__MY_LOG_DRIVER_CONFIG__', {
factory: () => inject(lumberjackLogDriverConfigToken),
});