Skip to content

Instantly share code, notes, and snippets.

@jasonvarga
jasonvarga / snakeToPascal.js
Created Nov 25, 2020
JS snake_case to PascalCase
View snakeToPascal.js
const snakeToPascal = str => str
.split('_')
.map(word => word[0].toUpperCase() + word.slice(1))
.join('');
snakeToPascal('hello_world'); // HelloWorld
@jasonvarga
jasonvarga / console.php
Created Aug 17, 2020
Statamic Beta 45 Fields Migration Helper
View console.php
<?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 Aug 8, 2020
Statamic Beta 38 Blueprints Migration Helper
View console.php
<?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
HELO in Statamic 2
View email.yaml
driver: smtp
host: 127.0.0.1
port: 2525
username: 'Your Mailbox Name'
encryption: null
View FieldOptionsTags.php
<?php
namespace Statamic\Addons\FieldOptions;
use Statamic\API\Fieldset;
use Statamic\API\Parse;
use Statamic\Extend\Tags;
class FieldOptionsTags extends Tags
{
View statamic2-vs-3.md

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

@jasonvarga
jasonvarga / ClickHandler.js
Created Feb 6, 2019
Vue component that handles single and double clicks
View ClickHandler.js
export default {
render() {
return this.$scopedSlots.default({});
},
data() {
return {
listener: null,
timer: null,
@jasonvarga
jasonvarga / aliases.sh
Created Jan 8, 2019
Turn off xdebug while running phpunit
View aliases.sh
# First, copy ext-xdebug.ini to ext-xdebug.ini.bak
alias xdebug-disable='echo "" > /usr/local/etc/php/7.1/conf.d/ext-xdebug.ini'
alias xdebug-restore='cat /usr/local/etc/php/7.1/conf.d/ext-xdebug.ini.bak > /usr/local/etc/php/7.1/conf.d/ext-xdebug.ini'
function phpunit {
xdebug-disable
./vendor/bin/phpunit "$@"
xdebug-restore
}
View Factory.php
<?php
namespace App\Factories;
abstract class Factory
{
public function instance()
{
return $this;
}
@jasonvarga
jasonvarga / aliases
Last active May 2, 2017
Interchangeable "please" and "artisan" regardless of Laravel/Statamic project type.
View aliases
alias artisan='art_plz'
alias please='art_plz'
alias art='art_plz'
alias plz='art_plz'
function art_plz {
if [ -e artisan ]; then
php artisan "$@"
elif [ -e please ]; then
php please "$@"
You can’t perform that action at this time.