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
// #!/usr/bin/env node --experimental-json-modules | |
import readline from 'readline/promises' | |
import fs from 'fs/promises' | |
const GRAPHQL_ENDPOINT = process.argv[2] | |
if (!GRAPHQL_ENDPOINT) { | |
console.error('🚨 Please provide a GraphQL endpoint as an argument.') | |
process.exit(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
function createLogger(namespace) { | |
return new Proxy(console, { | |
get(target, key) { | |
return target[key].bind(target, "\x1b[33m%s\x1b[0m", namespace, "-"); | |
}, | |
}); | |
} | |
const logger = createLogger('my-namespace') |
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
/** | |
* Convert relative paths to absolute paths | |
* @author HaNdTriX | |
* @param {string} html - HTML string | |
* @param {string} baseUrl - base url to prepend to relative paths | |
* @param {string[]} [attributes] - attributes to convert | |
* @returns {string} | |
*/ | |
function absolutify( | |
html, |
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 { useEffect, useRef } from "react"; | |
type ElementPickerProps = { | |
onPick: (event: MouseEvent, element: HTMLElement) => void; | |
}; | |
export default function ElementPicker({ onPick }: ElementPickerProps) { | |
const lastSelectedRef = useRef<HTMLElement>(); | |
const topRef = useRef<HTMLDivElement>(null); | |
const rightRef = useRef<HTMLDivElement>(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
/** | |
* Convert a string to an sha256 hash | |
* @param str {string} | |
* @returns {string} | |
*/ | |
async function sha256(str) { | |
const arrayBuffer = new TextEncoder("utf-8").encode(str) | |
const hashAsArrayBuffer = await crypto.subtle.digest('SHA-256', arrayBuffer); | |
const uint8ViewOfHash = new Uint8Array(hashAsArrayBuffer); | |
return Array.from(uint8ViewOfHash).map((b) => b.toString(16).padStart(2, '0')).join(''); |
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 Y from "yjs"; | |
import { bindProxyAndYMap } from "valtio-yjs"; | |
import { WebrtcProvider } from "y-webrtc"; | |
import { IndexeddbPersistence } from "y-indexeddb"; | |
import { proxy } from "valtio"; | |
import { useMemo, useEffect } from "react"; | |
type WebrtcProviderOptions = ConstructorParameters<typeof WebrtcProvider>[2]; | |
export default function useRoom<T extends Record<string, unknown>>( |
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
// THIS IS JUST A POC. DO NOT USE THIS CODE! | |
module.exports = function babelPluginGenerateLanguageKatalog(api, options) { | |
const componentNames = ['FormattedMessage'] | |
const functionNames = ['formatMessage'] | |
const foundIds = new Set() | |
return { | |
inherits: require('babel-plugin-syntax-jsx'), |
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 React, { useImperativeHandle } from "react"; | |
import PropTypes from "prop-types"; | |
import TextField from "@material-ui/core/TextField"; | |
import { fade, useTheme } from "@material-ui/core/styles"; | |
function StripeInput(props) { | |
const { | |
component: Component, | |
inputRef, | |
/* eslint-disable no-unused-vars */ |
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
/** | |
* Allows to repeatedly call | |
* an async code block | |
* | |
* @callback callback | |
* @callback [filterError] Allows to differentiate beween different type of errors | |
* @param {number} [maxRetries=Infinity] | |
*/ | |
function asyncRetry( | |
callback, |
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 React from 'react' | |
function Error({ statusCode }) { | |
return ( | |
<> | |
<h1>{statusCode}</h1> | |
<h2>This is the Next.js _error.js page</h2> | |
<p>Choose the status code by changing the url param above</p> | |
<p> | |
This page supports the 7.x.x status code range{' '} |
NewerOlder