Skip to content

Instantly share code, notes, and snippets.

View JustSteveKing's full-sized avatar
🐘
Building API tools and educational content

Steve McDougall JustSteveKing

🐘
Building API tools and educational content
View GitHub Profile
@JustSteveKing
JustSteveKing / pint.json
Last active March 1, 2024 19:28
Laravel Pint configuration
{
"preset": "per",
"rules": {
"align_multiline_comment": true,
"array_indentation": true,
"array_syntax": true,
"blank_line_after_namespace": true,
"blank_line_after_opening_tag": true,
"combine_consecutive_issets": true,
"combine_consecutive_unsets": true,
@JustSteveKing
JustSteveKing / phpstan.neon
Last active February 28, 2024 19:36
Default Laravel PHPStan Config
parameters:
paths:
- app/
level: 9
ignoreErrors:
excludePaths:
@JustSteveKing
JustSteveKing / rector.php
Created January 13, 2024 22:44
Laravel Rector Config
<?php
declare(strict_types=1);
use Rector\CodeQuality\Rector\Class_\InlineConstructorDefaultToPropertyRector;
use Rector\Config\RectorConfig;
use Rector\Set\ValueObject\LevelSetList;
use Rector\Set\ValueObject\SetList;
return static function (RectorConfig $rectorConfig): void {
@JustSteveKing
JustSteveKing / ApiRenderer.php
Last active September 8, 2023 15:03
Handling Errors in Laravel
<?php
declare(strict_types=1);
namespace App\Exceptions\Rendering;
use Illuminate\Contracts\Support\Responsable;
use Illuminate\Http\Request;
use Symfony\Component\HttpKernel\Exception\NotFoundHttpException;
use Throwable;
@JustSteveKing
JustSteveKing / State.php
Created August 11, 2023 18:31
US States as a PHP Enum
<?php
declare(strict_types=1);
namespace App\Enums;
enum State: string
{
case ALABAMA = 'AL';
case ALASKA = 'AK';
@JustSteveKing
JustSteveKing / Mock Test.md
Created February 1, 2022 09:22
A Mock Tech test

Task

We need a new website built that will show a list of products and categories available from our online store. Our online store is currently available through a third party system API

Our products and categories go through weekly releases, so we need a task in place that will sync our records on a weekly basis.

There is no stock control system needed.

@JustSteveKing
JustSteveKing / tailwind_light.yaml
Created September 5, 2022 19:18
TailwindCSS Light Warp Theme
accent: "#818cf8"
foreground: "#0f172a"
background: "#f8fafc"
details: "lighter"
terminal_colors:
normal:
red: "#f87171"
yellow: "#facc15"
black: "#0f172a"
cyan: "#22d3ee"
@JustSteveKing
JustSteveKing / Notification.php
Last active March 26, 2023 19:32
Simple Livewire and Tailwind notifications
<?php
namespace App\Http\Livewire;
use Livewire\Component;
class Notification extends Component
{
public $loaded = false;
@JustSteveKing
JustSteveKing / localStorage.async.js
Created March 2, 2017 15:18
Using JavaScript Promises to stop render blocking with localStorage
class Storage {
get(item) {
const request = new Promise((resolve, reject) => {
let data = localStorage.getItem(item);
console.log(`Start of promise`);
(data) ? resolve(data) : reject();
});
request.then((data) => {
console.log(`promise resolved`);
@JustSteveKing
JustSteveKing / localStorage.size.js
Created March 2, 2017 15:11
A little script to check the size of your localStorage - for management purposes
let total = 0, amount, item;
for (item in localStorage) {
amount = ((localStorage[item].length + item.length) * 2);
total += amount;
}
console.log(`Total = ${(total / 1024).toFixed(2)}KB`);