Skip to content

Instantly share code, notes, and snippets.

@renddrew
renddrew / ipv4-condenser.php
Created October 6, 2023 01:21
IPv4 Cleanup and Condenser
<?php
/*
This PHP script takes a list of IPv4 addresses and performs the following operations:
- Remove Duplicates: Eliminates any duplicate IP addresses from the list.
- IPv4 Validation: Checks if each entry is a valid IPv4 address. Invalid entries are retained but not duplicated.
- Wildcard Replacement: For IPs with the same prefix (first three octets), replaces them with a single entry using a wildcard for the last octet.
- Preserve Unique IPs: If an IP address has a unique prefix, it's retained in its original form.
Usage
- Replace the $ipList variable with your list of IP addresses, one per line.
@renddrew
renddrew / tha_update_woo_shipping_province_change.php
Created May 24, 2017 14:47
Update WooCommerce Checkout Shipping on State/Province Change
// Add into your theme's functions file
function tha_update_woo_shipping_province_change(){
if ( function_exists('is_checkout') && is_checkout() ) {
?>
<script>
window.addEventListener('load', function(){
var el = document.getElementById("billing_state_field");
el.className += ' update_totals_on_change';
});
@renddrew
renddrew / marketo-form-fill.js
Created April 29, 2017 15:00
Cookie and pre-fill Marketo form data - hide filled fields for progressive profiling
/*
Cookie Marketo form data and pre-fill other Marketo forms
- works across site for any Marketo forms (if they use the same field names)
- saves and updates only changed form values
- saves values either on form submit or after the field value is entered
- can hide pre-filled form data - useful for progressive profiling
Needs: https://github.com/carhartl/jquery-cookie