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
Show hidden characters
{ | |
// ## Top-Level Keys | |
// Whether Wrangler should keep variables configured in the dashboard on deploy. | |
// See https://developers.cloudflare.com/workers/wrangler/configuration/#source-of-truth | |
"keep_vars": false, | |
// Whether Wrangler should send usage data to Cloudflare for this project. Defaults to true. | |
// See https://github.com/cloudflare/workers-sdk/blob/main/packages/wrangler/telemetry.md | |
"send_metrics": true, | |
// When making changes to your Durable Object classes, you must perform a migration. |
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 { DurableObject } from 'cloudflare:workers'; | |
const attempts = 3; | |
const baseBackoff = 100; | |
const maxBackoff = 20000; | |
function getBackoff(attempt: number) { | |
const backoff = baseBackoff * Math.pow(2, attempt) * Math.random(); | |
return Math.round(Math.min(maxBackoff, backoff)); | |
} |
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
/* | |
Enabled by "strict": | |
- alwaysStrict | |
- noImplicitAny | |
- noImplicitThis | |
- strictNullChecks | |
- strictBindCallApply | |
- strictFunctionTypes | |
- strictPropertyInitialization | |
- useUnknownInCatchVariable |
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, { | |
createContext, | |
ReactNode, | |
useCallback, | |
useEffect, | |
useState, | |
} from 'react'; | |
import { unstable_batchedUpdates } from 'react-dom'; | |
import { ReadonlyJSONValue, ReadTransaction, Replicache } from 'replicache'; |
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 { useEffect, useState } from 'react'; | |
import { unstable_batchedUpdates } from 'react-dom'; | |
import type { | |
ReadonlyJSONValue, | |
ReadTransaction, | |
Replicache, | |
} from 'replicache'; | |
// We wrap all the callbacks in a `unstable_batchedUpdates` call to ensure that | |
// we do not render things more than once over all of the changed subscriptions. |
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 { createCss } from '@stitches/react'; | |
import { mint } from '@radix-ui/colors'; | |
type ScaleNum = 1 | 2 | 3 | 4 | 5 | 6 | 7 | 8 | 9 | 10 | 11 | 12; | |
type ScaleKey<Name extends string> = `${Name}${ScaleNum}`; | |
type ColorScale<Name extends string> = { [K in ScaleKey<Name>]: string }; | |
function mapColorScale<FromName extends string, ToName extends string>( | |
fromScale: ColorScale<FromName>, | |
fromName: FromName, |
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 opcode = op => { | |
const str = String(op); | |
return parseInt(str.substr(str.length - 2)); | |
}; | |
const mode = (op, pos) => { | |
const str = String(op); | |
if (pos + 2 > str.length) return 0; | |
return parseInt(str.substr(str.length - (2 + pos), 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
## dgraph query | |
{ | |
person(func: uid(0x41d)) { | |
__typename | |
uid | |
name: Person.name | |
partner: Person.partner { | |
__typename | |
uid | |
name: Person.name |
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
# Require Swiss File Knife (sfk) (available from homebrew on macOS) | |
# find all files detected as CRLF and force CRLF | |
find . -not -path "./.git*" -type f | xargs file | grep "CRLF" | awk -F ':' '{ print $1 }' | xargs sfk addcr | |
# find all files detected as LF and force LF | |
find . -not -path "./.git*" -type f | xargs file | grep -v "CRLF" | awk -F ':' '{ print $1 }' | xargs sfk remcr |
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 Buffer(a) { | |
this.buffer = a; | |
this.position = 0; | |
} | |
Buffer.prototype = { | |
seek: function(a) { | |
this.position = a; | |
}, | |
skip: function(a) { | |
this.position += a; |
NewerOlder