Skip to content

Instantly share code, notes, and snippets.

View workeffortwaste's full-sized avatar
Staring into the abyss.

Chris Johnson workeffortwaste

Staring into the abyss.
View GitHub Profile
@xdesro
xdesro / .eleventy.js
Created October 27, 2022 19:44
Hint VS Code for eleventyConfig autocompletion.
/**
* @param {import("@11ty/eleventy/src/UserConfig")} eleventyConfig
*/
module.exports = (eleventyConfig) => {
return {};
};
@Orangetronic
Orangetronic / spongecase.js
Last active June 22, 2022 22:09
a crYoTPGRApHicaLly rEVeRsIBle SPoNGebOb-casE alGORiThm
/*
* Cryptographically reversible spongebob-case text transformation
*
* Sometimes you want to encode some text in a way that is not completely
* secret, but is quite hard to read. But what if you need to decode it again?
*
* Now you can!
*
* to De-sponge some text, simply pass the sponged text back through the sponge
* function
@RemcoWessels
RemcoWessels / wordpress-auto-add-alttext-on-upload.php
Last active January 21, 2022 16:41
WordPress function; As it is important for a11y (accessibility) that images got an ALT text this function adds, on upload, the IPTC description from the image to the "Alternative Text" field within WordPress.
/* Automatically set an image Alt-Text on upload */
add_action( 'add_attachment', 'kreks__add_alt_text_from_image_IPTC_on_upload' );
function kreks__add_alt_text_from_image_IPTC_on_upload( $post_ID ) {
// Check if uploaded file is an image, else do nothing
if ( wp_attachment_is_image( $post_ID ) ) {
$postMeta = get_post_meta($post_ID);
$uploads = wp_get_upload_dir();
$imgURL = $uploads['basedir'] . "/" . $postMeta['_wp_attached_file']['0'];
@Myndex
Myndex / WCAG2vsAPCA_someLightReading.md
Last active March 23, 2023 09:59
WCAG 2 vs APCA • A Contrast in Applied Maths

WCAG 2 vs APCA Contrast Shootout

A Response to Comments Regarding APCA vs WCAG2/1.4.3

We have on occasion heard the comment "APCA produces less contrast" — this is not true, though I see how some might come to that conclusion, it does not consider the totality of the new guidelines.

APCA does not produce contrast. APCA does nothing to the colors, it only predicts how a human will perceive them, and their effect on readability. And yes, if you try to compare APCA to the WCAG2 math it might appear that APCA allows lower contrast in some specific cases where one color is white or very bright, but across the entire range, APCA clearly, consistently, and correctly predicts contrast, while WCAG2 more often than not allows lower contrasts to pass that have even been shown to be unreadable, even with normal vision.

Here's an example a user brought to my attention recently:

@webtoffee-git
webtoffee-git / functions.php
Last active February 5, 2024 16:40
Google consent mode compatibility - CookieYes | GDPR Cookie Consent Premium (https://www.webtoffee.com/product/gdpr-cookie-consent/)
<?php // do not copy this line
add_action('wp_head', 'wt_cli_consent_mode_integration',9);
function wt_cli_consent_mode_integration() {
if (!class_exists('Cookie_Law_Info'))
return;
$cli_bypass = isset($_GET['cli_bypass']) ? 1 : 0;
?>
<script>
var wt_cli_ad_storage = 'denied';
//set default value "denied" or "granted"
@fedegomez
fedegomez / checkTitles.js
Last active May 24, 2023 03:38
Checks if the title of the result in the SERP matches the title of the URL
javascript: (function (doc){var changed=0; function checkTitles(){console.log('jQuery version ', $.fn.jquery, ' loaded'); var position=1; var items=[]; var results=$('#rso .kp-blk .g, #rso .g[class="g"], #rso .srg .g').not('.kno-kp .g').find('div:first').find('a:first'); $('.title-changed, #CountTitlesChanged').remove(); results.each(function (){if (!$(this).parents('.related-question-pair').length){var parent=$(this).closest('.tF2Cxc').length > 0 ? $(this).closest('.tF2Cxc') : $(this).closest('li'); items.push([ position, $(this).find('h3').text(), encodeURI($(this).attr('href')), parent]); position++;}}); var numItems=1; cors_proxies=[ 'https://api.codetabs.com/v1/proxy?quest=', 'https://jsonp.afeld.me/?url=',]; items.forEach(item=>{$.ajax({url: cors_proxies[Math.floor(Math.random() * cors_proxies.length)] + item[2], success: function (data, status, xhr){title=$(data).filter('title').text(); var html='<div class="title-changed">'; if (title !=item[1]){html +='<span style="font-weight: bold;color: #ff6961;">
@Alexs7zzh
Alexs7zzh / .eleventy.js
Created April 24, 2021 04:44
eleventy-img in markdown
const Image = require('@11ty/eleventy-img')
const { parseHTML } = require('linkedom')
module.exports = eleventyConfig => {
if (process.env.ELEVENTY_ENV)
eleventyConfig.addTransform('transform', (content, outputPath) => {
if (outputPath && outputPath.endsWith('.html')) {
let { document } = parseHTML(content)
@ebidel
ebidel / findall_elements_deep.js
Last active August 9, 2021 20:05
Finds all elements on the page, including those within shadow dom.
/**
* @author ebidel@ (Eric Bidelman)
* License Apache-2.0
*/
/**
* Finds all elements on the page, inclusive of those within shadow roots.
* @param {string=} selector Simple selector to filter the elements by. e.g. 'a', 'div.main'
* @return {!Array<string>} List of anchor hrefs.
*/
@amboutwe
amboutwe / yoast_seo_canonical_change_woocom_shop.php
Last active April 11, 2024 02:02
Code snippets for the Yoast SEO canonical output
<?php
/********* DO NOT COPY THE PARTS ABOVE THIS LINE *********/
/* Change the canonical link for the shop page
* Credit: Scott Weiss of somethumb.com
* Yoast Doc: https://developer.yoast.com/features/seo-tags/canonical-urls/api/
* Last Tested: Jan 25 2017 using Yoast SEO 6.0 on WordPress 4.9.1
*/
add_filter( 'wpseo_canonical', 'yoast_seo_canonical_change_woocom_shop', 10, 1 );
@cookrn
cookrn / links.md
Created March 20, 2012 19:51
How to Create and Apply a Patch w/ Git Across Similar Repositories