hey :)
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 getTypeofValue = (value: any) => typeof value; | |
export type TypeofReturnType = ReturnType<typeof getTypeofValue>; | |
// prettier-ignore | |
export type TypeFromTypeString<TypeString extends TypeofReturnType> = | |
TypeString extends "string" ? string : | |
TypeString extends "number" ? number : | |
TypeString extends "bigint" ? BigInt : | |
TypeString extends "boolean" ? boolean : | |
TypeString extends "symbol" ? symbol : |
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 type UseRasterizedImageUrlParameters = [imageUrl: string, width: number, height?: number]; | |
export interface UseRasterizedImageUrlCache { | |
promise: Promise<void>; | |
inputs: UseRasterizedImageUrlParameters; | |
error?: unknown; | |
rasterizedImageUrl?: string; | |
} | |
const caches: UseRasterizedImageUrlCache[] = []; |
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 { useCallback, useState } from "react"; | |
export const useForceUpdate = () => { | |
const [, dispatch] = useState(Object.create(null)); | |
return useCallback(() => dispatch(Object.create(null)), [dispatch]); | |
}; |
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 { useEffect, useRef } from 'react' | |
export interface ScrollEvents<Event extends any> { | |
scrollStart?: (event: Event) => void | |
scrollStop?: (event: Event) => void | |
scroll?: (event: Event) => void | |
} | |
export const useScrollEvents = <Event extends any = React.UIEvent>( | |
scrollEvents: ScrollEvents<Event>, |
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 { useEffect, useRef } from 'react' | |
type Callback = () => void | |
export const useInterval = (callback: Callback, delay: number | null = null) => { | |
const savedCallback = useRef<Callback>() | |
useEffect(() => { | |
savedCallback.current = callback | |
}, [callback]) |
Epitech's API is located at https://intra.epitech.eu/
and for the most part is any intranet page with the format=json
param added.
To access most endpoints a PHPSESSID
cookie must be set to an authenticated session. Authentification can be done with an autologin code or via Office 365 oauth.
API endpoints and what they require and do. JSON file of endpoints below the documentation.
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
// ⚠ IMPORTANT: this is old and doesn't work for many different edge cases but I'll keep it as-is for any of you want it | |
// ⚠ IMPORTANT: you can find more robust versions in the comments or use a library implementation such as lodash's `merge` | |
// Merge a `source` object to a `target` recursively | |
const merge = (target, source) => { | |
// Iterate through `source` properties and if an `Object` set property to merge of `target` and `source` properties | |
for (const key of Object.keys(source)) { | |
if (source[key] instanceof Object) Object.assign(source[key], merge(target[key], source[key])) | |
} |