Skip to content

Instantly share code, notes, and snippets.

View dgoguerra's full-sized avatar

Diego Guerra dgoguerra

View GitHub Profile
@dgoguerra
dgoguerra / logslaravel.sh
Created August 20, 2018 07:20 — forked from jakebathman/logslaravel.sh
Tail Laravel logs and filter out the stack traces
tail -f -n 450 storage/logs/laravel*.log \
| grep -i -E \
"^\[\d{4}\-\d{2}\-\d{2} \d{2}:\d{2}:\d{2}\]|Next [\w\W]+?\:" \
--color
<?php
namespace App\Traits;
use App\Entities\User;
use DateTime;
use GuzzleHttp\Psr7\Response;
use Illuminate\Events\Dispatcher;
use Laravel\Passport\Bridge\AccessToken;
use Laravel\Passport\Bridge\AccessTokenRepository;
@dgoguerra
dgoguerra / homebrew-dynamodb-local.md
Last active November 5, 2023 11:15
Install dynamodb-local through Homebrew (custom formula)

Install dynamodb-local through Homebrew

An official formula for dynamodb-local existed, but was removed since dynamodb-local is not open source and stopped having versions.

Now its available either through a Cask, or by installing it as a formula from an unofficial tap (third party repo).

When installed as a cask dynamodb-local cannot be exposed as a service, so here we are installing it as a formula. It has been forked from rjcoelho/homebrew-boneyard and updated to be a head-only formula, to avoid checksum erros on new versions. It is available at dgoguerra/homebrew-boneyard.

# dynamodb-local depends on Java 6+
@dgoguerra
dgoguerra / forge-db.sh
Last active April 24, 2018 16:04
Dump a Laravel Forge site's DB through SSH using the .env's credentials
#!/usr/bin/env bash
SERVER="$1"
SITE="$2"
# script to run in the remote host
REMOTE_CMD="
# ensure the site exists in the user's home
if [ ! -d $SITE ]; then
echo '$SITE' not found, aborting
@dgoguerra
dgoguerra / fpm-nginx-max-upload.md
Created April 12, 2018 16:57
php-fpm + nginx config to increase max upload size

Server’s PHP FPM configuration (through Forge):

upload_max_filesize = 20M
post_max_size = 20M

Site’s Nginx configuration (through Forge):

@dgoguerra
dgoguerra / slack-deploy-webhook.sh
Last active April 19, 2018 14:52
slack deploy info webhook
SITE=domain.com
GITHUB_REPO=owner/repo
BRANCH=$(git symbolic-ref --short HEAD)
COMMIT_SHA=$(git log --pretty="%h" -n1 HEAD)
COMMIT_URL=https://github.com/$GITHUB_REPO/commit/$SHA
COMMIT_MSG=$(git log --format=%B -n 1)
COMMIT_TITLE=$(git log --format='Commit %h by %an %ar' -n 1)
GITHUB_REPO_URL=https://github.com/$GITHUB_REPO
GITHUB_COMMIT_URL=https://github.com/$GITHUB_REPO/commits/$COMMIT_SHA
@dgoguerra
dgoguerra / Laravel-Container.md
Created April 3, 2018 15:17
Laravel's Dependency Injection Container in Depth

Laravel's Dependency Injection Container in Depth

Laravel has a powerful Inversion of Control (IoC) / Dependency Injection (DI) Container. Unfortunately the official documentation doesn't cover all of the available functionality, so I decided to experiment with it and document it for myself. The following is based on Laravel 5.4.26 - other versions may vary.

Introduction to Dependency Injection

I won't attempt to explain the principles behind DI / IoC here - if you're not familiar with them you might want to read What is Dependency Injection? by Fabien Potencier (creator of the Symfony framework).

Accessing the Container

@dgoguerra
dgoguerra / install-sentry.md
Last active July 24, 2019 23:16
Install Sentry on-premise in Ubuntu 16.04 with Docker CE (Community Edition)

Install Docker

See: https://docs.docker.com/install/linux/docker-ce/ubuntu/#install-from-a-package

sudo apt-get update
sudo apt-get install apt-transport-https ca-certificates curl software-properties-common
curl -fsSL https://download.docker.com/linux/ubuntu/gpg | sudo apt-key add -
sudo add-apt-repository "deb [arch=amd64] https://download.docker.com/linux/ubuntu $(lsb_release -cs) stable"
sudo apt-get update
@dgoguerra
dgoguerra / create-swapfile.md
Last active June 30, 2023 01:02
create swapfile in ubuntu

Taken from a DigitalOcean tutorial.

Create and enable swapfile:

# create a 2GB file only accessible by root
sudo fallocate -l 2G /swapfile
sudo chmod 600 /swapfile

# mark the file as a swap space
@dgoguerra
dgoguerra / mails-tools.md
Created February 16, 2018 11:46
Some notes about tools to test emails and domains configuration

Tools to test specific emails

  • Test the score of your emails: https://www.mail-tester.com/.

Testing a domain's mail configuration

  • General domain health report: https://mxtoolbox.com/domain/.

  • SPF records lookup: https://mxtoolbox.com/spf.aspx.