Skip to content

Instantly share code, notes, and snippets.

View rphlmr's full-sized avatar
Making things with Remix Run

Raphaël Moreau rphlmr

Making things with Remix Run
View GitHub Profile
@rphlmr
rphlmr / helpers.ts
Last active February 25, 2025 15:58
Drizzle ORM, deep sub queries
/* -------------------------------------------------------------------------- */
/* More here; */
/* -------------------------------------------------------------------------- */
// https://gist.github.com/rphlmr/0d1722a794ed5a16da0fdf6652902b15
export function distinctOn<Column extends AnyColumn>(column: Column) {
return sql<Column["_"]["data"]>`distinct on (${column}) ${column}`;
}
export function jsonBuildObject<T extends SelectedFields>(shape: T) {
#
# See https://fly.io/docs/reference/configuration/ for information about how to use this file.
#
app = "my-app"
primary_region = "cdg"
kill_signal = "SIGINT"
kill_timeout = "5s"
swap_size_mb = 256
@rphlmr
rphlmr / index.ts
Last active April 13, 2025 14:59
Link XState and Remix fetcher
import type { ActionFunctionArgs, LoaderFunctionArgs } from '@remix-run/node';
import {
ClientActionFunctionArgs,
ClientLoaderFunctionArgs,
useFetcher,
useLoaderData,
} from '@remix-run/react';
import { enqueueActions, fromPromise, setup } from 'xstate';
import { useActor } from '@xstate/react';
import { useEffect, useRef } from 'react';
@rphlmr
rphlmr / readme.md
Created July 24, 2024 16:46
Test .dockerignore
@rphlmr
rphlmr / api.og.ts
Created September 27, 2024 14:20
Remix + Vercel OG image
import cachified, {
type CacheEntry,
type Cache,
totalTtl,
} from "@epic-web/cachified";
import { ImageResponse } from "@vercel/og";
import { LRUCache } from "lru-cache";
import { serverDb } from "~/database/.server/db";
import { type PlaygroundId } from "~/database/types";
@rphlmr
rphlmr / Dockerfile
Last active April 26, 2025 16:32
pnpm turbo monorepo and react router
ARG APP_NAME=my-app
# Base image
FROM node:22-alpine AS base
ENV COREPACK_ENABLE_DOWNLOAD_PROMPT=0
ENV PNPM_HOME="/pnpm"
ENV PATH="$PNPM_HOME:$PATH"
RUN addgroup --system --gid 1001 rr && \
adduser --system --uid 1001 --ingroup rr rr && \
apk add --no-cache libc6-compat && \
@rphlmr
rphlmr / media-client-hints.ts
Created July 9, 2025 09:11
media client hints
import { type ClientHint, getHintUtils } from "@epic-web/client-hints";
import { useEffect } from "react";
import { useRevalidator } from "react-router";
const MOBILE_BREAKPOINT = "(max-width: 1023px)"; // lower than lg
const media = {
mobile: "mobile",
desktop: "desktop",
} as const;