Skip to content

Instantly share code, notes, and snippets.

@fstorr
fstorr / useful-terminal-commands.md
Last active September 24, 2018 17:16
Various terminal commands for dealing with OS stuff

Version of macOS

$ sw_vers

System logs

  1. cd /Library/Logs/DiagnosticReports
  2. `grep -ir ".panic" *
  3. Note: can also use Console app → System Reports

Last shutdown code

log show --predicate 'eventMessage contains "Previous shutdown cause"' --last 24h

@fstorr
fstorr / bookmarklet-for-breaking-images-to-check-for-visible-alt-text.md
Last active October 25, 2017 04:41
JavaScript bookmarklet that breaks images so you can check to see if there is visible alt text.

Bookmarklet For Breaking Images To Check For Visible Alt Text

I was carrying out an accessibility evaluation of a site and, by chance, none of the images loaded. I noticed that the images' alt attributes but they weren't showing.

It turned out that the developer had put font-size:0 on the containing <figure> element and then specified a new font-size on the <figcaption> element. I don't know why either.

As current accessibility testing tools don't currently test for this (which isn't suprising as it is something of an edge case), I wrote a bookmarklet to break all the images created with an element so that their alt text (if any) would show.

The bookmarklet works by replacing each image's URL with a new one.

@fstorr
fstorr / code-of-shame.md
Last active September 24, 2018 20:47
HTML standards. If only there was such a reference document for developers to use…

Code I have seen and wish I hadn't

Removing the bullets from an unordered list and typing in numbers to create an ordered list

<ul style="list-style:none;">
  <li>1. Something</li>
  <li>2. Something</li>
  <li>3. Something</li>
</ul>
@fstorr
fstorr / how-to-get-speech-output-as-text-from-screen-readers.md
Last active May 12, 2025 12:43
How to get speech output as text from screen readers

How to get speech output as text from screen readers

Sometimes you need text, rather than voice, output from screen readers. Why? It's really useful for bug reports ("this disclosure icon is announced as 'black dash triangle dash filled dash x2 underscore final dot png' and needs alt text"). Luckily, getting this text is easy to do.

VoiceOver on MacOS

In VoiceOver you press Option + Control + Shift + C to have the last item that was announced copied to the clipboard. Bonus feature: pressing Option + Control + Shift + Z to save the last phrase to the desktop as an audio file.

VoiceOver on iOS

A three-finger quadruple tap copies the last announcement to the clipboard.

@fstorr
fstorr / word-cloud-prep
Created May 1, 2015 17:18
word cloud prep
1. Split each word onto it's on line (use text editor until bash command can be found)
2. Strip out things like speech marks, brackets, full stops, commas, slashes, dashes, etc
3. `awk '{print tolower($0)}' filename | sort > outputfilename`
@fstorr
fstorr / helpful-git-commands
Last active August 29, 2015 14:07
Helpful git commands
# Useful Git commands
## Config Options
git config --global user.name "First Last"
git config --global user.email "emailaddress"
git config user.email "emailaddress" : sets email address for a repo instead of globally
git config user.email : shows which email address it is using in the repo you're currently in
git config --global core.editor emacs : should you want to specifiy an editor for interactive commands See [associating text editors with Git](https://help.github.com/articles/associating-text-editors-with-git/) for more options
git config --global merge.tool opendiff : specify a merge tool (OSX only)
@fstorr
fstorr / Dynamically set the width of a select element based on its contents
Last active August 29, 2015 13:57
Occasionally there's a need to create a fancy-looking dropdown menu that involves showing and hiding all manner of things. This seems to mean the select element doesn't expand to the width of its content. This function loops through the option tags, finds the amount of letters in the longest one, grabs the document's font size, multiples those v…
function sizeSelects(){
var fs = window.getComputedStyle(document.querySelector("body"),null).getPropertyValue("font-size").slice(0,-2);
var selects = document.querySelectorAll("select");
for (var select = 0; select < selects.length; select++){
var opts = selects[select].querySelectorAll("option");
var len = 0;
var longest = 0;
@fstorr
fstorr / load jQuery remotely and fallback
Created November 13, 2013 18:18
Load jQuery from Google with a local fallback
<script src="http://ajax.googleapis.com/ajax/libs/jquery/2.0.3/jquery.min.js"></script>
<script>window.jQuery || document.write("<script src='URL'>\x3C/script>")</script>
@fstorr
fstorr / HTML5 download attribute
Last active December 16, 2015 21:09
Setting the HTML5 download attribute in capable browser. This assumes support for document.querySelector.
<!doctype html>
<html lang="en">
<head>
<meta charset="UTF-8">
<title>HTML download attribute</title>
</head>
<body>
<ul>
<li><a href="downloadable-file.txt">View your invoice</a></li>
<li class="download"><a href="downloadable-file.txt">Right-click and select Save to download your invoice</a></li>
@fstorr
fstorr / SASS px to em and em to px
Created April 17, 2013 18:22
SASS functions for px to em and em to px
$eminpx:14;
@function pxtoem($target, $context:$eminpx){
@return #{$target/$context}em;
}
@function emtopx($target, $context:$eminpx){
@return #{$target*$context}px;
}