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 createSpan = (text) => { | |
const node = document.createElement("span"); | |
node.textContent = text; | |
return node; | |
}; | |
const insertBetweenElementWhitespace = (elements) => | |
elements.reduce((acc, span) => acc.concat(span, " "), []).slice(0, -1); | |
const spanifyText = text => { |
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 RecursiveKeyOf< | |
TObj, | |
TPrefix extends string = '' | |
> = TObj extends Record<string, any> | |
? { | |
[K in keyof TObj & string]: | |
| `${TPrefix}${K}` | |
| RecursiveKeyOf<TObj[K], `${TPrefix}${K}.`>; | |
}[keyof TObj & string] | |
: never; |
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 Obj = Record<any, any>; | |
export const isArray = Array.isArray; | |
export const isObject = (val: unknown): val is Obj => { | |
return val !== null && typeof val === 'object'; | |
}; | |
export type StrapiAttributesObject = { | |
attributes: any; |
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 } from 'react'; | |
export default function RealViewport() { | |
useEffect(() => { | |
function onWindowResize() { | |
const vh = window.innerHeight * 0.01; | |
document.documentElement.style.setProperty('--vh', `${vh}px`); | |
} | |
window.addEventListener('resize', onWindowResize, false); |
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' | |
const IS_SERVER = typeof window === 'undefined' | |
export const useIsomorphicLayoutEffect = IS_SERVER | |
? React.useEffect | |
: React.useLayoutEffect |
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
precision highp float; | |
uniform float u_alpha; | |
uniform sampler2D t_map; | |
varying vec2 v_uv; | |
float fn_border_radius(vec2 position, vec2 half_size, float corner_radius) { | |
position = abs(position) - half_size + corner_radius; | |
return length(max(position, 0.)) + min(max(position.x, position.y), 0.) - corner_radius; |
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 debounceToNextFrame = <F extends (...args: any[]) => void>( | |
fn: F, | |
): ((...funcArgs: Parameters<F>) => void) & { | |
cancel: () => void; | |
} => { | |
let frameReference: number; | |
const cancel = (): void => { | |
cancelAnimationFrame(frameReference); | |
}; |
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 fs = require('node:fs') | |
const path = require('node:path') | |
const BUFFER_ENCODING = 'utf8' | |
const getFilePath = (filename) => path.resolve(__dirname, filename) | |
const format = (filename) => { | |
return fs | |
.readFileSync(getFilePath(filename), BUFFER_ENCODING) |
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 ROBUST_TEST_SET = [ | |
[2047n, [2n]], | |
[1373653n, [2n, 3n]], | |
[9080191n, [31n, 73n]], | |
[25326001n, [2n, 3n, 5n]], | |
[3215031751n, [2n, 3n, 5n, 7n]], | |
[4759123141n, [2n, 7n, 61n]], | |
[1122004669633n, [2n, 13n, 23n, 1662803n]], | |
[2152302898747n, [2n, 3n, 5n, 7n, 11n]], | |
[3474749660383n, [2n, 3n, 5n, 7n, 11n, 13n]], |
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
#!/bin/bash | |
# This script allows switching between different PHP versions on macOS using Homebrew. | |
# Version 1.0.0 | |
# Copyright (c) Grégoire Ciles | |
# Usage: ./switch-php.sh <version_number> (e.g., ./switch-php.sh 8.1) | |
function error() { | |
echo "Error: $1" | |
exit 1 |
OlderNewer