Skip to content

Instantly share code, notes, and snippets.

View pebueno's full-sized avatar
🦉
Available

Pedro Ivo pebueno

🦉
Available
View GitHub Profile
@pebueno
pebueno / index.jsx
Created February 27, 2024 16:28
Optimized Data Transformation: Achieving O(N) Time Complexity
// The task is to implement generateOrderSummary function
const users = [
{ id: 1, name: 'Alice', age: 30 },
{ id: 2, name: 'Bob', age: 25 },
{ id: 3, name: 'Charlie', age: 35 }
];
const products = [
@pebueno
pebueno / index.jsx
Created February 27, 2024 15:38
Multiselect button React
// The task is to implement multiselect from scratch (styling is not required)
// While closed it should show selected items separated by coma,
// on click it should open a list where you can check/uncheck items
const Component = () => {
const [items, setItems] = React.useState([])
const [selected, setSelected] = React.useState([])
const [isOpen, setIsOpen] = React.useState(false);
@pebueno
pebueno / App.tsx
Created February 27, 2024 14:48
Use hooks to Fetch from URL and Resolve all Promises
import "./styles.css";
import PeopleList from "./PeopleList";
export default function App() {
const peopleIds = [1, 2, 3, 4, 5, 6, 7, 8, 9, 10];
return <PeopleList ids={peopleIds} />;
}
@pebueno
pebueno / index.jsx
Created February 27, 2024 14:45
Scroll To Section with Ref
// Task is to implement scroll to section for buttons in the menu without anchoring
const Component = () => {
const section2Ref = React.useRef(null);
const section3Ref = React.useRef(null);
const section4Ref = React.useRef(null);
const scrollToSection = (sectionRef) => {
if (sectionRef.current) {
@pebueno
pebueno / index.jsx
Created February 27, 2024 14:42
Button Gradient Roll on Hover
// Implement animation for gradient on hover
const Component = () => {
return (
<div className="container">
<button>BUTTON</button>
</div>
)
@pebueno
pebueno / crawling.js
Created December 20, 2022 22:44
Simple crawler to gather url's of a website
const axios = require('axios')
const cheerio = require('cheerio')
const urlParser = require("url");
const fs = require("fs");
function replaceCommaLine(data) {
//convert string to array and remove whitespace
let dataToArray = data.split(',').map(item => item.trim());
//convert array to string replacing comma with new line
return dataToArray.join("\n");