Skip to content

Instantly share code, notes, and snippets.

@GerritRiesch94
GerritRiesch94 / test.ts
Last active December 20, 2021 08:14
Test Gist!
import {TestBed} from '@angular/core/testing';
import {ExampleService} from './example.service';
import {HttpClientTestingModule, HttpTestingController} from '@angular/common/http/testing';
import {HttpClient} from '@angular/common/http';
describe('ExampleService', () => {
let service: ExampleService;
let httpTestingController: HttpTestingController;
const baseUrl = 'http://my.base.url';
@GerritRiesch94
GerritRiesch94 / simpleFilter.ts
Created March 3, 2022 08:19
SimpleRxJSFilterChain
import { of } from 'rxjs';
import { filter} from 'rxjs/operators';
of(0815, 4711, 99, 98)
.pipe(filter((precinctNumber) => precinctNumber === 99))
.subscribe((value) => console.log(`The coolest precinct: ${value}`));
// Logs:
// The coolest precinct: 99
interface Detective {
id: string
}
interface Case {
id: string,
}
interface Report {
id: number,
private solvedCaseIds$ = this.reports$.pipe(
filter((report) => report.solved),
map((report) => report.id),
toArray()
)
public solvedCaseIds$ = this.reports$.pipe(
extractIdsOfSolvedCases()
)
export function extractIdsOfSolvedCases() {
return function(source: Observable<Report>): Observable<number[]> {
return source.pipe(
filter((report) => report.solved),
map((report) => report.id),
toArray()
)
}
}
import {extractIdsOfSolvedCases} from './rxjs-operators';
import {marbles} from 'rxjs-marbles';
import {Report} from './reports.service';
describe('rxjs-operators', () => {
describe('extractIdsOfSolvedCases', () => {
it('should extract all ids of solved cases', marbles((context) => {
const source = context.cold('abc|', {
@GerritRiesch94
GerritRiesch94 / node.js.yml
Created September 15, 2022 07:05
Ci_CD_GithubActions
name: Deploy
on:
push:
branches:
- main #1
jobs:
deploy:
runs-on: ubuntu-latest
name: Deploy
@GerritRiesch94
GerritRiesch94 / app.component.html
Last active March 2, 2023 13:02
Example for ngOptimizedImage usage
<mat-drawer-container autosize class="h-screen">
<mat-drawer class="flex h-full flex-col justify-center overflow-x-hidden px-2" mode="side" opened="true">
<app-sidebar></app-sidebar>
</mat-drawer>
<mat-drawer-content>
<!-- // random image to load -->
<img ngSrc="https://picsum.photos/200/300" width="200" height="300" alt="random Picture" priority />
<app-navbar></app-navbar>
<router-outlet></router-outlet>
</mat-drawer-content>
@GerritRiesch94
GerritRiesch94 / index.html
Last active January 27, 2023 15:02
Example for ngOptimizedImage usage index.html
<!DOCTYPE html>
<html lang="en">
<head>
<meta charset="utf-8" />
<title>FitPlaner</title>
<base href="/" />
<meta name="viewport" content="width=device-width, initial-scale=1" />
<link rel="icon" type="image/x-icon" href="favicon.ico" />
<link rel="preconnect" href="https://fonts.gstatic.com" />