Skip to content

Instantly share code, notes, and snippets.

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

Yann YannBirba

⚛️
React ♥️
View GitHub Profile
@eusonlito
eusonlito / 01-README.md
Last active January 12, 2026 12:53
SQLite optimization for Laravel

The SQLite optimizations must be carried out at two different times: once in a unique and permanent way for the database and another time for each connection that is made. Below are the configurations that should be made in each case.

Unique and Permanent Configurations

These configurations are set only once and affect the database persistently, meaning they do not need to be reconfigured each time a connection is established:

PRAGMA journal_mode = WAL;

Sets the database journal mode to "WAL" (Write-Ahead Logging), which improves performance in concurrent operations.

@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,
},
},
});
@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"
}
@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 });
@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;
@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 March 3, 2026 11:28
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 => {