Skip to content

Instantly share code, notes, and snippets.

@pimatco
pimatco / estados-cidades-capitais.json
Last active June 24, 2022 14:05 — forked from letanure/estados-cidades.json
JSON com Estados Cidades Capitais e Regiões
{
"estados": [
{
"sigla": "AC",
"nome": "Acre",
"região": "Norte",
"capital": "Rio Branco",
"cidades": [
"Acrelândia",
"Assis Brasil",
@pimatco
pimatco / all-angular-material-components-imports.txt
Last active September 17, 2024 21:54
All Angular Material Components Imports from app.module.ts
import { BrowserModule } from '@angular/platform-browser';
import { NgModule } from '@angular/core';
import { AppComponent } from './app.component';
//Angular Material Components
import {BrowserAnimationsModule} from '@angular/platform-browser/animations';
import {MatCheckboxModule} from '@angular/material';
import {MatButtonModule} from '@angular/material';
@pimatco
pimatco / SelecionarValoresUnicosDeJsonComJavascript.txt
Last active March 6, 2021 18:23
Select unique values from JSON file when clicking a button with Javascript
var json = [
{
"Year": 2001
},
{
"Year": 2017
},
{
"Year": 1900
},
@pimatco
pimatco / pushToArray.txt
Last active December 7, 2017 16:30
Push values to an Array Function Javascript
function pushToArray(array, descricao, value){
array.push({descricao: value});
}
@pimatco
pimatco / isAvailableFunction
Created December 7, 2017 16:31
Check if a value exists, otherwise pass Undefined
function isAvailable(param){
if(!param){
return param='Undefined'
}else{
return param=param;
}
}
@pimatco
pimatco / typesOfEventBindingAngular
Created December 15, 2017 13:23
All Event Binding Types in Angular 4
(focus)="myMethod()" // An element has received focus
(blur)="myMethod()" // An element has lost focus
(submit)="myMethod()" // A submit button has been pressed
(scroll)="myMethod()"
(cut)="myMethod()"
(copy)="myMethod()"
(paste)="myMethod()"
@pimatco
pimatco / convertDateToLocalTimeFunction
Last active December 22, 2017 11:48
Convert Date to Local Time using Momentjs library and Get Difference from one date to another in minutes, hours or days
//returns a string
convertToLocalTimeToString(hora){
hora = moment.utc(hora);
hora = hora.local().format();
return hora;
}
//returns a moment obj - use to get difference
convertToLocalTimeToObj(hora){
hora = moment.utc(hora);
@pimatco
pimatco / timeagoPipeAngular
Created February 7, 2018 15:46
Pipe with timeago for Angular
import { Pipe, PipeTransform } from '@angular/core';
import * as moment from 'moment';
//insert your locale
moment.locale('pt-br');
@Pipe({
name: 'timeago',
})
export class TimeagoPipe implements PipeTransform {
@pimatco
pimatco / passwordregexp
Created February 26, 2018 16:33
Reg Exp Password Validation
Minimum eight characters, at least one letter and one number:
"^(?=.*[A-Za-z])(?=.*\d)[A-Za-z\d]{8,}$"
Minimum eight characters, at least one letter, one number and one special character:
"^(?=.*[A-Za-z])(?=.*\d)(?=.*[$@$!%*#?&])[A-Za-z\d$@$!%*#?&]{8,}$"
Minimum eight characters, at least one uppercase letter, one lowercase letter and one number:
"^(?=.*[a-z])(?=.*[A-Z])(?=.*\d)[a-zA-Z\d]{8,}$"
Minimum eight characters, at least one uppercase letter, one lowercase letter, one number and one special character:
@pimatco
pimatco / listadenomesbrasileiros-feminino-masculino
Created February 26, 2018 17:12
20000 Nomes Brasileiros Masculino e Feminino
"AANA",
"AANTONIO",
"AARAO",
"AARON",
"ABADIA",
"ABADIO",
"ABDA",
"ABDALA",
"ABDIAS",
"ABDIEL",