Skip to content

Instantly share code, notes, and snippets.

View alberto1el's full-sized avatar

Alberto alberto1el

View GitHub Profile
@alberto1el
alberto1el / gist:7cd65d6c4af6293287e176fe667aa13f
Last active April 15, 2023 20:32
Disable/Enable xdebug on Ubuntu
sudo phpdismod xdebug
sudo phpdismod -v 7.4 xdebug #disable
sudo phpenmod -v 7.4 xdebug #enable
sudo service php7.4-fpm restart && sudo service nginx restart
#Change branch in Forge UI
#then on console in project folder
git checkout -b branch_name
#Edit vim .git/config
#change [remote "origin"] section just the branch name
git fetch --all
git branch merge/devtasks --set-upstream-to origin/branch_name
git pull origin branch_name
@alberto1el
alberto1el / DedupWithGroupConcat
Created August 4, 2020 00:59
A way to find duplicates in MySQL using group concat (its been fast so far, with tens of thousands records)
/*
THE SETUP:
An "order_status_logs" table with the following columns: order_id, status_id, created_at
There is no constraint for order_id and status_id so you can have the same order and status multiple times on "order_status_logs"
THE OBJECTIVE:
A query that returns the order_status_logs records that have duplicates (same order_id and status_id) for a known status_id
*/
@alberto1el
alberto1el / s3PresignedPUTUriLaravel.php
Created April 16, 2020 05:50
get an S3 presigned PUT url in Laravel (I dont know if there is a more elegant way but this seems to work... did not test the actual upload but it did return a uri)
<?php
namespace App\Http\Controllers;
use Illuminate\Http\Request;
use Illuminate\Support\Facades\Storage;
use League\Flysystem\Filesystem;
class S3PresignedURIController extends Controller
{
@alberto1el
alberto1el / PolymorphicRelationshipInPowerBI.txt
Created June 26, 2019 21:08
A PowerBI formula to handle polymorphic relationships using conditional columns (MySQL source)
let
Source = MySQL.Database("127.0.0.1:33060", "dbname", [ReturnSingleDatabase=true]),
table = Source{[Schema="dbname",Item="location_logs"]}[Data],
#"Added Conditional Column1" = Table.AddColumn(table, "location_name",
each if [locatable_type] = "condition_one" then (
let conditionOneID = [locatable_id] in
Table.SelectRows(#"dbname source_table_one", each [id] = conditionOneID)
){0}[name]
@alberto1el
alberto1el / gist:b472f5768360d038fa6c5b280277a901
Created November 11, 2016 01:03
Artisan Commands debugging on PHPStorm with XDEBUG
#http://stackoverflow.com/a/20120264
#where server_name stands for name of the server in PhpStorm project conifuguration
$ XDEBUG_CONFIG="idekey=PHPSTORM" PHP_IDE_CONFIG="serverName=server_name" php -dxdebug.remote_host=`echo $SSH_CLIENT | cut -d "=" -f 2 | awk '{print $1}'` artisan command
@alberto1el
alberto1el / l5 on aws ec2
Last active August 29, 2015 14:25
Laravel 5.1 on EC2 July 2015
Boot up an ubuntu instance ( I used ubuntu-trusty-14.04-amd64-server-20150325 (ami-df6a8b9b) )
———- Installing Apache ———-
$ sudo apt-get install apache2
———- Installing Latest PHP ———-
$ sudo add-apt-repository ppa:ondrej/php5
$ sudo apt-get update
$ sudo apt-get install php5 libapache2-mod-php5
———- Installing PHP Mcrypt ext. ———-
$ sudo apt-get install php5-mcrypt
@alberto1el
alberto1el / gist:d5ae07da6fdfa05535b1
Last active August 29, 2015 14:15
Cool Regex PHP Session to Laravel Session
if\(isset\(\$_SESSION\[("|')regr("|')\]\[("|')([a-zA-Z_]+)("|')\]\)\)(| )echo \$_SESSION\[("|')regr("|')\]\[("|')([a-zA-Z_]+)("|')\]
if(Session::has('regr.$4'))echo Session::get('regr.$4')
//AnotherOne
if\(\$_POST\['([a-zA-Z_]+)'\]\!\=''\)\{\$_SESSION\["regr"\]\['([a-zA-Z_]+)'\] \= \$_POST\['([a-zA-Z_]+)'\];
}else{$mensaje.='Falto Nombre Completo del distribuidor';$continua=false;}
if(Request::has('$1') && Request::input('$1')!=''){Session::put('regr.$1', Request::input('$1') ) ; } //replace
#Add the Tokutek package signing key.
sudo apt-key adv --keyserver keyserver.ubuntu.com --recv-key 505A7412
#Add an entry for the TokuMX package repository for your release (wheezy, precise, quantal, raring, saucy, or trusty).
echo "deb [arch=amd64] http://s3.amazonaws.com/tokumx-debs $(lsb_release -cs) main" | sudo tee /etc/apt/sources.list.d/tokumx.list
#Update apt and install TokuMX.
sudo apt-get update
sudo apt-get install tokumx
mongo
@alberto1el
alberto1el / gist:e52051e243093c6f605a
Created July 14, 2014 23:41
Remove .svn directories from repository
You can also issue the line below straight from the Command Prompt:
FOR /F "tokens=*" %G IN ('DIR /B /AD /S *.svn*') DO RMDIR /S /Q "%G"