Skip to content

Instantly share code, notes, and snippets.

View AugustMiller's full-sized avatar
🌳

August Miller AugustMiller

🌳
View GitHub Profile
@AugustMiller
AugustMiller / CustomKirbyValetDriver.php
Created June 27, 2017 00:36
Kirby Driver for Valet, with support for running the application in a subfolder of the project.
<? class CustomKirbyValetDriver extends ValetDriver
{
/**
* Determine if the driver serves the request.
*
* @param string $sitePath
* @param string $siteName
* @param string $uri
* @return void
*/
@AugustMiller
AugustMiller / serialize-form-as-object.coffee
Created September 26, 2017 01:48
Convert jQuery's `serializeArray` output into an object that better matches the structure of an HTTP request or POST body.
module.exports = (serializeArrayResult) ->
obj = {}
arr = serializeArrayResult
for pair in arr
if obj[pair.name] isnt undefined
if !Array.isArray obj[pair.name]
# Convert existing single value to an array:
obj[pair.name] = [obj[pair.name]]
@AugustMiller
AugustMiller / image-resizer.liquid
Last active March 9, 2018 06:04
A roundabout way of re-building image URLs in Shopify without the `img_url` helper. Supports size declarations, but not cropping settings.
{% comment %}
Set up `transform` string for inclusion in a URL:
{% endcomment %}
{% if size %}
{% assign transform = size | prepend: '_' %}
{% else %}
{% assign transform = '' %}
{% endif %}
@AugustMiller
AugustMiller / deploy.php
Last active April 15, 2019 05:19
Boilerplate Deployer config for a Craft 3 project https://deployer.org
<?php
namespace Deployer;
require 'recipe/composer.php';
// Project name
set('application', 'my-project');
// Project repository
set('repository', '[email protected]:organization/repo.git');
@AugustMiller
AugustMiller / TestAdjuster.php
Last active January 9, 2020 09:53
Simple Commerce Adjuster implementation
<?php
/**
* Example Adjuster.
* Place in: `/myplugin/adjusters/Test.php` (and rename as such)
*
* @link https://oof.studio/
* @copyright Copyright (c) 2018 oof. Studio
*/
namespace oofbar\test\adjusters;

Keybase proof

I hereby claim:

  • I am augustmiller on github.
  • I am awmiller (https://keybase.io/awmiller) on keybase.
  • I have a public key ASBgbxeFHc-8kvRHREGvnJy2bEqD5s8caibq0ohbwJnm4wo

To claim this, I am signing this object:

@AugustMiller
AugustMiller / Module.php
Last active November 30, 2019 21:06
Basic Craft/Yii Module + Controller
<?php
namespace modules;
use Craft;
/**
* Custom module class.
*
* This class will be available throughout the system via:
* `Craft::$app->getModule('my-module')`.
@AugustMiller
AugustMiller / BaseController.php
Last active February 18, 2020 18:32
Quick method for setting a Payment Source on a Commerce Order
<?php namespace modules\mymodule\controllers;
use Craft;
use craft\web\Controller;
use yii\web\ForbiddenHttpException;
/**
* The Base Controller for all Module Controllers
*
@AugustMiller
AugustMiller / Directory Layout
Last active October 26, 2021 18:06
Minecraft Bedrock Server ("BDS") configuration
.
├── backup.sh
├── backups
│   ├── latest -> /home/minecraft/bedrock/backups/worlds-2020-04-04T19:30:01+00:00
│   ├── lock (When a backup is running)
│   ├── worlds-2020-04-03T23:31:10+00:00
│   ├── worlds-2020-04-03T23:31:10+00:00
│   ├── worlds-2020-04-04T00:00:01+00:00
│   ├── worlds-2020-04-04T18:30:01+00:00
│   ├── worlds-2020-04-04T19:00:01+00:00
@AugustMiller
AugustMiller / FrequentBuyer.php
Last active January 26, 2021 23:09
Reduces the current Cart/Order's total by some percentage of the combined total of the previous 6 orders.
<?php
namespace dpdx\plugin\adjusters;
use Craft;
use craft\base\Component;
use craft\helpers\ArrayHelper;
use craft\commerce\Plugin as Commerce;
use craft\commerce\base\AdjusterInterface;
use craft\commerce\elements\Order;