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
package smallbitset | |
import ( | |
"fmt" | |
) | |
type BitSetI interface { | |
Set(uint64) | |
Clear(uint64) | |
Test(uint64) bool |
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
{ "keys": ["k4.public.9KzD6ag94xlrBpUf1tAs6MAoevCLfHLa530TimMW6lg"] } |
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 { generateKeys, sign, verify } from "paseto-ts/v4"; | |
const key = generateKeys("public", { format: "paserk" }); | |
console.log("key", key); |
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 { generateKeyPair } from "jose/key/generate/keypair"; | |
import { exportJWK } from "jose/key/export"; | |
import { JWK } from "jose"; | |
async function generateKey() { | |
const keyId = globalThis?.crypto.randomUUID(); | |
const algorithm = "EdDSA"; // Some example asymmetric algorithms | |
const key = await generateKeyPair(algorithm, { extractable: true }); | |
const exportedPrivate = await exportJWK(key.privateKey); |
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
{ | |
"keys": [ | |
{ | |
"crv": "Ed25519", | |
"x": "qD7X8DrHfg0UuYstKt3FPBGqGBqY3N4lGwn9xX-nnXE", | |
"kty": "OKP", | |
"kid": "4b901935-5a56-4891-be18-a0a29cc9d35e", | |
"alg": "EdDSA" | |
} | |
] |
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
export function foo0(any: string) { | |
console.log(any); | |
} | |
export function bar0() { | |
const any = "asdf"; | |
console.log(any); | |
} | |
export function foo1(as: string) { | |
console.log(as); | |
} |
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, { useEffect, useLayoutEffect, useState } from 'react' | |
import { FlatList, SafeAreaView } from 'react-native' | |
import RNFS from 'react-native-fs' | |
import Realm from 'realm' | |
export function App() { | |
const r = useWaitForRealm() | |
const [initialized, setInitialized] = useState(false) | |
useEffect(() => { |
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, { useEffect, useLayoutEffect, useState } from 'react' | |
import { FlatList, SafeAreaView } from 'react-native' | |
import RNFS from 'react-native-fs' | |
import Realm from 'realm' | |
export function App() { | |
const r = useWaitForRealm() | |
const [initialized, setInitialized] = useState(false) |
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
/** | |
* The transformer signature is based on https://github.com/cevek/ttypescript#program | |
* Need to use https://github.com/microsoft/TypeScript/blob/bae0f508184280c59d2865a35efc63be362eacfa/src/compiler/factory/nodeFactory.ts | |
* The goal is to conver `a!.m()` to `if (!a) { throw new Error('Attempted to use nullish value "a"'} else { a.m() }` | |
* https://astexplorer.net/#/gist/9ec2af3e8c15fd2cde848941e14f566b/d9ddca954379374f98a4097d9bde4c346dac8567 | |
*/ | |
export default function (program) { | |
const checker = program.getTypeChecker() | |
return (context) => { | |
return (sourceFile) => { |
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
// ---- START IMPORTS ---- | |
export type AssertionExtra = (Record<string, unknown> & { name?: ErrorCode }) | ErrorCode | |
export function assert(predicate: any, message: string, extra: AssertionExtra = {}): asserts predicate { | |
if (!predicate) { | |
extra = typeof extra === 'string' ? { name: extra } : extra | |
if (!('name' in extra)) { | |
extra.name = ErrorCode.AssertionError | |
} |
NewerOlder