Skip to content

Instantly share code, notes, and snippets.

View DarkGhostHunter's full-sized avatar

Italo DarkGhostHunter

View GitHub Profile
@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
{
@DarkGhostHunter
DarkGhostHunter / ExampleService.php
Created April 10, 2021 06:15
Don't fuck up your Laravel Octane app
<?php
namespace App\Services;
use App\Helpers\ProtectsBoot;
use Illuminate\Contracts\Foundation\Application;
class ExampleService
{
use ProtectsBoots;
@DarkGhostHunter
DarkGhostHunter / main.go
Created October 27, 2020 04:46
Pinging sites using goroutines
package main
import (
"fmt"
"os/exec"
"strings"
"sync"
)
func isSiteDown(site string, group *sync.WaitGroup) {
@DarkGhostHunter
DarkGhostHunter / main.go
Created October 27, 2020 03:09
Simple iterator system
package main
import "fmt"
type KeyChain struct {
labels []string
keys []string
lock []string
}
<?php
namespace App\Http\Controllers;
use App\Template;
class TemplateController extends Controller
{
/**
* Create a new contract.
<?php
class SecureJSON
{
public $array;
public $key;
public function __construct(array $array)
{
@DarkGhostHunter
DarkGhostHunter / Request.php
Last active July 9, 2020 05:09
Container example
<?php
class ExampleController
{
/**
* The new way
*
* @param Transport $transport
* @param Package $package
* @param Weather $weather
@DarkGhostHunter
DarkGhostHunter / Container.php
Created July 9, 2020 04:44
Container class to pass through the next method.
<?php
class Container
{
protected $target;
protected $value;
public function __construct($target, $value)
{
$this->target = $target;
@DarkGhostHunter
DarkGhostHunter / Throttler.php
Last active February 10, 2023 10:58
A class that throttles it's target methods calls.
<?php
namespace App\Throttler;
use Illuminate\Cache\RateLimiter;
class Throttler
{
/**
* Target to rate limit.