Skip to content

Instantly share code, notes, and snippets.

Avatar

Brandon R. Howard brayhoward

View GitHub Profile
@brayhoward
brayhoward / convert_aax_files.md
Last active Nov 10, 2020
Directions for converting Audible audiobook files, .aax, to .m4a files
View convert_aax_files.md
@brayhoward
brayhoward / getStatusBarHeight.ts
Last active Aug 19, 2020
A react hook for getting status bar height in ReactNative that works with iOS and android. This accounts for hotspot and GPS banners
View getStatusBarHeight.ts
import { useState, useEffect } from "react";
import { NativeModules, StatusBarIOS, Platform, StatusBar } from "react-native";
import get from "lodash/get";
const { StatusBarManager } = NativeModules;
export default function useStatusBarHeight() {
// Initialize w/ currentHeight b/c StatusBar.currentHeight works properly on android on Android
const [height, setHeight] = useState(StatusBar.currentHeight || 0);
@brayhoward
brayhoward / globals.d.ts
Last active Aug 14, 2020
Typescript utility types. Mostly more descriptive aliases for the any type
View globals.d.ts
type IFixMe = any;
type IToDo = any;
type IInexpressible = any;
type INotWorthIt = any;
type IFuckIt = any;
// When the library you are consuming is fucked up
type IBadTypings = any;
type IAnyFields = { [field: string]: any };
type IWithAnyFields<T> = T & IAnyFields;
@brayhoward
brayhoward / Correct_GnuPG_Permission.sh
Created Jul 28, 2020 — forked from oseme-techguy/Correct_GnuPG_Permission.sh
This fixes the " gpg: WARNING: unsafe permissions on homedir '/home/path/to/user/.gnupg' " error while using Gnupg .
View Correct_GnuPG_Permission.sh
#!/usr/bin/env bash
# To fix the " gpg: WARNING: unsafe permissions on homedir '/home/path/to/user/.gnupg' " error
# Make sure that the .gnupg directory and its contents is accessibile by your user.
chown -R $(whoami) ~/.gnupg/
# Also correct the permissions and access rights on the directory
chmod 600 ~/.gnupg/*
chmod 700 ~/.gnupg
@brayhoward
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
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
brayhoward / iterm2.md
Created Jun 5, 2018 — forked from squarism/iterm2.md
iterm2 cheatsheet
View iterm2.md

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
brayhoward / MySQL_macOS_Sierra.md
Created Feb 26, 2018 — forked from nrollr/MySQL_macOS_Sierra.md
Install MySQL on Sierra using Homebrew
View MySQL_macOS_Sierra.md

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 https://raw.githubusercontent.com/Homebrew/install/master/install)"
  • 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
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)
end
@brayhoward
brayhoward / osx_bootstrap.sh
Created Jan 17, 2018 — forked from codeinthehole/osx_bootstrap.sh
Script to install stuff I want on a new OSX machine
View osx_bootstrap.sh
#!/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)
You can’t perform that action at this time.