Skip to content

Instantly share code, notes, and snippets.

@ptrin
ptrin / example.js
Created May 13, 2020 13:15
Adjust scroll position on focus (if necessary)
const oldHTMLFocus = HTMLElement.prototype.focus;
HTMLElement.prototype.focus = function () {
oldHTMLFocus.apply(this, arguments);
setTimeout(function() {
const currentScrollPos = window.scrollY || window.scrollTop;
const offset = $(this).offset().top;
// if difference between currentScrollPos and offset from top of document is less than x, adjust
const difference = Math.abs(currentScrollPos - offset);
if (difference < 100) {
window.scrollTo(0, currentScrollPos - 100);
@ptrin
ptrin / 0-add-id-to-error-div.jsx
Last active November 13, 2019 17:38
Formik a11y examples
<ErrorMessage name="firstName">
{msg => (
<div id="firstName-error" className="invalid-feedback">
{msg}
</div>
)}
</ErrorMessage>
@ptrin
ptrin / consulting-opportunity.md
Created July 14, 2019 03:06
Fable Consulting Opportunity

Consulting opportunity:

At Fable, we’ve built an online platform that connects researchers, designers, and developers to people with disabilities, with the goal of making it easier to create accessible digital products.

We have upcoming projects that involve conducting accessibility research remotely, through moderated and unmoderated research, on various digital products. We are looking for someone who can manage a project, conduct the research, and lead the writing of reports. We don’t have exact dates of the projects yet, but anticipate some starting in August and completing before November. Further clarification on dates is expected soon.

What you’ll do:

  • Learn about the client’s digital products and production workflow to identify and establish user journeys for testing, a configuration matrix, and reporting structure
  • Use Fable’s platform to
#!/usr/bin/env python
import csv
import os
import re
import sys
print "Input file of pages to assess: "+sys.argv[1]
def slug(str):
"""Replace non-alphanumeric characters with hyphen"""

Import and backup

  • Monthly dumps from phones, sometimes camera to ~/Pictures on laptop
  • Every time the external HD is mounted, the backup.sh script runs to sync the ~/Pictures directory to the backup dir on the external - sometimes when I'm paranoid I run it manually and check to be sure it's working correctly
#!/bin/bash
if [ -d "/Volumes/My Book" ]; then
    rsync -a /Users/perry/Pictures /Volumes/My\ Book/_backup;
    rsync -a /Users/perry/Library/Application\ Support/Google/Picasa3 /Volumes/My\ Book/_backup/Picasa\ Metadata;
fi 
@ptrin
ptrin / scrape.rb
Last active August 29, 2015 14:13
Small script to scrape plane data and download images from Canadian Warplane Heritage Museum website
require "fileutils"
require "httparty"
require "json"
require "nokogiri"
require "open-uri"
DOMAIN = "http://www.warplane.com/"
# strip domain from URL
def strip_domain(url)
var jsonTemplates = {
"test": '{' + "\n" +
' "property": "value"' + "\n" +
'}'
};
var bodyParser = require('body-parser'),
express = require('express'),
http = require('http'),
sio = require('socket.io');
var app = express();
var server = http.createServer(app);
app.use(
bodyParser.json(),
express.static(__dirname+'/test-ui')
Plugin 'SirVer/ultisnips'
Plugin 'aalvarado/ultisnips-snippets'
Plugin 'rstacruz/vim-ultisnips-css'
def get_file_list(dir=options.source_dir):
""" Returns list of all html files in specified directory (recursive) """
fileList = []
print dir
try:
for root, subFolders, files in os.walk(dir):
for file in files:
filepath = os.path.join(root,file)
if ".html" in filepath: