Skip to content

Instantly share code, notes, and snippets.

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

Roberto Obando robertoandres24

🏠
Working from home
View GitHub Profile
@robertoandres24
robertoandres24 / for-of-loop.js
Last active October 17, 2021 21:34 — forked from anvk/promises_reduce.js
Sequential execution of Promises using reduce()
//recibe un array y una callback asyncrona
// y cada promesa se va ejecutando secuencialmente
// seria lo contrario a un Promise.all()
// me fue util para manejar los insert en la bd con typeorm y evitar conflictos de ids, duplicacion y fallos en las queries
export const runPromisesSequentally = async (
arr: any,
asyncFn: (item: any) => Promise<any>
): Promise<any[]> => {
const allContents = [];
@robertoandres24
robertoandres24 / schema.ts
Created December 7, 2020 04:15 — forked from mattmazzola/schema.ts
GraphQL Paginated Query Implementation
units: {
type: pagination.Page(Unit),
description: "Return the 'first' X number of items 'after' the specified cursor'",
args: {
first: {
type: graphql.GraphQLInt,
description: "Limits the number of results returned in the page. Defaults to 10."
},
after: {
type: graphql.GraphQLString,
@robertoandres24
robertoandres24 / ts-boilerplate.md
Created November 14, 2020 05:01 — forked from silver-xu/ts-boilerplate.md
Setup a Node.js project with Typescript, ESLint, Prettier, Husky

Setup a Node.js project with Typescript, ESLint, Prettier, Husky

1_D8Wwwce8wS3auLAiM3BQKA

Starting a personal node project could be easy; starting a team node project could be challenging.

I am a developer currently working in SEEK Australia.

In my experience, common mistakes developer make when starting a projects are:

  • No Linting
@robertoandres24
robertoandres24 / .eslintrc.js
Last active November 14, 2020 04:17
Nodejs typescript Eslint + Prettier
module.exports = {
parser: '@typescript-eslint/parser', // Specifies the ESLint parser
extends: [
'plugin:@typescript-eslint/recommended', // Uses the recommended rules from the @typescript-eslint/eslint-plugin
'prettier/@typescript-eslint', // agrega las reglas de prettier a eslint
'plugin:prettier/recommended' // agregar el plugin que integra eslint con prettier
],
parserOptions: {
ecmaVersion: 2018, // Allows for the parsing of modern ECMAScript features
sourceType: 'module' // Allows for the use of imports
@robertoandres24
robertoandres24 / .eslintrc.json
Last active November 14, 2020 02:40
create react app typescript eslint+prettier config
{
"env": {
"browser": true,
"es6": true
},
"extends": ["react-app", "prettier"],
"plugins": ["react", "prettier"],
"parserOptions": {
"ecmaVersion": 2018
},
@robertoandres24
robertoandres24 / mongodb-basic-connection.js
Last active October 28, 2020 20:05
mongo db basic connection
const mongoose = require('mongoose')
const connect = async function () {
try {
await mongoose.connect('mongodb://localhost:27017/graphql-test', {
useNewUrlParser: true,
useUnifiedTopology: true,
})
console.log('Mongo DB is connected...')
} catch (error) {
@robertoandres24
robertoandres24 / .eslintrc.json
Last active July 23, 2022 16:41
eslint + airbnb style + prettier config for Node js
{
"env": {
"node": true,
"commonjs": true,
"es2021": true
},
"extends": ["airbnb-base", "prettier"],
"plugins": ["prettier"],
"parserOptions": {
"ecmaVersion": "latest"
@robertoandres24
robertoandres24 / 2017_11_21_144804_create_regions_table.php
Created September 16, 2020 12:33 — forked from gdespirito/2017_11_21_144804_create_regions_table.php
Comunas y regiones de Chile - 2017 | Migraciones y Seeders para Laravel
<?php
use Illuminate\Support\Facades\Schema;
use Illuminate\Database\Schema\Blueprint;
use Illuminate\Database\Migrations\Migration;
class CreateRegionsTable extends Migration
{
/**
* Run the migrations.
@robertoandres24
robertoandres24 / Confirm.vue
Created June 28, 2020 03:54 — forked from eolant/Confirm.vue
Vuetify Confirm Dialog component that can be used locally or globally
<template>
<v-dialog v-model="dialog" :max-width="options.width" :style="{ zIndex: options.zIndex }" @keydown.esc="cancel">
<v-card>
<v-toolbar dark :color="options.color" dense flat>
<v-toolbar-title class="white--text">{{ title }}</v-toolbar-title>
</v-toolbar>
<v-card-text v-show="!!message" class="pa-4">{{ message }}</v-card-text>
<v-card-actions class="pt-0">
<v-spacer></v-spacer>
<v-btn color="primary darken-1" text @click.native="agree">Yes</v-btn>
//returns true if is empty
Object.keys(obj).length === 0 && obj.constructor === Object