This file contains 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
type AsyncMapParams = { | |
timeout: number; | |
steps: number; | |
coolDown?: number; | |
} | |
const asyncMap = async <I, O>(inList: I[], fn: (input: I) => O, inParams: AsyncMapParams): Promise<O[]> => { | |
const params = Object.assign({}, { | |
timeout: 16, | |
coolDown: 16, |
This file contains 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
const REG = { | |
RAX: 0, | |
RBX: 1, | |
RCX: 2, | |
RDX: 3, | |
} as const; | |
const ADDRESSING_MODES = { | |
AUTO: 0b00, | |
REGISTER: 0b01, |
This file contains 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
// constants.js | |
const authLock = createFence(); | |
// somewhere in auth.js | |
setInterval(() => { | |
authLock.lockFence(updateToken(refreshToken)); | |
This file contains 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
const useExport = (tree, documentTitle, ready) => { | |
const containerRef = useRef(null); | |
const frameRef = useRef(); | |
const [readyToExport, setReadyToExport] = useState(false); | |
useEffect(() => { | |
if (!ready) return; | |
const sheet = new ServerStyleSheet(); |
This file contains 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
#include <math.h> | |
double converge(double current, double target, double step_size) { | |
double direction = target - current; | |
direction = (direction > 0) - (direction < 0); | |
double remaining = target - current; | |
double step = direction * step_size; | |
return current + fmin(step, direction * remaining); | |
} |
This file contains 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
const MAX_HEAP_SIZE = 5000; | |
let HEAP_BASE = 0; | |
const HEAP = new ArrayBuffer(MAX_HEAP_SIZE); | |
const seal = () => HEAP.slice(0, HEAP_BASE); | |
const reset = () => { | |
HEAP_BASE = 0; | |
new Uint8Array(HEAP).fill(0); |
This file contains 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
const fs = require('fs'); | |
const inspector = require('node:inspector'); | |
const { statSync } = fs; | |
Object.assign(fs, { | |
statSync() { | |
if (arguments[0].includes('\x00')) { | |
console.log('YOU ACTIVATED MY TRAP CARD!!!', arguments[0].split('')); | |
inspector.open(); | |
inspector.waitForDebugger(); |
This file contains 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
const fs = require('fs'); | |
const { stat, statfs, statSync, statfsSync } = fs; | |
Object.assign(fs, { | |
stat(){ | |
console.log('Running stat', arguments[0], new Error().stack); | |
return stat.call(fs, ...[...arguments]); | |
}, | |
statfs(){ |
This file contains 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 { render } from "react-dom"; | |
import { atom, useAtom } from "jotai"; | |
import { useEffect, useState } from "react"; | |
const portalGun = () => { | |
const Children = atom(null); | |
const EntryPortal = ({ children }) => { | |
const [, setChildren] = useAtom(Children); |
This file contains 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
#![feature(local_key_cell_methods)] | |
use std::{cell::RefCell, collections::HashMap, rc::Rc}; | |
/// Traits are separated into RuntimeManaged and ParentManaged because | |
/// in the COMPONENTS thread_local we need to erase the prop type since we | |
/// don't know it there (and we don't need props there too). | |
/// | |
/// Luckly for us Rust automatically downcasts a `Rc<RefCell<Component<T>>>` to `Rc<RefCell<dyn RuntimeManaged>>` | |
/// when we clone the a component to the thread_local, while still keeping the original concrete type |
NewerOlder