Skip to content

Instantly share code, notes, and snippets.

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

Reny Ramos DesolatorMagno

🏠
Working from home
View GitHub Profile
@DesolatorMagno
DesolatorMagno / general.php
Created March 21, 2024 14:08
Helper functions (Laravel)
<?php
namespace App\Helpers;
use DateTime;
use Illuminate\Database\Eloquent\Collection;
use Illuminate\Support\Facades\Crypt;
class General
{
COMPOSE_PROJECT_NAME=Cool_Project
DB_PASSWORD=mypassword
DB_DATABASE=database_name
DB_USERNAME=user_name
DB_PORT=3306
DB_PORT_FORWARD=3307
#for implementantion
WEB_PORT=80
SSL_PORT=443
@DesolatorMagno
DesolatorMagno / dock.sh
Last active January 18, 2023 20:45
Dock
#!/usr/bin/env bash
# Author: Reny Ramos <renyramosgarcia@gmail.com>
# Licence: GPL-2
# Description.
nombre=$(cat .env | grep COMPOSE_PROJECT_NAME | cut -d "=" -f 2)
#######################################
# FUNCTIONS
#######################################
@DesolatorMagno
DesolatorMagno / chronos.php
Created July 15, 2021 13:42
tomar el tiempo de ejecucion de partes del codigo.
<?php
class Chronometer
{
private $start = [];
private $end = [];
public function start(string $name = 'default'): void
{
$this->start[$name] = microtime(true);
@DesolatorMagno
DesolatorMagno / app.blade.php
Created December 3, 2020 16:19
Layout utilizando componentes
<!DOCTYPE html>
<html lang="en">
<head>
<meta charset="UTF-8">
<meta name="viewport" content="width=device-width, initial-scale=1.0">
<meta http-equiv="X-UA-Compatible" content="ie=edge">
{{ $meta ?? '' }}
<title>{{ $title }}</title>
@yield('style')
{{ $style ?? '' }}
@DesolatorMagno
DesolatorMagno / Company.php
Created May 25, 2020 20:17
Trait para el manejo de Archivos, se encarga de almacenar, eliminar y verificar que el archivo sea correcto, ademas de actualizar el campo con la url correcta.
<?php
namespace App;
use App\Traits\ModelFileManager;
use Illuminate\Database\Eloquent\Model;
class Company extends Model
{
use ModelFileManager;
fetch(route,{
method: 'get'
}).then(function(response){
return response.text();
}).then(function(res){
console.log(res)
}).catch(function(err){
});
@DesolatorMagno
DesolatorMagno / CheckRole.php
Last active July 21, 2020 00:23
Middleware que se encarga de verificar si el usuario logueado tiene el o uno de los roles especificados, con el funcionamiento adicional de redireccionar a una ruta especificada.
<?php
namespace App\Http\Middleware;
use Closure;
class CheckRole
{
/**
* Handle the incoming request.
@DesolatorMagno
DesolatorMagno / gist:b80cbe8a1e0158d85b1afa9a0b83bb5d
Created March 9, 2020 19:17 — forked from jrmadsen67/gist:bd0f9ad0ef1ed6bb594e
Laravel Quick Tip: Handling CsrfToken Expiration gracefully
Quick tip for handling CSRF Token Expiration - common issue is when you use csrf protection is that if
a form sits there for a while (like a login form, but any the same) the csrf token in the form will
expire & throw a strange error.
Handling it is simple, and is a good lesson for dealing with other types of errors in a custom manner.
In Middleware you will see a file VerifyCsrfToken.php and be tempted to handle things there. DON'T!
Instead, look at your app/Exceptions/Handler.php, at the render($request, Exception $e) function.
All of your exceptions go through here, unless you have excluded them in the $dontReport array at the
@DesolatorMagno
DesolatorMagno / Dockerfile
Last active October 10, 2020 19:22
docker-composer config01
FROM phpdockerio/php73-fpm:latest
WORKDIR "/application"
# Fix debconf warnings upon build
ARG DEBIAN_FRONTEND=noninteractive
# Install selected extensions and other stuff
RUN apt-get update \
&& apt-get -y --no-install-recommends install php7.3-mysql \
&& apt-get clean; rm -rf /var/lib/apt/lists/* /tmp/* /var/tmp/* /usr/share/doc/*