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 / 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 / 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 / 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 / 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 / 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> {
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 / 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:
@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"