Skip to content

Instantly share code, notes, and snippets.

Avatar

Joel joelhsmith

View GitHub Profile
@joelhsmith
joelhsmith / add_aria_toggle.js
Last active Oct 16, 2020
MINIMALLY INVASIVE WCAG 2.1 COMPATIBLE MENU ADD-ON (as an afterthought)
View add_aria_toggle.js
/**
* 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 / detect_tagged_pdf.py
Last active Jun 17, 2019
Python script to check if a PDF has tags. Result is export of tagged content to console and searches it for traditional acrobat tags
View detect_tagged_pdf.py
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 / hash-remote-file.py
Last active Feb 7, 2019
Creates a hash of a remote file, like a PDF
View hash-remote-file.py
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 / logify.py
Last active May 20, 2019
Convert Lighthouse 4 JSON audit file to a common log format and append the results to it each time it runs
View logify.py
import json
import argparse
import io
import sys
def get_args():
example_text = '''
examples:
python3 ./logify.py --input-file='foo.json'
@joelhsmith
joelhsmith / lh-config-a11y-extras.js
Last active Oct 4, 2018
Custom Lighthouse config with all a11y audits and a few from Best Practices and SEO that are accessibility related.
View lh-config-a11y-extras.js
/**
* 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 / dedupchoice.js
Created Aug 3, 2018
Deduplicate the labels in choice questions in Qualtrics
View dedupchoice.js
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 Jul 24, 2018
Flexslider initialization that adds aria attributes and improves it's accessibility
View gist:62e39463840aa91e7cc632b986f1e432
$(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 Jul 13, 2018
Interactive element manual audit for Lighthouse
View interactive-element-affordance.js
/**
* Interactive Element Affordance
*/
'use strict';
import ManualAudit from 'lighthouse-core'
const ManualAudit = require('../node_modules/lighthouse/lighthouse-core/audits/manual/manual-audit');
View a11y-simple-contrast-only.js
/**
* Config file for running just color-contrast.
*/
'use strict';
module.exports = {
extends: 'lighthouse:default',
settings: {
onlyAudits: ['color-contrast'],
View basic-a11y-menu.html
<!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;
}