Skip to content

Instantly share code, notes, and snippets.

View JuanDMeGon's full-sized avatar

JuanDMeGon JuanDMeGon

View GitHub Profile
@JuanDMeGon
JuanDMeGon / Kernel.php
Last active November 28, 2023 15:13
A small Laravel command to collect the sessions garbage if applicable to the current session driver
<?php
namespace App\Console;
use Illuminate\Console\Scheduling\Schedule;
use Illuminate\Foundation\Console\Kernel as ConsoleKernel;
class Kernel extends ConsoleKernel
{
//...
<?php
namespace App\Exceptions;
use Exception;
use GuzzleHttp\Exception\ClientException;
use Illuminate\Foundation\Exceptions\Handler as ExceptionHandler;
class Handler extends ExceptionHandler
{
@JuanDMeGon
JuanDMeGon / DoS and DDoS Nginx Mitigation
Created June 26, 2019 21:15
DoS and DDoS Nginx Mitigation
##
# DoS and DDoS Protection Settings
##
#Define limit connection zone called conn_limit_per_ip with memory size 15m based on the unique IP
limit_conn_zone $binary_remote_addr zone=conn_limit_per_ip:15m;
#Define limit request to 40/sec in zone called req_limit_per_ip memory size 15m based on IP
limit_req_zone $binary_remote_addr zone=req_limit_per_ip:15m rate=40r/s;
@JuanDMeGon
JuanDMeGon / ConsumesExternalServices.php
Created March 21, 2019 04:29
Consumes almost any kind of HTTP service using Guzzle
<?php
namespace App\Traits;
use GuzzleHttp\Client;
trait ConsumesExternalServices
{
/**
* Send a request to any service
@JuanDMeGon
JuanDMeGon / TransformInput.php
Created July 13, 2017 17:38
This is the modification of middleware to Transform file inputs too
<?php
namespace App\Http\Middleware;
use Closure;
use Illuminate\Validation\ValidationException;
class TransformInput
{
/**
@JuanDMeGon
JuanDMeGon / TransformInput.php
Last active October 7, 2018 06:05
Este es el código completo del middleware que ayuda a resolver el problema de los nombres transformados
<?php
namespace App\Http\Middleware;
use Closure;
use Illuminate\Validation\ValidationException;
class TransformInput
{
/**