Skip to content

Instantly share code, notes, and snippets.

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

Fernando Magrosoto Vásquez fmagrosoto

🏠
Working from home
View GitHub Profile
@fmagrosoto
fmagrosoto / headerAnimado.js
Created May 6, 2025 23:08
Script para que aparezca un elemento cuando otro elemento llegue al borde de la página
window.addEventListener("scroll", function () {
let header = document.getElementById("headerDesktop");
let menu = document.getElementById("menuFixed");
if (header.getBoundingClientRect().top <= 0) {
menu.style.top = "0";
} else {
menu.style.top = "-100px";
}
});
@fmagrosoto
fmagrosoto / bumpVersion.sh
Created February 21, 2025 20:49
Archivo bash para automatizar la versión de repositorio git
#!/bin/bash
echo "Haciendo un bump de la versión..."
# Variables
DEVELOP_BRANCH="develop"
VERSION_BRANCH="version"
MAIN_BRANCH="main"
# Verificar el parámetro de versión
@fmagrosoto
fmagrosoto / SubirArchivoHelper.php
Last active July 7, 2024 22:47
Clase especial de PHP para poder subir un archivo al servidor y poder validar varias cosas, como el peso y el tipo MIME
<?php
/**
* CLASE PARA SUBIR UN ARCHIVO A LA CARPETA PASADA COMO PARÁMETRO
*
* Hay casos donde deberemos de estar subiendo archivos al servidor. Antes de subirlos,
* deberemos de estar validando el peso y el formato. Y una vez subido el archivo, deberemos
* de regresar el nombre del archivo, debidamente limpiado y con una marca de tiempo para
* evitar que haya duplicados y se sobreescriban. Será entonces cuando podamos almacenar
* en una base de datos el nombre del archivo.
@fmagrosoto
fmagrosoto / index.html
Last active June 30, 2024 17:37
Uso de API REST de WooCommerce para importar clientes masivamente
<!DOCTYPE html>
<html lang='es-MX'>
<head>
<meta charset='UTF-8'>
<meta content='width=device-width, initial-scale=1.0' name='viewport'>
<title>Importador de clientes a WooCommerce</title>
</head>
<body>
<h1>Importar clientes a WooCommerce</h1>
<p>
@fmagrosoto
fmagrosoto / borrarHijos.js
Created April 4, 2024 18:19
Borra de manera recursiva los hijos de un elemento, usando javascript y while
/**
* ELIMINAR DE MANERA RECURSIVA A LOS HIJOS DEL ELEMENTO PASADO COMO PARÁMETRO
*
* @author Fernando Magrosoto V.
* @since abril, 2024
*/
function borrarHijosRecursivamente(elemento) {
while (elemento.firstChild) {
elemento.removeChild(elemento.firstChild);
}
@fmagrosoto
fmagrosoto / docker-compose.yml
Created February 8, 2023 22:08
Docker compose file for MySQL Server and phpMyAdmin
# v1.0.0 Fernando Magrosoto V.
version: "3.7"
services:
servidor-mysql:
image: mysql:8.0
environment:
MYSQL_ROOT_PASSWORD: acceso2023
ports:
- "3306:3306"
@fmagrosoto
fmagrosoto / ModificarFecha.php
Created April 7, 2022 16:40
Función PHP para añadir días a una fecha dada y en formato MySQL: YYYY-mm-dd
$fechaMasQuince = date('Y-m-d', strtotime($fechaCruda . ' + 15 days'));
@fmagrosoto
fmagrosoto / muro.js
Created August 16, 2021 19:49
Detectar cuando se llega al final de una página
$(window).scroll(() => {
if ($(window).scrollTop() === ($(document).height() - $(window).height())) console.log('This is the end...')
})
@fmagrosoto
fmagrosoto / salida.php
Created April 23, 2021 22:02
Salida json desde PHP
header('Content-Type: application/json');
echo json_encode([
'estado' => $estado,
'correo' => $correo
]);
@fmagrosoto
fmagrosoto / hellip.scss
Last active January 5, 2021 18:19
Overflow hellip
h1 {
margin: 0;
padding: 0;
font-weight: 300;
color: whitesmoke;
font-size: 36px;
width: 100%;
white-space: nowrap;
overflow: hidden;
text-overflow:ellipsis;