Skip to content

Instantly share code, notes, and snippets.

View haveigonemental's full-sized avatar

Benjamin Daniel haveigonemental

View GitHub Profile
@JoonHoSon
JoonHoSon / iframe.js
Created October 29, 2024 06:55 — forked from PechenkiUA/iframe.js
Youtube iframe contentWindow.postMessage command
document.querySelector('iframe').contentWindow.postMessage('{"event":"command","func":"pauseVideo","args":""}', '*');
/**
* Adds "failed" status to Action Scheduler cleanup action.
*
* Default is "complete" and "canceled," leaving "failed" actions
* in the Action Scheduler to pile up indefinitely.
*
* Filter located in action-scheduler/classes/ActionScheduler_QueueCleaner.php
*
* @see https://wpcodebook.com/woocommerce-action-scheduler-cleanup-php/
*/
@MaximilianKohler
MaximilianKohler / Listmonk-tutorial.md
Last active October 26, 2025 21:03
Complete Listmonk setup guide. Step-by-step tutorial for installation and all basic functions. Amazon EC2 & SES

Listmonk setup and usage guide

When I first set up Listmonk it was to use with Amazon SES. At the time Amazon would give you free 62,000 emails/mo if you sent them from an EC2 instance. So EC2 was the best server to use. In mid 2023 Amazon ended that, so now you can use whatever server you like, which makes things much easier. It shouldn't be too hard to convert these directions to another server host of your choice.

I used Hetzner with another build, and once my free EC2 year ended the AWS t2.micro cost me $14/mo. Hetzner has better specs and costs me $5/mo, so I added an nginx vhost and moved listmonk to the same server. Here's a $20 credit for Hetzner.

There is also the possibility to use the 1-click installers for their featured hosts: https://listmonk.app/ - listed under "Hosting providers". I'm not familiar with any of them but there are lots of new guides

@lukecav
lukecav / Queries
Created June 30, 2023 20:52
Delete Action Scheduler actions with a status of failed and canceled and truncate the Action Scheduler logs database table
DELETE FROMwp_actionscheduler_actions WHERE status IN ('failed','canceled')
TRUNCATE wp_actionscheduler_logs
@blizzardengle
blizzardengle / function.php
Last active January 11, 2024 07:56
Allows you to enqueue scripts as modules or import maps in WordPress using the built-in wp_enqueue_script function. You should add this code somewhere in your plugin or theme, most likely your functions.php file.
<?php
// If your PHP version is < 8
if ( ! function_exists( 'str_contains' ) ) {
/**
* Based on original work from the PHP Laravel framework.
*
* @author scm6079
* @link https://www.php.net/manual/en/function.str-contains.php#125977 Original Source
*
@PechenkiUA
PechenkiUA / iframe.js
Created December 29, 2022 07:18
Youtube iframe contentWindow.postMessage command
document.querySelector('iframe').contentWindow.postMessage('{"event":"command","func":"pauseVideo","args":""}', '*');
@dasbairagya
dasbairagya / functions.md
Last active January 30, 2024 21:53
Get variation product data on selecting variation options - WooCommerce

Get variation product data on selecting variation options - WooCommerce

functions.php

add_action( 'woocommerce_before_single_variation',
 'action_wc_before_single_variation' );
function action_wc_before_single_variation() {
    ?>
    <script type="text/javascript">
    (function($){
        $('form.variations_form').on('show_variation', function(event, data){
@Martin-Pitt
Martin-Pitt / pan-zoom-touch-and-trackpad.js
Last active July 9, 2025 18:09
Panning and Pinch-Zoom gesture handler for both touchscreens and trackpads; Works really well on a MacBook trackpad
// Target state
var tx = 0;
var ty = 0;
var scale = 1;
function visualiseTargetState() {
box.style.transform = `translate(${tx}px, ${ty}px) scale(${scale})`;
}
@jesperorb
jesperorb / php_form_submit.md
Last active April 30, 2024 22:27
PHP form submitting with fetch + async/await

PHP Form submitting

If we have the following structure in our application:

  • 📁 application_folder_name
    • 📄 index.php
    • 📄 handle_form.php
    • 📄 main.js

And we fill our index.php with the following content just to get a basic website with a form working. You should be able to run this through a php-server of your choice.

@mehrshaddarzi
mehrshaddarzi / wordpress_image.php
Last active July 13, 2025 23:27
wordpress image thumbnail list Hook
<?php
// Upload to Custom folder in media_handle_upload
https://wordpress.stackexchange.com/questions/290257/media-handle-upload-with-custom-upload-folder
//Download image and to attachment
https://codex.wordpress.org/Function_Reference/media_handle_sideload
//change SrcSet
https://gschoppe.com/wordpress/fix-broken-images-after-wordpress-4-4-update/