Skip to content

Instantly share code, notes, and snippets.

View YannBirba's full-sized avatar
⚛️
React ♥️

Yann YannBirba

⚛️
React ♥️
View GitHub Profile
@MRezaSafari
MRezaSafari / enforce-element-jsx-rule.js
Created August 29, 2023 11:04
Enforce allowed child types for custom components
module.exports = {
meta: {
type: "suggestion",
docs: {
description: "Enforce allowed child types for custom components",
category: "Best Practices",
recommended: true,
},
},
create(context) {
@AlemTuzlak
AlemTuzlak / gist:89ee03a57c97cb820d6c30d7cd88b341
Created August 10, 2023 09:31
Type inference with zod and remix-hook-form
import type { ZodType, z } from "zod";
import { zodResolver } from "@hookform/resolvers/zod";
import { getValidatedFormData as getValidatedFormDataPrimitive, useRemixForm as useForm, UseRemixFormOptions } from "remix-hook-form";
interface UseRemixFormZodOptions<T extends ZodType, U extends FromZodType<T>> extends UseRemixFormOptions<U> {
schema: T;
}
export type FromZodType<T extends ZodType> = z.infer<T>;
@kadiks
kadiks / cmd.js
Created July 5, 2023 11:49
Basic CLI
#!/usr/bin/env node
const { mkdirSync, writeFileSync } = require('node:fs');
const params = process.argv.slice(2);
if (params.length === 0) {
console.log('No arguments provided');
process.exit(1);
}
@artistro08
artistro08 / README.MD
Last active April 27, 2025 23:39
How to setup a LEMP Development Environment with WSL2 & Valet Linux
// Turn all HTML <a> elements into client side router links, no special framework-specific <Link> component necessary!
// Example using the Next.js App Router.
import { useRouter } from 'next/navigation';
import { useEffect } from 'react';
function useLinkHandler() {
let router = useRouter();
useEffect(() => {
let onClick = e => {
@VanTanev
VanTanev / README.md
Created May 2, 2023 13:01
A github workflow to track progress of convertion JavaScript to TypeScript.

A github workflow to track the progress of converting JavaScript to TypeScript.

Last year, we migrated a large project form JS to TS. We did this with ts-migrate, and we renamed all instances of any to $TSFixMe, to differentiate them from real uses of any.

Tracking the convertion over time

In order to see our progress on removing $TSFixMe, we build the a github workflow that adds comments to PRs with our progress, eg:

image

@fabiospampinato
fabiospampinato / fast_css_reset.css
Last active July 18, 2023 18:07
The fastest CSS reset possible
:where(abbr), :where(address), :where(area), :where(article), :where(aside), :where(audio), :where(b), :where(base), :where(bdi), :where(bdo), :where(big), :where(blockquote), :where(body), :where(br), :where(caption), :where(cite), :where(code), :where(col), :where(colgroup), :where(data), :where(datalist), :where(dd), :where(del), :where(details), :where(dfn), :where(dialog), :where(dl), :where(dt), :where(em), :where(embed), :where(fieldset), :where(figcaption), :where(figure), :where(footer), :where(form), :where(h1), :where(h2), :where(h3), :where(h4), :where(h5), :where(h6), :where(head), :where(header), :where(hgroup), :where(hr), :where(i), :where(input), :where(ins), :where(kbd), :where(keygen), :where(label), :where(legend), :where(li), :where(link), :where(main), :where(map), :where(mark), :where(menu), :where(menuitem), :where(meta), :where(meter), :where(nav), :where(object), :where(ol), :where(optgroup), :where(option), :where(output), :where(param), :where(picture), :where(pre), :where(progress
@smontlouis
smontlouis / react-query-lite.tsx
Last active November 22, 2023 17:37
React Query Lite
import React from 'react'
import { usePrevious } from './usePrevious'
export type QueryStatus = 'idle' | 'loading' | 'error' | 'success'
type QueryClientProviderProps = {
children: React.ReactNode
client: QueryClient
}
@OnurGvnc
OnurGvnc / clearBrowserExtensionInjectionsBeforeHydration.ts
Last active September 24, 2024 09:20
removes injected HTML codes from browser extensions for react hydration
import { RemixBrowser } from '@remix-run/react'
import { startTransition, StrictMode } from 'react'
import { hydrateRoot } from 'react-dom/client'
function clearBrowserExtensionInjectionsBeforeHydration() {
document
.querySelectorAll(
[
'html > *:not(body, head)',
'script[src*="extension://"]',
// TODO: make `pages` optional and measure the div when unspecified, this will
// allow more normal document flow and make it easier to do both mobile and
// desktop.
import {
createContext,
useCallback,
useContext,
useEffect,
useMemo,
useRef,