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 { useEffect, useRef } from 'react'; | |
// Source: https://overreacted.io/making-setinterval-declarative-with-react-hooks/ | |
export function useInterval(callback: () => void, delay: number | null): void { | |
const savedCallback = useRef<() => void>(); | |
// Remember the latest callback. | |
useEffect(() => { | |
savedCallback.current = callback; | |
}, [callback]); |
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
services: | |
hapi-fhir: | |
image: 'hapiproject/hapi:latest' | |
ports: | |
- 8080:8080 | |
environment: | |
SPRING_DATASOURCE_URL: jdbc:sqlserver://sql-server:1433;databaseName=hapi;trustServerCertificate=true | |
SPRING_DATASOURCE_USERNAME: sa | |
SPRING_DATASOURCE_PASSWORD: YourStrong@Passw0rd | |
SPRING_DATASOURCE_DRIVERCLASSNAME: com.microsoft.sqlserver.jdbc.SQLServerDriver |
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
// Source: https://stackoverflow.com/a/54178819 | |
export type PartialBy<T, K extends keyof T> = Omit<T, K> & Partial<Pick<T, K>>; |
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
public class FakeUserManager : UserManager<ApplicationUser> | |
{ | |
public FakeUserManager() | |
: base(new Mock<IUserRoleStore<ApplicationUser>>().Object, | |
new Mock<IOptions<IdentityOptions>>().Object, | |
new Mock<IPasswordHasher<ApplicationUser>>().Object, | |
new IUserValidator<ApplicationUser>[0], | |
new IPasswordValidator<ApplicationUser>[0], | |
new Mock<ILookupNormalizer>().Object, | |
new Mock<IdentityErrorDescriber>().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 resolveSynchronously = async (promises) => { | |
return promises.reduce(async (prevPromise, nextPromise) => { | |
await prevPromise; | |
return nextPromise(); | |
}, Promise.resolve()); | |
}; | |
const promise = () => | |
new Promise((resolve) => { | |
setTimeout(() => { |
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 order = useQuery(['order']); // Use this in OrderPanel | |
const getOrder = useQuery(['order'], () => fetchOrderById(todoId)); // Use this in OrderGetForm | |
const createOrder = useMutation((orderCreateDto) => createOrder(orderCreateDto), { | |
onSuccess: (orderDto) => { | |
queryClient.setQueryData(['order], orderDto); | |
} | |
}); | |
// Etc |
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 { createContext, Dispatch, SetStateAction } from 'react'; | |
export interface CatFact { | |
fact: string; | |
length: number; | |
} | |
export const CatFactContext = createContext<[CatFact | undefined, Dispatch<SetStateAction<CatFact | undefined>>]>([ | |
undefined, | |
(): void => undefined, |
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 { ActionsObservable, ofType } from 'redux-observable'; | |
import { Observable, of } from 'rxjs'; | |
import { AjaxError } from 'rxjs/ajax'; | |
import { catchError, map, switchMap } from 'rxjs/operators'; | |
import { searchSeries } from '../../utils/api/tvmaze'; | |
import { SeriesSearch } from '../../utils/api/tvmaze.types'; | |
import { GlobalState } from './index'; | |
// Actions |
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 { | |
ActionsObservable, | |
combineEpics, | |
Epic, | |
ofType, | |
StateObservable, | |
} from 'redux-observable'; | |
import { from, iif, Observable, of, zip } from 'rxjs'; | |
import { AjaxError } from 'rxjs/ajax'; | |
import { |
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 { | |
ActionsObservable, | |
combineEpics, | |
Epic, | |
ofType, | |
} from 'redux-observable'; | |
import { Observable, of } from 'rxjs'; | |
import { AjaxError } from 'rxjs/ajax'; | |
import { catchError, map, mergeMap, switchMap } from 'rxjs/operators'; |
NewerOlder