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 {Animated} from "react-native" | |
export function getSpoingyTransform( | |
scrollY: Animated.Value, | |
headerHeight: number, | |
) { | |
return [ | |
{ | |
translateY: scrollY.interpolate({ | |
inputRange: [-headerHeight, 0, 1], |
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 * as React from "react" | |
import {captureScroll, getSpoingyTransform} from "spoingyHelpers" | |
import {Animated} from "react-native" | |
const headerHeight = 300 | |
export default () => { | |
// use an instance variable if using component classes | |
const scrollY = React.useRef(new Animated.Value(0)).current |
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
/* | |
Copy this into the console of any web page that is interactive and doesn't | |
do hard reloads. You will hear your DOM changes as different pitches of | |
audio. | |
I have found this interesting for debugging, but also fun to hear web pages | |
render like UIs do in movies. | |
*/ | |
const audioCtx = new (window.AudioContext || window.webkitAudioContext)() |
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 audioCtx = new window.AudioContext(); | |
const oscillator = audioCtx.createOscillator(); | |
oscillator.connect(audioCtx.destination); | |
oscillator.type = "sine"; | |
let numItems = 0 | |
oscillator.frequency.setValueAtTime( | |
1, | |
audioCtx.currentTime |
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 "node-svm.h" | |
#include "training-worker.h" | |
#include "prediction-worker.h" | |
#include "probability-prediction-worker.h" | |
using v8::FunctionTemplate; | |
using v8::Object; | |
using v8::String; | |
using v8::Array; |
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 React from "react" | |
import {InternalRoutes} from "types/routes" | |
import Link, {LinkProps} from "next/link" | |
export function InternalLink({ | |
routeName, | |
routeParams, | |
...linkProps | |
}: Omit<LinkProps, "href" | "as"> & | |
InternalRoutes & {children: React.ReactChild}) { |
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
function useTaskQueue(params: { | |
shouldProcess: boolean | |
}): { | |
tasks: ReadonlyArray<Task> | |
isProcessing: boolean | |
addTask: (task: Task) => void | |
} { | |
const [queue, setQueue] = React.useState<{ | |
isProcessing: boolean | |
tasks: Array<Task> |
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 PromiseSequencer<T> = { | |
/** | |
* Add a promise to the end of the queue. When this promise resolves, you | |
* may be notified via onLatest, assuming that no later promise has resolved | |
* in the meantime. | |
*/ | |
push(promise: Promise<T>): void; | |
/** | |
* Remove all promises from the queue. Any promises in the queue can still |
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 {ChakraProvider, useColorMode} from "@chakra-ui/react" | |
import {Html} from "next/document" | |
import React from "react" | |
type ColorMode = "light" | "dark" | |
export function ChakraThemedHtmlComponent(props: { | |
colorMode: ColorMode | |
children: React.ReactNode | |
}) { | |
return ( |
OlderNewer