Skip to content

Instantly share code, notes, and snippets.

View mateusduraes's full-sized avatar
🏠
Working from home

Mateus Duraes mateusduraes

🏠
Working from home
View GitHub Profile
const route = '/products/:id';
type Split<S extends string> = S extends ''
? []
: S extends `${infer C}${infer R}`
? [C, ...Split<R>]
: never
type RequestHandler<TRoute extends string> = {
params: TRoute extends `${infer _}:${infer R}` ? {
@mateusduraes
mateusduraes / estados-cidades.json
Last active August 18, 2022 20:59 — forked from letanure/estados-cidades.json
JSON estados cidades do brasil, dividido por estados. segunda lista atualizada em 2020, dados do IBGE
{
"estados": [
{
"sigla": "AC",
"nome": "Acre",
"cidades": [
"Acrelândia",
"Assis Brasil",
"Brasiléia",
"Bujari",
interface Person {
name: string;
age: number;
extraInformation: {
salary: number;
role: string;
}
}
type Stringify<T> = {
* Database (Firestore)
* Authentication
* Functions
* Triggers
Registrando objetos com AngularFire2 - See docs
Estrutura do banco
<!-- https://developer.mozilla.org/pt-BR/docs/Web/API/MutationObserver -->
<ion-content>
<div>
<message *ngFor></message>
</div>
</ion-content>
<script>
const llist = null;
import * as functions from 'firebase-functions';
import { app } from '../../../utils/admin';
import { ERRORS } from '../../../consts/errors';
const getCountCommentsByPost = async (post: FirebaseFirestore.QueryDocumentSnapshot): Promise<number> => {
const comments = await post.ref.collection('comments').get();
const postComments = comments.size;
const subCommentsPromises = comments.docs.map(comment => comment.ref.collection('subcomments').get());
const subComments = await Promise.all(subCommentsPromises);
const totalSubcomments = subComments.map(subComment => subComment.size).reduce((prev, curr) => prev + curr, 0);
// Routes
const routes: Routes = [
{
canActivate: [UnauthenticatedGuard],
path: 'signin',
loadChildren: './pages/signin/signin.module#SigninPageModule',
},
{
canActivate: [AuthenticatedGuard],
import { AngularFirestore, QueryFn } from '@angular/fire/firestore';
import { Injectable } from '@angular/core';
import { Observable } from 'rxjs-compat';
import { map } from 'rxjs/operators';
import * as firebase from 'firebase';
@Injectable()
export class FirebaseService<T> {
constructor(
@mateusduraes
mateusduraes / .zshrc
Created April 7, 2018 04:05
My zsh config
if [ $TILIX_ID ] || [ $VTE_VERSION ]; then
source /etc/profile.d/vte.sh
fi
# If you come from bash you might have to change your $PATH.
# export PATH=$HOME/bin:/usr/local/bin:$PATH
# Path to your oh-my-zsh installation.
export ZSH=/home/mduraes1994/.oh-my-zsh
@mateusduraes
mateusduraes / ionic-brazilian-inputdatetime.html
Created August 24, 2017 12:20
A way to use ion-datetime to display data in brazilian format.
<ion-datetime
displayFormat="DD/MM/YYYY"
pickerFormat="DD/MMM/YYYY"
formControlName="dtBirth"
cancelText="Cancelar"
doneText="Ok"
monthShortNames='JAN, FEV, MAR, ABR, MAI, JUN, JUL, AGO, SET, OUT, NOV, DEZ'>
</ion-datetime>