Skip to content

Instantly share code, notes, and snippets.

View jasonvarga's full-sized avatar
🇦🇺

Jason Varga jasonvarga

🇦🇺
View GitHub Profile
<div x-if="$request('comments').loading">
Loading...
</div>
<div x-if="$request('comments').errors">
Errors...
</div>
<template
x-for="comment in $request('comments').fetch(`/posts/${currentPost}/comments`)"
@jasonvarga
jasonvarga / EntryQueryBuilder.php
Created June 30, 2021 20:18
Fake Statamic SQL entries query for debugging
<?php
// A very crude way to see the "query" when using the stache.
// I used this to test https://github.com/statamic/cms/pull/3540
public function get($columns = ['*'])
{
$results = parent::get($columns);
$sql = 'select ';
@jasonvarga
jasonvarga / LocalValetDriver.php
Created June 19, 2021 02:43
Valet Driver that supports Statamic 3's static caching
<?php
class LocalValetDriver extends LaravelValetDriver
{
public function frontControllerPath($sitePath, $siteName, $uri)
{
if ($this->isActualFile($staticPath = $this->getStaticPath($sitePath))) {
return $staticPath;
}
@jasonvarga
jasonvarga / Hooks.php
Created March 1, 2021 17:03
PHPUnit Test Hooks Extension
<?php
namespace Tests;
use PHPUnit\Runner\AfterLastTestHook;
use PHPUnit\Runner\BeforeFirstTestHook;
use PHPUnit\Runner\BeforeTestHook;
class Hooks implements BeforeFirstTestHook, AfterLastTestHook, BeforeTestHook
{
@jasonvarga
jasonvarga / snakeToPascal.js
Created November 25, 2020 22:07
JS snake_case to PascalCase
const snakeToPascal = str => str
.split('_')
.map(word => word[0].toUpperCase() + word.slice(1))
.join('');
snakeToPascal('hello_world'); // HelloWorld
@jasonvarga
jasonvarga / console.php
Created August 17, 2020 20:51
Statamic Beta 45 Fields Migration Helper
<?php // copy everything after this line
use Illuminate\Support\Facades\Artisan;
use Statamic\Facades\File;
use Statamic\Facades\YAML;
class MigrateBetaFortyFive
{
protected $console;
@jasonvarga
jasonvarga / console.php
Last active July 31, 2022 18:01
Statamic Beta 38 Blueprints Migration Helper
<?php // copy everything after this line
use Illuminate\Support\Facades\Artisan;
use Statamic\Facades\AssetContainer;
use Statamic\Facades\Blueprint;
use Statamic\Facades\Collection;
use Statamic\Facades\File;
use Statamic\Facades\Form;
use Statamic\Facades\GlobalSet;
use Statamic\Facades\Taxonomy;
@jasonvarga
jasonvarga / email.yaml
Created May 4, 2020 16:48
HELO in Statamic 2
driver: smtp
host: 127.0.0.1
port: 2525
username: 'Your Mailbox Name'
encryption: null
<?php
namespace Statamic\Addons\FieldOptions;
use Statamic\API\Fieldset;
use Statamic\API\Parse;
use Statamic\Extend\Tags;
class FieldOptionsTags extends Tags
{
@jasonvarga
jasonvarga / statamic2-vs-3.md
Last active March 5, 2021 18:53
Statamic 2 vs 3

Tests run on a 2013 Macbook Pro with 2.8GHz Intel Core i7, 16 GB 1600 MHz DDR3 using Laravel Valet.

Statamic 2 with 5000 entries

On a template listing 10 posts sorted by date.

Concurrency 1