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
// Types for the result object with discriminated union | |
type Success<T> = { | |
data: T; | |
error: null; | |
}; | |
type Failure<E> = { | |
data: null; | |
error: E; | |
}; |
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
{ | |
"description": "Caps Lock to Hyper, Hyper + u/o to pageup/pagedown, IJKL to arrows, Hyper + A to Ctrl+A", | |
"manipulators": [ | |
{ | |
"from": { | |
"key_code": "caps_lock", | |
"modifiers": { "optional": ["any"] } | |
}, | |
"to": [ | |
{ |
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
.doc | |
.docx | |
.rtf | |
.epub | |
.odt | |
.odp | |
.pptx | |
.txt | |
.py |
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 { revalidateTag, unstable_cache } from "next/cache"; | |
import { db } from "~/server/db"; | |
import { todoItems } from "~/server/db/schema"; | |
const getTodos = unstable_cache( | |
async () => { | |
return await db.query.todoItems.findMany(); | |
}, | |
["todoItems"], | |
{ |
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 { useQuery } from "@tanstack/react-query"; | |
type Action<TActionInput = unknown, TActionReturn = unknown> = ( | |
input: TActionInput, | |
) => Promise<TActionReturn>; | |
export type BundledAction<TAction extends Action> = { | |
key: string[]; | |
result: Awaited<ReturnType<TAction>>; | |
action: TAction; |
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 input = await Deno.readTextFile("./input.txt"); | |
const lines = input.split("\n"); | |
const dv = { | |
"2": 2, | |
"1": 1, | |
"0": 0, | |
"-": -1, // === -1 | |
"=": -2, // === -2 |
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 const options: QualityOption[] = [ | |
{ | |
tag: "480p_30", | |
name: "480p 30fps", | |
configuration: { | |
width: 640, | |
height: 480, | |
frameRate: 30, | |
bitrateMin: 750, |
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
DATABASE_URL="mysql://[email protected]:3309/roundest-mon" | |
SHADOW_URL="mysql://[email protected]:3310/roundest-mon" |
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 const useGetUserProfile = (userId: string) => { | |
return useQuery(["user-profile", userId], async () => { | |
return await fetch("/user/"+userId); | |
}); | |
} |
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
// /pages/index.tsx | |
function ExamplePage() { | |
const { data } = useBackend( | |
"get-user-info", | |
async () => { | |
const data = await getProfileFromDB(); | |
return data; // {name: string} | |
}, | |
{ prefetch: true } |
NewerOlder