This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
### Find & Replace | |
## basic examples | |
# replaces "urchin" with "analytics" in all files in current directory and backs up originals as .bak files | |
find . -type f -exec sed -i.bak "s/urchin.js/analytics.js/g" {} \; | |
# reverses the prior command, restoring all the original (now .bak) files | |
find . -name "*.bak" -exec sh -c 'mv -f $0 ${0%.bak}' {} \; |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
/** | |
* Loads javascript file by url and saves reference to it by name, so it's not loaded again | |
* @param {string} name Name of js library | |
* @param {string} url Url to js library | |
* @return {promise} Resolves when library is loaded | |
* | |
* Based on example by Brad Berger: https://bradb.net/blog/promise-based-js-script-loader/ | |
* Extended w/ global variable to keep track of previously loaded scripts. | |
* Removed support for loading several independent scripts at once via Promise.all() | |
* |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
<?php | |
/** | |
* Move image inside <p> tag above the <p> tag while preserving any link around image. | |
* Can be prevented by adding any attribute or whitespace to <p> tag, e.g. <p class="yolo"> or even <p > | |
*/ | |
function gc_remove_p_tags_around_images($content) | |
{ | |
$contentWithFixedPTags = preg_replace_callback('/<p>((?:.(?!p>))*?)(<a[^>]*>)?\s*(<img[^>]+>)(<\/a>)?(.*?)<\/p>/is', function($matches) | |
{ | |
/* |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
// ==UserScript== | |
// @name Convert post to Gutenberg | |
// @namespace http://tampermonkey.net/ | |
// @version 0.1 | |
// @description Convert Wordpress classic posts to Gutenberg layout | |
// @author Micah Engle-Eshleman | |
// @include /^https:\/\/subdomain\.domain\.com\/wp-admin\/post.php\?post=\d+&action=edit/ | |
// @grant none | |
// ==/UserScript== |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
/* eslint-disable prefer-spread, prefer-rest-params, no-console */ | |
/** | |
* Queue up Sentry.* method calls, thrown errors, and unhandled Promise rejections and | |
* replay them as soon as Sentry JS SDK has loaded | |
* | |
* Minify & inline this script before any other JS in the <head> | |
* | |
* Remember to add onload="onSentryLoad()" to your asynchronously loaded Sentry script, e.g. | |
* <script defer src="https://.../sentry-1.13.3.min.js" onload="onSentryLoad()"><script> |