Skip to content

Instantly share code, notes, and snippets.

View erickvieira's full-sized avatar
👨‍🎓
Software Engineer - UFG 2021

Erick Vieira erickvieira

👨‍🎓
Software Engineer - UFG 2021
View GitHub Profile
@erickvieira
erickvieira / AlertType.kt
Last active May 8, 2018 20:28
[ANDROID][ALERTDIALOG][KOTLIN] An Android Native alert builder code: this code contains two classes that abstracts the usage of AlertDialog class in AndroidStudio projects. Obs.: The third file is an implementation example, it helps you to learn the right idealized usage.
// package com.example.user.project // REPLACE THIS LINE BY YOUR PACKAGE
import android.support.annotation.DrawableRes
import com.example.edmilton.prototipoamerica.R
enum class AlertType(@DrawableRes internal val path: Int) {
// THAT IS ONLY AN EXAMPLE, YOU CAN REPLACE WITH YOUR ICONS FILE NAMES
WARNING(R.drawable.ic_warning),
SUCCESS(R.drawable.ic_success),
@erickvieira
erickvieira / megasena.js
Last active December 28, 2018 11:05
Software de sorteio dos números da mega sena.
const sorteios = {
s2009: '10 27 40 46 49 58',
s2010: '02 10 34 37 43 50',
s2011: '03 04 29 36 45 55',
s2012: '14 32 33 36 41 52',
s2013: '20 30 36 38 47 53',
s2014: '01 05 11 16 20 56',
s2015: '02 18 31 42 51 56',
s2016: '05 11 22 24 51 53',
s2018: '03 06 10 17 34 37'
/**
* Códigos HTTP tipicamente usados em retornos do servidor.
*/
public enum HttpStatusPtBr {
/**
* Solicitação aceita.
*/
ACCEPTED(202, "solicitacao aceita"),
/**
* Solicitação ambígua ou inconsistente.
@erickvieira
erickvieira / app.component.ts
Last active February 13, 2020 16:55
Angular 7|8|9 LongPressDirective with RxJS
import { Component } from '@angular/core';
@Component({
selector: 'app',
template: `
<div long-press [debounce]="2000" (onLongPress)="logEvent($event)">
Press me for 2 seconds
</div>
`,
styles: [`
@erickvieira
erickvieira / useMountEffect.ts
Last active September 22, 2020 23:11
React Hooks for lifecycle abstractions
import { useEffect, useCallback } from "react";
export default function (effect: () => void | Promise<void>) {
const mountEffect = useCallback(() => {
effect();
}, [effect]);
useEffect(mountEffect, []);
}
import * as functions from 'firebase-functions';
import * as admin from 'firebase-admin';
import * as express from 'express';
import * as bodyParser from 'body-parser';
import * as cors from 'cors';
/**
* Apenas uma imagem de demonstração
*/
const appIcon = "https://img.icons8.com/carbon-copy/2x/bot.png";
tune = "data:audio/mpeg;base64,SUQzBAAAAAAAI1RTU0UAAAAPAAADTGF2ZjU1LjEyLjEwMAAAAAAAAAAAAAAA//uQAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAASW5mbwAAAAcAAAAIAAAOsAA4ODg4ODg4ODg4ODhVVVVVVVVVVVVVVVVxcXFxcXFxcXFxcXFxjo6Ojo6Ojo6Ojo6OqqqqqqqqqqqqqqqqqsfHx8fHx8fHx8fHx+Pj4+Pj4+Pj4+Pj4+P///////////////9MYXZmNTUuMTIuMTAwAAAAAAAAAAAkAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAA//uQRAAAAn4Tv4UlIABEwirzpKQADP4RahmJAAGltC3DIxAAFDiMVk6QoFERQGCTCMA4AwLOADAtYEAMBhy4rBAwIwDhtoKAgwoxw/DEQOB8u8McQO/1Agr/5SCDv////xAGBOHz4IHAfBwEAQicEAQBAEAAACqG6IAQBAEAwSIEaNHOiAUCgkJ0aOc/a6MUCgEAQDBJAuCAIQ/5cEAQOCcHAx1g+D9YPyjvKHP/E7//5QEP/+oEwf50FLgApF37Dtz3P3m1lX6yGruoixd2POMuGLxAw8AIonkGyqamRBNxHfz+XRzy1rMP1JHVDJocoFL/TTKBUe2ShqdPf+YGleouMo9zk////+r33///+pZgfb/8a5U/////9
@erickvieira
erickvieira / javascriptreact.json
Last active September 15, 2020 20:16
Create React.FC snippet for VSCode
{
"New React FC": {
"prefix": "importReact",
"body": [
"import React from \"react\";",
// "import \"./${1:$TM_FILENAME_BASE}Styles\";",
// "import \"./${1:$TM_FILENAME_BASE}.${0:css}\";",
"import \"./${1:$TM_FILENAME_BASE}.${0:less}\";",
// "import \"./${1:$TM_FILENAME_BASE}.${0:sass}\";",
// "import \"./${1:$TM_FILENAME_BASE}.${0:scss}\";",
@erickvieira
erickvieira / benford.js
Last active August 21, 2020 16:50
A JavaScript basic implementation of the Benford Law
/**
* A JavaScript basic implementation of the Benford Law
* @param data an integer array to be used on algorithm
*
* #### Usage
* const citiesPopulation = [12252023, 6718903, 3015268, …, 765]
* const benford = new Benford(citiesPopulation)
* benford.printAsTable()
*/
@erickvieira
erickvieira / CLI_UTILS.md
Last active September 15, 2020 23:49
CLI utils

CLI utils

Instalação

    1. Baixe o .zip e extraia em ~/.cli_utils (nome de diretório sugerido).
    1. Edite o seu ~/.bashrc (ou equivalente) e adicione o caminho da pasta à variável $PATH do sistema.
export PATH="$PATH:$HOME/.cli_utils"
    1. Torne os arquivos descompactados executáveis. Para isso, é possível rodar chmod +x gendoc, por exemplo, e repetir o processo para cada um dos demais sccripts. Alternativamente, se você se sentir confortável com isso, é possível rodar o comando find ~/.cli_utils/ -type f -exec chmod +x {} \;, para fazer com que todos os scripts sejam executáveis de uma só vez.

Obs.: lembre-se de substituir o caminho do diretório após a palavra-chave find, caso tenha decidido descompactar em uma pasta com nome diferente.