This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
let controls = this.form.controls; | |
for (const name in controls) { | |
if (controls[name].invalid) { | |
console.log('control invalid: ', name, controls[name]); | |
} | |
} | |
this.isSubmited = true; |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
// adds breaks to the mat-checkboxes with long labels | |
::ng-deep .mat-checkbox-layout { | |
white-space: normal !important; | |
} | |
// rather than center the checkbox, put the checkbox in the first line | |
::ng-deep .mat-checkbox-inner-container { | |
margin-top: 3px !important; | |
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
#!/bin/bash | |
while true; do | |
sensors; | |
lscpu | grep MHz; | |
sleep 1; | |
clear; | |
done |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
public buscarCidades(): void { | |
this.form.get('genCidadeId').valueChanges.pipe( | |
debounceTime(600), | |
filter((termo) => typeof termo === 'string'), | |
map(termo => termo.toString().trim()), | |
distinctUntilChanged(), | |
tap(() => this.carregandoCidades = true), | |
switchMap(termo => this.cidadeService.getCidadeAutocomplete(0, 50, termo) | |
.pipe( | |
finalize(() => this.carregandoCidades = false) |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
import {Directive, EventEmitter, HostListener, Input, OnDestroy, OnInit, Output} from '@angular/core'; | |
import {Subscription, timer} from 'rxjs'; | |
import {debounceTime, distinctUntilChanged, filter, find, map, skipUntil, tap} from 'rxjs/operators'; | |
import {NgControl} from '@angular/forms'; | |
/** | |
Usage: | |
<mat-form-field appearance="outline" fxFlex="35" class="pr-8"> | |
<mat-label>{{ 'pessoa.label.cep' | translate }}</mat-label> | |
<input matInput formControlName="nrCep" mask="00.000-000" [(ngModel)]="nrCep" |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
var myArray = [ | |
{'id': 15,'name':'bazinga'}, | |
{'id': 73,'name':'foo'}, | |
{'id': 45,'name':'bar'}]; | |
// Using filter | |
myArray = myArray.filter(value => value.id != 15) | |
console.log('myArray: ', myArray); | |
// Using map |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
private createForm() { | |
this.cadastroForm = this.formBuilder.group({ | |
nome: ['', [ | |
Validators.required, | |
Validators.maxLength(100), | |
]], | |
email: ['', [ | |
Validators.required, | |
Validators.email, | |
]], |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
public buscarDadosLoginStorage(): Promise<any> { | |
return new Promise(async () => { | |
let authData = { | |
access_token: await this.storage.get(Constants.STORAGE_LOGIN_TOKEN_DATA), | |
identUsuario: await this.storage.get(Constants.STORAGE_LOGIN_IDENT_USUARIO), | |
identUnidadePersistencia: await this.storage.get(Constants.STORAGE_LOGIN_IDENT_UNIDADE_PERSISTENCIA) | |
}; | |
return authData; | |
}); | |
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
new Date(new Date().setHours(11,00-5)).getHours(); | |
// 10 | |
new Date(new Date().setHours(11,00-5)).getMinutes(); | |
// 55 | |
//Result: 10:55 |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
^(\d{2}\.?\d{3}\.?\d{3}\/?\d{4}-?\d{2}|\d{3}\.?\d{3}\.?\d{3}-?\d{2})$ |
NewerOlder