Skip to content

Instantly share code, notes, and snippets.

View gnowland's full-sized avatar
💭
Let's design a world that's thoughtful, considered, and aesthetically pleasing.

Gifford Nowland gnowland

💭
Let's design a world that's thoughtful, considered, and aesthetically pleasing.
View GitHub Profile
@gnowland
gnowland / install-homebrew-locally.rb
Last active December 22, 2023 06:31 — forked from devinrhode2/install.rb
Homebrew without sudo-Aub's fork with a few minor changes from kenchan's fork
#!/System/Library/Frameworks/Ruby.framework/Versions/Current/usr/bin/ruby
# chmod +x install.rb
# ./install.rb
YOUR_HOME = ENV['HOME']
HOMEBREW_PREFIX = "#{YOUR_HOME}/usr/local"
system "mkdir -p #{HOMEBREW_PREFIX}"
HOMEBREW_CACHE = "#{YOUR_HOME}/Library/Caches/Homebrew"
HOMEBREW_REPO = 'https://github.com/Homebrew/brew'
@gnowland
gnowland / reduce-aka-collate.ts
Last active July 20, 2023 00:44
elegantly reduce objects (aka collator/collate)
// Elegantly reduce array of objects into an object labeled by the value of a specific property
// Source: https://vmarchesin.medium.com/using-array-prototype-reduce-in-objects-using-javascript-dfcdae538fc8
interface Person {
name: string;
year: number;
sign: "Aries" | "Taurus" | "Gemini" | "Cancer" | "Leo" | "Virgo" | "Libra" | "Scorpio" | "Sagittarius" | "Capricorn" | "Aquarius" | "Pisces";
}
const people: Person[] = [
useEffect(() => {
isLoading = true;
getData(someParam).then(data => {
if (isLoading) {
setState(data))
}
})
return() => { isLoading = false }
}, [someParam]); // fetch only happens if param (like url) changes. Don't use objects.
type FetchSecure = (
...args: [...[keycloak: KeycloakInstance], ...Parameters<typeof fetch>]
) => ReturnType<typeof fetch>;
For example, this takes the parameters from the http fetch api and assigns them to my new type with my response type override:
```
type Fetch = (...args: [...Parameters<typeof fetch>]) => Promise<any>;
// result: (input: RequestInfo | URL, init?: RequestInit | undefined) => Promise<any>
@gnowland
gnowland / OverrideTSDeclaration.tsx
Last active June 28, 2022 10:32
Override TypeScript type declarations from imported modules
// Credit:
// https://stackoverflow.com/questions/43952198/how-to-override-or-extend-a-libary-type-definition-in-typescript
// https://stackoverflow.com/questions/40322788/how-to-overwrite-incorrect-typescript-type-definition-installed-via-types-packa
import {
MUIDataTable,
TableToolbarSelect,
} from 'mui-datatables';
// ⭐️ This is where the magic happens:
for COMMIT in $(git log --format=format:%H master..HEAD | tail -1) ; do
git log $COMMIT^1 --oneline | head -1
done
@gnowland
gnowland / venmo csv excel description generator.vb
Created April 16, 2022 07:49
Venmo CSV description generator excel function
=IF(EXACT([@Type],"Standard Transfer"),"To "&[@Column2],IF([@[Amount (total)]]>0,"From "&IF(EXACT([@Type],"Charge"),[@To],[@From]),"To "&IF(EXACT([@Type],"Charge"),[@From],[@To]))&" for "&CHAR(34)&[@Note]&CHAR(34))
@gnowland
gnowland / bump.sh
Last active March 25, 2022 12:11
interactive semver target script
#!/bin/bash
# Portions of this script are Copyright (C) 2017 Ingo Hollmann - All Rights Reserved
# Permission to copy and modify is granted under the Creative Commons Attribution 4.0 license
# https://www.bughunter2k.de/blog/cursor-controlled-selectmenu-in-bash
# Last revised 2020-11-12 by Gifford Nolwland <hi@giffordnowland.com>
# Call this file as so: `./select.sh "${ARRAY[@]}"`
# per https://stackoverflow.com/a/36808100/2764290
ESC=$(printf "\e")

Promises must be handled appropriately or explicitly marked as ignored with the void operator.eslint@typescript-eslint/no-floating-promises

That's a crappy error message. A better one might be,

every expression of type Promise must end with a call to .catch or a call to .then with a rejection handler (source).

So, for example, if you do

@gnowland
gnowland / bump.sh
Last active November 13, 2021 00:06
Use interactive menu to pass SemVer target to npm-version command
#!/bin/bash
# Portions of this script are Copyright (C) 2017 Ingo Hollmann - All Rights Reserved
# Permission to copy and modify is granted under the Creative Commons Attribution 4.0 license
# https://www.bughunter2k.de/blog/cursor-controlled-selectmenu-in-bash
# Last revised 2020-11-12 by Gifford Nolwland [https://giffordnowland.com]
ESC=$(printf "\e")
curr=0
declare -a target=("patch" "minor" "major") # mac does not support associative arrays