Skip to content

Instantly share code, notes, and snippets.

View stevebauman's full-sized avatar

Steve Bauman stevebauman

View GitHub Profile
@stevebauman
stevebauman / pipeline-challenge.php
Created January 30, 2021 21:24
Pipeline Challenge
<?php
function make_pipeline(...$funcs)
{
return function($arg) use ($funcs)
{
foreach ($funcs as $func) {
$arg = $func($arg);
}
@stevebauman
stevebauman / thesaurus-challenge.php
Created January 30, 2021 21:22
Thesaurus Challenge
<?php
class Thesaurus
{
private $thesaurus;
function __construct(array $thesaurus)
{
$this->thesaurus = $thesaurus;
}
@stevebauman
stevebauman / league-table.php
Last active May 28, 2023 06:37
League Table PHP Challenge
<?php
class LeagueTable
{
public function __construct(array $players)
{
$this->standings = [];
foreach($players as $index => $p) {
$this->standings[$p] = [
'index' => $index,
@stevebauman
stevebauman / Mix.cs
Last active December 18, 2019 16:35
Laravel Mix manifest helper for ASP MVC apps (C#)
using System;
using System.IO;
using System.Web;
using System.Web.Helpers;
namespace Helpers
{
/// <summary>
/// Helper class for parsing the Laravel Mix manifest.
/// </summary>
@stevebauman
stevebauman / GeneratesXml.php
Created December 10, 2019 06:29
A Scheduled Tasks XML File Generator using PHP, Laravel and Spatie - Array-to-XML
<?php
namespace App\System;
use Spatie\ArrayToXml\ArrayToXml;
trait GeneratesXml
{
/**
* The XML template.
@stevebauman
stevebauman / GeneratesXml.php
Created December 10, 2019 06:29
A Scheduled Tasks XML File Generator using PHP, Laravel and Spatie - Array-to-XML
<?php
namespace App\System;
use Spatie\ArrayToXml\ArrayToXml;
trait GeneratesXml
{
/**
* The XML template.
@stevebauman
stevebauman / IsSelfReferencing.php
Last active July 8, 2025 11:41
Laravel model trait for easily adding self-referential tables
<?php
namespace App;
use Illuminate\Database\Eloquent\Builder;
trait IsSelfReferencing
{
/**
* The self referencing key on the database table.
@stevebauman
stevebauman / web.php
Created November 28, 2019 15:43
Run Laravel queue's from an HTTP endpoint
<?php
Route::get('/queue', function () {
echo "Starting Queue...<br/>";
ob_flush();
flush();
Queue::before(function (JobProcessing $event) {
$message = "Processing {$event->job->resolveName()}...";
info($message);
@stevebauman
stevebauman / calendar.blade.php
Created November 11, 2019 21:29
Custom calendar view in blade.
@php($date = isset($date) ? $date->startOfMonth() : now()->startOfMonth())
<table class="calendar m-auto" style="border-spacing:10px;border-collapse: separate;">
<thead>
<tr class="text-center text-uppercase text-secondary">
<th colspan="7">{{ $date->format('F Y') }}</th>
</tr>
</thead>
<thead>
<tr class="text-muted text-center">
@stevebauman
stevebauman / ReCaptcha.php
Created October 31, 2019 14:39
Google ReCAPTCHA Laravel Rule
<?php
namespace App\Rules;
use GuzzleHttp\Client;
use Illuminate\Contracts\Validation\Rule;
class ReCaptcha implements Rule
{
/**