Skip to content

Instantly share code, notes, and snippets.

View Gustavo-Kuze's full-sized avatar
🚀
while(alive){ keepLearning(); }

Gustavo-Kuze

🚀
while(alive){ keepLearning(); }
View GitHub Profile
@Gustavo-Kuze
Gustavo-Kuze / force-ctrl-c-v.md
Last active July 10, 2024 16:38
Enable copy and paste in a webpage from the browser console
javascript:(function(){
  allowCopyAndPaste = function(e){
  e.stopImmediatePropagation();
  return true;
  };
  document.addEventListener('copy', allowCopyAndPaste, true);
  document.addEventListener('paste', allowCopyAndPaste, true);
  document.addEventListener('onpaste', allowCopyAndPaste, true);
})(); 
@Gustavo-Kuze
Gustavo-Kuze / dates_comparing.js
Created July 11, 2019 00:30
Métodos para comparação de datas, ignorando as horas
const _compareDates = (date1, date2) => {
date2.setHours(date1.getHours());
date2.setMinutes(date1.getMinutes());
date2.setSeconds(date1.getSeconds());
date2.setMilliseconds(date1.getMilliseconds());
return date2 - date1;
};
const isDatePast = (now, date) => _compareDates(now, date) < 0;
@Gustavo-Kuze
Gustavo-Kuze / react_navigation.js
Last active July 23, 2019 11:32
Instalando React Navigation no InstaluraMobile
// 1- yarn add react-navigation
// 2- yarn add react-navigation
// 3- Criar um container component, eu utilizei o App.js
import {createStackNavigator, createAppContainer} from 'react-navigation';
import Feed from "./src/screens/Feed";
import Login from "./src/screens/Login";
const MainNavigator = createStackNavigator({
Login: {screen: Login},
Feed: {screen: Feed},
@Gustavo-Kuze
Gustavo-Kuze / keystore_sha-1_react_native.md
Last active October 7, 2020 11:13
Creating keystore and getting SHA-1 React Native

Go to keytool's location

cd "C:\Program Files\Java\jdk1.8.0_211\bin"

Generate keystore

keytool -genkeypair -v -keystore [MYKEYSTORE].keystore -alias [MY-ALIAS] -keyalg RSA -keysize 2048 -validity 10000

Get SHA-1

keytool -list -v -keystore [PATH_TO_YOUR_KEYSTORE].keystore -alias [YOUR_ALIAS_NAME] -storepass YOUR_STORE_PASSWORD -keypass YOUR_KEY_PASSWORD

@Gustavo-Kuze
Gustavo-Kuze / react-native-usb-proxy.txt
Created August 27, 2019 15:52
como usar a API localhost com react native debugger
1. Abra o menu de desenvolvimento do app (CTRL + M no emulador)
2. vá para as opções de desenvolvedor (Dev Settings)
3. Selecione "Debug server host & port for device"
4. digite 127.0.0.1:8081 (ou a porta customizada do seu APP)
5. abra um terminal na pasta do projeto da API e digite o comando: adb reverse tcp:8000 tcp:8000 (ou a porta da sua API)
@Gustavo-Kuze
Gustavo-Kuze / genymotion_react_native.txt
Created August 29, 2019 22:18
Genymotion React Native
1. Baixar o geny versão free (personal) sem VirtualBox caso já tenha instalado
2. Instalar tudo no padrão
3. Baixar uma VM por dentro do GM (eu usei um Nexus 5x com API level 23 Android 6)
4. Rodar a VM pra ver se está tudo OK
5. Abrir as configurações do Genymotion e ir na aba ADB
6. Selecionar um SDK customizado e apontar para a pasta do SDK usado pelo React Native (Android Studio padrão)
7. reiniciar a VM
8. Abrir o genymotion shell e rodar "devices list"
9. Copiar o IP do device e abrir um cmd
10. Rodar o comando: adb connect IP_DO_DEVICE:5555
@Gustavo-Kuze
Gustavo-Kuze / setup_prettier_eslint_airbnb.md
Last active February 11, 2024 03:45
Como configurar o Prettier/ESLint com o preset do AirBnb em projetos React e NodeJS

Como configurar o Prettier/ESLint com o preset do AirBnb em projetos React e NodeJS

ReactJS

  1. Instale as seguintes dependencias em seu projeto React:
yarn add -D babel-eslint prettier eslint-config-prettier eslint-plugin-prettier eslint eslint-plugin-react eslint-config-airbnb eslint-plugin-jsx-a11y eslint-plugin-import eslint-import-resolver-webpack
@Gustavo-Kuze
Gustavo-Kuze / alter_mysql_id_when_fk
Created October 27, 2019 10:18
ERRO: Cannot change column 'id': used in a foreign key constraint '
Quando o erro "Cannot change column 'id': used in a foreign key constraint '"
acontecer ao tentar atualizar um id que é referenciado por uma FK é possível desativar
a verificação das FKs com a flag abaixo
SET FOREIGN_KEY_CHECKS = 0;
/* Faça o que quiser aqui */
SET FOREIGN_KEY_CHECKS = 1;
@Gustavo-Kuze
Gustavo-Kuze / node_redis_cache.js
Created July 4, 2020 00:56 — forked from bradtraversy/node_redis_cache.js
Node.js & Redis Caching
const express = require('express');
const fetch = require('node-fetch');
const redis = require('redis');
const PORT = process.env.PORT || 5000;
const REDIS_PORT = process.env.PORT || 6379;
const client = redis.createClient(REDIS_PORT);
const app = express();
@Gustavo-Kuze
Gustavo-Kuze / mei_atividades.js
Last active October 7, 2020 21:57
Lista de atividades do MEI. Array JavaScript
``` javascript
/*
Essas informações foram retiradas do site oficial do portal do empreendedor:
http://www.portaldoempreendedor.gov.br/temas/quero-ser/formalize-se/atividades-permitidas.
Atualizado em: 19/08/2020
*/
const mei = [
'ABATEDOR(A) DE AVES COM COMERCIALIZAÇÃO DO PRODUTO INDEPENDENTE',