Skip to content

Instantly share code, notes, and snippets.

View ycmjason's full-sized avatar
😆

YCM Jason ycmjason

😆
View GitHub Profile
@ycmjason
ycmjason / Icon.tsx
Created February 11, 2025 21:59
expo-icon FontAwesome 5 / 6 type safe icon component
import type { createIconSet } from '@expo/vector-icons';
import Untyped_FontAwesome6 from '@expo/vector-icons/FontAwesome6';
import type { FA6Style } from '@expo/vector-icons/build/FontAwesome6';
import type { ComponentProps, ReactNode } from 'react';
type FA6Variant = keyof typeof FA6Style;
type IconComponent = ReturnType<typeof createIconSet<string, string>>;
const FontAwesome6: IconComponent = Untyped_FontAwesome6;
export const Icon = ({
@ycmjason
ycmjason / PartialLoadingBar.tsx
Last active October 27, 2024 13:29
Deno Fresh Partial Fetch Events
import { useSignal } from "@preact/signals";
import { useEffect } from "preact/hooks";
export const PartialLoadingBar = () => {
const loadState = useSignal<"loading" | "loaded" | "not-loading">(
"not-loading",
);
useEffect(() => {
const onBeforePartialFetch = () => {
loadState.value = "loading";
type KeysOfUnion<T> = T extends T ? keyof T : never;
export type ExclusiveUnion<T> = KeysOfUnion<T> extends
infer K extends PropertyKey
? T extends infer A ? A & Partial<Record<Exclude<K, keyof A>, never>>
: never
: never;
@ycmjason
ycmjason / README.md
Created July 6, 2024 11:30
async queue with async generator

with this async generator queue, you could make sure the tasks given are run with at a maximum concurrency

@ycmjason
ycmjason / rerenderable.kt
Created April 27, 2024 23:55
A composable that allow particular block to be rerendered manually
@Composable
fun <T> rerenderable(
beforeRerender: () -> Unit = {},
block: @Composable (rerender: () -> Unit) -> T,
): () -> Unit {
var id by remember { mutableStateOf(0) }
val rerender = {
beforeRerender()
id += 1
}
@ycmjason
ycmjason / LazyListScope.itemsWithDivider.kt
Created April 20, 2024 22:41
List item with divider
package app.fishball.taskshuffle.ui.components.contextless
import androidx.compose.foundation.lazy.LazyItemScope
import androidx.compose.foundation.lazy.LazyListScope
import androidx.compose.foundation.lazy.itemsIndexed
import androidx.compose.runtime.Composable
inline fun <T> LazyListScope.itemsWithDivider(
items: List<T>,
noinline divider: (@Composable LazyItemScope.(left: T, right: T) -> Unit),
@ycmjason
ycmjason / .prettierrc.json
Created October 26, 2023 09:54
Best Prettier Config In The World
{
"printWidth": 100,
"semi": true,
"singleQuote": true,
"trailingComma": "all",
"arrowParens": "avoid"
}
@ycmjason
ycmjason / timeline.md
Last active February 17, 2025 07:18
Life in the UK Test - UK History Timeline
Time Events
50 million years ago The Giant’s Causeway was formed. Located on the north-east coast of Northern Ireland, the Giant’s Causeway is a land formation of columns made from volcanic lava.
@ycmjason
ycmjason / README.md
Created April 16, 2023 08:42
Reasons to hate safari as a frontend developer / Why Safari is the new IE

Reasons to hate safari as a frontend developer / Why Safari is the new IE

This is an on-going list of things that I constantly find missing in Safari, (and possibly ways to work around them)

RegExp Positive/Negative Lookbehind

I cannot believe my eyes when positive/negative lookbehind is still not available on safari. Here is how you can work around it:

Instead of

@ycmjason
ycmjason / example-usage.ts
Created April 11, 2023 06:36
A fancy way to type your react router config
const routes = [
{
path: '/',
element: <App />,
errorElement: <CircularProgress />,
children: [
{
index: true,
element: <LandingPage />,
},