Skip to content

Instantly share code, notes, and snippets.

View brunormferreira's full-sized avatar
:octocat:
coding and learning

Bruno Ramires brunormferreira

:octocat:
coding and learning
View GitHub Profile
@brunormferreira
brunormferreira / reduce.js
Last active February 19, 2021 14:17
This is a exercise to do with Javascript.
[
{ id: 1, likes: 13, text: 'Lets code in Reactjs for all day long!' },
{ id: 2, likes: 87, text: 'Software Developer is a good choice to your life!' },
{ id: 3, likes: 51, text: 'Make your code readability.' },
{ id: 4, likes: 32, text: 'Open Source Software is the best thing for the developers learn more and more.' },
]
// -> Remove the likes property ->
[
{ id: 1, text: 'Lets code in Reactjs for all day long!' },
{ id: 2, text: 'Software Developer is a good choice to your life!' },
const localStorageKey = '__bookshelf_token__'
function client(endpoint, {body, ...customConfig} = {}) {
const token = window.localStorage.getItem(localStorageKey)
const headers = {'content-type': 'application/json'}
if (token) {
headers.Authorization = `Bearer ${token}`
}
const config = {
method: body ? 'POST' : 'GET',
...customConfig,
import React from 'react';
function Counter(props) {
const { counter, setCounter } = props;
return (
<div>
<h1>Functional Component Example for Counter</h1>
<p>We clicked {counter} times</p>
<button onClick={() => setCounter(counter + 1)}>Increase counter</button>
Hi! This works for me.
Just install the font that you want.
Set "editor.fontLigatures": true and "editor.fontLigatures": true in settings.json on VS Code.
Restart your VS Code.
Be happy!
@brunormferreira
brunormferreira / poll.js
Created August 3, 2021 14:43
polling function
const poll = ({ fn, validate, interval, maxAttempts }) => {
console.log('Start poll...');
let attempts = 0;
const executePoll = async (resolve, reject) => {
console.log('- poll');
const result = await fn();
attempts++;
if (validate(result)) {