Skip to content

Instantly share code, notes, and snippets.

View DavidMRGaona's full-sized avatar
:shipit:
Improving. Always.

David Manuel Ramos Gaona DavidMRGaona

:shipit:
Improving. Always.
View GitHub Profile
@DavidMRGaona
DavidMRGaona / brew_php_switch_alias.sh
Created March 8, 2019 09:17
Script to easily change PHP version in OS X with brew
#!/bin/bash
phpv() {
valet stop
brew unlink php@5.6 php@7.0 php@7.1 php@7.2
brew link --force --overwrite $1
brew services start $1
composer global update
valet install
}
@DavidMRGaona
DavidMRGaona / LocalizationMiddleware.php
Last active October 2, 2020 10:02
Fragmento para utilizar en un middleware. Este comprueba si existe un locale en la sesión en cuyo caso utilizará ese. En caso contrario utilizara el que existe en la cabecera del servidor. tambien cambia el locale de la librería Carbon.
<?php
namespace App\Http\Middleware;
use Closure;
use Illuminate\Support\Carbon;
use Illuminate\Support\Facades\{App, Config, Session};
class LocalizationMiddleware
{
@DavidMRGaona
DavidMRGaona / LoginController.php
Last active March 8, 2019 09:40
Function that allows the user to log in with both the username and the email.
<?php
class LoginController extends Controller
{
(...)
/**
* Checks if the parameter passed at login is a username or an email account.
* Depending on the check it will return one login method or another
@DavidMRGaona
DavidMRGaona / SecureHeaders.php
Created November 21, 2018 15:04
Laravel Middleware to add/remove headers
<?php
namespace App\Http\Middleware;
use Closure;
class SecureHeaders
{
// Enumerate unwanted headers
private $unwantedHeaderList = [
@DavidMRGaona
DavidMRGaona / README.md
Created July 24, 2017 09:51 — forked from oodavid/README.md
Deploy your site with git

Deploy your site with git

This gist assumes:

  • you have a local git repo
  • with an online remote repository (github / bitbucket etc)
  • and a cloud server (Rackspace cloud / Amazon EC2 etc)
    • your (PHP) scripts are served from /var/www/html/
    • your webpages are executed by apache
  • apache's home directory is /var/www/