Skip to content

Instantly share code, notes, and snippets.

View bhubbard's full-sized avatar
:octocat:
Hello

Brandon Hubbard bhubbard

:octocat:
Hello
View GitHub Profile
@bhubbard
bhubbard / pdf_magic.js
Created July 27, 2017 00:48 — forked from mozz100/pdf_magic.js
Zendesk embedded PDF viewer via Google Docs
// add this javascript to your Zendesk Help Center pages
(function($) {
$(function() {
// for all attachment links whose URLs end with .pdf (case sensitive)...
var pdfs = $('.attachments a[href$=".pdf"]');
var eleBody = $('div.article-body');
if (pdfs.length > 0) {
@liuyigh
liuyigh / wp_gdrive_backup_manual.sh
Last active October 23, 2017 05:35
On-demand back up WordPress to Google Drive with Bash Script. Adapted frpm [email protected] for serverpilot server. Removed some scripts for automatic backup, such as old backup deletion, directory checking etc.
#!/usr/bin/env bash
# Source: https://guides.wp-bullet.com
# Author: Mike
#define local path for backups
BACKUPPATH="/srv/users/serverpilot/bak/tmp"
#define remote backup path
BACKUPPATHREM="gBackup"
@davidegreenwald
davidegreenwald / WordPress-wp_posts-MySQL-data-size
Last active January 4, 2018 11:15
MySQL statement for WordPress wp_posts table breaking down data size for each post_type
-- This will show you the size of post, revision, attachment and other fields in `wp_posts`
-- this method can be applied to any WordPress table to get a breakdown of clutter and data use
-- this will not get you index size, but WP indexes are typically a small fraction of overall table size
SELECT post_type
COUNT(*) AS NUM, -- adds a column with the number of rows for each key value for comparison
SELECT post_type, COUNT(*) AS NUM,
(SUM(LENGTH(ID) -- add all column data together to group the total row data by post_type
+LENGTH(post_author)
+LENGTH(post_date)
+LENGTH(post_date_gmt)
// https://developers.cloudflare.com/workers/about/
// https://tutorial.cloudflareworkers.com
//
// A Service Worker which adds Security Headers.
// Checks:
// https://securityheaders.io/
// https://observatory.mozilla.org/
// https://csp-evaluator.withgoogle.com/
// https://hstspreload.org/
// https://www.ssllabs.com/ssltest/
@devinsays
devinsays / class-nf-hubspot.php
Created January 25, 2018 23:42
Custom Ninja Forms + Hubspot integration.
<?php
/**
* Hubspot Integration for Ninja Forms.
*
* @package Nano
*/
class NF_Hubspot {
// Hooks into ninja_forms_after_submission
public function init() {
@mfurlend
mfurlend / datastore-index.js
Created February 6, 2018 02:19
#cloud functions #datastore #google
'use strict';
const Datastore = require('@google-cloud/datastore');
// Instantiates a client
const datastore = Datastore();
/**
* Gets a Datastore key from the kind/key pair in the request.
*
@mfurlend
mfurlend / save-to-datastore-index.js
Created February 6, 2018 03:13
#google #datastore #save #cloud functions
exports.transaction = function transaction (req, res) {
// Imports the Google Cloud client library
const Datastore = require('@google-cloud/datastore');
// Your Google Cloud Platform project ID
const projectId = 'moneypenny-dabc6';
// Instantiates a client
const datastore = Datastore({
projectId: projectId
@jtsternberg
jtsternberg / wpcli-flywheel-cache-command.php
Last active March 21, 2018 07:24
Place in your mu-plugins folder to replace the default wp-cli cache commands with customized remote version for flywheel local. Used in conjunction with https://github.com/jtsternberg/Dot-Files/blob/master/bin/local-wpcli-config
<?php
function handle_remote_cache_requests_for_local() {
global $_wp_using_ext_object_cache;
if (
empty( $_wp_using_ext_object_cache )
|| ! isset( $_REQUEST['check'], $_REQUEST['command'] )
|| ! function_exists( 'wp_cache_' . $_REQUEST['command'] )
|| str_replace( ABSPATH, '', __FILE__ ) !== $_REQUEST['check']
) {
#!/bin/bash
#
# https://support.1password.com/command-line-getting-started/
#
# Full docs: https://support.1password.com/command-line/
#
# gpg --receive-keys 3FEF9748469ADBE15DA7CA80AC2D62742012EA22
# gpg --verify op.sig op
#
@fastdivision
fastdivision / class-wc-taxjar-integration.php
Last active July 22, 2019 20:15
TaxJar WooCommerce Plugin v1.6+ Shipping Overrides
<?php
/**
* Manually override shipping taxability in TaxJar for WooCommerce
* Tweak class-wc-taxjar-integration.php around line 332
* https://github.com/taxjar/taxjar-woocommerce-plugin/blob/1.6.1/includes/class-wc-taxjar-integration.php#L332
*/
// Make shipping taxable
if ( 'AZ' == $to_state ) {
$taxes['freight_taxable'] = 1;