Skip to content

Instantly share code, notes, and snippets.

View nelsondev19's full-sized avatar
😃
Hello!

Nelson Hernández nelsondev19

😃
Hello!
View GitHub Profile
const imageBinary = null
const changeImagenUpdate = (e) => {
e.preventDefault();
const imageSelected = e.target.files[0];
const reader = new FileReader();
reader.readAsDataURL(imageSelected);
reader.onload = e => {
e.preventDefault();
imageBinary = e.target.result
@nelsondev19
nelsondev19 / generateTextRandom.js
Created July 26, 2021 04:22
Ejemplo de como generar text random con JavaScript
export const generateCode = (nombre)=> {
//OBTENIENDO PARTE DEL NOMBRE DE LA PERSONA
var primerNombre = ""
var arrayNombre = nombre.split(" ");
var nombreConEspacios = arrayNombre.length;
if (nombreConEspacios > 1) {
primerNombre = arrayNombre[0]
}
const abecedario = ["ww","a","b","c","d","e","f","g","h","i","j","k","l","m","n","o","p","q","r","s","t","u","v","w","x","y","z","$","&","#","@"];
@nelsondev19
nelsondev19 / send_files_with_fetch.js
Last active January 19, 2023 09:13
How to send multiple files to backend with API Fetch or Axios
<!DOCTYPE html>
<html lang="en">
<head>
<meta charset="UTF-8" />
<meta name="viewport" content="width=device-width, initial-scale=1.0" />
<title>Document</title>
</head>
<body>
<input id="myInput" type="file" multiple />
<button type="click" id="btn">CLICK</button>
import { Fragment, useState } from "react";
function App() {
const [Autos] = useState(["volvo", "saab", "mercedes", "audi"]);
const [ValueSelected, setValueSelected] = useState(0);
const toggle = (AutoSeleccionado) => {
const indexSelected = Autos.findIndex((auto) => auto === AutoSeleccionado);
setValueSelected(indexSelected);
@nelsondev19
nelsondev19 / optimization-images-fastapi.py
Created November 19, 2021 22:10
Optimization of images with FastAPI (Python)
from fastapi import FastAPI, UploadFile, File, BackgroundTasks
from fastapi.responses import JSONResponse
from os import getcwd
from PIL import Image
app = FastAPI()
PATH_FILES = getcwd() + "/"
@nelsondev19
nelsondev19 / azure_blob_storage_python.py
Last active February 18, 2023 20:11
The main methods to use with Azure Blob Storage and python
from os import getenv
from azure.storage.blob import BlobServiceClient
blob_service_client = BlobServiceClient.from_connection_string(
getenv("AZURE_STORAGE_CONNECTION_STRING"))
### Methods for blobs (Files)
def upload_blob(filename: str, container: str, data: BinaryIO):
try:
@nelsondev19
nelsondev19 / google_calendar_python.py
Last active July 8, 2022 14:37
Google Calendar API con Python
from os import path
import pickle
from google.auth.transport.requests import Request
from google_auth_oauthlib.flow import InstalledAppFlow
from googleapiclient.discovery import build
# IF YOU MODIFY THE SCOPE DELETE THE TOKEN.TXT FILE
SCOPES = ['https://www.googleapis.com/auth/calendar.events',
'https://www.googleapis.com/auth/calendar']
@nelsondev19
nelsondev19 / azure_blob_storage_javascript.js
Created January 5, 2022 02:21
Azure Blob Storage with JavaScript (Express JS)
import { BlobServiceClient } from "@azure/storage-blob";
import { config } from "dotenv";
config();
const blobService = BlobServiceClient.fromConnectionString(
process.env.AZURE_STORAGE_CONNECTION_STRING
);
// Methods for blobs (Files)
@nelsondev19
nelsondev19 / docker-compose.yml
Last active April 12, 2024 08:18
How to monitor Redis with Prometheus and Grafana | Docker
version: "3.9"
services:
grafana:
image: grafana/grafana
ports:
- 3000:3000
prometheus:
image: prom/prometheus
ports:
@nelsondev19
nelsondev19 / docker-compose.yml
Last active June 28, 2022 17:51
How to monitor PostgreSQL with Prometheus and Grafana | Docker
version: "3.9"
services:
grafana:
image: grafana/grafana
ports:
- 3000:3000
prometheus:
image: prom/prometheus
ports: