Skip to content

Instantly share code, notes, and snippets.

View dbagley1's full-sized avatar

Darrian Bagley dbagley1

View GitHub Profile
@dbagley1
dbagley1 / Design Mode Bookmarklet.js
Created March 18, 2025 18:12
Toggle Design Mode Bookmarklet
javascript:(function () {if (document.documentElement.contentEditable === false || document.designMode === "off") {document.body.contentEditable='true';document.designMode='on';void 0;} else if (document.documentElement.contentEditable === true || document.designMode === "on") {document.body.contentEditable='false';document.designMode='off';void 0;}})();
@dbagley1
dbagley1 / disable-classic-editor-for-gp-elements.php
Created December 2, 2024 20:05
Disable Classic Editor Plugin for GeneratePress Elements
<?php
/** Disable Classic Editor Plugin for GeneratePress Elements
* Prevents GeneratePress Block Elements from opening in the classic editor when using the Classic Editor plugin in WordPress.
*/
function disable_classic_editor_for_gp_elements($editors, $post_type) {
if ('gp_elements' === $post_type) {
$editors['classic_editor'] = false;
$editors['block_editor'] = false;
}
return $editors;
@dbagley1
dbagley1 / html-template-tag-function.js
Created August 1, 2024 17:45
html Template Literal Function that Does Nothing (for Syntax Highlighting HTML in Template Literals in VS Code)
// Template literal tag function that has the default behavior of a template literal.
// This is useful for formatters that give special treatment to literals tagged html (or other special names).
const html = (strings, ...values) => String.raw({ raw: strings }, ...values);
// Source: https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Template_literals#tagged_templates
/* VS Code Extensions that enable HTML Syntax Highlighting in Template Literals */
// Install one of these extensions to enable syntax highlighting and HTML language features in template literals:
// - lit-html by Matt Bierner
@dbagley1
dbagley1 / rowsToJsonArray.gs
Created June 17, 2024 20:11
Convert the rows of a Google Sheet into a JSON array.
/**
* Converts the rows of a Google Sheet into a JSON array.
* The JSON array is split into chunks of 50,000 characters due to the Google Sheets character limit.
* Object keys in the JSON array will be the headers of the Google Sheet.
*
* @param {string} sheetName - The name of the sheet to convert.
* @returns {Array.<Array.<string>>} An array of arrays, where each inner array contains a chunk of the JSON string.
* Each chunk is a string of up to 50,000 characters.
*
* @example
@dbagley1
dbagley1 / allow-summary-tag-in-tinymce-editor.php
Created March 13, 2024 20:32
Allow Summary tag in WordPress TinyMCE Editor
// Allow <summary> tag in WordPress TinyMCE Editor
function summary_tinymce_support($initArray) {
// Add summary to extended_valid_elements config
$ext = 'summary';
if ( isset( $initArray['extended_valid_elements'] ) ) {
$initArray['extended_valid_elements'] .= ',' . $ext;
} else {
$initArray['extended_valid_elements'] = $ext;
}
@dbagley1
dbagley1 / convert-css-variables-to-values.html
Created October 24, 2023 16:06
HTML Tool to Convert CSS Variables to Computed Values (WIP)
<html>
<head>
<style>
body {
margin: 0;
}
* {
box-sizing: border-box;
@dbagley1
dbagley1 / restore-win10-context-menu.bat
Created August 18, 2023 17:40
Registry Edit Command to Restore Win10 Full Context Menu in Windows 11 Explorer
reg add "HKCU\Software\Classes\CLSID\{86ca1aa0-34aa-4e8b-a509-50c905bae2a2}\InprocServer32" /f
@dbagley1
dbagley1 / Open Button JS Links in New Tab with Ctrl Key.user.js
Last active August 18, 2023 13:53
Open Button JS Links in New Tab with Ctrl Key User Script
@dbagley1
dbagley1 / javascript-factorial-function-using-for-loop.js
Created August 8, 2023 21:35
Javascript Factorial Function Using For Loop
function factorial(num) {
let result = 1;
for (let i = 1; i <= num; i++) {
result *= i;
}
return result;
}
console.log(factorial(0)); // 1
console.log(factorial(5)); // 120
@dbagley1
dbagley1 / vs-code-task-to-kill-process-on-port-windows.jsonc
Last active August 8, 2023 16:29
VS Code Task to Kill Process on Port - Windows
{
// See https://go.microsoft.com/fwlink/?LinkId=733558
// for the documentation about the tasks.json format
"version": "2.0.0",
"tasks": [
{
"label": "Kill Port",
"type": "shell",
"windows": {
"command": "for /f \"tokens=5\" %A in ('netstat -aon ^| findstr \":${input:portNumber}\" ^| more +1') do @taskkill /F /PID %A",