Skip to content

Instantly share code, notes, and snippets.

View guiseek's full-sized avatar
🌱
Winners don't care what others think, the real battle is overcoming yourself.

Guilherme Siquinelli guiseek

🌱
Winners don't care what others think, the real battle is overcoming yourself.
View GitHub Profile
import { FormErrors } from '../interfaces/form-errors.interface';
export const FORM_ERRORS_CONFIG: FormErrors = {
required: error => `Este campo é obrigatório`,
email: error => `Email inválido`,
min: ({ min, actual }) => `O mínimo é ${min} e tem ${actual}`,
max: ({ max, actual }) => `O máximo é ${max} e tem ${actual}`,
minlength: ({ requiredLength, actualLength }) =>
`O mínimo é ${requiredLength} e tem ${actualLength}`,
maxlength: ({ requiredLength, actualLength }) =>
@Directive({
selector: '[uiErrorBuilder], formControlName, ngModel, [ngModel], [formControlName], [formControl]',
exportAs: 'errorBuilder'
})
export class ErrorBuilderDirective implements OnInit, OnDestroy {
@Input() messages: ErrorMessages = {};
public message: string;
private sub: Subscription;
@guiseek
guiseek / .block
Created December 19, 2019 01:04 — forked from gkhays/.block
Oscillating Sine Wave Rendered with JavaScript
license: cc-by-4.0
@guiseek
guiseek / client.service.ts
Last active March 30, 2020 01:44
Firebase útils
@Inj.....
export class ClientService {
//....
async saveMeasures({ id, ...data }: PatientMeasures) {
let path = `${this.document.ref.path}/measures`;
path = id ? `${path}/${id}` : path;
const date = this.timenow;
import { firestore } from 'firebase/app';
export class FirebaseQuery {
where?: Array<
[
string | firestore.FieldPath,
firestore.WhereFilterOp,
any
]
>;
// Função
export const addColumn = <T = any>(prop: string) => {
const shift = prop.split('.').pop();
return (payload: T): T => {
const column = prop.split('.')
.reduce((p, c) => payload[p][c]);
return ({ ...payload, [shift]: column });
}
export function getAge(birthday: Date, date = new Date()) {
let age = date.getFullYear() - birthday.getFullYear();
const m = date.getMonth() - birthday.getMonth();
if (m < 0 || (m === 0 && date.getDate() < birthday.getDate())) {
age--;
}
return age;
}
export function orZero(data) {
return !!data
&& typeof data === 'number'
&& !isNaN(data) ? data : 0;
}
@guiseek
guiseek / app.component.html
Last active July 18, 2021 19:15
My City App
<mat-sidenav-container class="sidenav-container" [hasBackdrop]="(isHandset$ | async) === true">
<mat-sidenav #drawer class="sidenav" fixedInViewport [attr.role]="(isHandset$ | async) ? 'dialog' : 'navigation'"
[mode]="(isHandset$ | async) ? 'over' : 'side'" [opened]="(isHandset$ | async) === false">
<div class="tool-list">
<my-city-tool-items>
<div myCityToolItem role="listitem">
<my-city-tool-item *ngFor="let toolItem of toolsList" [tool]="toolItem"
@guiseek
guiseek / confirm.decorator.ts
Created March 9, 2021 00:27
Decorators / Tweet 3 / 08/03/2021
/**
* Confirm Action
*
* Keep it Simple Sir
*
* @param message
*/
export function Confirm(message: string) {
/**
* @param target é a classe, no nosso claso o componente ListaComponent