Skip to content

Instantly share code, notes, and snippets.

View marvinhagemeister's full-sized avatar
☀️

Marvin Hagemeister marvinhagemeister

☀️
View GitHub Profile
@marvinhagemeister
marvinhagemeister / input-mask.html
Last active September 16, 2023 20:08
DOM input masking
<!DOCTYPE html>
<html lang="en">
<head>
<meta charset="UTF-8" />
<meta name="viewport" content="width=device-width, initial-scale=1.0" />
<title>Document</title>
</head>
<body>
<label for="foo">Input mask demo</label>
<input id="foo" type="text" pattern="\d{6}" />
@marvinhagemeister
marvinhagemeister / metafile.json
Created October 15, 2023 20:52
fresh esbuild
{
"inputs": {
"../src/runtime/polyfills.ts": { "bytes": 134, "imports": [] },
"https://esm.sh/stable/[email protected]/denonext/preact.mjs": {
"bytes": 10781,
"imports": [],
"format": "esm"
},
"https://esm.sh/[email protected]": {
"bytes": 104,
This file has been truncated, but you can view the full file.
<!DOCTYPE html>
<html lang="en">
<head>
<meta charset="UTF-8" />
<meta name="viewport" content="width=device-width, initial-scale=1.0" />
<title>Document</title>
</head>
<body>
<h1>hello world</h1>
<p>
<!DOCTYPE html>
<html lang="en">
<head>
<meta charset="UTF-8" />
<meta name="viewport" content="width=device-width, initial-scale=1.0" />
<title>Document</title>
</head>
<body>
<h1>hello</h1>
@marvinhagemeister
marvinhagemeister / use.ts
Last active February 3, 2025 15:15
preact use hook
function use<T>(promiseOrContext: Promise<T> | Context<T>): T {
if ('__c' in promiseOrContext) {
return useContext(promiseOrContext)
}
return usePromise(promiseOrContext)
}
function usePromise<T>(promise: Promise<T>): T {
const resolving = useRef(false);
import { ServerResponse, type IncomingMessage } from "node:http";
import { Http2ServerRequest, Http2ServerResponse } from "node:http2";
import { isArrayBufferView } from "node:util/types";
const INTERNAL_BODY = Symbol("internal_body");
const GlobalResponse = Response;
globalThis.Response = class Response extends GlobalResponse {
[INTERNAL_BODY]: BodyInit | null | undefined = null;