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 / 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)) {
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!
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>
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,
@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!' },
@brunormferreira
brunormferreira / useChuckNorris.jsx
Created April 3, 2020 13:04
chuck norris jokes hook
import { useState, useEffect } from 'react'
export function useChuckNorris() {
const [loading, setLoading] = useState(false)
const [error, setError] = useState(undefined)
const [data, setData] = useState(undefined)
useEffect(() => {
async function getJoke() {
setLoading(true)
{
// Define o tema do VSCode
"workbench.colorTheme": "Shades of Purple",
// Configura tamanho e família da fonte
"editor.fontSize": 18,
"editor.lineHeight": 24,
"editor.fontFamily": "Fira Code",
"editor.fontLigatures": true,
"explorer.compactFolders": false,
@brunormferreira
brunormferreira / react-router-dom-v5.js
Created February 18, 2020 16:46
react-router-dom-v5
import React from "react";
import {
Link,
BrowserRouter as Router,
Route,
Switch,
Redirect
} from "react-router-dom";
import "./App.css";
@brunormferreira
brunormferreira / gist:57bd7f216ef3eb9fee5423056266d8c8
Created February 11, 2020 14:00 — forked from rxaviers/gist:7360908
Complete list of github markdown emoji markup

People

:bowtie: :bowtie: 😄 :smile: 😆 :laughing:
😊 :blush: 😃 :smiley: ☺️ :relaxed:
😏 :smirk: 😍 :heart_eyes: 😘 :kissing_heart:
😚 :kissing_closed_eyes: 😳 :flushed: 😌 :relieved:
😆 :satisfied: 😁 :grin: 😉 :wink:
😜 :stuck_out_tongue_winking_eye: 😝 :stuck_out_tongue_closed_eyes: 😀 :grinning:
😗 :kissing: 😙 :kissing_smiling_eyes: 😛 :stuck_out_tongue:
@brunormferreira
brunormferreira / .editorconfig
Created January 31, 2020 00:19
.editorconfig
root = true
[*]
indent_style = space
end_of_line = lf
indent_size = 2
charset = utf-8
trim_trailing_whitespace = true
insert_final_newline = true