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
@Hidden50
Hidden50 / mainpage.js
Last active May 31, 2018 00:04
basic Service Worker example
// ...
window.addEventListener('load', () => {
if('serviceWorker' in navigator) {
navigator.serviceWorker.register( './sw.min.js', { scope: "./" } )
.then( registration => {
const newWorker = registration.installing;
if (newWorker) {
newWorker.onstatechange = function() {
if (newWorker.state == 'activated' && !navigator.serviceWorker.controller) {
@dustyfresh
dustyfresh / workerWAF.js
Last active August 24, 2021 14:24
Simple & experimental Web Application Firewall using Cloudflare's edge workers
/*
*
* Web Application Firewall built with Cloudflare workers
*
* Author: < https://twitter.com/dustyfresh >
*
* License: GPLv3 < https://www.gnu.org/licenses/gpl-3.0.en.html >
*
* Cloudflare worker documentation:
* < https://developers.cloudflare.com/workers/about/ >
@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;
#!/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
#
@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']
) {
@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
@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.
*
@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() {
// 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/
@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)