Skip to content

Instantly share code, notes, and snippets.

Avatar
🏠
Working from home

Igor Ming de Mesquita IgorMing

🏠
Working from home
View GitHub Profile
@IgorMing
IgorMing / store.ts
Created Oct 20, 2020
a quick way to check how to configure redux, redux-thunk and reactotron
View store.ts
import { applyMiddleware, compose, createStore } from 'redux';
import thunkMiddleware from 'redux-thunk';
import rootReducer from './reducers';
import reactotron from '../reactotron.config';
export default createStore(
rootReducer,
compose(applyMiddleware(thunkMiddleware), reactotron.createEnhancer())
);
@IgorMing
IgorMing / metro.config.js
Created Oct 14, 2020
required configuration for load svg files into your react native project
View metro.config.js
const { getDefaultConfig } = require('metro-config');
module.exports = (async () => {
const {
resolver: { sourceExts, assetExts }
} = await getDefaultConfig();
return {
transformer: {
getTransformOptions: async () => ({
transform: {
@IgorMing
IgorMing / boilerplate.md
Last active May 30, 2020
A simple guide to follow while starting a new project
View boilerplate.md

Project guide

The following suggestions are personal. That's how I like to go while I'm starting a React/React Native project.

Step by step

JS or TS?

Decide whether you want to use plain Javascript or Typescript

@IgorMing
IgorMing / novo_produto.md
Last active Sep 27, 2019
Descritivo para seguir de base em criações de novos produtos
View novo_produto.md

Criação de um produto

Descritivos

  • O que é o produto?
  • Qual problema ele resolve?
  • Modelo de negócio
  • Públicos alvo
  • Criação de personas (desejável)
@IgorMing
IgorMing / prettier_eslint.md
Last active Apr 26, 2019
Simple steps for prettier + eslint configuration
View prettier_eslint.md

How to configure Prettier + ESLint in VSCode

Motivation

Prettier is quite useful for format your code automatically, making you concern only with coding (which is what really matters)

ESLint has some personal rules, that makes your code have a particular pattern, where you can configure everything that you and the whole team will whose in project by default

Sometimes, you use prettier, and it has a personal pattern to deal with the styleguide. And those rules and patterns could conflict with project's ESLint rules. Looking at this problem, you can follow below some steps to configure a kind of integration between both tools.

@IgorMing
IgorMing / customWords.js
Last active May 6, 2018
Almost like my wordWrapper function, but a function to create custom words (I've created it to work with React Native)
View customWords.js
function customWords(text, customStyles, ...wordsToWrap) {
// Pattern to be considered to split every word
const regexp = /([\A-zÀ-ÿ]+|([!.,:?]))/gi;
// Separate the phrase with all the words and characters "!.,:?"
const splittedText = text.match(regexp);
// Convert everything for lower case, to compare it correctly
// and breaking words to wrap even if it contains some compound word
const splittedWordsToWrap = wordsToWrap.reduce((acc, curr) => {
@IgorMing
IgorMing / wordWrapper.js
Last active May 6, 2018
A function which can help you to do something in a phrase in either specific words or specific parts from the phrase.
View wordWrapper.js
function wordWrapper(text, wrapperFunc, ...wordsToWrap) {
// Separate the phrase with all the words and characters "!.,:?"
const splittedText = text.match(/([\A-zÀ-ÿ]+|([!.,:?]))/gi);
// Convert everything for lower case, to compare it correctly
const lowerWords = wordsToWrap.map(each => each.toLowerCase());
// Wrap every word doing what the function suggests to do
const wrappedSplittedText = splittedText.reduce((acc, curr) => {
acc.push(lowerWords.includes(curr.toLowerCase()) ? wrapperFunc(curr) : curr);
@IgorMing
IgorMing / .editorconfig
Created Feb 25, 2018
Editorconfig file just with useful stuff
View .editorconfig
# top-most EditorConfig file
root = true
# Unix-style newlines with a newline ending every file
[*]
end_of_line = lf
insert_final_newline = true
# Indentation override for all JS under lib directory
[**.{js,json}]
@IgorMing
IgorMing / normalizer.js
Created Nov 27, 2017
Simple normalizer
View normalizer.js
function normalize(array, key) {
return array.reduce((acc, curr) => {
acc.all[curr[key]] = curr;
acc.ids.push(curr[key]);
return { ...acc };
}, { all: {}, ids: [] });
}
@IgorMing
IgorMing / barcodescanner.js
Last active Sep 21, 2022
Barcode Scanner on React Native (with expo), stylized with opaque edges
View barcodescanner.js
import React from 'react';
import { StyleSheet, Text, View } from 'react-native';
import { BarCodeScanner } from 'expo';
export default class App extends React.Component {
render() {
return (
<BarCodeScanner
onBarCodeRead={(scan) => alert(scan.data)}
style={[StyleSheet.absoluteFill, styles.container]}