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
| export default function createCrudHooks({ | |
| baseKey, | |
| indexFn, | |
| singleFn, | |
| createFn, | |
| updateFn, | |
| deleteFn, | |
| }) { | |
| const useIndex = (config) => useQuery([baseKey], indexFn, config) | |
| const useSingle = (id, config) => |
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
| //@ts-check | |
| 'use strict'; | |
| const ChildProcess = require('child_process'); | |
| const Events = require('events'); | |
| const Path = require('path'); | |
| const { watch } = require('chokidar'); | |
| const { startService } = require('esbuild'); | |
| const Pino = require('pino'); |
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 { | |
| A, | |
| F, | |
| B, | |
| O, | |
| I, | |
| } from 'ts-toolbelt'; | |
| type OnlyUserKeys<O> = | |
| O extends L.List |
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 distributeEvenly< | |
| T extends { x: number; y: number; height: number; width: number } | |
| >(axis: "x" | "y", boxes: T[]) { | |
| const mboxes = [...boxes] | |
| const extent = axis === "x" ? "width" : "height" | |
| mboxes.sort((a, b) => a[axis] - b[axis]) | |
| // Overall boxes span | |
| const last = mboxes[mboxes.length - 1] | |
| const dist = last[axis] + last[extent] - mboxes[0][axis] |
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
| var text by mutableStateOf("") | |
| val charCount: Int get() = text.length | |
| val todoList = mutableStateListOf<Item>(emptyList()) | |
| val filteredTodoList get() = when (todoListFilter) { | |
| Filter.Completed -> todoList.filter { it.isComplete } | |
| Filter.Uncompleted -> todoList.filter { !it.isComplete } | |
| Filter.All -> todoList | |
| } | |
| @Composable fun Example() { |
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 SwiftUI | |
| import PlaygroundSupport | |
| struct AppleTV: View { | |
| var body: some View { | |
| ZStack { | |
| // Image(uiImage: #imageLiteral(resourceName: "IMG_6281.JPG")) | |
| // .resizable() | |
| // .aspectRatio(contentMode: .fill) | |
| Color.gray |
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 { ThemeType } from 'some/path/to/my/tokens'; | |
| import 'styled-components'; | |
| declare module 'styled-components' { | |
| export interface DefaultTheme extends ThemeType {} | |
| } |
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
| // | |
| // See: https://kentcdodds.com/blog/profile-a-react-app-for-performance#build-and-measure-the-production-app | |
| // See: https://nextjs.org/docs/api-reference/next.config.js/custom-webpack-config | |
| const TerserPlugin = require('next/dist/compiled/terser-webpack-plugin'); | |
| module.exports = { | |
| webpack: (config, options) => { | |
| // | |
| // Use profiler-enabled React builds |
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'; | |
| export type Breakpoints = { | |
| [key: string]: number; | |
| }; | |
| export type MediaQueries<BP extends Breakpoints, T> = { | |
| [key in keyof BP]: T; | |
| }; |
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 goes in you root types directory, filename is the [name-of-your-module].d.ts | |
| import '@emotion/react'; | |
| import { MyCustomTheme } from './theme'; | |
| declare module '@emotion/react' { | |
| export interface Theme extends MyCustomTheme {} | |
| } |