Skip to content

Instantly share code, notes, and snippets.

@nickserv
nickserv / App.jsx
Last active January 10, 2024 15:27
React script using module expression https://github.com/tc39/proposal-module-expressions
export default function App() {
return (
<>
<script>
{
module {
import analytics from "..."; // Import an analytics library, possibly from a CDN
// Configure analytics library
}
}
@nickserv
nickserv / actions.tsx
Last active July 21, 2023 06:45
RSC render JSX using server action from client component
"use server";
export async function hello() {
return <h1>Hello, world!</h1>;
}
@nickserv
nickserv / page.tsx
Last active December 31, 2023 14:59
RSC streaming using recursive promises https://twitter.com/shuding_/status/1681373460860108810
async function Row({ chunk }) {
const { next, value, done } = await chunk
if (done) return null
return (
<>
{value}
<Row chunk={next} />
</>
)
}
@nickserv
nickserv / README.md
Last active July 22, 2023 06:10
Browserslist config Baseline

Browserslist config Baseline

To consistently use Baseline browsers (Chrome, Edge, Firefox, Safari) with your web toolchain, add these to your Browserslist:

"browserslist": [
  "last 2 chrome versions",
  "last 2 edge versions",
  "last 2 firefox versions",
 "last 2 safari major versions"
@nickserv
nickserv / ts-node.diff
Created May 9, 2023 06:23
Quick fix to use ts-node with Node 20
- ts-node --esm [path]
+ node --loader ts-node/esm [path]
@nickserv
nickserv / parser.ts
Created December 28, 2022 02:39
Generic TypeScript parser type (similar to JSON)
interface Parser<T> {
parse(text: string): T
stringify(value: T): string
}
@nickserv
nickserv / README.md
Last active November 10, 2022 23:05
Hide Twitter Verified

Installation

  1. Install uBlock Origin
  2. Place a checkmark next to Import under the Custom section near the bottom of the Filter lists pane
  3. Paste the following URL into the text area that appears below
https://gist.githubusercontent.com/nickmccurdy/177e52afe1d5b4647e6b72705f5a652c/raw/no-verified.txt
@nickserv
nickserv / index.html
Created November 5, 2022 10:53
minimal valid HTML5
<!DOCTYPE html>
<html lang="en">
<title>Example</title>
</html>
@nickserv
nickserv / index.html
Created October 22, 2022 05:16
Falsy comparisons #jsbench #jsperf (https://jsbench.github.io/#bfab11ce73ab3353485f8c72051cb212) #jsbench #jsperf
<!DOCTYPE html>
<html>
<head>
<meta charset="utf-8"/>
<title>Falsy comparisons #jsbench #jsperf</title>
<script src="https://cdnjs.cloudflare.com/ajax/libs/benchmark/1.0.0/benchmark.min.js"></script>
<script src="./suite.js"></script>
</head>
<body>
<h1>Open the console to view the results</h1>
@nickserv
nickserv / index.tsx
Last active October 20, 2022 10:14
Type safe children with React and TypeScript https://twitter.com/nickemccurdy/status/1583036771415519232
import {
ComponentType,
createElement,
FunctionComponent,
ReactElement,
ReactNode,
} from "react"
interface RouteProps {
path?: string