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
<?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);
});
});
@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;
@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.

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 / README.md
Last active April 1, 2024 07:45
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]}"`)
@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
{
/**
<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 / md5.js
Created November 27, 2013 18:27
Closure of Joseph's Myers md5 javascript implementation
/*
* http://www.myersdaily.org/joseph/javascript/md5-text.html
*/
(function() {
var md5cycle = function(x, k) {
var a = x[0], b = x[1], c = x[2], d = x[3];
a = ff(a, b, c, d, k[0], 7, -680876936);
@jhoff
jhoff / gist:7348912
Last active December 27, 2015 15:39
Sample json data for positionTracker
{
"studyroom-0.0.0": [
"156,237,1,idle",
"156,237,1,idle",
"156,237,1,idle",
"156,237,1,idle",
"156,237,1,idle",
"157,237,1,walk",
"164,237,1,walk",
"178,237,1,walk",
@jhoff
jhoff / gist:4965700
Created February 16, 2013 05:42
Fixing a diverged master branch
# This is the easiest way to "reset" your master branch if you've jacked it up
# 1) Make sure you have a clean working directory
git status
# 2) Create a new temporary branch
git checkout -b temp_branch
# 3) Push the new temp_branch to github