Skip to content

Instantly share code, notes, and snippets.

View stephenway's full-sized avatar

Stephen Way stephenway

View GitHub Profile
@stephenway
stephenway / README.md
Last active April 13, 2024 21:45
BEMIT Cheatsheet
@stephenway
stephenway / git-change-author-commit.sh
Created December 19, 2015 04:02
Change last commit author
git commit --amend --author "Stephen Way <way.stephen@gmail.com>" --no-edit && \
git rebase --continue
...
git push origin master --force
@stephenway
stephenway / uniqueValidationMethod.js
Created August 9, 2019 22:22
Unique Method for Yup Validation
/*
* Author: @carlosagsmendes
* Source: https://github.com/jquense/yup/issues/345#issuecomment-487320558
*/
import yup from 'yup';
yup.addMethod(yup.array, 'unique', function (message, mapper = a => a) {
return this.test('unique', message, function (list) {
return list.length === new Set(list.map(mapper)).size;
import { useField } from 'formik'
import React from 'react'
import StringMask from 'string-mask'
import TextField from '@material-ui/core/TextField'
const DELIMITER = '-'
const MASK = '000-000-0000'
function removeTrailingCharIfFound(str: string, char): string {
return str
@stephenway
stephenway / tweetbot.sh
Created January 24, 2013 16:56
Tweetbot Secret Settings
# Tweetbot for Mac Super Secret Settings
# (updated on Oct 31, 2012)
# You will need to use the Terminal app to change these settings:
# these all affect the text in a DM or new tweet - the default is yes for all of them
defaults write com.tapbots.TweetbotMac TextAutomaticQuoteSubstitution -bool NO
defaults write com.tapbots.TweetbotMac TextAutoCorrect -bool NO
defaults write com.tapbots.TweetbotMac TextContinuousSpellChecking -bool NO
@stephenway
stephenway / log.shell
Created January 30, 2020 23:12
TSLint Member Ordering Warning
Warning: member-ordering - Direct string option is deprecated and does not support accessors.
See also https://palantir.github.io/tslint/rules/member-ordering/
You should replace "variables-before-functions"
with the following equivalent options and add -accessor categories as appropriate:
[
{
"name": "field",
"kinds": [
"public-static-field",
"protected-static-field",
@stephenway
stephenway / usePrevious.js
Created December 16, 2019 20:59
React Hook to Expose previous props for use in useEffect hook
import { useRef } from 'react'
const usePrevious = value => {
const ref = useRef()
useEffect(() => {
ref.current = value
})
return ref.current
}
/**
*
* AccountHolder Default Values
*/
import find from 'lodash.find'
import get from 'lodash.get'
import {
AccountHolderMutationVariables, AccountTypeEnum, GetAccountHolderQuery, GetPersonQuery
} from '@types-generated'
@stephenway
stephenway / README.md
Last active September 27, 2019 19:52
WIP: Convert FormikMultiWizard to React.FC & Context

React Compound Components

Source

  • [Original Formik Multistep Wizard Implementation][0]

Reference

  • [Compound React Components with Hooks + TypeScript][1]
  • [Guide to Typescript and Hooks][2]: A bit more basic but relevant