Skip to content

Instantly share code, notes, and snippets.

View duncanmcclean's full-sized avatar

Duncan McClean duncanmcclean

View GitHub Profile
name: "Annoying Users"
on:
issues:
jobs:
close_and_ban:
if: "contains(github.event.issue.title, '??') || contains(github.event.issue.body, '??')"
name: Close & Ban
<?php
namespace App\Tags;
use Statamic\Tags\Tags;
use Torchlight\Blade\BladeManager;
use Torchlight\Block;
class Torchlight extends Tags
{
<?php
namespace App\Http\Middleware;
use Closure;
use Illuminate\Http\Request;
use Illuminate\Support\Facades\Auth;
use Statamic\Facades\User;
class AutomaticallyLogin
<?php
namespace App\Tags;
use Statamic\Tags\Tags;
use Torchlight\Blade\BladeManager;
use Torchlight\Block;
class Torchlight extends Tags
{
@duncanmcclean
duncanmcclean / SalesExport.php
Last active January 22, 2022 10:15
Basic Sales Exporter for Simple Commerce
<?php
namespace App\Exports;
use DoubleThreeDigital\SimpleCommerce\Facades\Order;
use DoubleThreeDigital\SimpleCommerce\Facades\Product;
use Maatwebsite\Excel\Concerns\FromCollection;
use Maatwebsite\Excel\Concerns\WithHeadings;
use Maatwebsite\Excel\Concerns\WithMapping;
use Statamic\Facades\Entry;
@duncanmcclean
duncanmcclean / FormParameters.php
Created June 5, 2021 16:01
Generates & checks parameters are the same between creating & submitting a form. Inspiration from Livewire's checksum component: https://github.com/livewire/livewire/blob/master/src/ComponentChecksumManager.php
<?php
namespace DoubleThreeDigital\SimpleCommerce\Tags\Concerns;
class FormParameters
{
// TODO: this isn't really a 'concern', so maybe we should move this elsewhere?
// Kept in sync with $knownParams on `FormBuilder`
private static $knownParams = [
@duncanmcclean
duncanmcclean / console.php
Last active March 5, 2024 15:32
Identify & fix Duplicate IDs in Statamic 3.
<?php // copy everything after this line
Artisan::command('identify-duplicates', function () {
$duplicates = [];
$shouldFixDuplicates = $this->confirm('Should Duplicate IDs be replaced with fresh IDs?');
$items = collect(\Illuminate\Support\Facades\File::allFiles(__DIR__.'/../content'))
->filter(function ($file) {
return $file->isFile();
})
<?php
namespace App\Console\Commands;
use Illuminate\Console\Command;
use Faker\Factory;
use Statamic\Facades\Entry;
use Illuminate\Support\Str;
class CreateFakeEntries extends Command
@duncanmcclean
duncanmcclean / README.md
Last active May 8, 2020 13:56
Statamify to Simple Commerce migrator

Statamify Importer

This command should import most things like products, orders, customers etc for you but there are still some things that you'll need to configure by yourself.

If there's anything you neeed to customise for your store, just do it. It's why I didn't ship this as a package.

  1. Copy over the site directory of the site that used Statamify.
  2. Install Statamic's Migrator addon (this import script uses it) composer require statamic/migrator --dev
  3. Create a file in your App\Console\Commands folder called StatamifyImportCommand.php.
  4. Copy the whole of the script (the other Gist file) and paste it in as the command's contents.
# Installs Fathom Lite on Heroku
APPNAME=$1
EMAIL=$2
PASS=$3
heroku create $APPNAME --buildpack https://github.com/ph3nx/heroku-binary-buildpack.git
heroku git:clone -a $APPNAME
cd $APPNAME