Skip to content

Instantly share code, notes, and snippets.

View fransafu's full-sized avatar
🎯
Keep it simple

Francisco Javier Sánchez Fuentes fransafu

🎯
Keep it simple
View GitHub Profile
@fransafu
fransafu / install_oh_my_zsh_amazon_linux.md
Created April 23, 2022 06:33
Install Oh-My-Zsh on Amazon EC2 instance running Amazon Linux

Install Oh-My-Zsh on Amazon EC2 instance running Amazon Linux

  1. Check for updates

    • sudo yum update -y
  2. Install dependencies

    • sudo yum install -y zsh util-linux-user
  3. Change to zsh to default

  • sudo chsh -s /usr/bin/zsh $USER
@fransafu
fransafu / simple-rest-golang.yaml
Created May 4, 2020 03:32
k3s example for simple-rest-golang
---
apiVersion: apps/v1
kind: Deployment
metadata:
name: simple-rest-golang-deployment
namespace: retail-project-dev
spec:
replicas: 2
selector:
matchLabels:
@fransafu
fransafu / 2_serverHTTPWithRoutes.js
Created February 7, 2020 00:25
[Node.js] Servidor HTTP simple con rutas
// Llamar Biblioteca nativa para servidor HTTP
const http = require('http');
// Crear el servidor HTTP
const server = http.createServer((req, res) => {
// Observa como vienen las rutas
// console.log(req.url);
if (req.url === '/') {
res.write('Ahora te encuentras en el Home "/"');
return res.end();
@fransafu
fransafu / 1_serverHTTP.js
Created February 7, 2020 00:22
[Node.js] Servidor HTTP simple en el puerto 8080
// Llamar Biblioteca nativa para levantar un servidor HTTP
const http = require('http');
// Crear servidor
const server = http.createServer((req, res) => {
res.write('Hello World');
res.end();
});
// Especificar en que puerto debe escuchar el servidor las peticiones
@fransafu
fransafu / 4_tercero.js
Created February 7, 2020 00:15
[Node.js] Uso de modulo de tercero (npm)
/*
Para completar exitosamente este punto se debe inicializar npm dentro del proyecto
con el comando 'npm init'. Este genera una serie de preguntas como el nombre del proyecto,
la version, entre otras preguntas.
+ npm init
+ npm install --save is-number
Esperar a que se cree el archivo package.json, luego instalar la dependencia, esperar
a que este creado el archivo package-lock.json y la carpeta node_modules.
@fransafu
fransafu / 3_ejemplo.js
Created February 7, 2020 00:13
[Node.js] Probar modulo nativo y modulo propio
/*
En este ejemplo se realiza el uso de un modulo nativo junto con
el modulo que acabamos de hacer
*/
// Importamos una Biblioteca Nativa
const fs = require('fs');
const nuestroModulo = require('./2_propio');
// Nota: Si no especifican el 'encoding' readFile retorna un Buffer en la variable 'data'
// Nota 2: Probar sin 'uft8' como parametro
@fransafu
fransafu / 2_propio.js
Last active February 7, 2020 00:13
Ejemplo de uso de modulo propio en Node.js
// checkIfString verifica si el parametro corresponde a un String
const checkIfString = (str) => {
if (typeof str === 'string' || str instanceof String) {
return true;
}
return false;
}
// checkIfNumber verifica si el parametro ingresado corresponde a un Numero
const checkIfNumber = (num) => parseInt(num) === num;
@fransafu
fransafu / 1_nativo.js
Last active February 7, 2020 00:13
[Node.js] Ejemplo de uso de modulo nativo en Node.js
/*
URL DOC: https://nodejs.org/api/fs.html
URL Ejemplo: https://nodejs.org/api/fs.html#fs_fs_writefile_file_data_options_callback
*/
// Realizamos el llamado de la Biblioteca FileSystem (fs)
const fs = require('fs');
// Agregamos el mensaje 'Hello World' en un buffer y guardamos la salida en la variable 'data'
const data = new Uint8Array(Buffer.from('Hello World!'));
@fransafu
fransafu / Import and Clear
Created July 26, 2018 21:54
Import and Clear filename from path route [MACRO][VB]
Sub ImportarData()
Dim pathToExcel As String
Dim sheetExcelOrigin As String
Dim numRows As Long
pathToExcel = "C:\Users\fransafu\Desktop\filename.xlsx"
sheetExcelOrigin = "Sheet1"
sheetExcelDest = "Destino"
strSplit = "/"
@fransafu
fransafu / getFilename
Created July 26, 2018 21:52
Get filename and extension from path route in excel [MACRO][VB]
Sub getFilename()
' Obtener Ultima fila y ultima columna
Dim numRows As Long
Dim numCols As Long
' Guardar texto de la ruta
Dim strDoc As Variant
' Guardar arreglo separado por la variable strSplit