Skip to content

Instantly share code, notes, and snippets.

View mircobabini's full-sized avatar

Mirco Babini mircobabini

View GitHub Profile
#!/usr/bin/env bash
# inspired by
# https://gist.github.com/JannikArndt/feb720c1f5d210b4820b880af23f2a07
# which was inspired by
# https://github.com/fwartner/mac-cleanup/blob/master/cleanup.sh
# https://gist.github.com/jamesrampton/4503412
# https://github.com/mengfeng/clean-my-mac/blob/master/clean_my_mac.sh
# https://github.com/szymonkaliski/Dotfiles/blob/master/Scripts/clean-my-mac
# http://brettterpstra.com/2015/10/27/vacuuming-mail-dot-app-on-el-capitan/ / https://github.com/pbihq/tools/blob/master/MailDBOptimiser.sh
@mircobabini
mircobabini / wordfence-preserve-logs.php
Last active February 20, 2025 08:49
Extended Login Logs for Wordfence Security: preserve more logins history in a separate table
<?php
class WordFence_Logins_Extended_Logs {
protected $VERSION = 1;
public function __construct() {
add_action( 'admin_init', [ $this, 'init' ] );
add_action( 'wordfence_daily_cron', [ $this, 'update_backup' ], 5 );
add_action( 'wordfence_daily_cron', [ $this, 'cleanup_backup' ], 15 );
}
@mircobabini
mircobabini / pmpro-conpd-avoid-complete-cancellation.php
Last active January 16, 2025 17:45
PMPro snippet to disable the "Cancel" button when the auto-renew option is turned off.
<?php
/**
* Remove "Cancel" button for cancelled subscriptions.
*
* The user is still able to cancel auto-renew, but can't completely cancel the membership.
*/
add_filter( 'pmpro_member_action_links', function ( $pmpro_member_action_links ) {
global $current_user;
// bail if cancel link has been removed by someone else
@mircobabini
mircobabini / lib.markerclusterer-2.1.2.js
Last active January 8, 2025 04:42
MarkerClustererPlus for Google Maps V3 / v2.1.2
/**
* @name MarkerClustererPlus for Google Maps V3
* @version 2.1.2 [May 28, 2014]
* @author Gary Little
* @fileoverview
* The library creates and manages per-zoom-level clusters for large amounts of markers.
* <p>
* This is an enhanced V3 implementation of the
* <a href="http://gmaps-utility-library-dev.googlecode.com/svn/tags/markerclusterer/"
* >V2 MarkerClusterer</a> by Xiaoxi Wu. It is based on the
@mircobabini
mircobabini / wp-fix-load-text-domain-just-in-time.php
Created November 14, 2024 18:03
WP6.7 bloats the logs with a Deprecation Notice about text domains. Here's the fix.
<?php
add_filter( 'doing_it_wrong_trigger_error', function ( $doing_it_wrong, $function_name ) {
if ( '_load_textdomain_just_in_time' === $function_name ) {
return false;
}
return $doing_it_wrong;
}, 10, 2 );
@mircobabini
mircobabini / pmpro-cancel-on-billing-failure.php
Last active July 29, 2024 09:51 — 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-stripe-webhook-permitted-applications.php
Created April 10, 2024 08:38
Define which Stripe webhook applications are permitted, then exclude any other webhook request coming through
<?php
/**
* Define which Stripe webhook applications are permitted, then exclude any other webhook request coming through.
*
* This is expecially useful when you have multiple websites sharing the same Stripe account.
* Then, you gonna see multiple webhook requests coming from different applications.
* This snippet will allow you to filter out the ones you don't want to process.
*/
<?php
/**
* Don't apply coupons to the product addons from PPOM for WooCommerce plugin.
ì */
add_filter( 'woocommerce_coupon_get_discount_amount', function ( $discount, $discounting_amount, $cart_item, $single, $coupon ) {
if ( ! function_exists( 'ppom_get_field_prices' ) || ! function_exists( 'ppom_price_get_addon_total' ) ) {
return $discount;
}
if ( $coupon->is_type( 'percent' ) ) {
@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
-- Simhub telemetry mod, Wotever 2023
local M = {}
local ip = "127.0.0.1"
local port = 9999
local updateRate = 100
local udpSocket = nil
local lastSimHubFrameData = nil
local abs = math.abs
local ffi = require("ffi")