This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
function randomBetween(min, max) { | |
return Math.floor(Math.random() * (max - min + 1) + min) | |
} |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
:focus:not(:focus-visible) { | |
outline: none; | |
} |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
#/usr/bin/env bash | |
changed="$(git diff-tree -r --name-only --no-commit-id ORIG_HEAD HEAD)" | |
check() { | |
echo "$changed" | grep --quiet "$1" && eval "$2" | |
} | |
check package.json "npm install" |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
// import { UserInputError } from 'apollo-server' | |
import { IResolvers } from "graphql-tools"; | |
import merge from "lodash.merge"; | |
const ChargesRootResolvers: IResolvers = { | |
// Stripe returns either just a string as the charge id or an expanded object with all charge attributes. | |
// So we check if it's expanded by if the charge is an instanceof Object or a string | |
ChargeUnion: { | |
__resolveType(charge: string | { [key: string]: any }) { | |
if (charge instanceof Object) { |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
const data = { | |
name: "Ted Bundy", | |
email: "[email protected]", | |
address: { | |
line1: "9412 39th Street East", | |
line2: "Suite 456", | |
country: "", | |
city: "", | |
} | |
}; |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
// 8 characters minium. 1 uppercase character, 1 lowercase character, 1 number, 1 special character | |
const strongRegex = /^(?=.*[a-z])(?=.*[A-Z])(?=.*[0-9])(?=.*[!@#\$%\^&\*])(?=.{8,})/; | |
// 6 characters minium. 1 uppercase character, 1 lowercase character, 1 number | |
const mediumRegex = /^(((?=.*[a-z])(?=.*[A-Z]))|((?=.*[a-z])(?=.*[0-9]))|((?=.*[A-Z])(?=.*[0-9])))(?=.{6,})/ |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
import { useState, useEffect } from "react"; | |
import { useLocation } from "react-router-dom"; | |
export const useNestedMatch = (test, type = "") => { | |
const { pathname } = useLocation(); | |
const [match, setMatch] = useState(false); | |
useEffect(() => { | |
let result; | |
switch (type) { |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
function nestedMatch(test: string, type: string = "", path: string = location.pathname): boolean { | |
switch(type) { | |
case 'startsWith': | |
return path.match(new RegExp(`^\/${test}`))?.length ? true : false | |
case 'endsWith': | |
return path.match(new RegExp(`/${test}$`))?.length ? true : false | |
default: | |
return path.match(new RegExp(`${test}`))?.length ? true : false | |
} | |
} |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
// V5 | |
<Router> | |
<Switch> | |
<Route path="/one" component={ViewOne} /> | |
<Route path="/two" component={ViewTwo} /> | |
<Route path="/three" component={ViewThree} /> | |
<Route render={() => <Redirect to="/one" />} /> | |
</Switch> | |
</Router> |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
const items = [ | |
{type: 'phone', name: 'iPhone', color: 'gold'}, | |
{type: 'laptop', name: 'Chromebook', color: 'gray'}, | |
]; | |
const excludes = [ | |
{k: 'color', v: 'gold'}, | |
{k: 'color', v: 'silver'}, | |
{k: 'type', v: 'tv'} | |
]; |
NewerOlder