This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
import { readFileSync } from "node:fs" | |
import * as babel from "@babel/core" | |
import BabelPluginReactCompiler from "babel-plugin-react-compiler" | |
import type { Plugin } from "esbuild" | |
import QuickLRU from "quick-lru" | |
export function ReactCompilerEsbuildPlugin({ | |
filter, | |
sourceMaps, | |
runtimeModulePath, |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
import * as stylex from '@stylexjs/stylex' | |
export default stylex.create({ | |
sr_only: { | |
position: 'absolute', | |
width: 1, | |
height: 1, | |
padding: 0, | |
margin: -1, | |
overflow: 'hidden', |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
:root { | |
/* Slate */ | |
--slate-50: #f8fafc; | |
--slate-100: #f1f5f9; | |
--slate-200: #e2e8f0; | |
--slate-300: #cbd5e1; | |
--slate-400: #94a3b8; | |
--slate-500: #64748b; | |
--slate-600: #475569; | |
--slate-700: #334155; |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
from polygenerator import random_polygon | |
import matplotlib.pyplot as plt | |
def is_inside(edges, xp, yp): | |
cnt = 0 | |
for edge in edges: | |
(x1, y1), (x2, y2) = edge | |
if (yp < y1) != (yp < y2) and xp < x1 + ((yp-y1)/(y2-y1))*(x2-x1): | |
cnt += 1 |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
// Note: this gist is a part of this OSS project that I'm currently working on: https://github.com/steven-tey/dub | |
export default async function getTitleFromUrl (url: string) { | |
const controller = new AbortController(); | |
const timeoutId = setTimeout(() => controller.abort(), 2000); // timeout if it takes longer than 2 seconds | |
const title = await fetch(url, { signal: controller.signal }) | |
.then((res) => { | |
clearTimeout(timeoutId); | |
return res.text(); | |
}) |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
/* These rules are ignored when ui-monospace is supported. */ | |
@font-face { font-family: ui-monospace; src: | |
/* MacOS (El Capitan +) */ | |
local(Menlo-Regular), | |
/* Windows (11 +) */ | |
local(CascadiaCode-Regular), | |
/* Windows (Vista +) */ | |
local(Consolas), | |
/* Android */ | |
local(RobotoMono-Regular), |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
// codecols designed after Rasmus Andersson's linelen_hist.sh | |
// https://gist.github.com/rsms/36bda3b5c8ab83d951e45ed788a184f4 | |
{ | |
println: println | |
default: default | |
map: map | |
stdin: stdin | |
range: range | |
filter: filter |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
interface LifecycleFunction { | |
(): void; | |
} | |
interface EventCallback<T = unknown> { | |
(event: CustomEvent<T>): void; | |
} | |
export namespace Svelte { | |
export interface Fragment { | |
key?: string | null; | |
first?: Comment | null; |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
/* | |
* Change from https://gist.github.com/unki2aut/4ac81c33be2e8f121e80a26eba1735d7 | |
* - Use top level await (Node.js v14.8.0+) | |
* - To use top level await, you need to write a script as ES Modules | |
* - Set chokidar options to avoid duplicate building | |
* - Define NODE_ENV (For React) | |
* - Add API proxy setting by using proxy-middleware | |
*/ | |
import chokidar from "chokidar"; | |
import esbuild from "esbuild"; |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
import log from "ololog" | |
class Grid { | |
rows = [] | |
width = 0 | |
height = 0 | |
chars = { | |
active: ["┌", "─", "┒", "┃", "┛", "━", "┕", "│"], | |
inactive: ["┌", "─", "┐", "│", "┘", "─", "└", "│"], |
NewerOlder