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 / micmute.workflow
Last active July 12, 2022 12:28
Automator service for microphone mute key binding on Mac OS
on run {input, parameters}
set inputVolume to input volume of (get volume settings)
if inputVolume < 60 then
set inputVolume to 60
set displayNotification to "Microphone is unmuted"
set speechMessage to "unmuted"
else
set inputVolume to 0
set displayNotification to "Microphone is muted"
@erickvieira
erickvieira / SQL-IN-Groovy.sql.groovy
Created January 31, 2022 19:06
SQL-IN-Groovy Datagrip extractor
/*
* Available context bindings:
* COLUMNS List<DataColumn>
* ROWS Iterable<DataRow>
* OUT { append() }
* FORMATTER { format(row, col); formatValue(Object, col) }
* TRANSPOSED Boolean
* plus ALL_COLUMNS, TABLE, DIALECT
*
* where:
import com.google.gson.Gson
import com.google.gson.reflect.TypeToken
inline fun <I, reified O> I?.convert(): O? = this?.let { input ->
try {
Gson().let { gson ->
gson.toJson(input).let { output ->
gson.fromJson(output, object : TypeToken<O>() {}.type)
}
}
@erickvieira
erickvieira / TheUltimateSearchInput.tsx
Last active May 18, 2021 22:48
THE ULTIMATE ANTD SEARCH INPUT (autocomplete, react, antd, antdesign, ant design, search, dynamic)
import React, { useCallback, useMemo, useState } from "react";
import { AutoComplete, Empty } from "antd";
import { debounce, get } from "lodash";
import { MaterialIcon } from "icons";
import { mdiLoading } from "@mdi/js";
import Text from "components/Text";
import useMountEffect from "hooks/Lifecycle/useMountEffect";
export interface SearchInputProps<T extends Dict> {
@erickvieira
erickvieira / AntD4FormExample.tsx
Last active April 28, 2021 16:08
Exemplo de implementação de um form não controlado com AntD 4.x
import { mdiDeleteForever } from "@mdi/js";
import { Form, Input, Space, Divider, Button } from "antd";
import MaterialIcon from "components/MaterialIcon";
import { Rule } from "rc-field-form/lib/interface";
// Estabelecendo uma interface simples para servir de objeto de estudo
interface Example {
displayName: string;
topics: string[];
user: {
@erickvieira
erickvieira / TagsCloud.styled.tsx
Last active April 12, 2021 21:17
AntD TagsCloud Component with StyledComponents
import React from 'react';
import styled, { css } from 'styled-components';
export interface TagsWrapperProps extends React.HTMLAttributes<HTMLDivElement> {
collapsed?: boolean;
uncollapsedHeight?: number | string;
}
const handleCollapse = (props: TagsWrapperProps) => css`
max-height: ${props.collapsed
@erickvieira
erickvieira / useSharedState.ts
Last active October 26, 2020 13:41
ReactJS Hook to create a RxJS based state and share it between React.FC components. No matters what level the state had been created, it will be available on whole app scope due to the BehaviorSubject. Read more about this approach here: https://medium.com/@thomasburlesonIA/https-medium-com-thomasburlesonia-react-hooks-rxjs-facades-4e116330bbe1 |
import { BehaviorSubject } from "rxjs"; // remember to install rxjs dependency
import { useCallback, useEffect, useState } from "react";
import { skip } from "rxjs/operators";
const globalSubject = new BehaviorSubject<any>({});
type SetSharedStateAction<S> = (state: S) => void;
export default function <T>(
subject: BehaviorSubject<T> = globalSubject
@erickvieira
erickvieira / sequenciaMaximal.c
Last active October 5, 2020 00:14
Sequência maximal de um array de inteiros.
#include <math.h>
#include <stdbool.h>
#include <stdio.h>
#include <stdlib.h>
#include <string.h>
// = IMPLEMENTACAO DE ARRAY DINAMICO ===========================================
typedef struct {
int *arranjo;
size_t quantidadeDeElementos;
@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.

@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()
*/