This file contains 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
curl \ 20:19:16 | |
-H "Accept: application/vnd.github.v3+json" \ | |
# replace :token below with your personal access token | |
-H "Authorization: token :token" \ | |
-H "Content-Length: 0" \ | |
-X PUT \ | |
# replace ORGNAME with your organization name and USERNAME your username | |
https://api.github.com/orgs/ORGNAME/public_members/USERNAME |
This file contains 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 quickSort = (arr, low = 0, high = arr.length - 1) => { | |
if (low < high) { | |
const p = partition(arr, low, high) | |
quickSort(arr, low, p) | |
quickSort(arr, p + 1, high) | |
} | |
} | |
const partition = (arr, low, high) => { | |
const pivot = arr[Math.floor((high + low) / 2)] | |
let i = low |
This file contains 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 IO = effect => | |
({ | |
effect, | |
run() { | |
return this.effect() | |
}, | |
map(fn) { | |
if (!fn ?? typeof fn !== 'function') { | |
throw new Error('.map requires a function argument.') | |
} |
This file contains 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
{ | |
"semi": false, | |
"embeddedLanguageFormatting": "off", | |
"bracketSpacing": false, | |
"jsxBracketSameLine": true, | |
"proseWrap": "never", | |
"trailingComma": "all", | |
"singleQuote": true | |
} |
This file contains 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 [name, setName] = React.useState( | |
someExpensiveComputation(props); // run on every render | |
) | |
const [state, setState] = useState(() => { | |
const initialState = someExpensiveComputation(props); // only run on the initial render | |
return initialState; | |
}); |
This file contains 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 React from "react"; | |
const useStateReducer = (prevState, dispatchArg) => | |
typeof dispatchArg === "function" ? dispatchArg(prevState) : dispatchArg; | |
const useStateInitializer = (initialArg) => | |
typeof initialArg === "function" ? initialArg() : initialArg; | |
function useState(initialValue) { | |
return React.useReducer(useStateReducer, initialValue, useStateInitializer); |
This file contains 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
// Prop Collections and Getters | |
// merge all passed functions into one | |
const mergeFn = | |
(...fns) => | |
(...args) => | |
fns.forEach(fn => fn?.(...args)) | |
function useToggle() { | |
const [on, setOn] = React.useState(false) |
This file contains 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 getFirstItem<Type>(list: Type[]): Type { | |
return list[0] | |
} | |
const item = getFirstItem([1]) | |
const item2 = getFirstItem(['']) | |
const item3 = getFirstItem([new Object()]) | |
type Tree<Type> = { | |
value: Type |
This file contains 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
// Compound Components w/ `React.Children.map` & `React.cloneElement` | |
import * as React from 'react' | |
import {Switch} from '../switch' | |
function Toggle({children}) { | |
const [on, setOn] = React.useState(false) | |
const toggle = () => setOn(!on) | |
return React.Children.map(children, child => | |
// tell if a child is a built-in DOM component | |
typeof child.type === 'string' |
This file contains 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
interface Fruit { | |
readonly name?: string | |
readonly color?: string | |
readonly sweetness?: number | |
} | |
type Properties<Type> = keyof Type | |
type Values<Type> = Type[Properties<Type>] | |
type FruitProperties = Properties<Fruit> |
OlderNewer