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;
@fwenzel
fwenzel / b2.md
Last active July 31, 2023 04:40
Mastodon --> Backblaze B2

Using Mastodon with Backblaze B2

Mastodon can store its assets in Amazon S3 (it speaks the S3 protocol). But it does not, by default, speak to Backblaze B2.

There are a couple of reasons why you might want that:

  • you already know and trust B2
  • it's cheaper
  • you do not want to make your instance dependent on AWS
  • etc.
@MikeNGarrett
MikeNGarrett / wp-config.php
Last active April 26, 2024 10:15
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
@pocesar
pocesar / get domain without subdomain.php
Created April 11, 2013 20:27
PHP code to get the domain name without subdomains (includes the tld, and the special types from IANA). Don't have support for unicode domain names.
<?php
/**
* @param string $domain Pass $_SERVER['SERVER_NAME'] here
* @param bool $debug
*
* @debug bool $debug
* @return string
*/
function get_domain($domain, $debug = false)
{
@dnaber-de
dnaber-de / hands-off-from-content.php
Created August 25, 2012 11:43
WP Plugin: Don't replace 'Wordpress' with 'WordPress'. Keep ' and " as they are.
<?php
/**
* Plugin Name: dna Hands off from content
* Description: Don't replace 'Wordpress' with 'WordPress'. Keep ' and " as they are.
* Plugin URI: https://gist.github.com/3464269
* Version: 2012.08.25
* Author: David Naber
* Author URI: http://dnaber.de/
* License: MIT
* License URI: http://www.opensource.org/licenses/mit-license.php
@pfefferle
pfefferle / blavatars.php
Created February 2, 2012 16:35
Blog Avatar
<?php
/*
Plugin Name: Blavatars
Plugin URI: https://gist.github.com/1724438
Description: Use Gravatar as a blogs avatar (Web Clip, Favicon, ...)
Version: 0.1
Author: Matthias Pfefferle
Author URI: http://notizblog.org/
*/