Skip to content

Instantly share code, notes, and snippets.

View mircobabini's full-sized avatar

Mirco Babini mircobabini

View GitHub Profile
@mircobabini
mircobabini / BeamNG.Hooks.md
Created December 15, 2023 16:00 — forked from codecat/BeamNG.Hooks.md
BeamNG Extension hooks

BeamNG Extension hooks

These are called in extensions. For example, the following module has some hooks:

local M = {}

M.onBeamNGTrigger = function(data)
	-- ...
end
@mircobabini
mircobabini / wc-sell-or-ship-to-specific-countries-europe.sql
Last active February 9, 2023 08:27 — forked from pascalknecht/query.sql
WooCommerce sell/ship EU Countries only (small area, extended area or the whole continent)
# Sell to specific EU countries only
UPDATE `wp_options` SET `option_value`='specific' WHERE option_name = 'woocommerce_allowed_countries';
UPDATE `wp_options` SET `option_value`='a:30:{i:0;s:2:"AT";i:1;s:2:"BE";i:2;s:2:"BG";i:3;s:2:"HR";i:4;s:2:"CY";i:5;s:2:"CZ";i:6;s:2:"DK";i:7;s:2:"EE";i:8;s:2:"FI";i:9;s:2:"FR";i:10;s:2:"DE";i:11;s:2:"GR";i:12;s:2:"HU";i:13;s:2:"IE";i:14;s:2:"IM";i:15;s:2:"IT";i:16;s:2:"JE";i:17;s:2:"LV";i:18;s:2:"LT";i:19;s:2:"LU";i:20;s:2:"MT";i:21;s:2:"NL";i:22;s:2:"PL";i:23;s:2:"PT";i:24;s:2:"RO";i:25;s:2:"SK";i:26;s:2:"SI";i:27;s:2:"ES";i:28;s:2:"SE";i:29;s:2:"GB";}' WHERE option_name = 'woocommerce_specific_allowed_countries';
# Ship to specific EU countries only
UPDATE `wp_options` SET `option_value`='specific' WHERE option_name = 'woocommerce_ship_to_countries';
UPDATE `wp_options` SET `option_value`='a:30:{i:0;s:2:"AT";i:1;s:2:"BE";i:2;s:2:"BG";i:3;s:2:"HR";i:4;s:2:"CY";i:5;s:2:"CZ";i:6;s:2:"DK";i:7;s:2:"EE";i:8;s:2:"FI";i:9;s:2:"FR";i:10;s:2:"DE";i:11;s:2:"GR";i:12;s:2:"HU";i:13
@mircobabini
mircobabini / my-pmpro-reset-cron-schedules.php
Last active March 11, 2022 17:26 — forked from sc0ttkclark/my-pmpro-reset-cron-schedules.php
Reset the Cron Schedules for Paid Memberships Pro. The single-use version can be found at: https://gist.github.com/sc0ttkclark/bd319a47656b786ccee3eca6f2dc4a9a
<?php
/**
* Reset the Cron Schedules for Paid Memberships Pro.
*
* You can add this recipe to your site by creating a custom plugin
* or using the Code Snippets plugin available for free in the WordPress repository.
* Read this companion article for step-by-step directions on either method.
* https://www.paidmembershipspro.com/create-a-plugin-for-pmpro-customizations/
*/
@mircobabini
mircobabini / mainwp-add-child-info.php
Last active January 19, 2022 14:34 — forked from ragoand/mainwp-add-child-info
Add MainWP Child info and save
<?php
/**
* Code for MAINWP DASH
* Save information to the table {table_prefix}_mainwp_wp_options once the site is successfully synced
*
* @param mixed $pWebsite
* @param array $information
*
* @return void
@mircobabini
mircobabini / my_pmpro_forward_ipn.php
Last active October 5, 2021 16:16 — forked from andrewlimaza/my_pmpro_forward_ipn.php
Forward PMPro PayPal IPNs to another domain
<?php
/**
* Forward PMPro PayPal IPNs to another domain.
* Each domain will process the IPNs. The IPN handlers should be setup to ignore
* messages that aren't for that site. PMPro does this.
* This is useful if you have 2 different sites using the same PayPal account
* and the IPN is setup to go to a PMPro site.
* Add this to a custom plugin on the PMPro site the IPN hits.
* Update the domain/url to the IPN you want to forward to.
* The pmprodev_gateway_debug_setup check makes sure this DOESN'T run if you have the
@mircobabini
mircobabini / pmpro-cancel-on-billing-failure.php
Last active December 5, 2020 20:30 — forked from ideadude/pmpro-cancel-on-billing-failure.php
Cancel PMPro subscriptions when a recurring payment fails.
<?php
/**
* Cancel subscriptions when a recurring payment fails.
* You should also use the PMPro Email Templates Add On to edit the
* default billing_failure.html email to mention that users are cancelled upon failure.
*/
function my_cancel_subscriptions_on_any_failed_payment( $order ) {
pmpro_cancelMembershipLevel( $order->membership_id, $order->user_id );
// ensure cancel at gateway
@mircobabini
mircobabini / pmpro_cancel_on_next_payments_date.php
Last active April 28, 2020 08:42 — forked from strangerstudios/pmpro_cancel_on_next_payments_date.php
Change PMPro membership cancellation to set expiration date for next payment instead of cancelling immediately.
<?php
/*
Change cancellation to set expiration date for next payment instead of cancelling immediately.
Assumes orders are generated for each payment (i.e. your webhooks/etc are setup correctly).
Since 2015-09-21 and PMPro v1.8.5.6 contains code to look up next payment dates via Stripe and PayPal Express APIs.
*/
//before cancelling, save the next_payment_timestamp to a global for later use. (Requires PMPro 1.8.5.6 or higher.)
function my_pmpro_before_change_membership_level($level_id, $user_id) {
@mircobabini
mircobabini / visibly.js
Last active July 13, 2023 22:58 — forked from Swaagie/visibly.js
Cross-browser page visibility wrapper for the HTML5 Visibility API (polyfill - check visibility, handle change visibility events)
/*!
* isVis - v0.5.5 Aug 2011 - Page Visibility API Polyfill
* Copyright (c) 2011 Addy Osmani
* Dual licensed under the MIT and GPL licenses.
*
* Changes:
* - Forked by: https://gist.github.com/Swaagie/6221897 (supports moz native)
* - Added: methods isVisible, isHidden (based on this.s property)
*/
(function () {
<?php
include __DIR__ . '/threads.php';
$commands = array();
for ( $i=0; $i<10; $i++ ) {
$commands[] = "bash -c 'sleep `shuf -i 1-5 -n 1`; echo $i'";
}