Skip to content

Instantly share code, notes, and snippets.

View SagnikPradhan's full-sized avatar
🚄
Gotta push more work! Not commits.

Sagnik Pradhan SagnikPradhan

🚄
Gotta push more work! Not commits.
View GitHub Profile
@SagnikPradhan
SagnikPradhan / tsc-alias-npm-1.8.10-a746925ff7.patch
Created January 1, 2025 06:40
Patch for tsc-alias to support yarn berry
diff --git a/dist/bin/index.js b/dist/bin/index.js
old mode 100755
new mode 100644
diff --git a/dist/helpers/config.d.ts b/dist/helpers/config.d.ts
index dca15b57f31eb935a08b4498f8b3289fc2848b3d..fc5e95887e4abfaa640fca88ea9e08ce9bcd6671 100644
--- a/dist/helpers/config.d.ts
+++ b/dist/helpers/config.d.ts
@@ -1,5 +1,5 @@
import { IConfig, IOutput, ITSConfig, ReplaceTscAliasPathsOptions } from '../interfaces';
export declare function prepareConfig(options: ReplaceTscAliasPathsOptions): Promise<IConfig>;
@SagnikPradhan
SagnikPradhan / client.ts
Created May 20, 2024 15:26
GraphQL Client
import { TypedDocumentString } from "~/graphql/graphql";
import extractFiles, { ExtractableFile } from "extract-files/extractFiles.mjs";
import isExtractableFile from "extract-files/isExtractableFile.mjs";
import { ExecutionResult } from "graphql";
type BaseFetcherProps<GQLResult, GQLVariables> = {
document: TypedDocumentString<GQLResult, GQLVariables>;
signal?: AbortSignal;
};
@SagnikPradhan
SagnikPradhan / pin-input.tsx
Last active February 12, 2024 15:32
Controlled Pin Input
import { Text } from "~/components/primitives/text/text";
import { cx } from "~/utils/css";
import * as LabelPrimitive from "@radix-ui/react-label";
import React, { useCallback, useEffect, useId, useRef } from "react";
interface ControlledPinInputProps {
readonly name: string;
readonly label?: string;
readonly description?: string;
@SagnikPradhan
SagnikPradhan / backup.sh
Last active October 27, 2023 12:51
🗄️ Back up a postgres database running inside a docker container to S3
#!/bin/bash
set -e
set -o pipefail
GENERATION_DATE=$(date -u +"%Y-%m-%dT%H-%M-%SZ")
GENERATED_BACKUP_FILE="backup-$GENERATION_DATE.dump"
if [ -e .env ]; then
read -ra env < <(xargs < .env)
export interface Context<Data> extends Koa.DefaultContext {
session: Session<Data>;
}
export class Session<Data> {
protected static cookieName = "sessId" as const;
protected static httpOnly = true as const;
protected static maxAge = 1000 * 60 * 2;
protected static sameSite = "lax" as const;
@SagnikPradhan
SagnikPradhan / config.ts
Last active April 17, 2022 17:17
Express OAuth2
import config from "$/core/config";
import OAuth2 from "./helper";
import * as Discord from "discord-api-types/v10";
import * as Github from "@octokit/types";
export const discord = new OAuth2.Provider<Discord.RESTGetAPIUserResult>({
credentials: config.oauth.discord!,
accountURL: Discord.RouteBases.api + Discord.Routes.user(),
@SagnikPradhan
SagnikPradhan / path.ts
Last active March 25, 2022 15:36
Dot notation implementation
export type Indices = string | number
export type Indexable = { [index: Indices]: any }
export type Path<O, K extends keyof O = keyof O> = K extends Indices
? K | `${K}${InnerPath<O[K]>}`
: ""
type InnerPath<O, K extends keyof O = keyof O> = K extends Indices &
StripInheritedKeys<O>
?
version: "3.9"
volumes:
caddy_data:
external: true
caddy_config:
services:
app:
env_file:
model OAuthAccount {
id String
type OAuthProvider
username String
photoURL String?
email String
accessToken String
refreshToken String
expiresBy DateTime
@SagnikPradhan
SagnikPradhan / store.ts
Created February 24, 2022 11:34
💎 Koa Session Prisma Store
import { PrismaClient } from "#/gen/prisma"
import { stores } from "koa-session"
const prisma = new PrismaClient()
export const SessionStore: stores = {
async get(key) {
return prisma.session.findUnique({ where: { id: key } })
},