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
// adjust refreshing value in time for more pleasant loading indicator animation | |
// it is true if it was awlays true in the last 0.3 seconds | |
// it stays true for at least 1.0 second | |
function useAdjustedRefreshingValue(isRefreshing: boolean): boolean { | |
const DO_NOT_SHOW_BEFORE_MILLIS = 300; | |
const SHOW_FOR_AT_LEAST_MILLIS = 1000; | |
const [adjustedIsRefreshing, setAdjustedIsRefreshing] = | |
React.useState(isRefreshing); | |
const [isRefrescingSince, setIsRefreshingSince] = React.useState(0); | |
React.useEffect(() => { |
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
data DependentState : Type -> Type -> Type -> Type where | |
MakeDependentState : (s' -> (s'', r)) -> DependentState s' s'' r | |
ret : r -> DependentState s s r | |
ret r = MakeDependentState $ \s => (s, r) | |
get : DependentState s s s | |
get = MakeDependentState $ \s => (s, s) | |
set : s'' -> DependentState s' s'' () |
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
data Heap : Nat -> (Nat -> Type) -> Type where | |
Lin : Heap Z a | |
(:<) : Heap l a -> a l -> Heap (S l) a | |
data Tree : Nat -> Type where | |
Leaf : String -> Tree n | |
Branch : Fin n -> Fin n -> Tree n | |
u1 : Heap 4 Tree | |
u1 = [< |
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
interface Idempotent (action : stateType -> stateType) where | |
law : (state : stateType) -> let u = action state in action u = u | |
IncFrom : Nat -> Nat -> Nat | |
IncFrom original state = case decEq state original of | |
Yes _ => S state | |
No _ => state | |
{o : Nat} -> Idempotent (IncFrom o) where | |
law s with (decEq s o) |
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
module Parser | |
import Data.Nat | |
import Data.List | |
%default total | |
-- interface Codec input output where | |
-- encode : input -> output | |
-- decode : output -> Maybe input |
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
export type Outcome<Value, Report> = { type: "valid"; value: Value } | { type: "invalid"; reports: Array<Report> }; | |
export type ValidatorSyncBase<Value, Report> = { | |
validateSync(value: unknown): Outcome<Value, Report>; | |
}; | |
export function makeValidatorSync<const Value, const Report>(validatorSyncBase: ValidatorSyncBase<Value, Report>) { | |
return { | |
...validatorSyncBase, | |
refine: refine(validatorSyncBase), |
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
apply plugin: 'maven-publish' | |
/* | |
* Fix NodeJS version | |
*/ | |
node.nodeVersion="20.11.1" | |
node.npmVersion="10.2.4" | |
/* | |
* Fix for artifact deploy |
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
- check with browser plugin "wave" and "axe" also chrome lighthouse accesibility | |
open chrome inspect element and see the accesibility tree | |
- generally copy accessibility from mui.com components | |
- banner role (first <header> in page) should contain title, logo, optionally nav | |
- contentinfo role (first <footer> in page) | |
- <main/> (ensure there is only one so that user can skip over heading and sides to most important content) | |
- <aside/> |
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 React from "react"; | |
export function useGeolocation({ | |
isEnabled, | |
positionOptions: { enableHighAccuracy, maximumAge, timeout }, | |
startTransition, | |
}: { | |
isEnabled: boolean; | |
positionOptions: PositionOptions; | |
startTransition?(update: () => void): void; |
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
/** | |
* React hook to measure an element before rendering it | |
* given some jsx it renders it in a hidden div then measures its size | |
* the hook returns width and height and portal | |
* @important the portal must be in the page to be able to render the hidden div for measurements | |
* @warning the jsx will be renred probably twice, once for measurement, and where you actually use it | |
*/ | |
export function useDomSize(children: JSX.Element) { | |
const [width, setWidth] = React.useState(0); | |
const [height, setHeight] = React.useState(0); |
NewerOlder