Skip to content

Instantly share code, notes, and snippets.

View GlauberF's full-sized avatar
🎯
Foco e determinação nos objetivos.

Glauber Funez GlauberF

🎯
Foco e determinação nos objetivos.
View GitHub Profile
@GlauberF
GlauberF / check-format-app.sh
Created July 15, 2019 18:34
prettier - Glauber Funez
#!/usr/bin/env bash
#instalar
#npm install --save-dev --save-exact prettier
#npm install @types/prettier --save-dev
#criar arquivos (.prettierrc) e (.prettierignore), exemplo (https://github.com/nrwl/nx)
read -p "Digite o nome da pasta do módulo, que deve ser verificada? " response
if [ "$response" != "" ]; then
import { BrowserModule } from '@angular/platform-browser';
import { NgModule, ErrorHandler, Injectable, LOCALE_ID } from '@angular/core';
import { HTTP_INTERCEPTORS, HttpClientModule } from '@angular/common/http';
import { BrowserAnimationsModule } from '@angular/platform-browser/animations';
import { RouterModule, Routes } from '@angular/router';
import { TranslateModule } from '@ngx-translate/core';
import 'hammerjs';
import ptBr from '@angular/common/locales/pt';
import { registerLocaleData } from '@angular/common';
@GlauberF
GlauberF / async validation with debounce
Created August 6, 2019 17:26 — forked from ellipizle/async validation with debounce
async validation with debounce listening to value change
import { Component, OnInit } from '@angular/core';';
import { FormBuilder, FormGroup, Validators, AbstractControl, ValidationErrors } from '@angular/forms';
import { Router } from '@angular/router'
import { CommonValidators } from '../service/CommonValidator';
import { Response } from '@angular/http';
import { Observable } from 'rxjs/Observable';
import { GlobalService } from '../../shared/service/global.service';
import { AuthHttp } from 'angular2-jwt'
declare var $: any;
import 'rxjs/add/operator/delay';
@GlauberF
GlauberF / VirtualDOMService.ts
Last active October 25, 2019 13:14
Serviço e Dicas para lidar com Angular + Angular Universal
import { Injectable, Inject, PLATFORM_ID } from '@angular/core';
import { isPlatformBrowser, isPlatformServer, DOCUMENT } from '@angular/common';
@Injectable({
providedIn: 'root'
})
export class VirtualDOMService {
constructor(
@Inject(DOCUMENT) private documentRef: Document,
const dataString = "[
{
"label": "informaçoes basicas",
"fields": [
{
"key": "slug",
"type": "input",
"templateOptions": {
"label": "slug",
"translate": true,
@GlauberF
GlauberF / convertJsonWithFunctionToString.js
Last active November 8, 2019 20:52
convert json with function to string (converter json com função para string)
const stringify = function(obj, prop) {
const placeholder = '____PLACEHOLDER____';
const fns = [];
let json = JSON.stringify(obj, function(key, value) {
if (typeof value === 'function') {
fns.push(value);
return placeholder;
}
return value;
}, 2);
@GlauberF
GlauberF / deep-replaces-nested-javascript.js
Last active December 3, 2019 16:48
Deep Function that replaced values in nested objects / arrays.
import { clone, forEach } from 'lodash-es';
function replacePropertyValueDeep(arrayArgumentsReplace, object ) {
if (!arrayArgumentsReplace) {
console.error(`field arrayArgumentsReplace was not entered`);
return null;
}
if (!object) {
@GlauberF
GlauberF / searchDeep.ts
Created January 20, 2020 16:58
Search DeepArray Javascript/Typescript (Search Array Nested)
export class GlauberTS {
/**
* recursive function to be used when searching for a
* keyword in multi-level arrays
* ex: array.filter(VimboUtils.containsDeep('search content'))
* @param text
*/
public static containsDeep = (text: string) => (value?: any): any => {
if (!value) {
return false;
@GlauberF
GlauberF / paises.csv
Last active January 21, 2020 17:12
Países CSV
pai_sigla pai_codigo pai_nome
AF 0132 AFEGANISTÃO
AL 0175 REPÚBLICA DA ALBÂNIA
DE 0230 ALEMANHA
BF 0310 BURKINA FASO
AD 0370 ANDORRA
AO 0400 ANGOLA
AI 0418 ANGUILLA
AG 0434 ANTIGUA E BARBUDA
ANT 0477 ANTILHAS HOLANDESAS

Regex Cheat Sheet

Todos os exemplos usam grupos do regex () para separar o simbolo do dado. Isto é feito para tornar a vida mais facil para o programador, quando for usar o método replace. Exemplo:

const text = "2019-26-09";
const regex = /(\d{4})-(\d{2})-(\d{2})/g;
console.log(text.replace(regex, "$2/$3/$1"));
// 26/09/2019