Skip to content

Instantly share code, notes, and snippets.

View joelhsmith's full-sized avatar

Joel joelhsmith

View GitHub Profile
@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 / 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 / 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.
*
@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 / dedupchoice.js
Created August 3, 2018 18:05
Deduplicate the labels in choice questions in Qualtrics
const labelCheckboxeChoices = Array.from(document.querySelectorAll('.q-checkbox'));
const labelRadioChoices = Array.from(document.querySelectorAll('.q-radio'));
var labelAllChoices = labelCheckboxeChoices.concat(labelRadioChoices);
labelAllChoices.forEach(function(e) {
if (e.innerText === '') {
e.remove();
}
});
@joelhsmith
joelhsmith / gist:62e39463840aa91e7cc632b986f1e432
Created July 24, 2018 17:32
Flexslider initialization that adds aria attributes and improves it's accessibility
$(document).ready(function() {
// NOTE: I suggest using this in addition to my Fork of the Flexslider library:
// https://github.com/jhc36-duke-edu/FlexSlider (This Fork fixes empty link problems that cannot be fixed through the api.)
$('.flexslider').flexslider({
slideshow: false,
prevText: "Previous slide",
nextText: "Next slide",
animation: "fade",
@joelhsmith
joelhsmith / interactive-element-affordance.js
Last active July 13, 2018 19:23
Interactive element manual audit for Lighthouse
/**
* Interactive Element Affordance
*/
'use strict';
import ManualAudit from 'lighthouse-core'
const ManualAudit = require('../node_modules/lighthouse/lighthouse-core/audits/manual/manual-audit');
@joelhsmith
joelhsmith / a11y-simple-contrast-only.js
Created June 27, 2018 15:13
LIghthouse onlyAudits test
/**
* Config file for running just color-contrast.
*/
'use strict';
module.exports = {
extends: 'lighthouse:default',
settings: {
onlyAudits: ['color-contrast'],
@joelhsmith
joelhsmith / basic-a11y-menu.html
Last active June 19, 2018 16:48
basic-a11y-menu
<!DOCTYPE html>
<html lang="en">
<head>
<meta charset="utf-8">
<title>Basic nav</title>
<script src="https://code.jquery.com/jquery-1.12.4.min.js"></script>
<style>
body {
font-size: 30px;
}