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 { type paths } from "@/types/api-types"; | |
import { queryClient } from "@/api/api"; | |
import { toast } from "sonner"; | |
type OperationState<TData> = { | |
previousData: TData; | |
timestamp: number; | |
}; | |
// Constants for stack management |
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
# All command are inside a /src directory and excluding node_modules and files starting with a dot. | |
# Get amount of characters | |
(Get-ChildItem -Path ./src -Recurse -File | Where-Object { $_.FullName -notmatch '\\node_modules\\' -and $_.Name -notmatch '^\.' -and $_.Directory.Name -notmatch '^\.' } | ForEach-Object { (Get-Content $_.FullName -Raw).Length } | Measure-Object -Sum).Sum | |
# Get amount of OpenAI tokens (based on 1 token ≈ 4.325 characters, which I confirmed to be roughly accurate) | |
[math]::Round(((Get-ChildItem -Path ./src -Recurse -File | Where-Object { $_.FullName -notmatch '\\node_modules\\' -and $_.Name -notmatch '^\.' -and $_.Directory.Name -notmatch '^\.' } | ForEach-Object { (Get-Content $_.FullName -Raw).Length } | Measure-Object -Sum).Sum * 0.23129), 0) | |
# Ge amount of lines | |
(Get-ChildItem -Path ./src -Recurse -File | Where-Object { $_.FullName -notmatch '\\node_modules\\' -and $_.Name -notmatch '^\.' -and $_.Directory.Name -notmatch '^\.' } | ForEach-Object { (Get-Content $_.FullName | Where |
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 { Injectable, OnModuleInit, Optional, Logger } from "@nestjs/common"; | |
import { ThrottleMetrics } from "./throttle.metrics"; | |
import { | |
ThrottleConfig, | |
ThrottleRecord, | |
ThrottleCheckResult, | |
ThrottleRule, | |
} from "./throttle.types"; | |
import { ThrottleException } from "./throttle.exception"; |
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
type EventMap = { | |
loadMore: { lastMessage: sting }; | |
}; | |
class TypedEventTarget<T extends Record<string, any>> { | |
private listeners: Partial<{ [K in keyof T]: ((event: T[K]) => void)[] }> = {}; | |
addEventListener<K extends keyof T>(type: K, listener: (event: T[K]) => void) { | |
if (!this.listeners[type]) { | |
this.listeners[type] = []; |
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 * as React from "react"; | |
import { Platform } from "react-native"; | |
import DateTimePicker, { | |
AndroidNativeProps, | |
type IOSNativeProps, | |
} from "@react-native-community/datetimepicker"; | |
import { DateTimePickerModal } from "@/components/DateTimePickerModal"; | |
type CustomProps = { | |
iosModalLabel: React.ReactNode; |
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 { z } from "zod"; | |
type NullableKeys<T, K extends keyof T> = Omit<T, K> & { [P in K]: T[P] | null }; | |
export function makeFieldsNullable<T extends z.ZodTypeAny, K extends keyof z.infer<T>>( | |
schema: T, | |
keys: K[], | |
): z.ZodType<NullableKeys<z.infer<T>, K>> { | |
return schema.transform((data) => { | |
const result = { ...data }; |
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 * as fs from "fs/promises"; | |
import * as path from "path"; | |
import fetch from "node-fetch"; | |
import PQueue from "p-queue"; | |
interface PackageJson { | |
dependencies?: Record<string, string>; | |
devDependencies?: Record<string, string>; | |
} |
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 type { | |
FetchError, | |
ResponseType, | |
MutationVariablesType, | |
PathsWithDefinedMethods, | |
} from "@/types/api-mutators"; | |
import { client } from "@/api/common"; | |
import { createApiMutation } from "@/helpers/create-api-mutation.helper"; | |
// NOTE: WILL NOT WORK WITH "PATH" arguments (if the target API endpoint is e.g. "/user/:id"). |
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 os | |
def list_files(startpath, output_file, list_files=True): | |
ignored_directories = {"node_modules", "out", "ios", "public", "locales", "uploads", "volumes", "prisma", ".husky", ".turbo", "android", ".next", ".github", ".git", ".idea", ".vscode", ".vscode-counter"} | |
with open(output_file, 'w') as f_out: | |
for root, dirs, files in os.walk(startpath, topdown=True): | |
# Update dirs in-place to skip ignored directories | |
dirs[:] = [d for d in dirs if all(not root.replace(startpath, "").startswith(ignored) and d != ignored for ignored in ignored_directories)] | |
# Skip files at the root directory |
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
static readonly string[] DeclensedCzechMonthNamesBase = { "ledn", "únor", "březn", "dubn", "květn", "červn", "červenc", | |
"srpn", "září", "říjn", "listopad", "prosinc"}; | |
static readonly string[] FullCzechMonthNames = { "leden", "únor", "březen", "duben", "květen", "červen", "červenec", | |
"srpen", "září", "říjen", "listopad", "prosinec" }; | |
// C#8 | |
public static string GetCzechMonthName(byte month, byte @case = 1) |