Skip to content

Instantly share code, notes, and snippets.

View nickihastings's full-sized avatar
🏠
Working from home

Nicki Hastings nickihastings

🏠
Working from home
View GitHub Profile
@dsernst
dsernst / heapsPermute.js
Last active May 15, 2018 22:53
A JavaScript implement of Heap's efficient Permutation Algorithm: https://en.wikipedia.org/wiki/Heap%27s_algorithm
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);
@rrennick
rrennick / fix-as-action-ids.php
Last active October 3, 2020 14:04
Address fatal error in Action Scheduler when identity field was not correctly set on migration
<?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 / duplicate-post.php
Last active February 28, 2024 07:18
Programmatically duplicating a WordPress post
<?php
/**
* Duplicates a post & its meta and returns the new duplicated Post ID.
*
* @param int $post_id The Post ID you want to clone.
* @return int The duplicated Post ID.
*/
function duplicate_post(int $post_id): int
{