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
(async () => { | |
const link = document.createElement('a'); | |
document.body.appendChild(link); | |
// loop through matching images | |
for (const image of document.querySelectorAll('.pv-inner img:first-child')) { | |
const path = image.style.backgroundImage.split('"')[1].replace(/-\d.jpg/, '-5.jpg'); | |
// filename of the image | |
link.download = new URL(path).pathname.replace(/^.*\//, ''); | |
// fetch the image, convert it to a data URL, set as the href of the link element |
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 () { | |
let activeVideo; | |
const controls = document.createElement('div'); | |
controls.innerHTML = ` | |
<style> | |
body { | |
overflow: hidden; | |
margin: 0; | |
} | |
.input-rate { |
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
@mixin supports($property-dec) { | |
// find position of colon in property declaration | |
$colon: str-index($property-dec, ':'); | |
// extract the property | |
$property: str-slice($property-dec, 1, $colon - 1); | |
// extract the value | |
$value: str-slice($property-dec, $colon + 1); | |
// trim leading spaces | |
@while (str-slice($value, 1, 1) == ' ') { | |
$value: str-slice($value, 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
# establish an ssh session with the given args and apply all of your local bash aliases | |
# use just like you would ssh to login to a remote shell, e.g. `ssha user@host` | |
function ssha() { | |
ssh -t "$@" 'bash --init-file <(echo '"$(printf %q "$(alias)")"')' | |
} |
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
// make sure all custom emojis are loaded, then run this in the console | |
console.table(Object.entries(jQuery('.p-customize_emoji_list__author').toArray().reduce((accumulator, el) => {var user = el.textContent.trim(); accumulator[user] = accumulator[user] || 0; accumulator[user]++; return accumulator;}, {})).sort((a, b) => b[1] - a[1])); |
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 | |
function X($msg) { | |
$nameLen = 20; | |
$trace = debug_backtrace(); | |
$caller = array_shift($trace); | |
$date = date('c'); | |
list($ms) = explode(' ', microtime()); | |
$line = str_pad($caller['line'], 4, '0', STR_PAD_LEFT); | |
$file = str_pad(substr(basename($caller['file'], '.php'), -$nameLen), $nameLen); |
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
drush updatedb-status 2>&1 > /dev/null | sed 's/\[warning\]//g' | tr '\n' ' ' | sed 's/bootstrap[^ ]* */\n/g' | grep 'module is missing' | sed -E 's/.*: *([^ ]+) */\1/g' | |
# annotated version: | |
drush updatedb-status 2>&1 > /dev/null | # use updatedb-status because it will print an error message for each missing module but not make any changes to the drupal site; 2>&1 > /dev/null keeps only the error output | |
sed 's/\[warning\]//g' | # strip the string "[warning]" from the output | |
tr '\n' ' ' | # convert line breaks to spaces, because the lines get broken in odd spots due to an 80-character line length limit | |
sed 's/bootstrap[^ ]* */\n/g' | # replace the pattern "bootstrap*" with a line break, because each separate warning ends with this string | |
grep 'module is missing' | # filter down to only lines containing the string "module is missing" | |
sed -E 's/.*: *([^ ]+) */\1/g' # strip everything but the word that appears after a colon, which |
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
// example output CSS | |
.container :nth-of-type(5n + 1), .container :nth-of-type(5n + 2), .container :nth-of-type(5n + 3) { | |
background: orange; | |
} | |
.container :nth-of-type(5n + 4), .container :nth-of-type(5n + 5) { | |
background: blue; | |
} |
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 | |
/** | |
* When using the WordPress Importer, update existing | |
* posts instead of skipping them. Updates content according | |
* to the import file even if the existing post was updated | |
* more recently. | |
* | |
* To use, drop this file into your /mu-plugins/ folder or | |
* copy this code into your functions.php file. |
NewerOlder