Skip to content

Instantly share code, notes, and snippets.

View tanvirraj's full-sized avatar
🚢
coding

Tanvir Raj tanvirraj

🚢
coding
View GitHub Profile
@boristane
boristane / list.ts
Created April 29, 2025 03:07
Hono API
import { createRoute, OpenAPIHono } from "@hono/zod-openapi";
import { openapiGetResponses } from "./openapi";
import { z } from "@hono/zod-openapi";
const app = new OpenAPIHono()
const possibleStatusCodes = [200, 401, 500] as const satisfies readonly number[];
const route = createRoute({
operationId: "resource-name.list",
method: "get",
@mohilcode
mohilcode / result.ts
Last active April 24, 2025 08:45
typescript implementation of the result pattern for functional error handling. provides type-safe alternatives to try/catch with monadic operations for composition. use this to make error handling explicit in your function signatures and avoid throwing exceptions
import { inspect } from 'util'
export type Success<T> = {
readonly type: 'success'
readonly data: T
readonly error?: never
}
export type Failure<E> = {
readonly type: 'failure'
@elledienne
elledienne / zero.mdc
Last active April 7, 2025 16:09
Zero Custom Mutators MDC
# Instructions for Using Zero Custom Mutators
## Overview
Zero Custom Mutators provide a powerful mechanism for defining data write operations beyond simple CRUD. They allow you to embed arbitrary code within your write logic, running both client-side for optimistic updates and server-side for authority and complex operations.
**Key Concepts:**
- **Arbitrary Code:** Mutators are functions, enabling complex validation, permissions, calling external services (like LLMs or sending emails), calling queue, etc.
- **Client-Side Execution:** Mutators run immediately on the client for instant UI feedback.
@boxabirds
boxabirds / main.go
Created May 21, 2024 12:00
Demo of how to create a summariser using golang and Anthropic Claude.
package main
import (
"context"
"flag"
"fmt"
"io"
"log"
"os"
"time"
@phpfour
phpfour / git-revert.md
Created January 17, 2024 14:19
How to use git to revert a committed file to an earlier version

To revert a committed file to an earlier version using Git, you can use the git checkout command. Here's how you can do it:

git checkout {{commit_hash}} -- {{file_path}}

Replace {{commit_hash}} with the hash of the commit you want to revert to, and {{file_path}} with the path to the file you want to revert.

For example, if you want to revert the file script.js to an earlier version with the commit hash abc123, you would run:

Welcome to the wacky world of almost 30 years of web

All of the following values for the <script type=" ••• "> will cause inline or external JavaScript to execute:

Value Note
"" The default value of script.type (eg: no type attribute present)
"text/javascript" The official JavaScript MIME type
"application/javascript" Legacy MIME type from when semantics mattered
"text/x-javascript" Legacy MIME type from before JavaScript was accepted as a valid MIME type
@vivekgalatage
vivekgalatage / Note Taking.md
Last active April 5, 2024 08:52
Note Taking details
@jacob-ebey
jacob-ebey / deferred-overview.md
Last active February 28, 2025 05:42
Deferred Overview

Remix Deferred

Remix Deferred is currently implemented on top of React's Suspense model but is not limited to React. This will be a quick dive into how "promise over the wire" is accomplished.

SSR + Hydration

It isn't rocket science, but a quick recap of how frameworks such as react do SSR:

  1. Load data
  2. Render the app
@danielgross
danielgross / screenshot2pdf.py
Created November 19, 2022 15:41
Take screenshots of websites and place into PDF
from selenium import webdriver
from selenium.webdriver.chrome.options import Options
from PIL import Image
import io
import time
import os
import sys
import numpy as np
from fpdf import FPDF