Skip to content

Instantly share code, notes, and snippets.

import { ValidationPipe, VersioningType } from '@nestjs/common';
import { NestFactory } from '@nestjs/core';
import { DocumentBuilder, SwaggerModule } from '@nestjs/swagger';
import helmet from 'helmet';
import { AppModule } from './app.module';
import { AllExceptionsFilter } from './filters/all-exceptions/all-exceptions.filter';
import { ResponseFormatService } from './response-format/response-format.service';
async function bootstrap() {
const app = await NestFactory.create(AppModule);
import asyncio
from typing import TypeVar, Generic
T = TypeVar("T")
AnyMsg = TypeVar("AnyMsg", "Msg", "Msg2")
class Msg(Generic[T]):
body: T
@Gobot1234
Gobot1234 / features.md
Last active December 16, 2023 20:03
Typing Features I'd like to see/write a PEP for

Generalising currently special cased types

TypedMapping mixin

A generic version of typing.TypedDict.

This would allow for people to make there own typed Mappings, it would desugar to a series of overloads on __getitem__ and get

class MyMapping(MultiDict, TypedMapping):
 foo: int
@Gobot1234
Gobot1234 / non-async.py
Last active January 1, 2022 17:22
test.py
from __future__ import annotations
from typing import Any, Awaitable, Callable, TypeVar, cast, Generic
import asyncio
T = TypeVar("T", bound=int, covariant=True)
B = TypeVar("B", bound="Box[Any]")
class Box(Generic[T]): ...
async def foo(
check: Callable[[B], bool] | None = None,
async def request(self, method: str, url: Union[APIRoute, CRoute, str],
**kwargs) -> Optional[Any]: # adapted from d.py
kwargs['headers'] = {
"User-Agent": self.user_agent,
**kwargs.get('headers', {})
}
async with self._lock:
for tries in range(5):
async with self._session.request(method, str(url), **kwargs) as r:
@Gobot1234
Gobot1234 / enums.py
Created May 18, 2020 02:11
this is sorta working however _enum_member_map_ is always empty
# -*- coding: utf-8 -*-
"""
The MIT License (MIT)
Copyright (c) 2015-2020 Rapptz
Copyright (c) 2015 Rossen Georgiev <rossen@rgp.io>
Permission is hereby granted, free of charge, to any person obtaining a copy of
this software and associated documentation files (the "Software"), to deal in
@Gobot1234
Gobot1234 / .gitignore
Last active February 2, 2020 14:54 — forked from GhostofGoes/.gitignore
Basic .gitignore template for discord bots
# Editors
.vscode/
.idea/
# Mac/OSX
.DS_Store
# Windows
Thumbs.db
@Gobot1234
Gobot1234 / Sub-Classing Help.MD
Last active July 29, 2021 09:16
A guide to sub-classing help with discord.py

Subclassing the help command in discord.py

This is going to be a short-ish guide on sub-classing help as ?tag new help isn't great at explaining things.

Choosing which help command to subclass

  1. Don't subclass HelpCommand unless you're going to override every one of the send_x methods, because that class does not do anything (it literally just returns None)
  2. DefaultHelpCommand is for the default help command (the code block one) Example of the default help command class
  3. MinimalHelpCommandis a minimalistic version of the help command, this is an example of the command produced if you copy ?tag new helpExample of the minimal help command class
  4. HelpCommand is a completely blank slate and can be subclassed to look any way you want, although most people use them for embeds ![My example of a help co

Subclassing the help command in discord.py

This is going to be a short-ish guide on sub-classing help as ?tag new help isn't great at explaining things

Choosing which help command to subclass

  1. Don't subclass HelpCommand unless you're going to override every one of the send_x methods, because that class does not do anything (it literally just returns None)
  2. DefaultHelpCommand is for the default help command (the code block one) Example of the default help command class
  3. MinimalHelpCommandis a minimalistic version of the help command, this is an example of the command produced if you copy ?tag new helpExample of the minimal help command class
  4. HelpCommand is a completely blank slate and can be subclassed to look any way you want, although most people use them for embeds ![My example of a help com