Skip to content

Instantly share code, notes, and snippets.

💻
💪💪

Anartz Mugika Ledo mugan86

💻
💪💪
View GitHub Profile
@mugan86
mugan86 / index.js
Created Jul 12, 2020
Servidor básico con lo mínimo en GraphQL haciendo uso de GraphiQL
View index.js
const express = require("express");
const { buildSchema } = require("graphql");
const { graphqlHTTP } = require("express-graphql");
const bodyParser = require('body-parser');
const courses = [
{
id: 1,
title: "GraphQL de 0 a experto",
views: 29290,
},
@mugan86
mugan86 / canvas.html
Created Jul 3, 2020
Canvas HTML with template to use for generate video screens automatically
View canvas.html
<!DOCTYPE html>
<html>
<body>
<img
id="scream"
width="1280"
height="720"
src="https://res.cloudinary.com/dd7kbplmv/image/upload/v1593802420/gtnekt2jmmbojhqzrzk9.png"
alt="The Scream"
/>
@mugan86
mugan86 / app.component.ts
Last active Jun 13, 2020
Componente principal con el iframe para usar el reproductor de Youtube
View app.component.ts
import { Component, OnInit } from '@angular/core';
@Component({
selector: 'my-app',
templateUrl: './app.component.html',
styleUrls: [ './app.component.css' ]
})
export class AppComponent implements OnInit{
ngOnInit() {
// Este código carga el reproductor de la API en un iframe de manera asíncrona, siguiendo las instrucciones:
View schema-2020.ts
import 'graphql-import-node';
import { makeExecutableSchema } from 'graphql-tools';
import { GraphQLSchema } from 'graphql';
import resolvers from '../resolvers/resolverMap';
import { mergeTypeDefs } from '@graphql-tools/merge';
import { loadFilesSync } from '@graphql-tools/load-files';
const typeDefs = mergeTypeDefs(loadFilesSync(`${__dirname}/**/*.graphql`));
const schema: GraphQLSchema = makeExecutableSchema({
typeDefs,
@mugan86
mugan86 / take-all-branches.sh
Created Apr 21, 2020
Descargar todas las ramas remotas a local
View take-all-branches.sh
git branch -r | grep -v '\->' | while read remote; do git branch --track "${remote#origin/}" "$remote"; done
git fetch --all
git pull --all
@mugan86
mugan86 / aggregation-mongodb.txt
Created Apr 11, 2020
Añadiré las consultas para hacer inner join con MongoDB
View aggregation-mongodb.txt
Obtener los nombres de los datos principales del producto, limitado a 5 y que sean plataforma PC
db.products_platforms.aggregate( [{ $lookup: { from: 'products', localField: 'product_id', foreignField: 'id', as: 'info_general' } }, {$match: {platform_id: '4'}}, { $project: { product_id: 0 } }, {$limit: 5}]).pretty()
@mugan86
mugan86 / database-operations.ts
Last active Apr 10, 2020
Database operations
View database-operations.ts
import { Db } from 'mongodb';
export const asignDocumentId = async (
database: Db,
collection: string,
sort: object = { registerDate: -1 }
) => {
// Check las
const lastItem = await database
.collection(collection)
@mugan86
mugan86 / angular.json
Created Apr 1, 2020
Configuración pre e2e
View angular.json
"e2e": {
"builder": "@angular-devkit/build-angular:protractor",
"options": {
"protractorConfig": "e2e/protractor.conf.js",
"devServerTarget": "ssr-medium:serve"
},
"configurations": {
"production": {
"devServerTarget": "ssr-medium:serve:production"
}
@mugan86
mugan86 / tsconfig.server.json
Last active Apr 1, 2020
Fichero configuración ts server
View tsconfig.server.json
{
"extends": "./tsconfig.app.json",
"compilerOptions": {
"outDir": "./out-tsc/app-server",
"module": "commonjs",
"types": [
"node"
]
},
"files": [
@mugan86
mugan86 / server.ts
Created Apr 1, 2020
Server aplicando SSR en Angular 9
View server.ts
import 'zone.js/dist/zone-node';
import { ngExpressEngine } from '@nguniversal/express-engine';
import * as express from 'express';
import { join } from 'path';
import { AppServerModule } from './src/main.server';
import { APP_BASE_HREF } from '@angular/common';
import { existsSync } from 'fs';
You can’t perform that action at this time.