Skip to content

Instantly share code, notes, and snippets.

View cerbero90's full-sized avatar
๐Ÿš

Andrea Marco Sartori cerbero90

๐Ÿš
View GitHub Profile
<?php
declare(strict_types=1);
use Illuminate\Database\Migrations\Migration;
use Illuminate\Support\Facades\DB;
return new class extends Migration
{
public function up(): void
@cerbero90
cerbero90 / h.sh
Created July 1, 2021 06:55
SSH into a project inside Homestead
function h()
{
local project=${1:-"code/default-project"}
( cd ~/Homestead && vagrant ssh -c "cd $project && exec bash -i" ) || \
( cd ~/Homestead && vagrant up && vagrant ssh -c "cd $project && exec bash -i" )
}
@cerbero90
cerbero90 / 429.blade.php
Created April 3, 2021 08:41
Using the retry-after header of the 429 exception to show the waiting time
<button
:disabled="remainingSeconds > 0"
onclick="history.back()"
x-data="helpers.countdown({secondsToWait:{{ $exception->getHeaders()['Retry-After'] ?? 60 }}})"
x-init="init()">
Retry <span x-text="countdown"></span>
</button>
<script type="text/javascript">
<?php
namespace App\Domain\Shared;
/**
* The unsigned integer obfuscator.
*
* @see https://github.com/marekweb/opaque-id
* @see https://stackoverflow.com/a/51701466/1968492
*/
<?php
/**
* Abstract implementation of a cached item.
*
*/
abstract class AbstractCachedItem
{
/**
* Retrieve the key where the item is stored in.
@cerbero90
cerbero90 / AbstractValidator.php
Created October 2, 2014 18:22
Validation as a service in Laravel
# app/validation/AbstractValidator.php
<?php namespace YourApp\Validation;
/**
* Abstract implementation of a validator.
*
* @author Andrea Marco Sartori
*/
abstract class AbstractValidator implements ValidatorInterface