Skip to content

Instantly share code, notes, and snippets.

View joelbarbosa's full-sized avatar
🏠
Working from home

Joel Barbosa joelbarbosa

🏠
Working from home
View GitHub Profile
const deepClone = obj => {
const clone = {}
for (let i in obj) {
if (obj[i] != null && typeof obj[i] === 'object') {
clone[i] = deepClone(obj[i])
} else {
clone[i] = obj[i]
}
}
return clone
@joelbarbosa
joelbarbosa / test.js
Created December 4, 2018 21:56
questions
/*
Questions:
* What do you think PFC.props is doing?
- Creating a Object with reference parameters, map your keys;
* What is the concurrency variable good for?
- Its as especifique option where limits the number of Promise created.
* sendOutStatusEmails ignores errors (except for logging them).
Let's say your task was to make sure the whole function fails as soon sending out any
email failed. How would you adjust the code?
- follows the code:
function createNode(value) {
return {
value: value,
next: null
}
};
function createLinkedList() {
return {
head: null,
@joelbarbosa
joelbarbosa / stack
Last active December 4, 2018 22:00
function createStack() {
const array = [];
return {
push(item) {
array.push(item);
},
pop() {
return array.pop();
},
get length() {
import { createQueue } from './queueu';
function createPriorityQueue() {
const lowPriorityQueue = createQueue();
const highPriorityQueue = createQueue();
return {
enqueue(item, isHighPriority = false) {
isHighPriority
? highPriorityQueue.enqueue(item)
@joelbarbosa
joelbarbosa / queue
Last active December 4, 2018 22:00
queue
function createQueue() {
const queue = [];
return {
enqueue(item) {
queue.unshift(item);
},
dequeue() {
return queue.pop();
@joelbarbosa
joelbarbosa / gist:145280f7f2f43bcdf377da217189d558
Last active November 7, 2018 04:11
diff arrays Javascript
const arr1 = [1, 2, 3, 4, 5];
const arr2 = [0, 2, 4, 6, 10, 11];
const DIFF = [1, 3, 5, 0, 6, 10, 11];
function diffWithFor(arr1, arr2) {
const holderArr = [];
for(let i = 0; i < arr1.length; i++) {
if (arr2.indexOf(arr1[i]) === -1) {
holderArr.push(arr1[i]);
@joelbarbosa
joelbarbosa / gist:7eed77347f9c6258f0b62bf20e8b39c3
Created March 31, 2018 18:33 — 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:
@joelbarbosa
joelbarbosa / table-componente.txt
Created November 17, 2017 16:30
Componentes Controlados e Não Controlados.
╔═════════════════╦═════════════════╦═════════════╗
║ feature ║ Não Controlados ║ Controlados ║
╠═════════════════╬═════════════════╬═════════════╣
║ buscar valores ║ ║ ║
║ de um único ║ [ V ] ║ [ V ] ║
║ ponto ex:submit║ ║ ║
╠═════════════════╬═════════════════╬═════════════╣
║ validar ao ║ [ V ] ║ [ V ] ║
║ submit ║ ║ ║
╠═════════════════╬═════════════════╬═════════════╣
@joelbarbosa
joelbarbosa / UncontrolledComponents.js
Created November 17, 2017 16:05
Uncontrolled Components
import React , { Component } from 'react';
export default class ControlledComponent extends Component {
handleSubmit = event => {
const { name, idade } = event.target;
console.log(name.value, idade.value)
event.preventDefault()
}