Skip to content

Instantly share code, notes, and snippets.

View joelhsmith's full-sized avatar

Joel joelhsmith

View GitHub Profile
@joelhsmith
joelhsmith / lh-config-a11y-extras.js
Last active November 15, 2023 22:46
Custom Lighthouse config with all a11y audits and a few from Best Practices and SEO that are accessibility related.
/**
* Lighthouse custom config file for running A11y audits in Lighthouse.
* Includes all a11y audits and a few from Best Practices and SEO that are accessibility related.
* Organized into custom 'groups'
*
* Run:
lighthouse https://cats.com --config-path=/path/to/this/file/lh-config-a11y-extras.js --disable-device-emulation --output=json --output-path=catsaudit.json --chrome-flags="--headless --window-size=1300,600"
*
*/
module.exports = {
@joelhsmith
joelhsmith / logify.py
Last active May 20, 2019 20:21
Convert Lighthouse 4 JSON audit file to a common log format and append the results to it each time it runs
import json
import argparse
import io
import sys
def get_args():
example_text = '''
examples:
python3 ./logify.py --input-file='foo.json'
@joelhsmith
joelhsmith / hash-remote-file.py
Last active February 7, 2019 17:25
Creates a hash of a remote file, like a PDF
import os, hashlib, optparse, requests
def get_remote_sha_sum(url):
'''put remote file in memory and create hash'''
response = requests.get(url)
try:
response.raise_for_status()
sha1 = hashlib.sha1()
response = response.content
@joelhsmith
joelhsmith / detect_tagged_pdf.py
Last active April 5, 2024 19:57
Python script to check if a PDF has tags. Result is export of tagged content to console and searches it for traditional acrobat tags
from pdfminer3.pdfinterp import PDFResourceManager, PDFPageInterpreter
from pdfminer3.pdfdevice import TagExtractor
from pdfminer3.pdfpage import PDFPage
from io import BytesIO
def convert_pdf(path, password=''):
rsrcmgr = PDFResourceManager()
retstr = BytesIO()
try:
@joelhsmith
joelhsmith / add_aria_toggle.js
Last active October 16, 2020 18:49
MINIMALLY INVASIVE WCAG 2.1 COMPATIBLE MENU ADD-ON (as an afterthought)
/**
* MINIMALLY INVASIVE WCAG 2.1 COMPATIBLE MENU ADD-ON (as an afterthought).
*
* This example code provides the opportunity for a developer to make a menu that could possibly
* conform to WCAG 2.0 AA https://www.w3.org/WAI/standards-guidelines/wcag/new-in-21/ guidelines,
* if the developer follows and meets all realted WCAG 2.1 AA criteria.
*
* The script is intended to add an independent toggle button with ARIA and keyboard support without interfering with the current menu functionality.
* Compliance would likely require the toggle to be 44px. You can do that optionally in the Plugin's mm_toggle_styles options.
*