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 / 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
Created March 18, 2021 21:53
Ordering of Angular component class members.

Ordering of Angular component class members

Use the following order of groups to organize Angular components:

  1. Private properties.
  2. Data binding properties.
  3. View and content properties.
  4. UI properties.
  5. Component API properties.
  6. Constructor.
  7. Lifecycle hooks.
  8. Event handlers.
@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),
});
import { Injectable, Inject } from '@angular/core';
import { configToken } from './config.token';
import { Config } from './config';
@Injectable({
providedIn: 'any', // 👈 Tree-shakable, only bundled if used
})
export class ConfigService {
constructor(@Inject(configToken) private config: Config) {
@LayZeeDK
LayZeeDK / auth.guard.integration.spec.ts
Created September 9, 2020 14:33
AuthGuard: Integrated route guard test suite.
import { Location } from '@angular/common';
import { Component, Injectable, NgModule, NgZone } from '@angular/core';
import { TestBed } from '@angular/core/testing';
import { Router, RouterModule, Routes } from '@angular/router';
import { RouterTestingModule } from '@angular/router/testing';
import { of } from 'rxjs';
import { AuthGuard } from './auth.guard';
import { AuthService } from './auth.service';
@LayZeeDK
LayZeeDK / auth.guard.spec.ts
Created July 16, 2020 11:32
AuthGuard: Isolated route guard test suite.
import {
ActivatedRouteSnapshot,
Params,
Route,
Router,
RouterStateSnapshot,
UrlSegment,
} from '@angular/router';
import { AuthGuard } from './auth.guard';
@LayZeeDK
LayZeeDK / script.service.ts
Created July 3, 2020 23:46
Angular script service for loading JavaScript script files in the browser, using RxJS.
import { DOCUMENT } from '@angular/common';
import { Inject, Injectable, Renderer2 } from '@angular/core';
import { Observable, ReplaySubject } from 'rxjs';
import { switchMapTo, tap } from 'rxjs/operators';
@Injectable({
providedIn: 'root',
})
export class ScriptService {
private scriptLoaded = new Map<string, Observable<void>>();
@LayZeeDK
LayZeeDK / hero-detail.component.html
Created June 1, 2020 22:08
Hero detail: Integrated routed component test suite.
<div *ngIf="hero">
<h2>
{{hero.name | uppercase}} Details
</h2>
<div>
<span>id:</span>
{{hero.id}}
</div>
@LayZeeDK
LayZeeDK / hero-detail.component.html
Last active November 24, 2020 11:27
Hero detail: Shallow routed component test suite.
<div *ngIf="hero">
<h2>
{{hero.name | uppercase}} Details
</h2>
<div>
<span>id:</span>
{{hero.id}}
</div>