Skip to content

Instantly share code, notes, and snippets.

View johnsi15's full-sized avatar
🤖
Web technology lover 👨‍💻

John Serrano johnsi15

🤖
Web technology lover 👨‍💻
View GitHub Profile
<?php
// @codingStandardsIgnoreFile
/**
* @file
* Drupal site-specific configuration file.
*
* IMPORTANT NOTE:
* This file may have been set to read-only by the Drupal installation program.
@johnsi15
johnsi15 / NginxCache.conf
Created October 12, 2019 21:49 — forked from MichaelCduBois/NginxCache.conf
Nginx Cache with Reverse Proxy
user nginx;
worker_processes 1;
error_log /var/log/nginx/error.log warn;
pid /var/run/nginx.pid;
events {
worker_connections 1024;
}
http {
@johnsi15
johnsi15 / server.js
Created September 8, 2019 14:56 — forked from edolyne/server.js
Dynamic Sitemap creation for NextJS based projects
const express = require('express');
const next = require('next');
const sm = require('sitemap');
const axios = require('axios');
const port = parseInt(process.env.PORT, 10) || 3000;
const dev = process.env.NODE_ENV !== 'production';
const app = next({ dev });
const handle = app.getRequestHandler();
@johnsi15
johnsi15 / CRUD MongoDB
Created May 28, 2019 16:19
Example crud mongo
# Conectarse a MongoDB
mongo <URI Atlas>
# Usar la base de datos creada de platzi
use platzi-db
# El campo _id si no es agregado por nosotros de forma explícita, MongoDB lo agrega por nosotros como un ObjectId
# el campo _id es obligatorio en todos los documentos
<!DOCTYPE html>
<html>
<head>
<meta charset="utf-8">
<meta name="viewport" content="width=device-width">
<title>JS Bin</title>
</head>
<body>
<script id="jsbin-javascript">
@johnsi15
johnsi15 / firestore.js
Created April 25, 2019 02:43
Realizando inserciones, consultas compuestas, límites y ordenamiento
class PostDAO {
constructor () {
this.db = firebase.firestore()
const settings = { timestampsInSnapshots: true }
this.db.settings(settings)
}
add (post, id) {
this.db.collection('posts').doc(id).set({
titulo: post.titulo,
@johnsi15
johnsi15 / docker
Created August 24, 2018 16:40
Comandos básicos de docker
docker run hello-world
docker search Ubuntu
docker pull Ubuntu
docker images
docker run -it Ubuntu bash
@johnsi15
johnsi15 / read-write.js
Created May 4, 2018 22:07 — forked from AngelMunoz/read-write.js
leeer y escribir archivos en nodejs con node v6.0+
// importamos la libreria
const fs = require('fs');
//puede llevar cualquier nombre, generalmente
// se sigue la convencion de usar el mismo nombre que la libreria
// fs es parte de la libreria estandard
/**
* @param {string} directorio de destino
* @param {string} texto a escribir dentro del archivo
@johnsi15
johnsi15 / modulos.js
Created August 9, 2017 15:39
A esto lo llamo un browserify nativo. Ahora JavaScript se empieza a parecer a lenguajes como Python o Ruby. Llamamos a las funciones desde los propios Scripts, sin tener que importarlos en el HTML, si usamos JavaScript en el navegador.
//File: lib/person.js
module "person" {
export function hello(nombre) {
return nombre;
}
}
//También se puede exportar así, según una aclaración de Sergio Daniel Xalambrí
// export function hello(nombre) {...};
@johnsi15
johnsi15 / Destructuring.js
Created August 9, 2017 15:38
Tenemos nuevas formas de asignar valores a Arrays y a Objetos. Veamos unos ejemplos
var [a, b] = ["hola", "mundo"];
console.log(a); // "hola"
console.log(b); // "mundo"
var obj = { nombre: "Carlos", apellido: "Azaustre" };
var { nombre, apellido } = obj;
console.log(nombre); // "Carlos"
// Otro ejemplo
var foo = function() {