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 const capitalize = (str?: string): string => { | |
if (!str) return ''; | |
return str.charAt(0).toUpperCase() + (str.slice(1).toLowerCase() ?? ''); | |
}; | |
export const humanReadbleSlug = (str: string) => | |
str.split('_').map(capitalize).join(' '); |
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
/** Determines value is not undefined or null. */ | |
export const isValue = <T>(value: T | undefined | null): value is T => | |
(value as T) !== undefined && (value as T) !== null; | |
export function JoinElements(elements: ReactNode[]) { | |
return elements.reduce((prev, curr) => | |
!isValue(curr) ? prev : [prev, ', ', curr] | |
); | |
} |
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
/** | |
* Adopted from: https://gist.github.com/chibicode/fe195d792270910226c928b69a468206?permalink_comment_id=4568681#gistcomment-4568681 | |
*/ | |
import NextImage from 'next/image'; | |
import { memo } from 'react'; | |
function Applemoji({ | |
emoji, | |
width = 72, |
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
/** | |
* Adopted from: https://github.com/Emiyaaaaa/next-routes-list/blob/8a91e25edcf7226b4534f11cfc04b39515162bf1/src/getNextRoutes.ts#L1 | |
*/ | |
import listPaths from 'list-paths'; | |
export function getNextRoutes( | |
src = './app', | |
fileNames = ['page', 'route'], | |
extensions = ['tsx', 'ts', 'js', 'jsx', 'md', 'mdx'] |
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 { AsyncStorage, SyncStorage } from 'jotai/vanilla/utils/atomWithStorage'; | |
type Unsubscribe = () => void; | |
type Subscribe<Value> = ( | |
key: string, | |
callback: (value: Value) => void, | |
initialValue: Value | |
) => Unsubscribe; |
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
/** | |
* Adopted from an internal component of Radix-ui | |
* | |
* @link https://github.com/radix-ui/website/blob/6cf13bab6e56e8814f8e5cac156587c0fefe994d/components/marketing/Carousel.tsx | |
*/ | |
'use client'; | |
import { useCallback, useEffect, useRef, useState } from 'react'; | |
import debounce from 'lodash.debounce'; |
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
/** | |
* adopted from: https://stackoverflow.com/a/77146678/5863267 | |
*/ | |
// directory structure for this code was: | |
// file: /app/(api)/thumb/ellipsis/route.tsx | |
// font file: /assets/fonts/<font> | |
import { readFile } from 'node:fs/promises'; | |
import { join } from 'node:path'; |
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
function doSmthing() { | |
var videoEl = document.querySelector("video"); | |
videoEl.setAttribute("controls", ""); | |
var prevRotate = 0; | |
if (videoEl.style.transform) | |
prevRotate = parseInt(videoEl.style.transform.split("(")[1].slice(0, -4)); | |
document.body.style.cssText = ` | |
rotate: ${prevRotate + 90}deg; |
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
#!/usr/bin/env zx | |
const branch = (await $`git branch --show-current`).stdout.trim(); | |
if (branch === "debug") { | |
const currentVersion = ( | |
await $`awk '/version/{gsub(/("|",)/,"",$2);print $2}' package.json` | |
).stdout.trim(); | |
const date = new Date(); |
NewerOlder