Skip to content

Instantly share code, notes, and snippets.

View georgestephanis's full-sized avatar

George Stephanis georgestephanis

View GitHub Profile
@georgestephanis
georgestephanis / client.js
Last active June 2, 2024 23:54
This is an example client app to integrate with the WordPress 5.6 Application Passwords system. It walks the user through authenticating, and then queries and enumerates all users on the site.
(function($){
const $root = $( '#root' );
const $stage1 = $( '.stage-1', $root );
const $stage2 = $( '.stage-2', $root );
// If there's no GET string, then no credentials have been passed back. Let's get them.
if ( ! window.location.href.includes('?') ) {
// Stage 1: Get the WordPress Site URL, Validate the REST API, and Send to the Authentication Flow
const $urlInput = $( 'input[type=url]', $stage1 );
@georgestephanis
georgestephanis / environment-notifier.php
Last active October 13, 2020 13:56
This plugin adds a node to the adminbar clarifying the current environment setting if not production.
<?php
/*
* Plugin Name: Environment Notifier
* Plugin URI: http://github.com/georgestephanis/environment-notifier/
* Description: This plugin adds a node to the adminbar clarifying the current environment setting if not production.
* Author: George Stephanis
* Version: 1.0
* Author URI: http://wpspecialprojects.wordpress.com
*/
<?php
/**
* Plugin Name: Reusable Block Count
* Description: Display a "Reusable blocks" listing page, and a link to view all posts containing a given block.
* Author: georgestephanis
* Author URI: http://wpspecialprojects.wordpress.com/
* License: GPLv2+
*
* Loosely based on https://github.com/yeswework/fabrica-reusable-block-instances/
@georgestephanis
georgestephanis / _readme.md
Last active April 30, 2020 18:19
A validator script to confirm the validity and structure of Magic: The Gathering Arena Export/Import data. GPLv3

Arena Export Validator

This is designed as a validator designed around current Arena standards -- to be used to validate and confirm whether or not a platform's generated export format meets Arena's specs (as Arena has no officially published specs, I've tried to determine varied test cases including decks with both commanders and companions).

Assumed Format of Export Data

  • There are four possible sections, that appear in the following sequence: Commander, Companion, Deck, Sideboard.
  • The section title is the first line of each section.
  • Blank lines are inserted after each section.
  • If a line begins with an integer, it's a card. If it begins with anything else, it's a Section title.
class MtgCard {
/* raw;
quantity;
name = '';
set = '';
setNumber = 0;
*/
constructor( input = '' ) {
this.raw = '';
<?php
define( 'MTGA_LANG', 'EN' );
define( 'MTGA_PATH', '/Applications/MTGArena.app/Contents/Resources/drive_c/Program Files/Wizards of the Coast/MTGA' );
define( 'MTGA_LOGS', MTGA_PATH . '/MTGA_Data/Logs/Logs' );
define( 'MTGA_DATA', MTGA_PATH . '/MTGA_Data/Downloads/Data' );
// Get all the logs!
$logs = glob( MTGA_LOGS . '/UTC_Log - * - 1.htm' );
<?php
// Should this use RecursiveDirectoryIterator instead?
namespace Stephanis\Scan;
trait Props {
public $modified;
public $owner;
public $group;
<?php
function python_slug( $str ) {
$str = Normalizer::normalize( $str, Normalizer::FORM_KD );
$str = preg_replace( '~[\x00-\x1F\x80-\xFF]~', '', $str );
$str = preg_replace( '~[^\w\s-]~', '', $str );
$str = strtolower( trim( $str ) );
return preg_replace( '~[-\s]+~', '-', $str );
}
<?php
/*
* This is meant to be a port of the Python `slug.slug()` method, the
* source of which is as follows:
*
* value = unicodedata.normalize('NFKD', value).encode('ascii', 'ignore')
* value = re.sub('[^\w\s-]', '', value.decode('utf-8')).strip().lower()
* return re.sub('[-\s]+', '-', value)
*/
<?php
/**
* Plugin Name: Grunion to Google Sheets
*/
require __DIR__ . '/vendor/autoload.php';
define( 'SPREADSHEET_ID', '' );