Skip to content

Instantly share code, notes, and snippets.

View jhoff's full-sized avatar

Jordan Hoff jhoff

  • Givebutter
  • Fort Collins, CO
View GitHub Profile
<script> Sfdump = window.Sfdump || (function (doc) { var refStyle = doc.createElement('style'), rxEsc = /([.*+?^${}()|\[\]\/\\])/g, idRx = /\bsf-dump-\d+-ref[012]\w+\b/, keyHint = 0 <= navigator.platform.toUpperCase().indexOf('MAC') ? 'Cmd' : 'Ctrl', addEventListener = function (e, n, cb) { e.addEventListener(n, cb, false); }; (doc.documentElement.firstElementChild || doc.documentElement.children[0]).appendChild(refStyle); if (!doc.addEventListener) { addEventListener = function (element, eventName, callback) { element.attachEvent('on' + eventName, function (e) { e.preventDefault = function () {e.returnValue = false;}; e.target = e.srcElement; callback(e); }); }; } function toggle(a, recursive) { var s = a.nextSibling || {}, oldClass = s.className, arrow, newClass; if ('sf-dump-compact' == oldClass) { arrow = '&#9660;'; newClass = 'sf-dump-expanded'; } else if ('sf-dump-expanded' == oldClass) { arrow = '&#9654;'; newClass = 'sf-dump-compact'; } else { return false; } a.lastChild.innerHTML = arrow; s.classNam
@jhoff
jhoff / Enums.php
Last active August 27, 2024 09:51
Laravel Model Enumeration Trait
<?php
namespace App\Traits;
use Illuminate\Support\Str;
use App\Exceptions\InvalidEnumException;
trait Enums
{
/**
@jhoff
jhoff / README.md
Last active March 18, 2025 16:38
Bash-only Laravel Artisan tab auto-complete

If you are an Oh-my-zsh user, see the Laravel 5 plugin

For the rest of us Bash users, all of the Laravel Artisan autocomplete solutions out there require installing a composer package to get a list of artisan commands. Turns out this isn't really necessary. Simply add the provided code in ~/.bash_profile ( or similarly sourced file ) and you'll get artisan command tab completes on any project on your system.

_artisan()
{
	COMP_WORDBREAKS=${COMP_WORDBREAKS//:}
	COMMANDS=`php artisan --raw --no-ansi list | sed "s/[[:space:]].*//g"`
	COMPREPLY=(`compgen -W "$COMMANDS" -- "${COMP_WORDS[COMP_CWORD]}"`)

Keybase proof

I hereby claim:

  • I am jhoff on github.
  • I am jhoff484 (https://keybase.io/jhoff484) on keybase.
  • I have a public key ASAdOa4QlwuRZU1EXrTHLmDSlzYEOdHdUDkO_6x8hib1VQo

To claim this, I am signing this object:

@jhoff
jhoff / Removable Laravel Routes.md
Last active July 5, 2024 15:42
Removable Laravel Routes

Removable Laravel Routes

This is a Laravel Router mixin that was originally written for a Laravel Spark app that allows you to remove previously defined routes that are hard coded in a package.

We no longer need it, but thought the code might be useful to someone so here it is

Disclaimer

This should not be used to modify the authentication routes that come with Laravel out if the box. There is a much easier way to do this. See the documentation and Stack Overflow for examples.

@jhoff
jhoff / Test.php
Created June 5, 2020 15:05
Livewire Loader issue
<?php
namespace App\Http\Livewire;
use Livewire\Component;
class Test extends Component
{
public $showContent = true;
<?php
use Laravel\Dusk\Browser;
Browser::macro('waitUntilWire', function ($component, $key, $value, $seconds = null) {
return $this->waitUsing($seconds, 100, function () use ($component, $key, $value) {
return $value == $this->wireAttribute($component, $key);
});
});