Skip to content

Instantly share code, notes, and snippets.

View simonhamp's full-sized avatar
💭
Accidentally learning Rust

Simon Hamp simonhamp

💭
Accidentally learning Rust
View GitHub Profile
// Before
<h1>FooBar</h1>
<?php $foo = 'Foo'; ?>
<p>{{ $foo }}</p>
// After
<h1>FooBar</h1>
@include( 'partials/foo', [ 'foo' => 'Foo' ] )
<?php
trait AuthenticatesUsers {
public function getLogin() {
if (view()->exists('auth.authenticate')) {
return view('auth.authenticate');
}
return view('auth.login');
}
}
@simonhamp
simonhamp / Foo.php
Last active February 6, 2016 01:16
<?php
class Foo {
use AuthenticatesUsers {
getLogin as login;
}
public function getLogin() {
// Do my stuff
return $this->login()->with('myvar', 'Hello World');
}

Keybase proof

I hereby claim:

  • I am simonhamp on github.
  • I am simonhamp (https://keybase.io/simonhamp) on keybase.
  • I have a public key ASAHPdAFANeP0F6wuxEQSZ1pduJknbEHdlTnEIcd6CuB8go

To claim this, I am signing this object:

@simonhamp
simonhamp / quotes.md
Last active April 23, 2019 17:59
Some quotes and their sources

"A lot of times, you open up some code for something simple like this, and you find that it is just a massive tangle of unnecessary structure and indirection."

Casey Muratori 2014-05-28 (Retrieved 2018-05-18)

"Frameworks are not tools for organising your code, they are tools for organising your mind."

Rich Harris Code Camp 2019 (Retrieved 2019-04-23)

@simonhamp
simonhamp / AuthorizationTest.php
Created December 10, 2017 06:00
Laravel Testing: Ensure your controllers enforce authorization
<?php
namespace App\Tests;
use Illuminate\Support\Facades\Route;
class AuthorizationTest extends TestCase
{
public function setUp()
{
@simonhamp
simonhamp / BaseModel.php
Last active March 25, 2020 16:57
Eloquent: Simple Model Event Handling
<?php
namespace App;
use Illuminate\Database\Eloquent\Model;
class BaseModel extends Model
{
/**
* Override the default boot method to register some extra stuff for every child model.
@simonhamp
simonhamp / StachePrimeCommand.php
Created May 22, 2020 14:33
Prime your Stache
<?php
namespace Statamic\Addons\MyAddon\Commands;
use Statamic\API\Stache;
use Statamic\Extend\Command;
class StachePrimeCommand extends Command
{
/**
@simonhamp
simonhamp / ScheduleListCommand.php
Created January 6, 2021 13:12
Laravel: Back-port the schedule:list command
<?php
namespace App\Console\Commands;
use Cron\CronExpression;
use Illuminate\Console\Command;
use Illuminate\Support\Carbon;
use Illuminate\Console\Scheduling\Schedule;
class ScheduleListCommand extends Command
@simonhamp
simonhamp / RemoteArtisan.php
Last active February 10, 2021 10:41
RemoteArtisan: A way to call another Laravel/Lumen application's artisan command from the context of the current application.
<?php
namespace App;
use Dotenv\Dotenv;
use Illuminate\Support\Str;
use Symfony\Component\Process\Process;
use Symfony\Component\Process\Exception\ProcessFailedException;
class RemoteArtisan