Skip to content

Instantly share code, notes, and snippets.

View stevebauman's full-sized avatar
💎
Sparklin’

Steve Bauman stevebauman

💎
Sparklin’
View GitHub Profile
@stevebauman
stevebauman / .php_cs
Last active May 6, 2021 04:06
PHP CS Fixer Style
<?php
$finder = (new Symfony\Component\Finder\Finder)
->in([
__DIR__.'/src',
__DIR__.'/tests',
])
->name('*.php')
->ignoreVCS(true)
->ignoreDotFiles(true);
@stevebauman
stevebauman / quadratic-equation.php
Last active May 8, 2023 19:02
Find Quadratic Roots Challenge
<?php
/**
* @return array An array of two elements containing roots in any order
* @link https://www.testdome.com/questions/php/quadratic-equation/38497
*/
function findRoots($a, $b, $c)
{
return [
(-$b + sqrt(pow($b, 2) - ((4 * $a) * $c))) / (2 * $a),
(-$b - sqrt(pow($b, 2) - ((4 * $a) * $c))) / (2 * $a),
@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 June 20, 2023 01:13
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);