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 { IObjectWithKey, Selection, SelectionMode } from '@fluentui/react'; | |
import { useEffect, useRef } from 'react'; | |
/** Options interface for the `useControlledFluentSelection` hook. */ | |
export interface ControlledSelectionOptions<T> { | |
/** The currently selected items. */ | |
selectedItems: T[]; | |
/** Optional selection mode. */ | |
selectionMode?: SelectionMode; | |
/** Event handler called when the selected items change. */ |
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 { useState, Children, ReactElement, ReactNode } from "react"; | |
export function App() { | |
return ( | |
<Tabs> | |
<Tab name="Division">Division content!</Tab> | |
<Tab name="Wild card">Wild card content!</Tab> | |
<Tab name="Conference">Conference content!</Tab> | |
<Tab name="League">League content!</Tab> | |
</Tabs> |
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
// AudioControlsProvider.tsx | |
import { createContext, useState, ReactNode, useContext } from 'react'; | |
// This is the interface of our context object, i.e. this is the interface of | |
// stuff that normal components will have access to | |
export interface AudioControls { | |
isAudioPlaying: boolean; | |
pauseAudio: () => void; | |
} |
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
// useInitializeTrackPlayer.ts | |
function useInitializeTrackPlayer() { | |
const [isInitialized, setIsInitialized] = useState(false); | |
useEffect(() => { | |
async function initializeTrackPlayer() { | |
await TrackPlayer.setupPlayer(); | |
TrackPlayer.setOptions(...); // maybe await this? Not sure if it's async | |
setIsInitialized(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
type ErrorFirstCallback<D> = (error: any, data: D) => void; | |
type FunctionThatAcceptsCallback<A extends any[], D> = ( | |
...args: [...A, ErrorFirstCallback<D>] | |
) => void; | |
type FunctionThatReturnsPromise<A extends any[], D> = (...args: A) => Promise<D> | |
function promisify<A extends any[], D>( | |
originalFunction: FunctionThatAcceptsCallback<A, D> |
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 { Dispatch, SetStateAction, useEffect, useState } from "react"; | |
interface VisibilityTrackerResult { | |
/** Ref callback, give this to the element to be observed */ | |
ref: Dispatch<SetStateAction<HTMLElement | null>>; | |
/** Whether or not the observed element is currently visible */ | |
isVisible: boolean; | |
} |
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
export interface TemperatureUnitToggleProps { | |
selectedUnit: TemperatureUnit; | |
onChange: (temperatureUnit: TemperatureUnit) => void; | |
} | |
/** | |
* A toggle component to swap between Celsius and Fahrenheit | |
*/ | |
export const TemperatureUnitToggle: FunctionComponent<TemperatureUnitToggleProps> = ({ selectedUnit, onChange }) => { | |
const isCelsiusSelected = selectedUnit === TemperatureUnit.Celsius; |
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
alias gpob='git push -u origin $(getCurrentGitBranch)' | |
getCurrentGitBranch() { | |
local branch=$(git rev-parse --abbrev-ref HEAD) | |
echo $branch; | |
} |
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 random | |
import time | |
# This is the decorator - it's essentially a function that takes in a function | |
# as a parameter and returns a modified version of it | |
def retry(func, max_attempts=4, initial_delay=1): | |
def wrapper(*args, **kwargs): | |
delay = initial_delay | |
attempt = 1 | |
while True: |
NewerOlder