Skip to content

Instantly share code, notes, and snippets.

View macbookandrew's full-sized avatar

Andrew Minion macbookandrew

View GitHub Profile
@macbookandrew
macbookandrew / worker.js
Created August 23, 2023 19:40
Cloudflare worker proxy for signed AWS S3 URLs
addEventListener('fetch', event => {
event.respondWith(handleRequest(event))
})
async function handleRequest(event) {
let url = new URL(event.request.url);
url.hostname = 'my-secure-bucket.s3-us-east-2.amazonaws.com';
let response = await fetch(url);
@macbookandrew
macbookandrew / HasRefinements.php
Created September 24, 2021 01:46
MeiliSearch PHP facets
<?php
trait HasRefinements
{
public static function convertFiltersForMeiliSearch(array $filters, mixed $parentKey = null)
{
$return = [];
foreach ($filters as $key => $value) {
if (! is_null($parentKey)) {
@macbookandrew
macbookandrew / readme.md
Last active September 13, 2024 13:44
Laravel VS Code Workspace Tasks

Runs these tasks automatically when the workspace is opened:

  1. npm run dev: recompiles assets when modified; useful for Tailwind JIT mode, Vite, etc.
  2. php artisan horizon: runs Horizon queue monitor
  3. php artisan schedule:work: runs scheduled tasks
  4. php artisan pulse:check: runs Pulse watcher
  5. Prunes failed queue jobs and telescope logs on open
@macbookandrew
macbookandrew / give-get-goal-fix.php
Created February 25, 2019 18:06
Returns false if goal is disabled
<?php
/**
* Plugin Name: Give - <code>get_goal()</code> fix
* Plugin URI: https://luminfire.com
* Description: Forces <code>get_goal()</code> to return false if goal is disabled for the form.
* Version: 1.0.0
* Author: LuminFire (Andrew Minion)
* Author URI: https://luminfire.com/
*
* @package give-get-goal-fix
<?php
/**
* Plugin Name: Menu Image + DevDMBootstrap3 Fix
* Plugin URI: https://gist.github.com/macbookandrew/d40a416c65c615e0e15e1b6fd0645a67
* Description: Fixes Menu Image PLugin used with DevDMBootstrap3 themes
* Author: Andrew Minion/Pressed Solutions
* Author URI: https://pressedsolutions.com/
* Requires WP: 4.4.0
* Requires PHP: 7.0
* Version: 1.0.0
@macbookandrew
macbookandrew / navigation.js
Created April 18, 2018 17:04
_s theme: multiple menus on a page
/**
* Handle multiple menus on one page
*/
(function($){
$('document').ready(function(){
$('.main-navigation .menu-toggle').on('click', function(){
$(this).toggleClass('toggled');
var $nav = $(this).parents('.main-navigation'),
$ul = $nav.find('ul.menu');
@macbookandrew
macbookandrew / WP-theme-version-filename.php
Last active June 15, 2022 19:51
WordPress theme stylesheet auto cache-busting
<?php
/**
* Autocalculate and define theme version constant for use in multiple stylesheets/scripts
*/
define( 'MY_THEME_VERSION', wp_get_theme()->get( 'Version' ) );
/**
* Enqueue stylesheet
*
@macbookandrew
macbookandrew / 0 - readme.md
Last active December 26, 2017 19:00
WooCommerce Downloadable Files: Grant Access for New Files to Previous Customers
@macbookandrew
macbookandrew / wp-amplify-ga-tracking.php
Last active September 11, 2017 16:29
Basic Google Analytics tracking for mailto: links
<?php
/**
* Plugin Name: WPAmplify GA Tracking
* Plugin URI: https://gist.github.com/macbookandrew/84ce54d73713d82b390fc9dc29b19e12/
* Description: Basic Google Analytics tracking for mailto: links
* Version: 1.0.0
* Author: AndrewRMinion Design
* Author URI: https://andrewrminion.com
* Copyright: 2017 AndrewRMinion Design
@macbookandrew
macbookandrew / sermon-manager-tax-archives.php
Last active August 16, 2017 19:17
WP plugin: shortcodes to create faux archive pages for all custom Sermon Manager taxonomies
<?php
/**
* Plugin Name: Sermon Manager Taxonomy Archives
* Plugin URI: https://gist.github.com/macbookandrew/62733a780899bb61773188641f4813de
* Description: Shortcode to create faux custom taxonomy archives; example: [sermon_tax_archive taxonomy="wpfc_preacher"]
* Version: 1.0.0
* Author: AndrewRMinion Design
* Author URI: https://andrewrminion.com
* Copyright: 2017 AndrewRMinion Design