Skip to content

Instantly share code, notes, and snippets.

View DarkGhostHunter's full-sized avatar
👨‍💻
Hands full

Italo DarkGhostHunter

👨‍💻
Hands full
View GitHub Profile
@DarkGhostHunter
DarkGhostHunter / StaticPassword.php
Last active May 11, 2022 20:42
Password helper for Factories
<?php
namespace Database\Factories;
use Illuminate\Support\Facades\Hash;
trait StaticPassword
{
/**
* An 8-character password containing lower case, upper case, an special caracter and a number.
@DarkGhostHunter
DarkGhostHunter / composer.json
Last active March 21, 2024 18:10
Laragear Subscriptions Composer.json
{
"name": "laragear/subscriptions",
"description": "Subscriptions on-premises, without any payment system!",
"type": "library",
"license": "MIT",
"minimum-stability": "stable",
"prefer-stable": true,
"authors": [
{
"name": "Italo Baeza C.",
@DarkGhostHunter
DarkGhostHunter / ConfirmByPassword.php
Last active March 12, 2022 04:39
Confirms an action with a password
<?php
namespace App\Http\Middleware;
use Closure;
use Illuminate\Http\Request;
use Illuminate\Validation\ValidationException;
use Illuminate\Support\Facades\Date;
use Illuminate\Support\Facades\Hash;
use Illuminate\Support\Facades\Lang;
@DarkGhostHunter
DarkGhostHunter / log-levels.csv
Last active July 3, 2025 09:42
Log levels table
Property / Log Level Debug Info Notice Warning Error Critical Alert Emergency
Disposable X
Statistical X X X X X X X
Relevant X X X X X X
Undersired X X X X X
Unstable X X X X
Stateful X X X
Unsecure X X
Unfixable X
@DarkGhostHunter
DarkGhostHunter / NormalizesMiddlewareParameter.php
Last active November 15, 2021 04:38
Normalizes a parameter from Laravel's middleware declaration.
<?php
namespace YOURNAMESPACE;
use function is_numeric;
use function strtolower;
trait NormalizesMiddlewareParameter
{
/**
@DarkGhostHunter
DarkGhostHunter / ExampleTest.php
Last active October 22, 2021 18:48
Creates the application 1,000 times
<?php
namespace Tests\Feature;
use Tests\TestCase;
class ExampleTest extends TestCase
{
public function test_leaks_memory_on_1000_iterations()
{
@DarkGhostHunter
DarkGhostHunter / ClearProperties.php
Created October 21, 2021 04:16
Removes any user property for garbage collection at the end of each test case
<?php
namespace Tests;
trait ClearProperties
{
/**
* Unset each property declared in this test class and its traits.
*
* @return void
<?php
namespace App\Helpers;
use DateInterval;
use DateTimeInterface;
use Illuminate\Contracts\Cache\Factory;
use Illuminate\Contracts\Cache\LockProvider;
use Illuminate\Contracts\Cache\Repository;
use RuntimeException;
@DarkGhostHunter
DarkGhostHunter / PublishesMigrations.php
Last active August 8, 2022 16:01
Publish migrations as assets instead of loading them.
<?php
namespace Vendor\Package;
use Generator;
use Illuminate\Support\Str;
trait PublishesMigrations
{
/**
@DarkGhostHunter
DarkGhostHunter / RegeneratesCache.php
Last active June 7, 2025 22:19
RegeneratesCache class
<?php
namespace App;
use Illuminate\Support\Carbon;
use Illuminate\Support\Facades\Cache;
use DateTimeInterface;
class RegeneratesCache
{