Skip to content

Instantly share code, notes, and snippets.

View janboddez's full-sized avatar

Jan Boddez janboddez

View GitHub Profile
@dshanske
dshanske / activitypub-xray.php
Created December 22, 2022 20:50
ActivityPub Xray Override
add_action( 'init', 'activitypub_xray_override_init', 11 );
function activitypub_xray_override_init() {
$user_agent = $_SERVER['HTTP_USER_AGENT'];
$accept_header = $_SERVER['HTTP_ACCEPT'];
if ( stristr( $accept_header, 'application/activity+json' ) && stristr( $user_agent, 'XRay' ) ) {
remove_filter( 'template_include', array( '\Activitypub\Activitypub', 'render_json_template' ), 99 );
}
}
@adactio
adactio / previewImageUploads.js
Created May 12, 2022 13:33
Show inline previews of images that are going to be uploaded.
// Licensed under a CC0 1.0 Universal (CC0 1.0) Public Domain Dedication
// http://creativecommons.org/publicdomain/zero/1.0/
(function (win,doc) {
'use strict';
if (!win.FileReader || !win.addEventListener || !doc.querySelectorAll) {
// doesn't cut the mustard.
return;
}
doc.querySelectorAll('input[type="file"][accept="image/*"]').forEach( function (fileInput) {
@adactio
adactio / saveTextarea.js
Last active December 2, 2023 06:52
Put the contents of a textarea into localStorage if the user leaves the page before submitting the form.
// Licensed under a CC0 1.0 Universal (CC0 1.0) Public Domain Dedication
// http://creativecommons.org/publicdomain/zero/1.0/
(function (win, doc) {
// Cut the mustard.
if (!win.localStorage) return;
// You should probably use a more specific selector than this.
var textarea = doc.querySelector('textarea');
// The key for the key/value pair in localStorage is the current URL.
var key = win.location.href;
@MikeNGarrett
MikeNGarrett / wp-config.php
Last active January 11, 2026 23:52
All those damned wp-config constants you can never remember.
<?php
// PHP memory limit for this site
define( 'WP_MEMORY_LIMIT', '128M' );
define( 'WP_MAX_MEMORY_LIMIT', '256M' ); // Increase admin-side memory limit.
// Database
define( 'WP_ALLOW_REPAIR', true ); // Allow WordPress to automatically repair your database.
define( 'DO_NOT_UPGRADE_GLOBAL_TABLES', true ); // Don't make database upgrades on global tables (like users)
// Explicitely setting url