Welcome to the lab.

Web Excursions for May 25, 2016

[Tweet : ADN : nvALT]

Hazel Field Guide — MacSparky
MacSparky (David Sparks) has released a new Video Field Guide focusing on Hazel, an amazing tool for automating file management. Currently $19.99, and worth every penny, even if you already think you know what Hazel can do.
Pay What You Want: Spring 2016 Mac Bundle
The Pay What You Want: Spring 2016 Mac Bundle has been extended for an extra week. 13 great apps, including Marked, at a price you get to choose.
Gutenberg — A Meaningful Web Typography Starter Kit
A “web typography starter kit.” Sets up vertical rhythm, base type sizes, and other important considerations in a flexible way using a Sass framework.
Simple Grid - Lightweight CSS grid for web development
If you’ve panned larger CSS frameworks in the past due to bloat, this one offers just the grid features for responsive design.
nylas/N1: An extensible desktop mail app built on the modern web.
There have been a few new options popping up for email clients on the Mac. I’m still sticking with MailMate (for very nerdy reasons), but AirMail 3 is looking great. This one is open source and easily extensible, so I’m pretty curious to dig in and see what it can do.
misterGF/echo: convert HTML tables into JSON/CSV objects
A Node.js tool for converting HTML tables into JSON/CSV objects. I’m hoping to incorporate this into Marky to get better table conversions.
Apple Music Affiliate Program FAQ – Affiliate Resources
If you’re an iTunes partner, take note of the new url queries specifically for Apple Music links.

Shell Tricks: halp – a universal help tool

[Tweet : ADN : nvALT]

I have a lot of aliases and functions in my terminal, in addition to the plethora of UNIX commands. If I’m not sure what the source of a command is, getting info on it can require multiple tries. First a man check, then a type or alias command to see if it’s custom, then a man -k to see if I misspelled something, and so on. I eventually decided to just write an automated way to sift through those possibilities.

The function below will simply check if the command exists, then flip through “file,” “function,” and “alias” to see what kind it is, displaying the man page, typing out the function, or showing the alias depending on the result. It really just combines the man and type functionality into one command.

The only switch is -k, which will show the results of man -k if no matching command is found.

