Skip to content

Instantly share code, notes, and snippets.

@arekmaz
arekmaz / prisma-effect.ts
Created October 27, 2023 14:59
prisma + effect-ts integration - client which returns effects instead of promises
import { db } from "../services/db.server";
import { Data, Effect } from "effect";
import type { PrismaClient } from "@prisma/client";
import type {
PrismaClientKnownRequestError,
PrismaClientUnknownRequestError,
PrismaClientRustPanicError,
PrismaClientInitializationError,
PrismaClientValidationError,
} from "@prisma/client/runtime/library";
@pesterhazy
pesterhazy / building-sync-systems.md
Last active October 13, 2025 10:44
Building an offline realtime sync engine

So you want to write a sync system for a web app with offline and realtime support? Good luck. You might find the following resources useful.

Overview articles

@slorber
slorber / sponsor-this-week-in-react.md
Last active August 31, 2022 17:00
Sponsor This Week In React
@steveruizok
steveruizok / [...nextauth].ts
Created July 8, 2021 13:20
Sponsorware with next-auth.
// pages/api/auth/[...nextAuth].ts
import { NextApiHandler, NextApiRequest, NextApiResponse } from 'next'
import NextAuth from 'next-auth'
import Providers from 'next-auth/providers'
export default function Auth(
req: NextApiRequest,
res: NextApiResponse
): ReturnType<NextApiHandler> {
@steveruizok
steveruizok / isUserSponsoringMe.ts
Created June 20, 2021 17:38
Use the GitHub API to check whether a given user is sponsoring you.
/**
* A function that will return whether the given user is sponsoring you.
* Requires a personal access token from GitHub.
* See https://docs.github.com/en/github/authenticating-to-github/keeping-your-account-and-data-secure/creating-a-personal-access-token
*
* @param userA The sponsoring user.
*/
async function isUserSponsoringMe(username: string) {
const res = await fetch('https://api.github.com/graphql', {
method: 'POST',
@garettbass
garettbass / shaders.nim
Created March 15, 2021 01:19
WIP, translating Nim code to GLSL
import glm
import macros
import sets
import strformat
import strutils
import tables
macro shader*(n: typed) =
n.expectKind(nnkStmtList)
let astFile = n.lineInfoObj.filename & ".ast"
import * as React from "react";
import { useMousePosition } from "~/hooks/useMousePosition";
/** Component to cover the area between the mouse cursor and the sub-menu, to allow moving cursor to lower parts of sub-menu without the sub-menu disappearing. */
export function MouseSafeArea(props: { parentRef: React.RefObject<HTMLDivElement> }) {
const { x = 0, y = 0, height: h = 0, width: w = 0 } = props.parentRef.current?.getBoundingClientRect() || {};
const [mouseX, mouseY] = useMousePosition();
const positions = { x, y, h, w, mouseX, mouseY };
return (
<div