Skip to content

Instantly share code, notes, and snippets.

View clebersonfalk's full-sized avatar

Cleberson Falk clebersonfalk

  • Java Software Engineer at ASAAS
  • Londrina - PR
View GitHub Profile
@clebersonfalk
clebersonfalk / angular_form_invalid_input.ts
Created July 17, 2020 14:08
Angular Form - Listar campos inválidos
let controls = this.form.controls;
for (const name in controls) {
if (controls[name].invalid) {
console.log('control invalid: ', name, controls[name]);
}
}
this.isSubmited = true;
@clebersonfalk
clebersonfalk / mat-checkbox.scss
Created June 8, 2020 17:28
Trata os labels de checkboxes no Angular Material
// 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;
}
@clebersonfalk
clebersonfalk / linux_sensors.sh
Created February 12, 2020 13:57
Linux sensors
#!/bin/bash
while true; do
sensors;
lscpu | grep MHz;
sleep 1;
clear;
done
@clebersonfalk
clebersonfalk / angular_material_autocomplete.ts
Last active January 31, 2020 13:56
Angular Material Autocomplete
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)
@clebersonfalk
clebersonfalk / angular_directive_debounce.ts
Last active January 31, 2020 13:54
Angular Directive Debounce
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"
@clebersonfalk
clebersonfalk / find and delete object of an array of objects.ts
Last active October 18, 2019 18:22
Find and delete object of array of objects
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
@clebersonfalk
clebersonfalk / ionic-termos-uso-checkbox-checked.ts
Created September 9, 2019 20:58
Ionic Form Builder Validate checkbox checked (Termos de Uso)
private createForm() {
this.cadastroForm = this.formBuilder.group({
nome: ['', [
Validators.required,
Validators.maxLength(100),
]],
email: ['', [
Validators.required,
Validators.email,
]],
@clebersonfalk
clebersonfalk / function_return_object_data.ts
Created September 2, 2019 18:41
Create function and return object with data
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;
});
}
@clebersonfalk
clebersonfalk / JS_sub_minuts_in_date.js
Last active July 4, 2019 19:06
JS - Subtrair minutos em Data, depois retornando a hora e minutos modificados
new Date(new Date().setHours(11,00-5)).getHours();
// 10
new Date(new Date().setHours(11,00-5)).getMinutes();
// 55
//Result: 10:55
^(\d{2}\.?\d{3}\.?\d{3}\/?\d{4}-?\d{2}|\d{3}\.?\d{3}\.?\d{3}-?\d{2})$