Skip to content

Instantly share code, notes, and snippets.

View saulin18's full-sized avatar
🏠
Working from home

Saúl Sondón saulin18

🏠
Working from home
View GitHub Profile
@saulin18
saulin18 / Slider.tsx
Created August 4, 2025 02:50 — forked from leonardof02/Slider.tsx
React Native Custom Input Slider
import React, { useEffect, useState } from "react";
import Animated, {
useSharedValue,
useAnimatedStyle,
runOnJS,
} from "react-native-reanimated";
import Ionicons from "@expo/vector-icons/Ionicons";
@saulin18
saulin18 / Validations.ts
Created August 4, 2025 02:52 — forked from leonardof02/Validations.ts
Best practices validation in React
export interface ValidationError extends Error {
errors: string[];
}
// Example: Password validator
export function validatePassword(password: string) {
const sixMinimumChars = /^.{6,}$/;
const atLeastOneLowercase = /^(?=.*[a-z]).*$/;
const atLeastOneUppercase = /^(?=.*[A-Z]).*$/;
const atLeastOneDigit = /^(?=.*\d).*$/;
@saulin18
saulin18 / drizzle-zod-helpers.ts
Created August 4, 2025 02:54 — forked from nandorojo/drizzle-zod-helpers.ts
Drizzle Zod Inserts & Selects from Schema Generator
import * as schema from './schema' // make this point to your schema file
import { PgEnum, PgTableWithColumns } from 'drizzle-orm/pg-core'
import { createInsertSchema, createSelectSchema } from 'drizzle-zod'
import { z } from 'zod'
type ExtractPgTableKeys<T> = {
[K in keyof T]: T[K] extends PgTableWithColumns<any> ? K : never
}[keyof T]
export const selects = Object.fromEntries(
@saulin18
saulin18 / create-context.tsx
Created August 4, 2025 02:56 — forked from nandorojo/create-context.tsx
A much better createContext, usable before React 19, with good TypeScript Types
import { createContext as create, useContext } from 'react'
export function createContext<T>(initial?: T) {
const ctx = create<T>(initial ?? (null as any))
return Object.assign(
function Provider(props: React.ComponentProps<typeof ctx.Provider>) {
return <ctx.Provider {...props} />
},
ctx,
@saulin18
saulin18 / 00-README-NEXT-SPA.md
Created August 4, 2025 03:02 — forked from gaearon/00-README-NEXT-SPA.md
Next.js SPA example with dynamic client-only routing and static hosting

Next.js client-only SPA example

Made this example to show how to use Next.js router for a 100% SPA (no JS server) app.

You use Next.js router like normally, but don't define getStaticProps and such. Instead you do client-only fetching with swr, react-query, or similar methods.

You can generate HTML fallback for the page if there's something meaningful to show before you "know" the params. (Remember, HTML is static, so it can't respond to dynamic query. But it can be different per route.)

Don't like Next? Here's how to do the same in Gatsby.

@saulin18
saulin18 / ExampleTable.tsx
Created August 31, 2025 01:21 — forked from leonardof02/ExampleTable.tsx
Generic Table used in Merco Sistema at NOX Creation
// This is an example table using the GenericTableComponent.tsx
// mockData is generated randomly
import { Image, Text, Checkbox, Badge, Box, Flex } from "@chakra-ui/react";
import { ColumnDef } from "@tanstack/react-table";
import React from "react";
import GenericTable from "@/frontend/core/components/GenericTable";
import TransitActionsButtonGroup from "./TransitTableActions";
import { formatDate } from "@/frontend/core/utils/formatDate";
import { ChevronDownIcon, ChevronRightIcon } from "@chakra-ui/icons";
@saulin18
saulin18 / ExampleTable.tsx
Created August 31, 2025 01:21 — forked from leonardof02/ExampleTable.tsx
Generic Table used in Merco Sistema at NOX Creation
// This is an example table using the GenericTableComponent.tsx
// mockData is generated randomly
import { Image, Text, Checkbox, Badge, Box, Flex } from "@chakra-ui/react";
import { ColumnDef } from "@tanstack/react-table";
import React from "react";
import GenericTable from "@/frontend/core/components/GenericTable";
import TransitActionsButtonGroup from "./TransitTableActions";
import { formatDate } from "@/frontend/core/utils/formatDate";
import { ChevronDownIcon, ChevronRightIcon } from "@chakra-ui/icons";
@saulin18
saulin18 / CursorPag.py
Last active May 7, 2026 20:36
Simple cursor pagination in Python with Pydantic
from typing import Generic, TypeVar, List, Optional, Any
from pydantic import BaseModel, Field
from enum import Enum
import base64
import json
T = TypeVar('T')
class PaginationDirection(str, Enum):
@saulin18
saulin18 / IQueryablePaginationExtension.cs
Last active May 7, 2026 20:36
Extensions for IQueryable class to do pagination
using CubaFiverr.Domain.Common;
using Microsoft.EntityFrameworkCore;
using System.Linq.Expressions;
using Serilog;
namespace CubaFiverr.Application.Features.Pagination.QueryableExtensions;
public static class QueryableExtensions
{
//Offset pagination just in case
@saulin18
saulin18 / PermissionsHandler.cs
Last active May 7, 2026 20:33
Permission Authorization Handler with wildcards
using Infrastructure.Authentication;
using Microsoft.AspNetCore.Authorization;
using Microsoft.AspNetCore.Http;
using Microsoft.AspNetCore.Routing;
using Microsoft.Extensions.DependencyInjection;
using System.Text.RegularExpressions;
namespace Infrastructure.Authorization;
internal sealed class PermissionAuthorizationHandler(IServiceScopeFactory serviceScopeFactory)