Skip to content

Instantly share code, notes, and snippets.

View carlosazaustre's full-sized avatar

Carlos Azaustre carlosazaustre

View GitHub Profile
@carlosazaustre
carlosazaustre / toReversed.js
Created May 16, 2023 09:36
Nuevos métodos Inmutables en JavaScript para 2023
// 3. toReversed
const studentGrades = [90, 88, 98, 61, 78, 62, 64];
// modifica el array original
studentGrades.reverse(); // [ 61, 62, 64, 78, 88, 90, 98 ]
const newStudentGrades = [90, 88, 98, 61, 78, 62, 64];
// Immutabilidad! Devuelve un nuevo array sin modificar el original
newStudentGrades.toReversed();
@carlosazaustre
carlosazaustre / App.jsx
Created April 13, 2023 09:27
ErrorBoundary Example
import { Suspense, lazy } from "react";
import { ErrorBoundary, ErrorMessage } from "./Counter";
import "./App.css";
const Counter = lazy(() => import("./Counter"));
function App() {
return (
<div className="App">
<Suspense fallback={<p>Loading...</p>}>
const logo = document.getElementById("logo");
let currentIndex = 0;
const keySequence = [
"ArrowUp",
"ArrowUp",
"ArrowDown",
"ArrowDown",
"ArrowLeft",
"ArrowRight",
"ArrowLeft",
@carlosazaustre
carlosazaustre / index.js
Created February 28, 2023 11:20
Asincronía en JavaScript
const data = [
{
title: "Aprendiendo JavaScript",
year: "2021",
isbn: "978-87001179623",
author: "Carlos Azaustre",
},
{
title: "Aprendiendo React",
year: "2023",
@carlosazaustre
carlosazaustre / db.js
Created October 23, 2020 15:09
Get Data from nested collection on Firestore
// Database format: /products/{productId}/prices/{priceId}
export async function getProductPricesById(id) {
const prices = []
const snapshot = await DataSource.collection('products')
.doc(id)
.collection('prices')
.get()
snapshot.forEach((doc) => {
@carlosazaustre
carlosazaustre / settings.json
Created October 17, 2020 11:01
VS Code Settings
{
"workbench.colorTheme": "Sorcerer",
"workbench.iconTheme": "material-icon-theme",
"editor.tabSize": 2,
"editor.cursorStyle": "block",
"window.zoomLevel": 0,
"[javascriptreact]": {
"editor.defaultFormatter": "esbenp.prettier-vscode"
},
"[javascript]": {
@carlosazaustre
carlosazaustre / extensions.json
Last active October 17, 2020 10:58
VS Code Extensions
{
"recommendations": [
"2gua.rainbow-brackets",
"alexcvzz.vscode-sqlite",
"bashmish.es6-string-css",
"bierner.jsdoc-markdown-highlighting",
"bierner.markdown-preview-github-styles",
"blanu.vscode-styled-jsx",
"bradlc.vscode-tailwindcss",
"bungcip.better-toml",
@carlosazaustre
carlosazaustre / main.js
Created June 12, 2019 10:09
Async API calls inside While Loop (node.js)
const requestPromise = require('request-promise-native');
const API = 'https://jsonplaceholder.typicode.com/posts/';
function makeAPICall(id) {
return requestPromise({
url: API + id,
method: 'GET',
json: true
});
@carlosazaustre
carlosazaustre / app.js
Created February 9, 2017 23:26
Guía React
class Empleado extends React.Component {
render () {
return (
<li>
{this.props.nombre} - {this.props.email}
</li>
);
}
}
@carlosazaustre
carlosazaustre / gulpfile.js
Last active August 29, 2015 14:23
Development server with Gulp
var gulp = require('gulp');
var webserver = require('gulp-webserver');
var historyApi = require("connect-history-api-fallback");
gulp.task('server', function(){
gulp.src( path.root )
.pipe(webserver({
host : "0.0.0.0",
port : 8080,
livereload : true,