# A little helper for man/alias/function info
halp() {
	local YELLOW="\033[0;33m" DEFAULT="\033[0;39m"
	local apro=0 helpstring="Usage: halp COMMAND"

	while getopts "kh" opt; do
		case $opt in
			k) apro=1 ;;
			h) echo -e $helpstring; return;;
			*) return 1;;
	shift $((OPTIND-1))

	if [ $# -ne 1 ]; then
		echo -e $helpstring
		return 1

	local helpresult cmd=$1
	local cmdtest=$(type -t ${cmd})

	if [ -z "$cmdtest" ]; then
		echo -e "${YELLOW}Not a command$DEFAULT"
		if [[ $apro == 1 ]]; then
			man -k $cmd
			return 1

	if [[ $cmdtest == "file" ]]; then
		man $cmd
	elif [[ $cmdtest == "alias" ]]; then
		echo -ne "$YELLOW$cmd is an alias:  $DEFAULT"
		alias ${cmd}|sed -E "s/alias $cmd='(.*)'/\1/"
	elif [[ $cmdtest == "function" ]]; then
		echo -e "$YELLOW$cmd is a function:  $DEFAULT"
		type $cmd | tail -n +2

I have this running with a modified version of bash-completion that scopes in the halp command for tab-completing command names. Easy hack, so I won’t elaborate on that.

My where? tool is also a handy companion to this if you have enough custom scripts and sourced files to make it useful.

Associate: Amazon affiliate linking for iOS

[Tweet : ADN : nvALT]

Associate, a new app from the creator of Blink, makes generating affiliate links for Amazon products on iOS a breeze. Blink is a tool for searching and creating iTunes affiliate links, and Associate takes all of the things learned from making Blink and applies them to Amazon.

If you’re not familiar with it, the Amazon Associate program allows you to make a little bit of money when sharing links to Amazon products. It doesn’t cost the people who click your link anything, and can be a good side source of revenue if you’re sharing a lot of links with a large enough audience.

Associate can search for products and generate concise urls with your Amazon Associate tag, ready to share. You can do it within the app and copy a plain or Markdown link, or use it from the share sheet with any selected text in whatever app you’re working in.

Associate’s extension also adds the ability to generate affiliate links from within Amazon’s own app, or anywhere you want to copy an Amazon link. With a single tap, you can convert an existing Amazon link to one that you can make a bit of money on.

Writers who use Markdown can also benefit from multiple Markdown link formats, with the option to add product names as link titles. Associate works with Split View on iPads, too, so you can access it easily while writing in your favorite editor.

You can check out Associate on the iTunes App Store. It’s currently $4.99 US, and as soon as Apple approves the bundle, you’ll be able to get it along with Blink at a 20% discount.

Web Excursions for May 11, 2016

[Tweet : ADN : nvALT]

Almost complete guide to flexbox (without flexbox)
A cheatsheet for replicating flexbox (CSS) functionality with backwards-compatible methods.
Another documentation system based on Markdown files. I love the built-in realtime search that’s automatically generated. My home brew system for Marked 2 documentation does a lot of this, but I may be switching over to a more polished system like this soon.
This collaborative wiki for teams is really nice. Simple in form and function, but with tools that make creating and maintaining a knowledge base easier (including some Markdown support within the rich text editor). Currently released as a free preview, pricing packages to be announced after full release.

I had a chat with the creators of Nuclino about the goals of this project. I think the roadmap sounds excellent and am looking forward to doing a more in-depth review as new features come together.


Flow is a static type checker for JavaScript. It can be used to catch common bugs in JavaScript programs before they run, including: silent type conversions, null dereferences, and the dreaded undefined is not a function.

Gemini 2
The latest version of Gemini is incredibly smart about locating and removing duplicate files on your Mac’s hard drive. John Voorhees has a full review over at MacStories.
A service that can turn any website into a JSON API using CSS selectors.
osnr/Screenotate: Automatically annotate your screenshots.
A Swift-based utility that captures a screenshot of a region and automatically detects and saves the surrounding context (app, window title, web url), plus OCRs the text in the screenshot for searching. Grab a compiled download from the Releases page.

Easy retina image serving with Apache rewrites

[Tweet : ADN : nvALT]

Today I thought I’d share a trick for offering retina (@2x) images on a blog where you don’t always have high-res images available.

The trick uses Apache rewrites and allows every image filename to be inserted in the HTML with “@2x” appended, falling back to the base filename if that file doesn’t exist. I also occasionally customize an additional format for social sharing, appending “_lg” instead of “@2x”, and the rules cascade such that if “_lg” doesn’t exist, it looks for “@2x”, and barring that, just uses the base filename.

My custom Jekyll image plugin adds the “@2x” automatically, so my tags include only the base name of the image. If I’m able to provide a high-res version, I just give it the exact same name, with “@2x” at the end, e.g. image1.png and image1@2x.png (and optionally image1_lg.png).

Here are the Apache rules from my .htaccess file:

# Image handling for opengraph meta
# Try @2x if _lg doesn't exist
RewriteCond %{REQUEST_FILENAME} !-f
RewriteRule (.*)_lg\.(jpg|png|gif) $1@2x.$2 [L]

# Fall back to base image file if no @2x
RewriteCond %{REQUEST_FILENAME} !-f
RewriteRule (.*)@2x\.(jpg|png|gif) $1.$2 [L]

To make life even easier, I have a Dropzone target that I can drop one or more images onto, and it will detect multiple versions (base, @2x, _lg) and output a single Jekyll (Liquid) tag for the set. (If you’re interested in that, let me know.)

My Jekyll image plugin also uses sips to automatically provide width and height attributes based on the lowest resolution image in the HTML output, ensuring that the image is displayed properly at different screen resolutions.

It’s a simple system, and possibly inefficient as it has to check for the existence of every image file during the load stage, but my tests don’t indicate any noticeable latency in the process. I can’t guarantee that would scale to more image-heavy sites, but it makes life easy for me on this blog.

Exercise and ADHD

[Tweet : ADN : nvALT]

I’ve been exercising a lot lately. As my issues with getting the meds I need have started to seem hopeless, I began using long walks to clear my mind. It helped. I lost 10 pounds and started being able to get about 60 solid minutes of work clocked per day, which is a huge step up from a few months of being able to handle about 30 minutes (elapsed) and not enough time to actually complete anything.

I started with hiking. First a mile at a time, then two, then extending beyond the point where at least one of my dogs could keep up1. The farther I walked, the more work I could do afterward. I have the good fortune of living within walking distance of an amazing trail system in the bluffs of Southeast Minnesota. I can walk out my door and be at a trailhead in 2 minutes. I’ve gotten to know about 8 miles of single track quite well, and have plenty more to explore.

Then I was talking to my friend Luc Beaudoin (creator of MySleepButton, one of the most effective sleep aids I’ve found), and he mentioned that the key is “vigorous” exercise. So I started incorporating short sprints into my hikes. Part of what I love about hiking is observing the forests and plains around me, and trail running absolutely requires keeping your eyes on the trail in front of you (or else ankle sprain), so I only ran for the “boring” sections of trails. A few minutes of sprinting combined with 30-60 minutes of walking was still enough to break me into a full sweat and maintain a high pulse rate, and it turned out he was right. Just walking isn’t enough to help with things like ADHD.

Then I started doing Yoga. I have a good friend who teaches a class at a local wellness center, so I decided to try it. It was good for me. I felt great afterward, and the class setting worked well for keeping me going. I decided to try out some other classes, and went to a Forrest Yoga class. It was an hour and fifteen minutes of soaking my yoga mat with sweat.

After the first Forrest class, I went to a friend’s poetry reading. I was sitting there when all of the sudden my brain started working. Thoughts, ideas, and plans all started flowing the way they used to. It lasted a couple of hours. I’ve been able to replicate it since then, but it takes about an hour of exercise to get two hours of work, so it’s not a perfect solution. I have, however, lost almost 20 pounds now and am feeling better physically than I have since I was 25 (which was 12 years ago).

Yoga wasn’t easy for me to get started with. I don’t like games I can’t win, and doing a flexibility-and-core-strength workout as a fat, out-of-shape guy was awkward. My instructors were very helpful and supportive, and my classmates were all—if not 100% encouraging—absolutely not judgmental. Having pretty girls around you is great encouragement to focus and try not to look like an idiot, and having better-looking guys around brings out some kind of primal competition in me that makes me push myself further than I would just working out on my own. It’s going well.

I’ve completed the ADHD testing that was asked of me by the psychiatrist I’ve parted ways with, and it confirms an ADHD Inattentive Type diagnosis (again). I don’t know yet if that will translate to me getting back on the meds I need, but it’s a good start, and these months of desperation have led to some lifestyle changes that I absolutely needed. It will all work out in the end. It always does…

  1. Our German Shepherd can actually do 4+ miles fine with pep in his step, unless he gets SQUIRREL… and ends up running twice as far. Our middle-aged pit bull with synthetic knees, though, can only go about two miles before I have to carry her home.