Skip to content

Instantly share code, notes, and snippets.

@ivandez
ivandez / gist:49d6122b211e0680f6d8843f52af9056
Created March 17, 2024 16:21
How to graceful shutdown an express docker app
// source: https://stackoverflow.com/questions/78121173/how-to-graceful-shutdown-an-express-docker-app
// Option 1
process.on("SIGTERM", function(code_signal_error){
process.exit(0) //or whatever you want
})
// Option 2
@ivandez
ivandez / solution.js
Created April 5, 2023 13:51
Q9 solution
// Importing
const fs = require("fs");
const https = require("https");
// INSTRUCTIONS TO RUN THE TEST
// Dear tester, just replace the bellow value with the path of the file you want to test
// and everything will work
const testFilePath = "url.txt"; // REPLACE ME!
import { useState } from "react";
function HiddenVulnerabilities() {
const [userMessage, setUserMessage] = useState("");
const [userEmail, setUserEmail] = useState("");
const [messages, setMessages] = useState([]);
const handleUserMessageChange = (e) => {
setUserMessage(e.target.value);
};
@ivandez
ivandez / HiddenVulnerabilities.js
Last active April 5, 2023 14:28
Q10 solution 1
import { useState } from "react";
function HiddenVulnerabilities() {
const [userMessage, setUserMessage] = useState("");
const [userEmail, setUserEmail] = useState("");
const [messages, setMessages] = useState([]);
const handleUserMessageChange = (e) => {
setUserMessage(e.target.value);
};
@ivandez
ivandez / gist:39b06478d5565225fd35ea90036a1436
Created July 12, 2022 20:23
function to convert Date into string formart TS
private formatDate = (date: Date): string => {
const formatedDate = date.getFullYear() + "-" + (date.getMonth() + 1) + "-" + date.getDate();
const formatedTtime = date.getHours() + ":" + date.getMinutes() + ":" + date.getSeconds();
const dateTime = formatedDate + " " + formatedTtime;
return dateTime;
};
@ivandez
ivandez / php
Created May 6, 2022 12:56
contar productos
public static function getSerialNumber()
{
// Get the last created order
$lastOrder = Product::orderBy('created_at', 'desc')->first();
if (!$lastOrder)
// We get here if there is no order at all
// If there is no number set it to 0, which will be 1 at the end.
$number = 0;
else
@ivandez
ivandez / api
Created November 24, 2021 02:38
token de amazon
<?php
use Illuminate\Http\Request;
use Illuminate\Support\Facades\Route;
/*
|--------------------------------------------------------------------------
| API Routes
|--------------------------------------------------------------------------
|
@ivandez
ivandez / gist:b1842a031193cf27d3972138dddb0dba
Created July 16, 2021 13:56
Contenedor centrado con css
.contenedor{
width: 90%;
max-width: 1000px;
margin: 20px auto;
background-color: red;
}
@ivandez
ivandez / ApiResponseTrait.php
Last active October 28, 2021 22:31
Laravel API Response trait
<?php
namespace App\Traits;
/*
|--------------------------------------------------------------------------
| Api Response Trait
|--------------------------------------------------------------------------
|
| This trait will be used for any response we sent to clients.
@ivandez
ivandez / gist:29f0760abc25fc9762514b78bdb8e70c
Created August 8, 2019 19:59
Bootstrap grip platzi challenge
<--challenge 1-->
<style>
.container{
margin-top: 25px;
}
.col {
background-color: #19E58D;
border: 1px solid white;
padding: 50px;
}