Skip to content

Instantly share code, notes, and snippets.

View peterfox's full-sized avatar

Peter Fox peterfox

View GitHub Profile
@peterfox
peterfox / BrowserAutomationServiceProvider.php
Last active March 25, 2022 00:12
Rough example of how to use Laravel Dusk directly in production code.
<?php
namespace App\Providers;
use Facebook\WebDriver\Chrome\ChromeOptions;
use Facebook\WebDriver\Remote\DesiredCapabilities;
use Facebook\WebDriver\Remote\RemoteWebDriver;
use Illuminate\Support\ServiceProvider;
use Laravel\Dusk\Browser;
use Laravel\Dusk\Chrome\ChromeProcess;
@peterfox
peterfox / example.php
Created September 9, 2021 15:47 — forked from jasonmccreary/example.php
Collection Challenge
<?php
// before
$registry = [
'tests/BasicClass.php' => [
'TestCase',
],
'tests/ComplexClass.php' => [
'TestCase',
'RefreshDatabase',
@peterfox
peterfox / dynamic_base_path.php
Created December 14, 2019 16:12
A Helper for use with Laravel to make configs using path names a lot easier
<?php
//
// Say the project is stored in the path /var/html then it could be used like so:
//
// dynamic_base_path('@storage/app/somefile.txt'); // returns /var/html/storage/
//
// dynamic_base_path('/etc/somefile.txt'); // returns /etc/somefile.txt
//
// Use this in your config files when you want relative paths for your local
@peterfox
peterfox / prioritise_unique.php
Created December 14, 2019 16:04
A Laravel Collection macro for prioritising certain attributes and then getting a unique set
<?php
\Illuminate\Support\Collection::macro('prioritiseUnique', function ($unique, $proritise) {
return $this->sortByDesc($proritise)
->unique($unique)
->values();
});
@peterfox
peterfox / .php_cs
Created February 25, 2018 23:58
PHP CS Fixer file
<?php
/**
* Config for PHP-CS-Fixer 2.10.0
*/
$rules = [
'@PSR2' => true,
'@PSR1' => true,
### Keybase proof
I hereby claim:
* I am peterfox on github.
* I am peterfox (https://keybase.io/peterfox) on keybase.
* I have a public key whose fingerprint is 15A7 F417 AF0D 2AC5 51B2 472E 35CC 582B 80CC F167
To claim this, I am signing this object:
@peterfox
peterfox / TermsPageController
Last active June 3, 2017 20:37
Terms and Conditions example
<?php
namespace AppBundle\Controller;
use Symfony\Bundle\FrameworkBundle\Templating\EngineInterface;
use Symfony\Component\HttpFoundation\Request;
use Symfony\Component\HttpFoundation\Response;
final class TermsPageController
{
@peterfox
peterfox / Task.php
Last active November 3, 2016 13:18
Intro to Laravel Workshop 3/11/16
<?php
namespace App;
use Illuminate\Database\Eloquent\Model;
class Task extends Model
{
protected $fillable = [
'task'

Keybase proof

I hereby claim:

  • I am peterfox on github.
  • I am peterfox (https://keybase.io/peterfox) on keybase.
  • I have a public key whose fingerprint is A902 1061 A14C C4C8 54DA FAA2 A63D 4815 39E1 1F00

To claim this, I am signing this object:

@peterfox
peterfox / Vagrantfile
Created February 29, 2016 19:44
Example vagrant file I use with Chef and Laravel cookbook
# -*- mode: ruby -*-
# vi: set ft=ruby :
# Vagrantfile API/syntax version. Don't touch unless you know what you're doing!
VAGRANTFILE_API_VERSION = "2"
Vagrant.configure(VAGRANTFILE_API_VERSION) do |config|
# config.vm.define "database" do |database|
# database.vm.box = "ubuntu-trusty-server-amd64"