Skip to content

Instantly share code, notes, and snippets.

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

Yann YannBirba

⚛️
React ♥️
View GitHub Profile
@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

// 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 => {
@artistro08
artistro08 / README.MD
Last active April 27, 2025 23:39
How to setup a LEMP Development Environment with WSL2 & Valet Linux
@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);
}
@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>;
@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) {
@dilaouid
dilaouid / bbcode.js
Created September 5, 2023 16:14
regex for global XSS protection and bbCode check
const bbCodeMatch = /\[(b|i|u|s)\](.*?)\[\/\1\]/gs;
const XSSMatch = /[<]*<[\s\u200B]*script[\s\u200B]*>.*[/]*[<]*<[\s\u200B]*\/[\s\u200B]*script[\s\u200B]*>/ig;
@pingrishabh
pingrishabh / useOptimisticUpdate.js
Created September 24, 2023 08:36
Simple hook to perform optimistic updates with react-query
import { useCallback } from "react";
import { useQueryClient } from "@tanstack/react-query";
export default function useOptimisticUpdate() {
const queryClient = useQueryClient();
return useCallback(
async (queryKey, updater) => {
await queryClient.cancelQueries({ queryKey });
@srsholmes
srsholmes / grecent.sh
Created November 23, 2023 15:58
Recent git branches
function grecent() {
local branches branch
branches=$(git branch --sort=-committerdate --format='%(HEAD) %(color:yellow)%(refname:short)%(color:reset) - %(contents:subject) %(color:green)(%(committerdate:relative)) [%(authorname)]') \
&& branch=$(echo "$branches" | fzf --ansi) \
&& branch=$(echo "$branch" | awk '{print $1}' | tr -d '*') \
&& git checkout "$branch"
}
@AlemTuzlak
AlemTuzlak / gist:9ecd385e7e3b57ba80c36914123800e8
Created March 2, 2024 11:12
react-query adapter for remix
import { QueryClient } from "@tanstack/react-query";
import { CacheAdapter, createCacheAdapter } from "remix-client-cache";
export const queryClient = new QueryClient({
defaultOptions: {
queries: {
staleTime: 1000 * 60 * 5,
},
},
});