Skip to content

Instantly share code, notes, and snippets.

View TheoKouzelis's full-sized avatar

Theo Kouzelis TheoKouzelis

View GitHub Profile
@TheoKouzelis
TheoKouzelis / Convert PHP exceptions into Python exceptions
Created July 30, 2018 07:11
How to convert PHP exceptions into Python exceptions in Lambda functions.
import json
import subprocess
def handler(event, context):
result = subprocess.run([
'php',
'index.php',
json.dumps(event),
json.dumps(context)],
stdout=subprocess.PIPE,
@TheoKouzelis
TheoKouzelis / PrivateResponse.php
Created March 24, 2017 00:53
Laravel middleware that stops pages being cached in the browser
<?php
namespace App\Http\Middleware;
use Carbon\Carbon;
use Closure;
class PrivateResponse
{
/**
@TheoKouzelis
TheoKouzelis / gist:c9069c1664207e03c6f81eb4d2770573
Created July 27, 2016 23:36
Install Mailcatcher on Laravel Homestead or Ubuntu 14.04 Virtual Machine
echo "Install mailcatcher"
sudo apt-add-repository ppa:brightbox/ruby-ng
sudo apt-get update
sudo apt-get -y install ruby2.3 ruby2.3-dev
sudo gem install mailcatcher
mailcatcher --ip=0.0.0.0
@TheoKouzelis
TheoKouzelis / Eloquent Relationship Query Trait
Last active June 20, 2016 16:21
This is a Laravel Eloquent scope query which will return all models that have relationship with all of the IDs supplied
<?php
namespace App;
trait QueryRelationships
{
public function scopeWhereHasRelationIds($query, $relationName, array $relationIdList)
{
$query->whereHas($relationName, function ($query) use ($relationIdList) {
$query->whereIn('id', $relationIdList)