Skip to content

Instantly share code, notes, and snippets.

View dmhendricks's full-sized avatar

Daniel M. Hendricks dmhendricks

View GitHub Profile
@dmhendricks
dmhendricks / disable-site-health.php
Last active January 10, 2024 14:54
Plugin to disable WordPress Site Health, because that's what logs are for and users shouldn't be bothered with them. Copy to your MU or plugins directory and activate.
<?php
/**
* Plugin Name: Disable Site Health
* Description: Disables WordPress Site Health notifications, dashboard widget and PHP update notice
* Version: 1.1.0
* Author: Daniel M. Hendricks
* Author URI: https://daniel.hn/
* Plugin URI: https://gist.github.com/dmhendricks/2d2c51da8a17d7a47b41bcfd26c3314d
*/
namespace MU_Plugins;
@dmhendricks
dmhendricks / delete-git-submodule.md
Created January 13, 2020 19:48
How to Remove a git submodule

The most effective way to remove a git submodule (source):

git submodule deinit <path_to_submodule>
git rm <path_to_submodule>
git commit -m "Removed submodule "
rm -rf .git/modules/<path_to_submodule>
@dmhendricks
dmhendricks / wordpress-trigger-scheduled-posts-plugin.md
Last active December 21, 2023 04:10
A simple WordPress plugin that publishes scheduled posts that were missed by cron (at defined interval).

Author License DigitalOcean Twitter

Scheduled Post Trigger Plugin for WordPress

This plugin is a fork of the Scheduled Post Trigger plugin, modified for slight performance i

@dmhendricks
dmhendricks / wordpress-remove-script-versions-plugin.php
Last active November 13, 2022 10:56
A simple WordPress plugin to remove the script version from linked CSS and JS scripts to improve cacheability.
<?php
/**
* @wordpress-plugin
* Plugin Name: Remove Script Versions
* Description: Removes the script version from linked CSS and JS scripts to improve cacheability.
* Plugin URI: https://gist.github.com/dmhendricks/fbf4c69b3c7a13ffa04526427083742a/
* Version: 1.0.0
* Author: Daniel M. Hendricks
* Author URI: https://daniel.hn/
* License: GPLv2 or later
@dmhendricks
dmhendricks / base64-encode-decode-string-example.java
Created October 15, 2019 19:07
Base64 encode / decode strings in Java (examples)
/**
* Because searching for a simple example of how to Base64 encode/decode in Java
* that hasn't been deprecated since the Crimean War is an exercise in madness...
*
* Requires Java 8 or higher
*/
package hn.daniel;
import java.util.Base64;
@dmhendricks
dmhendricks / open-graph-author-tags.php
Last active October 6, 2019 22:45
A simple WordPress plugin that adds Open Graph author tags for Facebook
<?php
/**
* @wordpress-plugin
* Plugin Name: Open Graph Author Tags
* Description: Adds author Open Graph tags to posts for Facebook
* Version: 1.0.0
* Author: Daniel M. Hendricks
* Author URI: https://www.danhendricks.com
* Plugin URI: https://gist.github.com/dmhendricks/63e135c22db3857f1dc1e69c5a6cdc16/
* Requires at least: 4.7
@dmhendricks
dmhendricks / wordpress-multiple-domains-single-instance.md
Last active June 30, 2019 22:48
A short guide on how to configure WordPress to use/observe multiple domains pointed to a single instance.

Multiple Domains Pointing to Single WordPress Instance

Scenario

Let's say that you want to point multiple domain names to the same WordPress instance. Normally, if you do this, WordPress will siimply redirect to the home URL in the database as configured in WP Admin > Settings > General > Site Address (URL).

Why Would You Want To Do This?

There may be a case where you want multiple domains pointing to the same site - perhaps for referral tracking, to migrate an old domain, to allow the use of short URL (for example, my-really-long-domain.com and shrturl.co), etc without using a redirect.

@dmhendricks
dmhendricks / index.html
Last active August 6, 2021 21:28
HTML 5 Boilerplate
<!DOCTYPE html>
<html lang="en">
<head>
<meta charset="utf-8" />
<title>Boilerplate</title>
<meta name="description" content="Boilerplate" />
<meta name="viewport" content="width=device-width, initial-scale=1" />
<link rel="canonical" href="https://example.com/" />
@dmhendricks
dmhendricks / benchmarking-ubuntu.md
Last active June 11, 2023 21:12
This is what I use to benchmark new Debian-based instances on any provider, VPS or dedicated.

Linux Benchmarking

These instructions are for Debian-based distributions, but they are similar for RPM-based distros.

It is best to do multiple tests and average the results, especially on VPS which may be affected by peek traffic.

sudo su
apt update && apt upgrade
@dmhendricks
dmhendricks / bind-queryselector-to-dollar-sign.js
Last active July 13, 2023 09:20
Bind querySelector to dollar sign ($) to reference DOM elements without jQuery
/**
* Bind querySelector to dollar sign ($) to easily reference DOM elements without jQuery
* Source: https://twitter.com/MrAhmadAwais/status/1113094169025708033
*/
// In case you're also loading jQuery
jQuery.noConflict();
// Example - Change an element's background color
// Shorthand for: document.querySelector( '.selector' ).style.background = '#BADA55';