Skip to content

Instantly share code, notes, and snippets.

Avatar

Nicki Hastings nickihastings

View GitHub Profile
@rrennick
rrennick / fix-as-action-ids.php
Last active Oct 3, 2020
Address fatal error in Action Scheduler when identity field was not correctly set on migration
View fix-as-action-ids.php
<?php
/*
Plugin Name: Fix Action Scheduler Action IDs
Version: 0.2
Author: Automattic
Author URI: https://automattic.com/
Description: This is a one time use plugin designed to address a fatal error during AS migration where the identity field in the actionscheduler_actions table did not get set before actions were migrated.
License: GNU General Public License v3.0 (or later)
License URI: http://www.opensource.org/licenses/gpl-license.php
@eduwass
eduwass / aux-functions.php
Last active Aug 27, 2020
Programmatically duplicating a WordPress post
View aux-functions.php
<?php
/**
* Duplicates a post & its meta and it returns the new duplicated Post ID
* @param [int] $post_id The Post you want to clone
* @return [int] The duplicated Post ID
*/
function duplicate($post_id) {
$title = get_the_title($post_id);
$oldpost = get_post($post_id);
@dsernst
dsernst / heapsPermute.js
Last active May 15, 2018
A JavaScript implement of Heap's efficient Permutation Algorithm: https://en.wikipedia.org/wiki/Heap%27s_algorithm
View heapsPermute.js
var swap = function (array, pos1, pos2) {
var temp = array[pos1];
array[pos1] = array[pos2];
array[pos2] = temp;
};
var heapsPermute = function (array, output, n) {
n = n || array.length; // set n default to array.length
if (n === 1) {
output(array);
You can’t perform that action at this time.