Skip to content

Instantly share code, notes, and snippets.

View nicobytes's full-sized avatar
🏠
Working from home

Nicolas Molina Monroy nicobytes

🏠
Working from home
View GitHub Profile
@nicobytes
nicobytes / steps.md
Last active November 9, 2020 00:41
Performance monitoring with Lighthouse CI

1. Install the Lighthouse CI CLI.

npm install -g @lhci/cli

2.

import { Component, OnInit, forwardRef } from '@angular/core';
import { ControlValueAccessor, NG_VALUE_ACCESSOR } from '@angular/forms';
@Component({
selector: 'app-stepper',
templateUrl: './stepper.component.html',
styleUrls: ['./stepper.component.scss'],
providers: [
{
provide: NG_VALUE_ACCESSOR,

1. Define marker

interface Marker {
  lat: number;
  lng: number;
  title: string;
  image: string;
  text: string;
  markerObj?: any;
@nicobytes
nicobytes / nest-pg.md
Last active February 18, 2022 02:59
NestJS, TypeORM and PostgreSQL
npm install --save @nestjs/typeorm typeorm pg
import { Module } from '@nestjs/common';
import { TypeOrmModule } from '@nestjs/typeorm';
import { AppController } from './app.controller';
import { AppService } from './app.service';
import { configService } from './config/config.service';
@nicobytes
nicobytes / arrays.md
Last active April 21, 2020 23:14
Arrays

Arrays

Why?

const averageTempJan = 31.9;
const averageTempJan = 35.3;
const averageTempMar = 42.4;
const averageTempApr = 52;
@nicobytes
nicobytes / steps.md
Last active October 4, 2022 17:14
Scale app with Docker Sawrm
  1. Create machines / nodes
node-01
node-02
node-03
  1. Update machine

service

@Injectable({
  providedIn: 'root'
})
export class UserService {

  constructor(
    private http: HttpClient
@nicobytes
nicobytes / 65-custom-validations.md
Last active June 14, 2021 21:18
Custom validations in Angular
import { AbstractControl } from '@angular/forms';

export class MyValidations {

  static age(control: AbstractControl) {
    const value = control.value;
    if (value < 18) {
      return {isYoung: true};
 }
@nicobytes
nicobytes / 64-angular-validations.md
Last active January 25, 2022 11:28
64-angular-validations
<div class="field">
    <label class="label">Age</label>
    <div class="control">
      <input
        class="input"
        [class.is-danger]="form.get('age').dirty && form.get('age').invalid"
        type="text"
        formControlName="age"
      />
import { Injectable } from '@angular/core';
import { HttpEvent, HttpHandler, HttpInterceptor, HttpRequest } from '@angular/common/http';
import { Router } from '@angular/router';
import { Observable, throwError } from 'rxjs';
import { catchError, switchMap } from 'rxjs/operators';
import { AuthService } from '@auth/services/auth.service';
import { TokenService } from '@auth/services/token.service';