Skip to content

Instantly share code, notes, and snippets.

@phillipwilhelm
phillipwilhelm / class-aggregator.php
Created July 2, 2020 04:37 — forked from gabrielcatellier/class-aggregator.php
Wordpress endpoint aggregator with Cache
<?php
/**
* Requires PHP 5.6+ due to the use of the splat operator and the [] "array declaration".
*/
class Rest_Aggregator {
/**
* Page number to fetch.
@rem *** Disable Some Service ***
sc stop DiagTrack
sc stop diagnosticshub.standardcollector.service
sc stop dmwappushservice
sc stop WMPNetworkSvc
sc stop WSearch
sc config DiagTrack start= disabled
sc config diagnosticshub.standardcollector.service start= disabled
sc config dmwappushservice start= disabled
@phillipwilhelm
phillipwilhelm / htaccess sal
Created June 7, 2020 00:04 — forked from salvatorecapolupo/htaccess sal
HTACCESS standard senza HTTP/HTTPS mixed content - https://overstep.it
########################################################################
# OPTIMAL .htaccess FILE FOR SPEED AND SECURITY @Version 2020
# ----------------------------------------------------------------------
# @Author: Andreas Hecht
# @Author URI: https://seoagentur-hamburg.com
# License: GNU General Public License v2 or later
# License URI: http://www.gnu.org/licenses/gpl-2.0.html
########################################################################
@phillipwilhelm
phillipwilhelm / wc-filter-products-on-orders-screen.php
Created June 5, 2020 15:32 — forked from RadGH/wc-filter-products-on-orders-screen.php
WooCommerce: Filter by purchased products on orders screen
<?php
/**
* Allow sorting orders screen by purchased product
* Modified version of https://github.com/wp-plugins/woocommerce-filter-orders-by-product/blob/master/woocommerce-filter-orders-by-product.php
*/
if ( function_exists('WC') && is_admin() ):
add_action( 'restrict_manage_posts', 'aa_product_filter_in_order', 50 );
add_filter( 'posts_where' , 'aa_product_filter_where' );
endif;
@phillipwilhelm
phillipwilhelm / class-wc-boxpack.php
Created June 5, 2020 15:20 — forked from RadGH/class-wc-boxpack.php
Modified version of "class-wc-boxpack.php" version "3.2.18". See: https://gist.github.com/RadGH/7c8f0ef77e242ce011932d41e9c06b8e
<?php
/**
* WooCommerce Box Packer
*
* @version 2.0.1
* @author WooThemes / Mike Jolley
*/
class WC_Boxpack {
@phillipwilhelm
phillipwilhelm / ups-self-packed-products.php
Created June 5, 2020 15:20 — forked from RadGH/ups-self-packed-products.php
[WooCommerce UPS Shipping] This script allows you to specify products as "already packed". They will not be added to separate boxes, and will not be combined with other products.
<?php
// This script allows you to specify products as "already packed". They will not be added to separate boxes, and will not be combined with other products.
// This is useful if you have products that are already packed and ready to ship that should not be put into another box.
//
// IMPORTANT:
// The plugin 'WooCommerce UPS Shipping' does not currently support the filter "woocommerce_shipping_ups_skip_packing".
// For now, you must manually edit the UPS plugin directly. The two edits are located below (for version 3.2.18):
// 1. https://gist.github.com/RadGH/ad8d8e599366a27c81bc84dd1f66aaa9
// 2. https://gist.github.com/RadGH/b7b69f65bbeb7212083058d1d644b0c9
//
@phillipwilhelm
phillipwilhelm / csvMessage
Created April 24, 2020 23:20 — forked from james-tindal/csvMessage
Send multiple iMessages from CSV and message template. Will prompt for .csv and .txt template files.
#!/bin/sh
if [ "$#" -eq 1 ]; then stdinmsg=$(cat); fi
exec <"$0" || exit; read v; read v; read v; exec /usr/bin/osascript - "$@" "$stdinmsg"; exit
on run
set pathCSVFile to (choose file with prompt "Select the CSV file" of type "csv")
set strCSV to read pathCSVFile
set pathTemplateFile to (choose file with prompt "Select the message template" of type "txt")
set messageTemplate to read pathTemplateFile
@phillipwilhelm
phillipwilhelm / convert_to_utf8.php
Created April 1, 2020 04:33 — forked from joostvanveen/ convert_to_utf8.php
Check to see if a string is UTF-8 and convert it if it's not. Accidentally posted this as anonymous before :(
<?php
function getUtf8String($string) {
if ( !isUtf8($string) )
return utf8_encode($string);
return $string;
}
function isUtf8($string) {
if ( function_exists("mb_check_encoding") ) {
return mb_check_encoding($string, 'UTF8');
@phillipwilhelm
phillipwilhelm / convert_windows_cp1252_to_latin1.php
Created April 1, 2020 04:33 — forked from joostvanveen/convert_windows_cp1252_to_latin1.php
Convert a Windows CP1252 string to Latin1. Converts the typical Windows (Word) crappy display characters like curly quotation marks, triple dots, etc. Windows-1252 or CP-1252 is a character encoding of the Latin alphabet, used by default in the legacy components of Microsoft Windows in English and some other Western languages. It is one version …
<?php
function transcribe_cp1252_to_latin1($cp1252) {
return strtr(
$cp1252,
array(
"\x80" => "e", "\x81" => " ", "\x82" => "'", "\x83" => 'f',
"\x84" => '"', "\x85" => "…", "\x86" => "+", "\x87" => "#",
"\x88" => "^", "\x89" => "0/00", "\x8A" => "S", "\x8B" => "<",
"\x8C" => "OE", "\x8D" => " ", "\x8E" => "Z", "\x8F" => " ",
"\x90" => " ", "\x91" => "`", "\x92" => "'", "\x93" => '"',
@phillipwilhelm
phillipwilhelm / du.sh
Created April 1, 2020 04:32 — forked from joostvanveen/du.sh
Get folder sizes on command line, including --max-depth, sorted by folder size desc
# Get available disk space
df -h
# Get the top 10 biggest folders in the current directory
du -h --max-depth=1 | sort -rh | head -10
# Get the top 10 biggest folders in the current directory and their first child directories
du -h --max-depth=2 | sort -rh | head -10
# Get sizes of all folders in the current directory