Navigation Menu

Skip to content

Instantly share code, notes, and snippets.

View oaugusto256's full-sized avatar
🏄‍♂️

Otavio Augusto oaugusto256

🏄‍♂️
View GitHub Profile
@oaugusto256
oaugusto256 / example-ts-input-handler-type.md
Created February 18, 2022 14:48
Example of TS Input event handler

Example of a Typescript function with ChangeEventHandler type:

const onChangeText: React.ChangeEventHandler<HTMLInputElement> = event => {
  setText(event.target.value);
};
@oaugusto256
oaugusto256 / code-review-articles-reference.md
Last active April 25, 2022 18:29
Code review articles to reference

Code review articles to reference

Articles to improve general code review proof of "truth", increasing the knowledge and quality code ruler of the team. If you have a place to study and get reference to point places that can be better; All collegues will be benefited. The one, whos is writing the code review, will have place to check possible things to look up and, the other, who is getting the code review, will know how to get better and have a place to study and visualize what has been discussed.

@oaugusto256
oaugusto256 / nubank-hackerrank-challenge.js
Created February 11, 2021 14:41
Nubank Hackerrank challenge solution ~ ASCII to Text
const getCurrentCharValue = (str, startIndex, endIndex) => {
const currentValueToDecode = str.substring(startIndex, endIndex);
const currentValueToDecodeInt = parseInt(currentValueToDecode);
return String.fromCharCode(currentValueToDecodeInt);
}
const getCurrentIndexJump = (value) => {
if (value === 32) {
return 1;

About me

Putting my energy to learn more about software development; trying day-by-day to be a better human; sharpening my soft skills and building strong relationships.

I faithfully believe that education, cooperation and technology can help the humanity reach its highest achievements.

Challenges

Check all my current made challenges below:

@oaugusto256
oaugusto256 / reactDebugger.js
Created November 7, 2019 20:30
See all request being made at your React application
// To see all the requests in the chrome Dev tools in the network tab.
XMLHttpRequest = GLOBAL.originalXMLHttpRequest ?
GLOBAL.originalXMLHttpRequest :
GLOBAL.XMLHttpRequest;
// fetch logger
global._fetch = fetch;
global.fetch = function (uri, options, ...args) {
return global._fetch(uri, options, ...args).then((response) => {
console.log('Fetch', { request: { uri, options, ...args }, response });
@oaugusto256
oaugusto256 / reactTips.md
Last active December 24, 2021 19:43
Bunch of React tips to follow

List of great React tips

  1. Standardise naming. onX for eventHandler props. handleX for the func.

  2. Avoid use of anonymous functions that may cause unnecessary re-renders.

Because we are passing anonymous functions, React will always re-render since it receives a new anonymous function as a prop which it is unable to compare to the previous anonymous function (since they are both anonymous). On the other hand, passing in a reference to the method like onClick={this.handleClick} lets React know when nothing has changed so it does not unnecessarily re-render. However, the anonymous function is sometimes unavoidable as when we need to pass in an argument available only in the context: onClick={() => {this.handleClick(argHereOnly)}} .

  1. Composition and componded components over passing everything by props.
@oaugusto256
oaugusto256 / mockRequest.js
Last active October 1, 2021 13:40
Mock HTTP requests at JavaScript
// Mock HTTP requests
import { users, departaments } from '../mock';
export const getUsers = async () => {
return new Promise(resolve => setTimeout(() => {
resolve(users);
}, 2000));
};
@oaugusto256
oaugusto256 / arrayManipulations.js
Last active October 31, 2019 13:36
Array manipulations with JavaScript
// Filter unique array
const array = [1, 1, 2, 3, 5, 5, 1]
const uniqueArray = [...new Set(array)];
// Add element in an array at state
addElement = (event) => {
this.setState(state => {
const list = [...list, state.element];
return {
@oaugusto256
oaugusto256 / dynamicallyHeaderNavigation.js
Last active October 31, 2019 13:26
Dynamically header navigation at React Native
SeuComponente = () => <Bla />;
SeuComponente.navigationOptions = ({navigation}) => {
headerStyle: {
backgroundColor: navigation.getParam(corNoticia),
},
}
export default SeuComponente;