Skip to content

Instantly share code, notes, and snippets.

View AugustMiller's full-sized avatar
🌳

August Miller AugustMiller

🌳
View GitHub Profile
@AugustMiller
AugustMiller / googly.js
Created October 9, 2024 23:32
Googly Eyes
let source = null;
window.addEventListener('mousedown', function (e) {
e.preventDefault();
source = e;
});
window.addEventListener('mouseup', function (e) {
const delta = Math.sqrt(Math.pow(source.pageX - e.pageX, 2) + Math.pow(source.pageY - e.pageY, 2));
const $eyes = document.createElement('img');
@AugustMiller
AugustMiller / settings.json
Created October 19, 2021 20:17
VS Code Settings
{
"editor.fontSize": 14,
"editor.cursorWidth": 2,
"editor.lineHeight": 25,
"editor.renderWhitespace": "all",
"files.insertFinalNewline": true,
"editor.wordWrap": "on",
"workbench.colorTheme": "BirdsofParadise",
"editor.rulers": [
80
@AugustMiller
AugustMiller / project-config-on-teams.md
Last active August 26, 2021 20:28
Using Craft’s Project Config on a Distributed Team

Project Config

Project Config is a powerful tool for managing the schema of a Craft application.

However, as with any text stored in version control, it can and will cause merge conflicts when multiple team members make changes to the same system settings.

These problems are exacerbated by Craft's strategy of rebuilding the entire config/project directory whenever a change is made. Of course, this helps keep the files and properties organized and up-to-date—but it can also squash changes under certain circumstances.

The Problem Scenario

@AugustMiller
AugustMiller / line-item-controls.twig
Created November 2, 2020 19:11
Increment or decrement quantity of product in cart
{% set incrementable = incrementable ?? true %}
{% set decrementable = decrementable ?? true %}
<div class="line-item__controls">
{% if incrementable or decrementable %}
<div class="line-item__quantity">
<form
method="POST"
data-ajax>
{{ csrfInput() }}
@AugustMiller
AugustMiller / MyModule.php
Last active June 6, 2021 00:57
Craft Commerce: Add user to a group when they make a purchase
<?php
namespace modules\mymodule;
use Craft;
use craft\elements\User;
use craft\helpers\ArrayHelper;
use yii\base\Event;
@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;
@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 / 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 / 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')`.

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: