Skip to content

Instantly share code, notes, and snippets.

Avatar
💭
party 🥳

Jason Stallings octalmage

💭
party 🥳
View GitHub Profile
@octalmage
octalmage / bulkUpdate.js
Created May 21, 2017 — forked from davideast/bulkUpdate.js
Bulk update with .push()
View bulkUpdate.js
/**
* Send a bulk update to Firebase from an array or an object literal.
*
* When .push() is called on a Firebase reference without a parameter passed no
* trip to the server is made.
*
* ex:
* var childRef = ref.push();
*
* A reference is returned which has a push-id that can be returned by calling .name().
@octalmage
octalmage / if_no_title.php
Created Feb 28, 2017
Modify the edit.php screen to show post excerpts if there is no title.
View if_no_title.php
<?php
/*
Plugin Name: If No Title
Description: Modify the edit.php screen to show post excerpts if there is no title.
Version: 0.0.1
*/
add_action( 'load-edit.php', function()
{
add_filter( 'the_title', function( $title )
@octalmage
octalmage / custom_timeout.php
Created Jul 14, 2016
PHP Compatibility Custom Timeout
View custom_timeout.php
<?php
/*
Plugin Name: PHP Compatibility Custom Timeout
*/
function custom_timeout( $timeout ) {
return 0;
}
add_filter( 'wpephpcompat_scan_timeout', 'custom_timeout', 10 );
@octalmage
octalmage / example.md
Created Jul 13, 2016 — forked from lee-dohm/example.md
HTML5 <details> in GitHub
View example.md

Using <details> in GitHub

Suppose you're opening an issue and there's a lot of noisy logs that may be useful.

Rather than wrecking readability, wrap it in a <details> tag!

<spoilers>
 <summary>Summary Goes Here</summary>
@octalmage
octalmage / purge-object-cache.php
Created Jun 14, 2016
Automatically purge object cache
View purge-object-cache.php
<?php
/*
Plugin Name: Automatically purge object cache
Description: Automatically purge object cache on post changes.
*/
foreach ( array( 'trashed_post', 'delete_post', 'edit_post', 'publish_page', 'publish_post', 'save_post' ) as $hook ) {
add_action( $hook, 'wp_cache_flush' );
}
@octalmage
octalmage / roles.md
Last active Oct 19, 2021
Default WordPress user roles and capabilities.
View roles.md

WordPress v4.3.1

Admin wp_capabilities wp_user_level 10

a:1:{s:13:"administrator";b:1;}

Contributor wp_capabilities wp_user_level 1

@octalmage
octalmage / clearcart.php
Created Oct 26, 2015
Force clear WooCommerce cart for WordPress user.
View clearcart.php
<?php
add_action( 'init', 'force_clear_woocommerce_cart' );
function force_clear_woocommerce_cart()
{
$user_ID = get_current_user_id();
if ($user_ID === 68364)
{
@octalmage
octalmage / sine.js
Created Oct 18, 2015
RobotJS - Move the mouse across the screen as a sine wave.
View sine.js
//Move the mouse across the screen as a sine wave.
var robot = require("robotjs");
//Speed up the mouse.
robot.setMouseDelay(2);
var twoPI = Math.PI * 2.0;
var screenSize = robot.getScreenSize();
var height = (screenSize.height / 2) - 40;
var width = screenSize.width;
@octalmage
octalmage / screen.js
Created Oct 6, 2015
RobotJS screen capture API preview.
View screen.js
var robot = require("robotjs");
var image = robot.screen.capture();
var hex = image.colorAt(25, 25);
console.log("#" + hex);
//#ebebeb
@octalmage
octalmage / send-reads-to-master.php
Last active Nov 23, 2015
HyperDB - Send Reads to Master.
View send-reads-to-master.php
<?php
/**
* Plugin Name: Send Reads to Master
* Description: Suggested fix for backend replication lag
* Author: WP Engine
* Version: 0.2
*
*/
if ( is_admin() ) {