Skip to content

Instantly share code, notes, and snippets.

View spenserhale's full-sized avatar

Spenser Hale spenserhale

View GitHub Profile
@spenserhale
spenserhale / wp-transients.php
Created February 16, 2024 07:42
delete_transients() - WP
/**
* Deletes all current site transients. (Blog not Network)
*
* @return array{ deleted: string[], errored: string[] } An array of successfully and failed to delete transients.
*/
function delete_transients(): array
{
if (wp_using_ext_object_cache()) {
global $wp_object_cache;
@spenserhale
spenserhale / git-batch-push.sh
Last active March 5, 2024 19:21
When your repo exceeds upload limit (GitHub 2GB), you can push in batches so you can store up to total size limit. (100GB) (Warning uses force push, ideally should be used for setting up new remote, once)
# Adjust the following variables as necessary
REMOTE=origin
BRANCH=$(git rev-parse --abbrev-ref HEAD)
BATCH_SIZE=250
# check if the branch exists on the remote
if git show-ref --quiet --verify refs/remotes/$REMOTE/$BRANCH; then
# if so, only push the commits that are not on the remote already
range=$REMOTE/$BRANCH..HEAD
else
@spenserhale
spenserhale / browser-file-download.js
Last active February 10, 2022 01:08
JavaScript function to trigger file download within the browser.
/**
* Triggers browser to download a file with content.
*
* Accomplishes by creating a temporary a tag that we encode filename and data to and then click on behalf of user.
*
* @example
* browserFileDownload("results.txt","Success Example!");
* @example
* browserFileDownload("example.xml", "<?xml version=\"1.0\" encoding=\"UTF-8\"?><collection><item>1</item></collection>", "application/xml");
*

Keybase proof

I hereby claim:

  • I am spenserhale on github.
  • I am spenserhale (https://keybase.io/spenserhale) on keybase.
  • I have a public key ASBk6vHu6G-HbBUhey9uB5X-f5Hje-GWDiW6UBcvnkHQIAo

To claim this, I am signing this object:

@spenserhale
spenserhale / AuthorizeNetRequest.php
Last active June 19, 2018 00:37
GravityForms AuthorizeNet AuthorizeNetRequest.php
<?php
// File: wp-content/plugins/gravityformsauthorizenet/api/lib/shared/AuthorizeNetRequest.php
/**
* Sends requests to the Authorize.Net gateways.
*
* @package AuthorizeNet
* @subpackage AuthorizeNetRequest
*/
abstract class AuthorizeNetRequest
@spenserhale
spenserhale / HttpClient.php
Last active June 19, 2018 00:37
Gravity Forms AuthorizeNet HttpClient
<?php
// file: wp-content/plugins/gravityformsauthorizenet/api/lib/net/authorize/util/HttpClient.php
namespace net\authorize\util;
/**
* A class to send a request to the XML API.
*
* @package AuthorizeNet
* @subpackage net\authorize\util