Skip to content

Instantly share code, notes, and snippets.

View crstauf's full-sized avatar
🤔
const THINKING = true;

Caleb Stauffer crstauf

🤔
const THINKING = true;
View GitHub Profile
@crstauf
crstauf / cssllc-cpt.php
Last active March 28, 2020 05:21
Abstract class for WordPress CPT registrars.
<?php
/**
* Abstract for CPT registrars.
*
* Description: Abstract class for WordPress CPT registrars from CSSLLC.
* Author URI: https://develop.calebstauffer.com
* Author: Caleb Stauffer
* Plugin URI: https://gist.github.com/crstauf/30ee826b9cd4f0044ba7b4febc3e9dbd
*/
@crstauf
crstauf / cssllc-subresourceintegrity.php
Last active March 22, 2020 15:21
WordPress drop-in for adding attribute to scripts and stylesheets for subresource integrity implementation.
<?php
/**
* Plugin name: CSSLLC Subresource Integrity
* Plugin URI: https://gist.github.com/crstauf/9a2f412e48c6630e6de945bd1d0e9e53
* Description: WordPress drop-in for adding attribute to scripts and stylesheets for subresource integrity implementation.
* Author URI: https://develop.calebstauffer.com
* Author: Caleb Stauffer
* Version: 1.0
*
* @link https://www.smashingmagazine.com/2019/04/understanding-subresource-integrity/ Explanation.
@crstauf
crstauf / wp-phpunit-instructions.md
Last active January 23, 2020 18:45
Simple installation instructions for PHPUnit for WordPress plugin.

SSH Commands

Run the following commands in order:

  1. apt-get update
  2. apt-get install curl
  3. apt-get install subversion
  4. wget -O phpunit https://phar.phpunit.de/phpunit-7.phar
  5. chmod +x phpunit
  6. mv phpunit /usr/local/bin/phpunit
  7. curl -s https://getcomposer.org/installer | php
  8. mv composer.phar /usr/local/bin/composer
@crstauf
crstauf / server-load.php
Last active September 13, 2019 23:39
WordPress drop-in (mu-plugin or include) to help manage features in certain server load conditions.
<?php
/**
* Plugin name: Server Load
* Plugin URI: https://gist.github.com/crstauf/67de8505ae628d9589c14e62e6ef69eb
* Author: Caleb Stauffer
* Author URI: https://develop.calebstauffer.com
* Version: 1.0
*/
class ServerLoad {
@crstauf
crstauf / dynamic-styles.php
Last active October 12, 2019 01:37
A drop-in (mu-plugin or include) helper for adding dynamic styles to a template.
<?php
/**
* Plugin name: Dynamic Styles
* Plugin URI: https://gist.github.com/crstauf/20479cb9d1dbcd59fa81647aae484cd9
* Author: Caleb Stauffer
* Author URI: https://develop.calebstauffer.com
* Version: 1.1
*/
/**
@crstauf
crstauf / gist:1d1e53b81db648875039f4ad1775fc2e
Created February 5, 2019 03:13
Terminal command to import SQL file
mysql -u <username> -p <databasename> < <filename.sql>
/**
* Source: https://remysharp.com/2010/07/21/throttling-function-calls
*/
function throttle(fn, threshhold, scope) {
threshhold || (threshhold = 250);
var last,
deferTimer;
return function () {
var context = scope || this;
@crstauf
crstauf / gform-quick-links.php
Last active October 3, 2018 06:24
Plugin to add quick links to bottom of Gravity Forms.
@crstauf
crstauf / iOS-Shortcut-Harvest.md
Last active October 1, 2018 06:38
iOS shortcut to get your Harvest hours via Harvest API. #iOS #iOSshortcut
@crstauf
crstauf / iOS-Shortcut-HubStaff.md
Last active October 1, 2018 06:39
iOS shortcut to get your HubStaff hours via HubStaff API. #iOS #iOSshortcut

iOS Shortcut: Get HubStaff Hours

  1. Login to your HubStaff account.
  2. Go to https://developer.hubstaff.com/my_apps.
  3. Create an app.
  4. Save the app ID.
  5. Follow the directions for obtaining your auth token.
  6. Save the auth token.
  7. Install the shortcut: https://www.icloud.com/shortcuts/a0489014fbda493bb933b07d7a31bfb3.
  8. Edit the shortcut, adding your App-Token and Auth-Token in the indicated Text boxes.