Skip to content

Instantly share code, notes, and snippets.

Brandon R. Howard brayhoward

Block or report user

Report or block brayhoward

Hide content and notifications from this user.

Learn more about blocking users

Contact Support about this user’s behavior.

Learn more about reporting abuse

Report abuse
View GitHub Profile
brayhoward / getLast.ts
Created Mar 1, 2020
Example of using Typescript keyof operator
View getLast.ts
interface RecursiveArray<T> extends Array<T | RecursiveArray<T>> {}
function getLast<O extends object, K extends keyof O>(
mapOrList: O | RecursiveArray<O>,
key: K
): O[K] | null {
if (!mapOrList) return null;
if (Array.isArray(mapOrList)) {
return getLast(mapOrList.reverse().find(m => !!getLast(m, key))!, key);
brayhoward / useAttentionWithin.ts
Created Jun 27, 2019
A React hook for determining whether or not a section of DOM still has the users attention. It's like clickAway logic on steroids
View useAttentionWithin.ts
import { useState, useEffect, RefObject } from "react";
export default function useAttentionWithin(ref: RefObject<HTMLElement>) {
const [attentionWithin, setAttentionWithin] = useState(false);
function handleAttentionLeave({ target }: Event) {
const targetIsWithin = !!(
ref.current && ref.current.contains(target as Node)
brayhoward /
Created Jun 5, 2018 — forked from squarism/
iterm2 cheatsheet

Tabs and Windows

Function Shortcut
Fullscreen + Enter
Previous Tab + Left Arrow
Next Tab + Right Arrow
Go to Tab + Number
Go to Window + Option + Number
Go to Split Pane by Direction + Option + Arrow
brayhoward /
Created Feb 26, 2018 — forked from nrollr/
Install MySQL on Sierra using Homebrew

Install MySQL on macOS Sierra

This procedure explains how to install MySQL using Homebrew on macOS Sierra 10.12

Install Homebrew

  • Installing Homebrew is effortless, open Terminal and enter :
    $ /usr/bin/ruby -e "$(curl -fsSL"
  • Note: Homebrew will download and install Command Line Tools for Xcode 8.0 as part of the installation process.

Install MySQL

At this time of writing, Homebrew has MySQL version 5.7.15 as default formulae in its main repository :

brayhoward / time_convert.ex
Created Jan 17, 2018
Elixir time conversion module for converting milliseconds or seconds to a readable format.
View time_convert.ex
defmodule TimeConvert do
@minute 60
@hour @minute*60
@day @hour*24
@week @day*7
@divisor [@week, @day, @hour, @minute, 1]
def to_str(time) do
to_str(time, :ms)
brayhoward /
Created Jan 17, 2018 — forked from codeinthehole/
Script to install stuff I want on a new OSX machine
#!/usr/bin/env bash
# Bootstrap script for setting up a new OSX machine
# This should be idempotent so it can be run multiple times.
# Some apps don't have a cask and so still need to be installed by hand. These
# include:
# - Twitter (app store)
brayhoward /
Last active Oct 21, 2019
Directions for converting Audible audiobook files, .aax, to .m4a files
brayhoward /
Created Sep 18, 2017 — forked from rafmagana/
This is a way to call the Heroku command-line utility adding the name of the Heroku App automatically.

Heroku command-line wrapper with app name

This is a kind of second version of, but in this version you don't need to call projectName_production or projecName_staging only production or staging.

How to make it work

If you have git remotes called production, staging and development already, then then the only thing you have to do is to source in your .bash_profile or .bashrc:

source /path/to/
brayhoward / mixin-fluid-typography.scss
Created Sep 11, 2017 — forked from italodr/mixin-fluid-typography.scss
A mixin for Mike Riethmuller fluid typography
View mixin-fluid-typography.scss
@mixin fluid-type($min-font-size, $max-font-size, $min-vw: 480px, $max-vw: 1200px) {
$u1: unit($min-vw);
$u2: unit($max-vw);
$u3: unit($min-font-size);
$u4: unit($max-font-size);
@if $u1 == $u2 and $u1 == $u3 and $u1 == $u4 {
font-size: $min-font-size;
@if $min-vw != $max-vw {
brayhoward / tts.js
Created Aug 4, 2017 — forked from dotproto/tts.js
ES2015 Text to Speech bookmarklet (Ctrl+S). Set up: Copy and paste the contents of this gist into a new bookmark. Use: Select some text and click the bookmarklet to start speaking. Once activated on a page, you can use Ctrl+S to speak the selected text. Speech Synthesis API Info:…
View tts.js
javascript: {
/* Adjust voice speed. Default = 1 */
var speed = 2.5;
if (window.runTTS === undefined) {
/* Text to Speech function. Adjust the value of msg.rate to increase/decrease the playback speed. */
window.runTTS = () => {
const text = window.getSelection().toString();
You can’t perform that action at this time.