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
#!/usr/bin/env bash | |
# Fakesnip: A pseudo-ksnip for Sway, based on `grim` and `slurp` — because we love the screenshot editing power of ksnip, but it does not have real Wayland + Sway support yet. | |
# Usage: | |
# | |
# Place this script in a location of your choosing, such as `~/.config/sway/scripts/`. | |
# Then, add the following to your Sway config: | |
# |
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 the sheet music images on the page | |
const elements = document.getElementsByClassName('split-image'); | |
// Check that there are actually images on the page | |
if (elements.length === 0) { | |
console.error('No images found'); | |
} else { | |
// If images were found, extract the base url from the 1st one | |
const imageUrl = elements[0].src; | |
const imageIdMatch = /\/sheets\/([\w\d]+)\//; |
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
-- This will show you the size of post, revision, attachment and other fields in `wp_posts` | |
-- this method can be applied to any WordPress table to get a breakdown of clutter and data use | |
-- this will not get you index size, but WP indexes are typically a small fraction of overall table size | |
SELECT post_type | |
COUNT(*) AS NUM, -- adds a column with the number of rows for each key value for comparison | |
SELECT post_type, COUNT(*) AS NUM, | |
(SUM(LENGTH(ID) -- add all column data together to group the total row data by post_type | |
+LENGTH(post_author) | |
+LENGTH(post_date) | |
+LENGTH(post_date_gmt) |
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
(function(){ | |
/** | |
* Create a new MediaLibraryTaxonomyFilter we later will instantiate | |
*/ | |
var MediaLibraryTaxonomyFilter = wp.media.view.AttachmentFilters.extend({ | |
id: 'media-attachment-taxonomy-filter', | |
createFilters: function() { | |
var filters = {}; | |
// Formats the 'terms' we've included via wp_localize_script() |
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 | |
#Add a query var to sniff requests | |
add_filter( 'query_vars', 'my_query_var_callback', 10, 1 ); | |
function my_query_var_callback( $vars ){ | |
$vars[] = 'dynamic_js'; | |
return $vars; | |
} | |
#Dynamic JavaScript | |
add_rewrite_rule( '^assets/js/dynamic\.js$', 'index.php?dynamic_js=1', 'top' ); //Note the hidden query variable |
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
// Just before switching jobs: | |
// Add one of these. | |
// Preferably into the same commit where you do a large merge. | |
// | |
// This started as a tweet with a joke of "C++ pro-tip: #define private public", | |
// and then it quickly escalated into more and more evil suggestions. | |
// I've tried to capture interesting suggestions here. | |
// | |
// Contributors: @r2d2rigo, @joeldevahl, @msinilo, @_Humus_, | |
// @YuriyODonnell, @rygorous, @cmuratori, @mike_acton, @grumpygiant, |
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 | |
/* | |
* Resize images dynamically using wp built in functions | |
* Based on the script by Victor Teixeira | |
* - Updated to use wp_get_image_editor() | |
* - Moves resized files to uploadpath/resized/ | |
* Joe Swann | |
* | |
* php 5.2+ | |
* |
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
#!/bin/sh | |
# Credentials for a MySQL user with PROCESS, SUPER permissions | |
USERNAME= | |
PASSWORD= | |
# MySQL Server location | |
HOST=127.0.0.1 | |
PORT=3306 |