Skip to content

Instantly share code, notes, and snippets.

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

Taku Amano usualoma

🏠
Working from home
View GitHub Profile
<svg xmlns="http://www.w3.org/2000/svg"
width="1200" height="800" viewBox="0 0 1200 800">
<mt:EntryAssets limit="1" offset="1"><image href="<mt:AssetThumbnailURL width="1200" height="800" />" width="1200" height="800" /></mt:EntryAssets>
<rect x="0" y="20%" width="100%" height="300px" fill="#ffffff" fill-opacity="0.8"></rect>
<text x="50%" y="32.5%" text-anchor="middle" dominant-baseline="central" font-size="80"><mt:EntryTitle /></text>
<text x="65%" y="49%" text-anchor="right" dominant-baseline="central" font-size="50"><mt:EntryAuthorDisplayName /></text>
<image href="<mt:AuthorUserpicURL />" x="59%" y="46%" width="50" height="50" />
<rect x="-5" y="-5" width="1210" height="810" fill="none" stroke="#00a78b" stroke-width="55px" rx="80" ry="80"></rect>
</svg>
declare global {
// eslint-disable-next-line @typescript-eslint/no-namespace
namespace jsx.JSX {
interface IntrinsicElements {
[tagName: string]: Record<string, string>
}
}
}
// eslint-disable-next-line @typescript-eslint/ban-types
/* @jsx jsx */
import { Hono } from '../hono'
import { jsx, render } from '../utils/jsx'
function Layout(props: any) {
return (
<html>
{props.children.map((c: any) => (
<div className='wrap'>{c}</div>
))}
@usualoma
usualoma / jsx.ts
Last active October 18, 2023 20:57
declare global {
// eslint-disable-next-line @typescript-eslint/no-namespace
namespace jsx.JSX {
interface IntrinsicElements {
[tagName: string]: Record<string, string>;
}
}
}
function escape(str: string): string {
declare global {
// eslint-disable-next-line @typescript-eslint/no-namespace
namespace jsx.JSX {
interface IntrinsicElements {
[tagName: string]: Record<string, string>;
}
}
}
class EscapedString {
import Benchmark from 'benchmark'
const suite = new Benchmark.Suite()
const obj = {
a: 1,
b: 2,
c: 3,
}
const obj2 = {
a: 1,
indexOf() x 850,664 ops/sec ±0.37% (95 runs sampled)
lastIndexOf() x 319,252 ops/sec ±0.08% (98 runs sampled)
lastIndexOf by for x 857,151 ops/sec ±0.02% (94 runs sampled)
lastIndexOf by while x 687,093 ops/sec ±0.03% (99 runs sampled)
Array.prototype.indexOf.call x 851,614 ops/sec ±0.19% (99 runs sampled)
Array.prototype.lastIndexOf.call x 319,220 ops/sec ±0.17% (99 runs sampled)
Fastest is lastIndexOf by for
indexOf() x 525,422,544 ops/sec ±0.50% (92 runs sampled)
lastIndexOf() x 620,680 ops/sec ±0.05% (95 runs sampled)
lastIndexOf by for x 1,698,597 ops/sec ±0.03% (94 runs sampled)
lastIndexOf by while x 1,362,382 ops/sec ±0.19% (99 runs sampled)
Array.prototype.indexOf.call x 1,672,314 ops/sec ±0.02% (94 runs sampled)
Array.prototype.lastIndexOf.call x 620,908 ops/sec ±0.03% (98 runs sampled)
Fastest is indexOf()
type MyElementTagNameLookup<T extends string> =
T extends keyof HTMLElementTagNameMap ? HTMLElementTagNameMap[T] :
T extends keyof SVGElementTagNameMap ? SVGElementTagNameMap[T] :
Element;
type MyElementTagNameMapWithSuffix<T extends string> =
T extends `${infer TagName}[${infer _Attr}`
? MyElementTagNameLookup<TagName>
: T extends `${infer TagName}.${infer _ClassName}`
? MyElementTagNameLookup<TagName>
"use strict";
exports.__esModule = true;
function equalsTo(value) {
console.log(value);
}
equalsTo("0");
equalsTo("1");
equalsTo("1");
equalsTo("10");
equalsTo("100");