Skip to content

Instantly share code, notes, and snippets.

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

Adarsha Acharya adarshaacharya

🏠
Working from home
View GitHub Profile
@perfectbase
perfectbase / await.tsx
Last active May 27, 2025 09:40
Await component for tRPC with prefetch
/* eslint-disable @typescript-eslint/no-explicit-any */
import { type TRPCQueryOptions } from '@trpc/tanstack-react-query';
import { unstable_noStore } from 'next/cache';
import { Fragment, Suspense, type ReactNode } from 'react';
import { ErrorBoundary } from 'react-error-boundary';
import { HydrateClient, prefetch as prefetchTRPC } from '@/trpc/server';
type AwaitProps<T> =
| {
promise: Promise<T>;
@jacobparis
jacobparis / .cursor\rules\shadcn-ui.mdc
Created March 7, 2025 06:13
shadcn-ui cursor rules
---
description: "Use shadcn/ui components as needed for any UI code"
patterns: "*.tsx"
---
# Shadcn UI Components
This project uses @shadcn/ui for UI components. These are beautifully designed, accessible components that you can copy and paste into your apps.
## Finding and Using Components
@mkcode
mkcode / route.ts
Last active April 7, 2025 11:24
How to setup Next App Router + Clerk + TRPC
// TRPC API endpoint
// src/app/api/trpc/[trpc]/route.ts
import { fetchRequestHandler } from "@trpc/server/adapters/fetch";
import { type NextRequest } from "next/server";
import { env } from "~/env";
import { appRouter } from "~/server/api/root";
import { createTRPCContext } from "~/server/api/trpc";
import { getAuth } from "@clerk/nextjs/server";
@jerriclynsjohn
jerriclynsjohn / settings.json
Created September 8, 2023 14:47
.vscode settings
{
// Custom Typings for Next 13
"typescript.tsdk": "node_modules/typescript/lib",
// For Prettier
"editor.formatOnSave": true,
"editor.defaultFormatter": "esbenp.prettier-vscode",
"prettier.requireConfig": true,
"[prisma]": {
"editor.defaultFormatter": "Prisma.prisma"
@gaearon
gaearon / 00-README-NEXT-SPA.md
Last active May 27, 2025 01:20
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.

@sahilmore-git
sahilmore-git / json_stringify_polyfill.js
Last active August 7, 2022 17:46
Polyfill for JSON.stringify
function stringify(data) {
if (data === undefined)
return undefined
if (data === null)
return 'null'
if (data.toString() === "NaN")
return 'null'
if (data === Infinity)
return 'null'
if (data.constructor === String)
@judaew
judaew / keychron_k2.adoc
Last active May 8, 2025 12:45
Keychron K2 Manual

Keychron K2 Manual

Connect Bluetooth

On the side of the keyboard, switch the toggle to Bluetooth. Press fn+1 3 seconds and pair with device named Keychron K2.

  • fn+1 connect to 1st device

  • fn+2 connect to 2nd device

  • fn+3 connect to 3rd device

@tinnet
tinnet / gist:1343179
Created November 6, 2011 17:02
anti-mongodb rant (mirror from pastebin)
Don't use MongoDB
=================
I've kept quiet for awhile for various political reasons, but I now
feel a kind of social responsibility to deter people from banking
their business on MongoDB.
Our team did serious load on MongoDB on a large (10s of millions
of users, high profile company) userbase, expecting, from early good
experiences, that the long-term scalability benefits touted by 10gen