Skip to content

Instantly share code, notes, and snippets.

View tharmann's full-sized avatar

Tate Harmann tharmann

View GitHub Profile
@tharmann
tharmann / additional-fields.php
Created April 19, 2018 16:02
Add upload field (for PDF Flyers attached to the Event) to Tribe Community Events with Events Pro - WordPress
<?php
/**
* Single Event Meta (Additional Fields) Template
*
* Override this template in your own theme by creating a file at:
* [your-theme]/tribe-events/pro/modules/meta/additional-fields.php
*
* @package TribeEventsCalendarPro
*/
@tharmann
tharmann / recursive_mogrify.c
Last active January 7, 2019 20:37
A little C program that recursively resizes images with variable minimum edge and quality values. Also supports an optional 'dry_run' switch. Utilizes MagickWand.
#include <sys/types.h>
#include <stdlib.h>
#include <dirent.h>
#include <stdio.h>
#include <string.h>
#include <wand/MagickWand.h>
int count = 0;
void processdir(const char *name, const int min_edge, const int quality, const int dry_run) {
@tharmann
tharmann / HiddenMickey.java
Last active January 7, 2019 20:34
A modified version of the java "Hidden Mickey" that plays a sound as java draws Mickey Mouse. Replace 'your_sound_byte_here.aiff' with your sound byte.
import java.awt.*;
import java.awt.Canvas;
import java.awt.Container;
import java.awt.Graphics;
import java.awt.Rectangle;
import java.awt.event.*;
import java.io.*;
import javax.sound.sampled.*;
import javax.swing.JButton;
import javax.swing.JFrame;
@tharmann
tharmann / extractcss.js
Created January 30, 2019 16:27 — forked from renoirb/extractcss.js
Extract CSS for a given element
/**
* Based on work from krasimirtsonev
*
* http://krasimirtsonev.com/blog/article/csssteal-chrome-extension-that-extracts-css
*/
// helper function for transforming
// node.children to Array
function toArray (obj, ignoreFalsy) {
var arr = [], i;
@tharmann
tharmann / fix-wordpress-permissions.sh
Created May 30, 2019 18:45 — forked from Adirael/fix-wordpress-permissions.sh
Fix wordpress file permissions
#!/bin/bash
#
# This script configures WordPress file permissions based on recommendations
# from http://codex.wordpress.org/Hardening_WordPress#File_permissions
#
# Author: Michael Conigliaro <mike [at] conigliaro [dot] org>
#
WP_OWNER=www-data # <-- wordpress owner
WP_GROUP=www-data # <-- wordpress group
WP_ROOT=$1 # <-- wordpress root directory
CREATE TABLE `wp_yoast_seo_links` (
`id` bigint(20) unsigned NOT NULL AUTO_INCREMENT,
`url` varchar(255) COLLATE utf8mb4_unicode_ci NOT NULL,
`post_id` bigint(20) unsigned NOT NULL,
`target_post_id` bigint(20) unsigned NOT NULL,
`type` varchar(8) COLLATE utf8mb4_unicode_ci NOT NULL,
PRIMARY KEY (`id`),
KEY `link_direction` (`post_id`,`type`)
) DEFAULT CHARSET=utf8mb4 COLLATE=utf8mb4_unicode_ci;
@tharmann
tharmann / woocommerce-optimize-scripts.php
Created June 7, 2019 14:21 — forked from DevinWalker/woocommerce-optimize-scripts.php
Only load WooCommerce scripts on shop pages and checkout + cart
/**
* Optimize WooCommerce Scripts
* Remove WooCommerce Generator tag, styles, and scripts from non WooCommerce pages.
*/
add_action( 'wp_enqueue_scripts', 'child_manage_woocommerce_styles', 99 );
function child_manage_woocommerce_styles() {
//remove generator meta tag
remove_action( 'wp_head', array( $GLOBALS['woocommerce'], 'generator' ) );
@tharmann
tharmann / functions.php
Created June 10, 2019 20:19
WooCommerce Custom "Return to Shop" link on empty cart
<?php
function wc_empty_cart_redirect_url() {
$url = site_url( '/custom-shop-url/', 'https' );
return $url;
}
add_filter( 'woocommerce_return_to_shop_redirect', 'wc_empty_cart_redirect_url' );
@tharmann
tharmann / functions.php
Created January 13, 2020 15:25
Customize Divi search module to include WooCommerce products
<?php
/*Add products to divi search module. Source: https://intercom.help/elegantthemes/en/articles/3030197-how-to-enable-products-and-other-post-types-in-divi-s-search-module */
function custom_remove_default_et_pb_custom_search() {
remove_action( 'pre_get_posts', 'et_pb_custom_search' );
add_action( 'pre_get_posts', 'custom_et_pb_custom_search' );
}
add_action( 'wp_loaded', 'custom_remove_default_et_pb_custom_search' );
function custom_et_pb_custom_search( $query = false ) {
if ( is_admin() || ! is_a( $query, 'WP_Query' ) || ! $query->is_search ) {
@tharmann
tharmann / pack_items.php
Last active August 25, 2021 07:45
4D Packer Idea Using Cloudstek's LAFF Packer - splits items into increasingly smaller chunks until everything fits into boxes (based on dimensions and weight)
<?php
//Uses: https://github.com/Cloudstek/php-laff
//THE doc: 'https://www.parkbeachsystems.com/images/usps/An_Efficient_Algorithm_for_3D_Rectangular_Box_Packing.pdf'
echo '<pre>';//readability
//DATA: array of defined boxes for shipping -outer and inner dimensions plus weight:
$boxes = array(
array( 'ol' => 8.125, 'ow' => 8.125, 'oh' => 4.125, 'il' => 8, 'iw' => 8, 'ih' => 4, 'max_weight' => 20 ),
array( 'ol' => 12.5, 'ow' => 9.875, 'oh' => 3.75, 'il' => 11.25, 'iw' => 9.75, 'ih' => 3.625, 'max_weight' => 10 ),